annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/share/gtk-doc/html/cairo/bindings-overloading.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>Overloading and optional arguments: 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="language-bindings.html" title="Appendix A. Creating a language binding for cairo">
jpayne@68 9 <link rel="prev" href="bindings-return-values.html" title="Multiple return values">
jpayne@68 10 <link rel="next" href="bindings-streams.html" title="Streams and File I/O">
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><a accesskey="u" href="language-bindings.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
jpayne@68 19 <td><a accesskey="p" href="bindings-return-values.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
jpayne@68 20 <td><a accesskey="n" href="bindings-streams.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="sect1">
jpayne@68 23 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
jpayne@68 24 <a name="bindings-overloading"></a>Overloading and optional arguments</h2></div></div></div>
jpayne@68 25 <p>
jpayne@68 26 Function overloading (having a several variants of a function
jpayne@68 27 with the same name and different arguments) is a language
jpayne@68 28 feature available in many languages but not in C.
jpayne@68 29 </p>
jpayne@68 30 <p>
jpayne@68 31 In general, language binding authors should use restraint in
jpayne@68 32 combining functions in the cairo API via function
jpayne@68 33 overloading. What may seem like an obvious overload now may
jpayne@68 34 turn out to be strange with future additions to cairo.
jpayne@68 35 It might seem logical to make
jpayne@68 36 <a class="link" href="cairo-cairo-t.html#cairo-set-source-rgb" title="cairo_set_source_rgb ()"><code class="function">cairo_set_source_rgb()</code></a>
jpayne@68 37 an overload of <code class="function">cairo_set_source()</code>, but future plans to add
jpayne@68 38 <code class="function">cairo_set_source_rgb_premultiplied()</code>,
jpayne@68 39 which will also take three doubles make this a bad idea. For
jpayne@68 40 this reason, only the following pairs of functions should
jpayne@68 41 be combined via overloading
jpayne@68 42 </p>
jpayne@68 43 <pre class="programlisting">
jpayne@68 44 void
jpayne@68 45 cairo_set_source (cairo_t *cr, cairo_pattern_t *source);
jpayne@68 46
jpayne@68 47 void
jpayne@68 48 cairo_set_source_surface (cairo_t *cr,
jpayne@68 49 cairo_surface_t *source,
jpayne@68 50 double surface_x,
jpayne@68 51 double surface_y);
jpayne@68 52
jpayne@68 53 void
jpayne@68 54 cairo_mask (cairo_t *cr,
jpayne@68 55 cairo_pattern_t *pattern);
jpayne@68 56
jpayne@68 57 void
jpayne@68 58 cairo_mask_surface (cairo_t *cr,
jpayne@68 59 cairo_surface_t *surface,
jpayne@68 60 double surface_x,
jpayne@68 61 double surface_y);
jpayne@68 62
jpayne@68 63 cairo_surface_t *
jpayne@68 64 cairo_image_surface_create (cairo_format_t format,
jpayne@68 65 int width,
jpayne@68 66 int height);
jpayne@68 67 cairo_surface_t *
jpayne@68 68 cairo_image_surface_create_for_data (unsigned char *data,
jpayne@68 69 cairo_format_t format,
jpayne@68 70 int width,
jpayne@68 71 int height,
jpayne@68 72 int stride);
jpayne@68 73
jpayne@68 74 cairo_status_t
jpayne@68 75 cairo_surface_write_to_png (cairo_surface_t *surface,
jpayne@68 76 const char *filename);
jpayne@68 77
jpayne@68 78 cairo_status_t
jpayne@68 79 cairo_surface_write_to_png_stream (cairo_surface_t *surface,
jpayne@68 80 cairo_write_func_t write_func,
jpayne@68 81 void *closure);
jpayne@68 82
jpayne@68 83 cairo_surface_t *
jpayne@68 84 cairo_image_surface_create_from_png (const char *filename);
jpayne@68 85
jpayne@68 86 cairo_surface_t *
jpayne@68 87 cairo_image_surface_create_from_png_stream (cairo_read_func_t read_func,
jpayne@68 88 void *closure);
jpayne@68 89 </pre>
jpayne@68 90 <p>
jpayne@68 91 Note that there are cases where all constructors for a type
jpayne@68 92 aren't overloaded together. For example
jpayne@68 93 <a class="link" href="cairo-PNG-Support.html#cairo-image-surface-create-from-png" title="cairo_image_surface_create_from_png ()"><code class="function">cairo_image_surface_create_from_png()</code></a>
jpayne@68 94 should <span class="emphasis"><em>not</em></span> be overloaded together with
jpayne@68 95 <a class="link" href="cairo-Image-Surfaces.html#cairo-image-surface-create" title="cairo_image_surface_create ()"><code class="function">cairo_image_surface_create()</code></a>.
jpayne@68 96 In such cases, the remaining constructors will typically need to
jpayne@68 97 be bound as static methods. In Java, for example, we might have:
jpayne@68 98 </p>
jpayne@68 99 <pre class="programlisting">
jpayne@68 100 Surface surface1 = ImageSurface(Format.RGB24, 100, 100);
jpayne@68 101 Surface surface2 = ImageSurface.createFromPNG("camera.png");</pre>
jpayne@68 102 <p>
jpayne@68 103 Some other overloads that add combinations not found in C may be
jpayne@68 104 convenient for users for language bindings that provide
jpayne@68 105 <span class="type">cairo_point_t</span> and <span class="type">cairo_rectangle_t</span>
jpayne@68 106 types, for example:
jpayne@68 107 </p>
jpayne@68 108 <pre class="programlisting">
jpayne@68 109 void
jpayne@68 110 cairo_move_to (cairo_t *cr,
jpayne@68 111 cairo_point_t *point);
jpayne@68 112 void
jpayne@68 113 cairo_rectangle (cairo_t *cr,
jpayne@68 114 cairo_rectangle_t *rectangle);
jpayne@68 115 </pre>
jpayne@68 116 </div>
jpayne@68 117 <div class="footer">
jpayne@68 118 <hr>Generated by GTK-Doc V1.27</div>
jpayne@68 119 </body>
jpayne@68 120 </html>