1 <refentry id="glib-genmarshal">
4 <refentrytitle>glib-genmarshal</refentrytitle>
5 <manvolnum>1</manvolnum>
9 <refname>glib-genmarshal</refname>
10 <refpurpose>C code marshaller generation utility for GLib closures</refpurpose>
15 <command>glib-genmarshal</command>
16 <arg choice="opt" rep="repeat">options</arg>
17 <arg choice="opt" rep="repeat">files</arg>
21 <refsect1><title>Description</title>
23 <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>Invokation</title>
36 <command>glib-genmarshal</command> takes a list of marshallers to generate as
37 input. The marshaller list is either read from standard input or from files
38 passed as additional arguments on the command line.
41 <refsect2><title>Options</title>
45 <term><option>--header</option></term>
47 Generate header file contents of the marshallers.
52 <term><option>--body</option></term>
54 Generate C code file contents of the marshallers.
59 <term><option>--prefix=string</option>, <option>--prefix string</option></term>
61 Specify marshaller prefix. The default prefix is <literal>`g_cclosure_marshal'</literal>.
66 <term><option>--skip-source</option></term>
68 Skip source location remarks in generated comments.
73 <term><option>--nostdinc</option></term>
75 Do not use the standard marshallers of the GObject library, and skip
76 <filename>gmarshal.h</filename> include directive in generated header files.
81 <term><option>--g-fatal-warnings</option></term>
83 Make warnings fatal, that is, exit immediately once a warning occurs.
88 <term><option>-h</option>, <option>--help</option></term>
90 Print brief help and exit.
95 <term><option>-v</option>, <option>--version</option></term>
97 Print version and exit.
104 <refsect2><title>Marshaller list format</title>
106 The marshaller lists are processed line by line, a line can contain a
107 comment in the form of
111 or a marshaller specification of the form
113 <replaceable>RTYPE</replaceable>:<replaceable>PTYPE</replaceable>
114 <replaceable>RTYPE</replaceable>:<replaceable>PTYPE</replaceable>,<replaceable>PTYPE</replaceable>
115 <replaceable>RTYPE</replaceable>:<replaceable>PTYPE</replaceable>,<replaceable>PTYPE</replaceable>,<replaceable>PTYPE</replaceable>
117 (up to 16 <replaceable>PTYPE</replaceable>s may be present).
120 The <replaceable>RTYPE</replaceable> part specifies the callback's return
121 type and the <replaceable>PTYPE</replaceable>s right to the colon specify
122 the callback's parameter list, except for the first and the last arguments
123 which are always pointers.
126 <refsect2><title>Parameter types</title>
128 Currently, the following types are supported:
131 <term><replaceable>VOID</replaceable></term>
133 indicates no return type, or no extra parameters.
134 If <replaceable>VOID</replaceable> is used as the parameter list, no
135 additional parameters may be present.
140 <term><replaceable>BOOLEAN</replaceable></term>
142 for boolean types (gboolean)
147 <term><replaceable>CHAR</replaceable></term>
149 for signed char types (gchar)
154 <term><replaceable>UCHAR</replaceable></term>
156 for unsigned char types (guchar)
161 <term><replaceable>INT</replaceable></term>
163 for signed integer types (gint)
168 <term><replaceable>UINT</replaceable></term>
170 for unsigned integer types (guint)
175 <term><replaceable>LONG</replaceable></term>
177 for signed long integer types (glong)
182 <term><replaceable>ULONG</replaceable></term>
184 for unsigned long integer types (gulong)
189 <term><replaceable>ENUM</replaceable></term>
191 for enumeration types (gint)
196 <term><replaceable>FLAGS</replaceable></term>
198 for flag enumeration types (guint)
203 <term><replaceable>FLOAT</replaceable></term>
205 for single-precision float types (gfloat)
210 <term><replaceable>DOUBLE</replaceable></term>
212 for double-precision float types (gdouble)
217 <term><replaceable>STRING</replaceable></term>
219 for string types (gchar*)
224 <term><replaceable>BOXED</replaceable></term>
226 for boxed (anonymous but reference counted) types (GBoxed*)
231 <term><replaceable>PARAM</replaceable></term>
233 for GParamSpec or derived types (GParamSpec*)
238 <term><replaceable>POINTER</replaceable></term>
240 for anonymous pointer types (gpointer)
245 <term><replaceable>OBJECT</replaceable></term>
247 for GObject or derived types (GObject*)
252 <term><replaceable>NONE</replaceable></term>
254 deprecated alias for <replaceable>VOID</replaceable>
259 <term><replaceable>BOOL</replaceable></term>
261 deprecated alias for <replaceable>BOOLEAN</replaceable>
268 <refsect1><title>Example</title>
270 To generate marshallers for the following callback functions:
273 void foo (gpointer data1,
275 void bar (gpointer data1,
278 gfloat baz (gpointer data1,
284 The marshaller list has to look like this:
292 The generated marshallers have the arguments encoded in their function name.
293 For this particular list, they are
296 g_cclosure_marshal_VOID__VOID(),
297 g_cclosure_marshal_VOID__INT(),
298 g_cclosure_marshal_FLOAT__BOOLEAN_UCHAR().
301 They can be used directly for GClosures or be passed in as the
302 GSignalCMarshaller c_marshaller; argument upon creation of signals:
305 GClosure *cc_foo, *cc_bar, *cc_baz;
307 cc_foo = g_cclosure_new (NULL, foo, NULL);
308 g_closure_set_marshal (cc_foo, g_cclosure_marshal_VOID__VOID);
309 cc_bar = g_cclosure_new (NULL, bar, NULL);
310 g_closure_set_marshal (cc_bar, g_cclosure_marshal_VOID__INT);
311 cc_baz = g_cclosure_new (NULL, baz, NULL);
312 g_closure_set_marshal (cc_baz, g_cclosure_marshal_FLOAT__BOOLEAN_UCHAR);
315 <refsect1><title>See also</title>
317 <command>glib-mkenums</command>(1)
320 <refsect1><title>Bugs</title>
325 <refsect1><title>Author</title>
327 <command>glib-genmarshal</command> has been written by Tim Janik
328 <email>timj@gtk.org</email>.
331 This manual page was provided by Tim Janik <email>timj@gtk.org</email>.