~ubuntu-branches/ubuntu/vivid/glib2.0/vivid-proposed

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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GObject Reference Manual: glib-genmarshal</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<link rel="home" href="index.html" title="GObject Reference Manual">
<link rel="up" href="rn02.html" title="Tools Reference">
<link rel="prev" href="glib-mkenums.html" title="glib-mkenums">
<link rel="next" href="gobject-query.html" title="gobject-query">
<meta name="generator" content="GTK-Doc V1.21 (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="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts"></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="rn02.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="glib-mkenums.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="gobject-query.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div lang="en" class="refentry">
<a name="glib-genmarshal"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle">glib-genmarshal</span></h2>
<p>glib-genmarshal — C code marshaller generation utility for GLib closures</p>
</td>
<td class="gallery_image" valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<div class="cmdsynopsis"><p><code class="command">glib-genmarshal</code>  [OPTION...] [FILE...]</p></div>
</div>
<div class="refsect1">
<a name="id-1.5.3.5"></a><h2>Description</h2>
<p><span class="command"><strong>glib-genmarshal</strong></span> is a small utility that generates C code
marshallers for callback functions of the GClosure mechanism in the GObject
sublibrary of GLib. The marshaller functions have a standard signature,
they get passed in the invoking closure, an array of value structures holding
the callback function parameters and a value structure for the return value
of the callback. The marshaller is then responsible to call the respective C
code function of the closure with all the parameters on the stack and to
collect its return value.
</p>
<p><span class="command"><strong>glib-genmarshal</strong></span> takes a list of marshallers to generate as
input. The marshaller list is either read from standard input or from files
passed as additional arguments on the command line.
</p>
<div class="refsect2">
<a name="id-1.5.3.5.4"></a><h3>Marshaller list format</h3>
<p>
The marshaller lists are processed line by line, a line can contain a
comment in the form of
</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="gtkdoc ppc"># this is a comment</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
or a marshaller specification of the form
</p>
<pre class="programlisting">
<em class="replaceable"><code>RTYPE</code></em>:<em class="replaceable"><code>PTYPE</code></em>
<em class="replaceable"><code>RTYPE</code></em>:<em class="replaceable"><code>PTYPE</code></em>,<em class="replaceable"><code>PTYPE</code></em>
<em class="replaceable"><code>RTYPE</code></em>:<em class="replaceable"><code>PTYPE</code></em>,<em class="replaceable"><code>PTYPE</code></em>,<em class="replaceable"><code>PTYPE</code></em>
</pre>
<p>
(up to 16 <em class="replaceable"><code>PTYPE</code></em>s may be present).
</p>
<p>
The <em class="replaceable"><code>RTYPE</code></em> part specifies the callback's return
type and the <em class="replaceable"><code>PTYPE</code></em>s right to the colon specify
the callback's parameter list, except for the first and the last arguments
which are always pointers.
</p>
</div>
<hr>
<div class="refsect2">
<a name="id-1.5.3.5.5"></a><h3>Parameter types</h3>
<p>
Currently, the following types are supported:
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="replaceable"><code>VOID</code></em></span></p></td>
<td><p>
indicates no return type, or no extra parameters.
If <em class="replaceable"><code>VOID</code></em> is used as the parameter list, no
additional parameters may be present.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="replaceable"><code>BOOLEAN</code></em></span></p></td>
<td><p>
for boolean types (gboolean)
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="replaceable"><code>CHAR</code></em></span></p></td>
<td><p>
for signed char types (gchar)
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="replaceable"><code>UCHAR</code></em></span></p></td>
<td><p>
for unsigned char types (guchar)
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="replaceable"><code>INT</code></em></span></p></td>
<td><p>
for signed integer types (gint)
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="replaceable"><code>UINT</code></em></span></p></td>
<td><p>
for unsigned integer types (guint)
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="replaceable"><code>LONG</code></em></span></p></td>
<td><p>
for signed long integer types (glong)
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="replaceable"><code>ULONG</code></em></span></p></td>
<td><p>
for unsigned long integer types (gulong)
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="replaceable"><code>INT64</code></em></span></p></td>
<td><p>
for signed 64bit integer types (gint64)
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="replaceable"><code>UINT64</code></em></span></p></td>
<td><p>
for unsigned 64bit integer types (guint64)
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="replaceable"><code>ENUM</code></em></span></p></td>
<td><p>
for enumeration types (gint)
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="replaceable"><code>FLAGS</code></em></span></p></td>
<td><p>
for flag enumeration types (guint)
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="replaceable"><code>FLOAT</code></em></span></p></td>
<td><p>
for single-precision float types (gfloat)
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="replaceable"><code>DOUBLE</code></em></span></p></td>
<td><p>
for double-precision float types (gdouble)
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="replaceable"><code>STRING</code></em></span></p></td>
<td><p>
for string types (gchar*)
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="replaceable"><code>BOXED</code></em></span></p></td>
<td><p>
for boxed (anonymous but reference counted) types (GBoxed*)
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="replaceable"><code>PARAM</code></em></span></p></td>
<td><p>
for GParamSpec or derived types (GParamSpec*)
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="replaceable"><code>POINTER</code></em></span></p></td>
<td><p>
for anonymous pointer types (gpointer)
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="replaceable"><code>OBJECT</code></em></span></p></td>
<td><p>
for GObject or derived types (GObject*)
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="replaceable"><code>VARIANT</code></em></span></p></td>
<td><p>
for GVariant types (GVariant*)
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="replaceable"><code>NONE</code></em></span></p></td>
<td><p>
deprecated alias for <em class="replaceable"><code>VOID</code></em>
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="replaceable"><code>BOOL</code></em></span></p></td>
<td><p>
deprecated alias for <em class="replaceable"><code>BOOLEAN</code></em>
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
</div>
</div>
<div class="refsect1">
<a name="id-1.5.3.6"></a><h2>Options</h2>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="option">--header</code></span></p></td>
<td><p>
Generate header file contents of the marshallers.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="option">--body</code></span></p></td>
<td><p>
Generate C code file contents of the marshallers.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="option">--prefix=<em class="replaceable"><code>PREFIX</code></em></code></span></p></td>
<td><p>
Specify marshaller prefix. The default prefix is <code class="literal">`g_cclosure_marshal'</code>.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="option">--skip-source</code></span></p></td>
<td><p>
Skip source location remarks in generated comments.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="option">--stdinc</code></span></p></td>
<td><p>
Use the standard marshallers of the GObject library, and include
<code class="filename">gmarshal.h</code> in generated header files.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="option">--nostdinc</code></span></p></td>
<td><p>
Do not use the standard marshallers of the GObject library, and skip
<code class="filename">gmarshal.h</code> include directive in generated header files.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="option">--internal</code></span></p></td>
<td><p>
Mark generated functions as internal, using G_GNUC_INTERNAL.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="option">--valist-marshallers</code></span></p></td>
<td><p>
Generate valist marshallers, for use with g_signal_set_va_marshaller().
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="option">-v</code>, <code class="option">--version</code></span></p></td>
<td><p>
Print version information.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="option">--g-fatal-warnings</code></span></p></td>
<td><p>
Make warnings fatal, that is, exit immediately once a warning occurs.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="option">-h</code>, <code class="option">--help</code></span></p></td>
<td><p>
Print brief help and exit.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="option">-v</code>, <code class="option">--version</code></span></p></td>
<td><p>
Print version and exit.
</p></td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="id-1.5.3.7"></a><h2>Example</h2>
<p>
To generate marshallers for the following callback functions:
</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="gtkdoc kwb">void</span>   <span class="function">foo</span> <span class="gtkdoc opt">(</span>gpointer data1<span class="gtkdoc opt">,</span>
            gpointer data2<span class="gtkdoc opt">);</span>
<span class="gtkdoc kwb">void</span>   <span class="function">bar</span> <span class="gtkdoc opt">(</span>gpointer data1<span class="gtkdoc opt">,</span>
            gint     param1<span class="gtkdoc opt">,</span>
            gpointer data2<span class="gtkdoc opt">);</span>
gfloat <span class="function">baz</span> <span class="gtkdoc opt">(</span>gpointer data1<span class="gtkdoc opt">,</span>
            gboolean param1<span class="gtkdoc opt">,</span>
            guchar   param2<span class="gtkdoc opt">,</span>
            gpointer data2<span class="gtkdoc opt">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
The <code class="filename">marshaller.list</code> file has to look like this:
</p>
<pre class="programlisting">
VOID:VOID
VOID:INT
FLOAT:BOOLEAN,UCHAR
</pre>
<p>
and you call glib-genmarshal like this:
</p>
<pre class="programlisting">
glib-genmarshal --header marshaller.list &gt; marshaller.h
glib-genmarshal --body marshaller.list &gt; marshaller.c
</pre>
<p>
The generated marshallers have the arguments encoded in their function name.
For this particular list, they are
</p>
<pre class="programlisting">
g_cclosure_user_marshal_VOID__VOID(),
g_cclosure_user_marshal_VOID__INT(),
g_cclosure_user_marshal_FLOAT__BOOLEAN_UCHAR().
</pre>
<p>
They can be used directly for GClosures or be passed in as the
GSignalCMarshaller c_marshaller; argument upon creation of signals:
</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8</pre></td>
        <td class="listing_code"><pre class="programlisting">GClosure <span class="gtkdoc opt">*</span>cc_foo<span class="gtkdoc opt">, *</span>cc_bar<span class="gtkdoc opt">, *</span>cc_baz<span class="gtkdoc opt">;</span>

cc_foo <span class="gtkdoc opt">=</span> <span class="function"><a href="gobject-Closures.html#g-cclosure-new">g_cclosure_new</a></span> <span class="gtkdoc opt">(</span>NULL<span class="gtkdoc opt">,</span> foo<span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span>
<span class="function"><a href="gobject-Closures.html#g-closure-set-marshal">g_closure_set_marshal</a></span> <span class="gtkdoc opt">(</span>cc_foo<span class="gtkdoc opt">,</span> g_cclosure_user_marshal_VOID__VOID<span class="gtkdoc opt">);</span>
cc_bar <span class="gtkdoc opt">=</span> <span class="function"><a href="gobject-Closures.html#g-cclosure-new">g_cclosure_new</a></span> <span class="gtkdoc opt">(</span>NULL<span class="gtkdoc opt">,</span> bar<span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span>
<span class="function"><a href="gobject-Closures.html#g-closure-set-marshal">g_closure_set_marshal</a></span> <span class="gtkdoc opt">(</span>cc_bar<span class="gtkdoc opt">,</span> g_cclosure_user_marshal_VOID__INT<span class="gtkdoc opt">);</span>
cc_baz <span class="gtkdoc opt">=</span> <span class="function"><a href="gobject-Closures.html#g-cclosure-new">g_cclosure_new</a></span> <span class="gtkdoc opt">(</span>NULL<span class="gtkdoc opt">,</span> baz<span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span>
<span class="function"><a href="gobject-Closures.html#g-closure-set-marshal">g_closure_set_marshal</a></span> <span class="gtkdoc opt">(</span>cc_baz<span class="gtkdoc opt">,</span> g_cclosure_user_marshal_FLOAT__BOOLEAN_UCHAR<span class="gtkdoc opt">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

</div>
<div class="refsect1">
<a name="id-1.5.3.8"></a><h2>See also</h2>
<p>
<span class="citerefentry"><span class="refentrytitle">glib-mkenums</span>(1)</span>
</p>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.21</div>
</body>
</html>