Blame docs/reference/gobject/glib-genmarshal.1

Packit ae235b
'\" t
Packit ae235b
.\"     Title: glib-genmarshal
Packit ae235b
.\"    Author: Emmanuele Bassi
Packit ae235b
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
Packit ae235b
.\"      Date: 04/07/2018
Packit ae235b
.\"    Manual: User Commands
Packit ae235b
.\"    Source: GObject
Packit ae235b
.\"  Language: English
Packit ae235b
.\"
Packit ae235b
.TH "GLIB\-GENMARSHAL" "1" "" "GObject" "User Commands"
Packit ae235b
.\" -----------------------------------------------------------------
Packit ae235b
.\" * Define some portability stuff
Packit ae235b
.\" -----------------------------------------------------------------
Packit ae235b
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Packit ae235b
.\" http://bugs.debian.org/507673
Packit ae235b
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
Packit ae235b
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Packit ae235b
.ie \n(.g .ds Aq \(aq
Packit ae235b
.el       .ds Aq '
Packit ae235b
.\" -----------------------------------------------------------------
Packit ae235b
.\" * set default formatting
Packit ae235b
.\" -----------------------------------------------------------------
Packit ae235b
.\" disable hyphenation
Packit ae235b
.nh
Packit ae235b
.\" disable justification (adjust text to left margin only)
Packit ae235b
.ad l
Packit ae235b
.\" -----------------------------------------------------------------
Packit ae235b
.\" * MAIN CONTENT STARTS HERE *
Packit ae235b
.\" -----------------------------------------------------------------
Packit ae235b
.SH "NAME"
Packit ae235b
glib-genmarshal \- C code marshaller generation utility for GLib closures
Packit ae235b
.SH "SYNOPSIS"
Packit ae235b
.HP \w'\fBglib\-genmarshal\fR\ 'u
Packit ae235b
\fBglib\-genmarshal\fR [OPTION...] [FILE...]
Packit ae235b
.SH "DESCRIPTION"
Packit ae235b
.PP
Packit ae235b
\fBglib\-genmarshal\fR
Packit ae235b
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\&.
Packit ae235b
.PP
Packit ae235b
\fBglib\-genmarshal\fR
Packit ae235b
takes a list of marshallers to generate as input\&. The marshaller list is either read from files passed as additional arguments on the command line; or from standard input, by using
Packit ae235b
\-
Packit ae235b
as the input file\&.
Packit ae235b
.SS "Marshaller list format"
Packit ae235b
.PP
Packit ae235b
The marshaller lists are processed line by line, a line can contain a comment in the form of
Packit ae235b
.sp .if n \{\ .RS 4 .\} .nf # this is a comment .fi .if n \{\ .RE .\}
Packit ae235b
or a marshaller specification of the form
Packit ae235b
.sp
Packit ae235b
.if n \{\
Packit ae235b
.RS 4
Packit ae235b
.\}
Packit ae235b
.nf
Packit ae235b
\fIRTYPE\fR:\fIPTYPE\fR
Packit ae235b
\fIRTYPE\fR:\fIPTYPE\fR,\fIPTYPE\fR
Packit ae235b
\fIRTYPE\fR:\fIPTYPE\fR,\fIPTYPE\fR,\fIPTYPE\fR
Packit ae235b
.fi
Packit ae235b
.if n \{\
Packit ae235b
.RE
Packit ae235b
.\}
Packit ae235b
.PP
Packit ae235b
The
Packit ae235b
\fIRTYPE\fR
Packit ae235b
part specifies the callback\*(Aqs return type and the
Packit ae235b
\fIPTYPE\fRs right to the colon specify the callback\*(Aqs parameter list, except for the first and the last arguments which are always pointers\&.
Packit ae235b
.SS "Parameter types"
Packit ae235b
.PP
Packit ae235b
Currently, the following types are supported:
Packit ae235b
.PP
Packit ae235b
\fIVOID\fR
Packit ae235b
.RS 4
Packit ae235b
indicates no return type, or no extra parameters\&. If
Packit ae235b
\fIVOID\fR
Packit ae235b
is used as the parameter list, no additional parameters may be present\&.
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fIBOOLEAN\fR
Packit ae235b
.RS 4
Packit ae235b
for boolean types (gboolean)
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fICHAR\fR
Packit ae235b
.RS 4
Packit ae235b
for signed char types (gchar)
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fIUCHAR\fR
Packit ae235b
.RS 4
Packit ae235b
for unsigned char types (guchar)
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fIINT\fR
Packit ae235b
.RS 4
Packit ae235b
for signed integer types (gint)
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fIUINT\fR
Packit ae235b
.RS 4
Packit ae235b
for unsigned integer types (guint)
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fILONG\fR
Packit ae235b
.RS 4
Packit ae235b
for signed long integer types (glong)
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fIULONG\fR
Packit ae235b
.RS 4
Packit ae235b
for unsigned long integer types (gulong)
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fIINT64\fR
Packit ae235b
.RS 4
Packit ae235b
for signed 64bit integer types (gint64)
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fIUINT64\fR
Packit ae235b
.RS 4
Packit ae235b
for unsigned 64bit integer types (guint64)
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fIENUM\fR
Packit ae235b
.RS 4
Packit ae235b
for enumeration types (gint)
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fIFLAGS\fR
Packit ae235b
.RS 4
Packit ae235b
for flag enumeration types (guint)
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fIFLOAT\fR
Packit ae235b
.RS 4
Packit ae235b
for single\-precision float types (gfloat)
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fIDOUBLE\fR
Packit ae235b
.RS 4
Packit ae235b
for double\-precision float types (gdouble)
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fISTRING\fR
Packit ae235b
.RS 4
Packit ae235b
for string types (gchar*)
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fIBOXED\fR
Packit ae235b
.RS 4
Packit ae235b
for boxed (anonymous but reference counted) types (GBoxed*)
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fIPARAM\fR
Packit ae235b
.RS 4
Packit ae235b
for GParamSpec or derived types (GParamSpec*)
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fIPOINTER\fR
Packit ae235b
.RS 4
Packit ae235b
for anonymous pointer types (gpointer)
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fIOBJECT\fR
Packit ae235b
.RS 4
Packit ae235b
for GObject or derived types (GObject*)
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fIVARIANT\fR
Packit ae235b
.RS 4
Packit ae235b
for GVariant types (GVariant*)
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fINONE\fR
Packit ae235b
.RS 4
Packit ae235b
deprecated alias for
Packit ae235b
\fIVOID\fR
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fIBOOL\fR
Packit ae235b
.RS 4
Packit ae235b
deprecated alias for
Packit ae235b
\fIBOOLEAN\fR
Packit ae235b
.RE
Packit ae235b
.SH "OPTIONS"
Packit ae235b
.PP
Packit ae235b
\fB\-\-header\fR
Packit ae235b
.RS 4
Packit ae235b
Generate header file contents of the marshallers\&. This option is mutually exclusive with the
Packit ae235b
\fB\-\-body\fR
Packit ae235b
option\&.
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fB\-\-body\fR
Packit ae235b
.RS 4
Packit ae235b
Generate C code file contents of the marshallers\&. This option is mutually exclusive with the
Packit ae235b
\fB\-\-header\fR
Packit ae235b
option\&.
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fB\-\-prefix=\fR\fB\fIPREFIX\fR\fR
Packit ae235b
.RS 4
Packit ae235b
Specify marshaller prefix\&. The default prefix is
Packit ae235b
`g_cclosure_user_marshal\*(Aq\&.
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fB\-\-skip\-source\fR
Packit ae235b
.RS 4
Packit ae235b
Skip source location remarks in generated comments\&.
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fB\-\-stdinc\fR
Packit ae235b
.RS 4
Packit ae235b
Use the standard marshallers of the GObject library, and include
Packit ae235b
glib\-object\&.h
Packit ae235b
in generated header files\&. This option is mutually exclusive with the
Packit ae235b
\fB\-\-nostdinc\fR
Packit ae235b
option\&.
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fB\-\-nostdinc\fR
Packit ae235b
.RS 4
Packit ae235b
Do not use the standard marshallers of the GObject library, and skip
Packit ae235b
glib\-object\&.h
Packit ae235b
include directive in generated header files\&. This option is mutually exclusive with the
Packit ae235b
\fB\-\-stdinc\fR
Packit ae235b
option\&.
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fB\-\-internal\fR
Packit ae235b
.RS 4
Packit ae235b
Mark generated functions as internal, using
Packit ae235b
G_GNUC_INTERNAL\&.
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fB\-\-valist\-marshallers\fR
Packit ae235b
.RS 4
Packit ae235b
Generate valist marshallers, for use with
Packit ae235b
\fBg_signal_set_va_marshaller()\fR\&.
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fB\-v\fR, \fB\-\-version\fR
Packit ae235b
.RS 4
Packit ae235b
Print version information\&.
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fB\-\-g\-fatal\-warnings\fR
Packit ae235b
.RS 4
Packit ae235b
Make warnings fatal, that is, exit immediately once a warning occurs\&.
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fB\-h\fR, \fB\-\-help\fR
Packit ae235b
.RS 4
Packit ae235b
Print brief help and exit\&.
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fB\-v\fR, \fB\-\-version\fR
Packit ae235b
.RS 4
Packit ae235b
Print version and exit\&.
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fB\-\-output=FILE\fR
Packit ae235b
.RS 4
Packit ae235b
Write output to
Packit ae235b
\fIFILE\fR
Packit ae235b
instead of the standard output\&.
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fB\-\-prototypes\fR
Packit ae235b
.RS 4
Packit ae235b
Generate function prototypes before the function definition in the C source file, in order to avoid a
Packit ae235b
missing\-prototypes
Packit ae235b
compiler warning\&. This option is only useful when using the
Packit ae235b
\fB\-\-body\fR
Packit ae235b
option\&.
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fB\-\-pragma\-once\fR
Packit ae235b
.RS 4
Packit ae235b
Use the
Packit ae235b
once
Packit ae235b
pragma instead of an old style header guard when generating the C header file\&. This option is only useful when using the
Packit ae235b
\fB\-\-header\fR
Packit ae235b
option\&.
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fB\-\-include\-header=\fR\fB\fIHEADER\fR\fR
Packit ae235b
.RS 4
Packit ae235b
Adds a
Packit ae235b
#include
Packit ae235b
directive for the given file in the C source file\&. This option is only useful when using the
Packit ae235b
\fB\-\-body\fR
Packit ae235b
option\&.
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fB\-D \fR\fB\fISYMBOL[=VALUE]\fR\fR
Packit ae235b
.RS 4
Packit ae235b
Adds a
Packit ae235b
#define
Packit ae235b
C pre\-processor directive for
Packit ae235b
\fISYMBOL\fR
Packit ae235b
and its given
Packit ae235b
\fIVALUE\fR, or "1" if the value is unset\&. You can use this option multiple times; if you do, all the symbols will be defined in the same order given on the command line, before the symbols undefined using the
Packit ae235b
\fB\-U\fR
Packit ae235b
option\&. This option is only useful when using the
Packit ae235b
\fB\-\-body\fR
Packit ae235b
option\&.
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fB\-U \fR\fB\fISYMBOL\fR\fR
Packit ae235b
.RS 4
Packit ae235b
Adds a
Packit ae235b
#undef
Packit ae235b
C pre\-processor directive to undefine the given
Packit ae235b
\fISYMBOL\fR\&. You can use this option multiple times; if you do, all the symbols will be undefined in the same order given on the command line, after the symbols defined using the
Packit ae235b
\fB\-D\fR
Packit ae235b
option\&. This option is only useful when using the
Packit ae235b
\fB\-\-body\fR
Packit ae235b
option\&.
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fB\-\-quiet\fR
Packit ae235b
.RS 4
Packit ae235b
Minimizes the output of
Packit ae235b
\fBglib\-genmarshal\fR, by printing only warnings and errors\&. This option is mutually exclusive with the
Packit ae235b
\fB\-\-verbose\fR
Packit ae235b
option\&.
Packit ae235b
.RE
Packit ae235b
.PP
Packit ae235b
\fB\-\-verbose\fR
Packit ae235b
.RS 4
Packit ae235b
Increases the verbosity of
Packit ae235b
\fBglib\-genmarshal\fR, by printing debugging information\&. This option is mutually exclusive with the
Packit ae235b
\fB\-\-quiet\fR
Packit ae235b
option\&.
Packit ae235b
.RE
Packit ae235b
.SH "USING GLIB\-GENMARSHAL WITH AUTOTOOLS"
Packit ae235b
.PP
Packit ae235b
In order to use
Packit ae235b
\fBglib\-genmarshal\fR
Packit ae235b
in your project when using Autotools as the build system, you will first need to modify your
Packit ae235b
configure\&.ac
Packit ae235b
file to ensure you find the appropriate command using
Packit ae235b
\fBpkg\-config\fR, similarly as to how you discover the compiler and linker flags for GLib\&.
Packit ae235b
.sp
Packit ae235b
.if n \{\
Packit ae235b
.RS 4
Packit ae235b
.\}
Packit ae235b
.nf
Packit ae235b
PKG_PROG_PKG_CONFIG([0\&.28])
Packit ae235b
Packit ae235b
PKG_CHECK_VAR([GLIB_GENMARSHAL], [glib\-2\&.0], [glib_genmarshal])
Packit ae235b
.fi
Packit ae235b
.if n \{\
Packit ae235b
.RE
Packit ae235b
.\}
Packit ae235b
.PP
Packit ae235b
In your
Packit ae235b
Makefile\&.am
Packit ae235b
file you will typically need very simple rules to generate the C files needed for the build\&.
Packit ae235b
.sp
Packit ae235b
.if n \{\
Packit ae235b
.RS 4
Packit ae235b
.\}
Packit ae235b
.nf
Packit ae235b
marshal\&.h: marshal\&.list
Packit ae235b
        $(AM_V_GEN)$(GLIB_GENMARSHAL) \e
Packit ae235b
                \-\-header \e
Packit ae235b
                \-\-output=$@ \e
Packit ae235b
                $<
Packit ae235b
Packit ae235b
marshal\&.c: marshal\&.list marshal\&.h
Packit ae235b
        $(AM_V_GEN)$(GLIB_GENMARSHAL) \e
Packit ae235b
                \-\-include\-header=marshal\&.h \e
Packit ae235b
                \-\-body \e
Packit ae235b
                \-\-output=$@ \e
Packit ae235b
                $<
Packit ae235b
Packit ae235b
BUILT_SOURCES += marshal\&.h marshal\&.c
Packit ae235b
CLEANFILES += marshal\&.h marshal\&.c
Packit ae235b
EXTRA_DIST += marshal\&.list
Packit ae235b
.fi
Packit ae235b
.if n \{\
Packit ae235b
.RE
Packit ae235b
.\}
Packit ae235b
.PP
Packit ae235b
In the example above, the first rule generates the header file and depends on a
Packit ae235b
marshal\&.list
Packit ae235b
file in order to regenerate the result in case the marshallers list is updated\&. The second rule generates the source file for the same
Packit ae235b
marshal\&.list, and includes the file generated by the header rule\&.
Packit ae235b
.SH "EXAMPLE"
Packit ae235b
.PP
Packit ae235b
To generate marshallers for the following callback functions:
Packit ae235b
.sp
Packit ae235b
.if n \{\
Packit ae235b
.RS 4
Packit ae235b
.\}
Packit ae235b
.nf
Packit ae235b
void   foo (gpointer data1,
Packit ae235b
            gpointer data2);
Packit ae235b
void   bar (gpointer data1,
Packit ae235b
            gint     param1,
Packit ae235b
            gpointer data2);
Packit ae235b
gfloat baz (gpointer data1,
Packit ae235b
            gboolean param1,
Packit ae235b
            guchar   param2,
Packit ae235b
            gpointer data2);
Packit ae235b
.fi
Packit ae235b
.if n \{\
Packit ae235b
.RE
Packit ae235b
.\}
Packit ae235b
.PP
Packit ae235b
The
Packit ae235b
marshaller\&.list
Packit ae235b
file has to look like this:
Packit ae235b
.sp
Packit ae235b
.if n \{\
Packit ae235b
.RS 4
Packit ae235b
.\}
Packit ae235b
.nf
Packit ae235b
VOID:VOID
Packit ae235b
VOID:INT
Packit ae235b
FLOAT:BOOLEAN,UCHAR
Packit ae235b
.fi
Packit ae235b
.if n \{\
Packit ae235b
.RE
Packit ae235b
.\}
Packit ae235b
.PP
Packit ae235b
and you call glib\-genmarshal like this:
Packit ae235b
.sp
Packit ae235b
.if n \{\
Packit ae235b
.RS 4
Packit ae235b
.\}
Packit ae235b
.nf
Packit ae235b
glib\-genmarshal \-\-header marshaller\&.list > marshaller\&.h
Packit ae235b
glib\-genmarshal \-\-body marshaller\&.list > marshaller\&.c
Packit ae235b
.fi
Packit ae235b
.if n \{\
Packit ae235b
.RE
Packit ae235b
.\}
Packit ae235b
.PP
Packit ae235b
The generated marshallers have the arguments encoded in their function name\&. For this particular list, they are
Packit ae235b
.sp
Packit ae235b
.if n \{\
Packit ae235b
.RS 4
Packit ae235b
.\}
Packit ae235b
.nf
Packit ae235b
g_cclosure_user_marshal_VOID__VOID(\&.\&.\&.),
Packit ae235b
g_cclosure_user_marshal_VOID__INT(\&.\&.\&.),
Packit ae235b
g_cclosure_user_marshal_FLOAT__BOOLEAN_UCHAR(\&.\&.\&.)\&.
Packit ae235b
.fi
Packit ae235b
.if n \{\
Packit ae235b
.RE
Packit ae235b
.\}
Packit ae235b
.PP
Packit ae235b
They can be used directly for GClosures or be passed in as the GSignalCMarshaller c_marshaller; argument upon creation of signals:
Packit ae235b
.sp
Packit ae235b
.if n \{\
Packit ae235b
.RS 4
Packit ae235b
.\}
Packit ae235b
.nf
Packit ae235b
GClosure *cc_foo, *cc_bar, *cc_baz;
Packit ae235b
Packit ae235b
cc_foo = g_cclosure_new (NULL, foo, NULL);
Packit ae235b
g_closure_set_marshal (cc_foo, g_cclosure_user_marshal_VOID__VOID);
Packit ae235b
cc_bar = g_cclosure_new (NULL, bar, NULL);
Packit ae235b
g_closure_set_marshal (cc_bar, g_cclosure_user_marshal_VOID__INT);
Packit ae235b
cc_baz = g_cclosure_new (NULL, baz, NULL);
Packit ae235b
g_closure_set_marshal (cc_baz, g_cclosure_user_marshal_FLOAT__BOOLEAN_UCHAR);
Packit ae235b
.fi
Packit ae235b
.if n \{\
Packit ae235b
.RE
Packit ae235b
.\}
Packit ae235b
.SH "SEE ALSO"
Packit ae235b
.PP
Packit ae235b
\fBglib-mkenums\fR(1)