/usr/share/gtk-doc/html/cairo/bindings-return-values.html is in libcairo2-doc 1.12.2-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Multiple return values</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="Cairo: A Vector Graphics Library">
<link rel="up" href="language-bindings.html" title="Appendix A. Creating a language binding for cairo">
<link rel="prev" href="bindings-memory.html" title="Memory management">
<link rel="next" href="bindings-overloading.html" title="Overloading and optional arguments">
<meta name="generator" content="GTK-Doc V1.18 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
<td><a accesskey="p" href="bindings-memory.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="language-bindings.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">Cairo: A Vector Graphics Library</th>
<td><a accesskey="n" href="bindings-overloading.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr></table>
<div class="sect1">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="bindings-return-values"></a>Multiple return values</h2></div></div></div>
<p>
There are a number of functions in the cairo API that have
multiple <em class="firstterm">out parameters</em> or
<em class="firstterm">in-out parameters</em>. In some languages
these can be translated into multiple return values. In Python,
what is:
</p>
<pre class="programlisting">
cairo_user_to_device (cr, &x, &y);</pre>
<p>
can by mapped to:
</p>
<pre class="programlisting">
(x, y) = cr.user_to_device (cr, x, y);</pre>
<p>
but many languages don't have provisions for multiple return
values, so it is necessary to introduce auxiliary types.
Most of the functions that require the auxiliary types
require a type that would, in C, look like
</p>
<pre class="programlisting">
typedef struct _cairo_point cairo_point_t;
struct _cairo_point {
double x;
double y;
}</pre>
<p>
The same type should be used both for functions that use a pair
of coordinates as an absolute position, and functions that use
a pair of coordinates as a displacement. While an argument could
be made that having a separate “distance” type is more correct,
it is more likely just to confuse users.
</p>
<pre class="programlisting">
void
cairo_user_to_device (cairo_t *cr, double *x, double *y);
void
cairo_user_to_device_distance (cairo_t *cr, double *dx, double *dy);
void
cairo_device_to_user (cairo_t *cr, double *x, double *y);
void
cairo_device_to_user_distance (cairo_t *cr, double *dx, double *dy);
void
cairo_matrix_transform_distance (cairo_matrix_t *matrix, double *dx, double *dy);
void
cairo_matrix_transform_point (cairo_matrix_t *matrix, double *x, double *y);
void
cairo_get_current_point (cairo_t *cr, double *x, double *y);
</pre>
<p>
There are also a couple of functions that return four values
representing a rectangle. These should be mapped to a
“rectangle” type that looks like:
</p>
<pre class="programlisting">
typedef struct _cairo_rectangle cairo_rectangle_t;
struct _cairo_rectangle {
double x;
double y;
double width;
double height;
}</pre>
<p>
The C function returns the rectangle as a set of two points to
facilitate rounding to integral extents, but this isn't worth
adding a “box” type to go along with the more obvious
“rectangle” representation.
</p>
<p class="remark"><em><span class="remark">
Q: Would it make sense here to define a standard
<code class="function">cairo_rectangle_round()</code> method
that language bindings should map?
</span></em></p>
<pre class="programlisting">
void
cairo_stroke_extents (cairo_t *cr,
double *x1, double *y1,
double *x2, double *y2);
void
cairo_fill_extents (cairo_t *cr,
double *x1, double *y1,
double *x2, double *y2);
</pre>
</div>
<div class="footer">
<hr>
Generated by GTK-Doc V1.18</div>
</body>
</html>
|