1 <refentry id="glib-genmarshal" lang="en">
4 <refentrytitle>glib-genmarshal</refentrytitle>
5 <manvolnum>1</manvolnum>
6 <refmiscinfo class="manual">User Commands</refmiscinfo>
10 <refname>glib-genmarshal</refname>
11 <refpurpose>C code marshaller generation utility for GLib closures</refpurpose>
16 <command>glib-genmarshal</command>
17 <arg choice="opt" rep="repeat">options</arg>
18 <arg choice="opt" rep="repeat">files</arg>
22 <refsect1><title>Description</title>
23 <para><command>glib-genmarshal</command> is a small utility that generates C code
24 marshallers for callback functions of the GClosure mechanism in the GObject
25 sublibrary of GLib. The marshaller functions have a standard signature,
26 they get passed in the invoking closure, an array of value structures holding
27 the callback function parameters and a value structure for the return value
28 of the callback. The marshaller is then responsible to call the respective C
29 code function of the closure with all the parameters on the stack and to
30 collect its return value.
34 <refsect1><title>Invocation</title>
35 <para><command>glib-genmarshal</command> takes a list of marshallers to generate as
36 input. The marshaller list is either read from standard input or from files
37 passed as additional arguments on the command line.
40 <refsect2><title>Options</title>
44 <term><option>--header</option></term>
46 Generate header file contents of the marshallers.
51 <term><option>--body</option></term>
53 Generate C code file contents of the marshallers.
58 <term><option>--prefix=string</option>, <option>--prefix string</option></term>
60 Specify marshaller prefix. The default prefix is <literal>`g_cclosure_marshal'</literal>.
65 <term><option>--skip-source</option></term>
67 Skip source location remarks in generated comments.
72 <term><option>--nostdinc</option></term>
74 Do not use the standard marshallers of the GObject library, and skip
75 <filename>gmarshal.h</filename> include directive in generated header files.
80 <term><option>--g-fatal-warnings</option></term>
82 Make warnings fatal, that is, exit immediately once a warning occurs.
87 <term><option>-h</option>, <option>--help</option></term>
89 Print brief help and exit.
94 <term><option>-v</option>, <option>--version</option></term>
96 Print version and exit.
103 <refsect2><title>Marshaller list format</title>
105 The marshaller lists are processed line by line, a line can contain a
106 comment in the form of
110 or a marshaller specification of the form
112 <replaceable>RTYPE</replaceable>:<replaceable>PTYPE</replaceable>
113 <replaceable>RTYPE</replaceable>:<replaceable>PTYPE</replaceable>,<replaceable>PTYPE</replaceable>
114 <replaceable>RTYPE</replaceable>:<replaceable>PTYPE</replaceable>,<replaceable>PTYPE</replaceable>,<replaceable>PTYPE</replaceable>
116 (up to 16 <replaceable>PTYPE</replaceable>s may be present).
119 The <replaceable>RTYPE</replaceable> part specifies the callback's return
120 type and the <replaceable>PTYPE</replaceable>s right to the colon specify
121 the callback's parameter list, except for the first and the last arguments
122 which are always pointers.
125 <refsect2><title>Parameter types</title>
127 Currently, the following types are supported:
130 <term><replaceable>VOID</replaceable></term>
132 indicates no return type, or no extra parameters.
133 If <replaceable>VOID</replaceable> is used as the parameter list, no
134 additional parameters may be present.
139 <term><replaceable>BOOLEAN</replaceable></term>
141 for boolean types (gboolean)
146 <term><replaceable>CHAR</replaceable></term>
148 for signed char types (gchar)
153 <term><replaceable>UCHAR</replaceable></term>
155 for unsigned char types (guchar)
160 <term><replaceable>INT</replaceable></term>
162 for signed integer types (gint)
167 <term><replaceable>UINT</replaceable></term>
169 for unsigned integer types (guint)
174 <term><replaceable>LONG</replaceable></term>
176 for signed long integer types (glong)
181 <term><replaceable>ULONG</replaceable></term>
183 for unsigned long integer types (gulong)
188 <term><replaceable>INT64</replaceable></term>
190 for signed 64bit integer types (gint64)
195 <term><replaceable>UINT64</replaceable></term>
197 for unsigned 64bit integer types (guint64)
202 <term><replaceable>ENUM</replaceable></term>
204 for enumeration types (gint)
209 <term><replaceable>FLAGS</replaceable></term>
211 for flag enumeration types (guint)
216 <term><replaceable>FLOAT</replaceable></term>
218 for single-precision float types (gfloat)
223 <term><replaceable>DOUBLE</replaceable></term>
225 for double-precision float types (gdouble)
230 <term><replaceable>STRING</replaceable></term>
232 for string types (gchar*)
237 <term><replaceable>BOXED</replaceable></term>
239 for boxed (anonymous but reference counted) types (GBoxed*)
244 <term><replaceable>PARAM</replaceable></term>
246 for GParamSpec or derived types (GParamSpec*)
251 <term><replaceable>POINTER</replaceable></term>
253 for anonymous pointer types (gpointer)
258 <term><replaceable>OBJECT</replaceable></term>
260 for GObject or derived types (GObject*)
265 <term><replaceable>VARIANT</replaceable></term>
267 for GVariant types (GVariant*)
272 <term><replaceable>NONE</replaceable></term>
274 deprecated alias for <replaceable>VOID</replaceable>
279 <term><replaceable>BOOL</replaceable></term>
281 deprecated alias for <replaceable>BOOLEAN</replaceable>
288 <refsect1><title>Example</title>
290 To generate marshallers for the following callback functions:
293 void foo (gpointer data1,
295 void bar (gpointer data1,
298 gfloat baz (gpointer data1,
304 The marshaller list has to look like this:
312 The generated marshallers have the arguments encoded in their function name.
313 For this particular list, they are
316 g_cclosure_marshal_VOID__VOID(),
317 g_cclosure_marshal_VOID__INT(),
318 g_cclosure_marshal_FLOAT__BOOLEAN_UCHAR().
321 They can be used directly for GClosures or be passed in as the
322 GSignalCMarshaller c_marshaller; argument upon creation of signals:
325 GClosure *cc_foo, *cc_bar, *cc_baz;
327 cc_foo = g_cclosure_new (NULL, foo, NULL);
328 g_closure_set_marshal (cc_foo, g_cclosure_marshal_VOID__VOID);
329 cc_bar = g_cclosure_new (NULL, bar, NULL);
330 g_closure_set_marshal (cc_bar, g_cclosure_marshal_VOID__INT);
331 cc_baz = g_cclosure_new (NULL, baz, NULL);
332 g_closure_set_marshal (cc_baz, g_cclosure_marshal_FLOAT__BOOLEAN_UCHAR);
335 <refsect1><title>See also</title>
337 <command>glib-mkenums</command>(1)
340 <refsect1><title>Bugs</title>
345 <refsect1><title>Author</title>
346 <para><command>glib-genmarshal</command> has been written by Tim Janik
347 <email>timj@gtk.org</email>.
350 This manual page was provided by Tim Janik <email>timj@gtk.org</email>.