annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/share/gtk-doc/html/cairo/language-bindings.html @ 68:5028fdace37b

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 16:23:26 -0400
parents
children
rev   line source
jpayne@68 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
jpayne@68 2 <html>
jpayne@68 3 <head>
jpayne@68 4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
jpayne@68 5 <title>Appendix A. Creating a language binding for cairo: Cairo: A Vector Graphics Library</title>
jpayne@68 6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
jpayne@68 7 <link rel="home" href="index.html" title="Cairo: A Vector Graphics Library">
jpayne@68 8 <link rel="up" href="index.html" title="Cairo: A Vector Graphics Library">
jpayne@68 9 <link rel="prev" href="index-1.16.html" title="Index of new symbols in 1.16">
jpayne@68 10 <link rel="next" href="bindings-memory.html" title="Memory management">
jpayne@68 11 <meta name="generator" content="GTK-Doc V1.27 (XML mode)">
jpayne@68 12 <link rel="stylesheet" href="style.css" type="text/css">
jpayne@68 13 </head>
jpayne@68 14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
jpayne@68 15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
jpayne@68 16 <td width="100%" align="left" class="shortcuts"></td>
jpayne@68 17 <td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
jpayne@68 18 <td><img src="up-insensitive.png" width="16" height="16" border="0"></td>
jpayne@68 19 <td><a accesskey="p" href="index-1.16.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
jpayne@68 20 <td><a accesskey="n" href="bindings-memory.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
jpayne@68 21 </tr></table>
jpayne@68 22 <div class="appendix">
jpayne@68 23 <div class="titlepage"><div><div><h1 class="title">
jpayne@68 24 <a name="language-bindings"></a>Appendix A. Creating a language binding for cairo</h1></div></div></div>
jpayne@68 25 <p>
jpayne@68 26 While cairo is implemented and C, and has a C API, it is expected
jpayne@68 27 that many users of cairo will be using it from languages other
jpayne@68 28 than C. The glue that connects the core cairo library to another
jpayne@68 29 language is known as a <em class="firstterm">language
jpayne@68 30 binding</em>. This appendix attempts to collect together
jpayne@68 31 issues that come up when creating a language bindings for cairo
jpayne@68 32 and present standardized solutions to promote consistency among
jpayne@68 33 the different language bindings.
jpayne@68 34 </p>
jpayne@68 35 <div class="sect1">
jpayne@68 36 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
jpayne@68 37 <a name="bindings-general"></a>General considerations</h2></div></div></div>
jpayne@68 38 <p>
jpayne@68 39 The naming of the central <a class="link" href="cairo-cairo-t.html#cairo-t" title="cairo_t"><span class="type">cairo_t</span></a> type is a
jpayne@68 40 special exception. The object is “a cairo context” not “a
jpayne@68 41 cairo”, and names such as <span class="type">cairo_t</span> rather than
jpayne@68 42 <span class="type">cairo_context_t</span> and
jpayne@68 43 <code class="function">cairo_set_source()</code> rather than
jpayne@68 44 <code class="function">cairo_context_set_source()</code> are simply
jpayne@68 45 abbreviations to make the C API more palatable. In languages
jpayne@68 46 which have object-oriented syntax, this abbreviation is much
jpayne@68 47 less useful. In fact, if ‘Cairo’ is used as a namespace, then
jpayne@68 48 in many languages, you'd end up with a ridiculous type name
jpayne@68 49 like ‘Cairo.Cairo’. For this reason, and for inter-language
jpayne@68 50 consistency all object-oriented languages should name this
jpayne@68 51 type as if it were <span class="type">cairo_context_t</span>.
jpayne@68 52 </p>
jpayne@68 53 <p>
jpayne@68 54 The punctuation and casing of the type names and
jpayne@68 55 method names of cairo should be changed to match the general
jpayne@68 56 convention of the language. In Java, where type names are written
jpayne@68 57 in StudlyCaps and method names in javaCaps, cairo_font_extents_t
jpayne@68 58 will become FontExtents and
jpayne@68 59 <code class="literal">cairo_set_source(cr,source)</code>,
jpayne@68 60 <code class="literal">cr.setSource(source)</code>.
jpayne@68 61 As compared to changing the punctuation, and casing, much
jpayne@68 62 more reluctance should be used in changing the method names
jpayne@68 63 themselves. Even if get is usually omitted from getters in
jpayne@68 64 your language, you shouldn't bind cairo_get_source() as
jpayne@68 65 cr.source().
jpayne@68 66 </p>
jpayne@68 67 </div>
jpayne@68 68 </div>
jpayne@68 69 <div class="footer">
jpayne@68 70 <hr>Generated by GTK-Doc V1.27</div>
jpayne@68 71 </body>
jpayne@68 72 </html>