2011-04-08 22:57:31 +02:00
<refentry id= "gdbus-codegen" lang= "en" >
2012-08-03 00:36:25 +02:00
<refentryinfo >
<title > gdbus</title>
<productname > GIO</productname>
<authorgroup >
<author >
<contrib > Developer</contrib>
<firstname > David</firstname>
<surname > Zeuthen</surname>
<email > zeuthen@gmail.com</email>
</author>
</authorgroup>
</refentryinfo>
2011-04-08 22:57:31 +02:00
<refmeta >
<refentrytitle > gdbus-codegen</refentrytitle>
<manvolnum > 1</manvolnum>
<refmiscinfo class= "manual" > User Commands</refmiscinfo>
</refmeta>
<refnamediv >
<refname > gdbus-codegen</refname>
2011-04-13 02:40:25 +02:00
<refpurpose > D-Bus code and documentation generator</refpurpose>
2011-04-08 22:57:31 +02:00
</refnamediv>
<refsynopsisdiv >
<cmdsynopsis >
<command > gdbus-codegen</command>
2013-05-05 03:01:35 +02:00
<arg > <option > -h</option> , <option > --help</option> </arg>
2011-04-08 22:57:31 +02:00
<arg > <option > --interface-prefix</option> <replaceable > org.project.Prefix</replaceable> </arg>
<arg > <option > --generate-c-code</option> <replaceable > OUTFILES</replaceable> </arg>
2011-04-12 17:50:34 +02:00
<arg > <option > --c-namespace</option> <replaceable > YourProject</replaceable> </arg>
<arg > <option > --c-generate-object-manager</option> </arg>
2016-05-04 00:11:09 +02:00
<arg > <option > --c-generate-autocleanup</option> none|objects|all</arg>
2017-02-17 03:03:18 +01:00
<arg > <option > --output-directory</option> <replaceable > OUTDIR</replaceable> </arg>
2011-04-08 22:57:31 +02:00
<arg > <option > --generate-docbook</option> <replaceable > OUTFILES</replaceable> </arg>
2018-01-03 17:01:30 +01:00
<arg > <option > --pragma-once</option> </arg>
2013-05-05 03:01:35 +02:00
<arg > <option > --xml-files</option> <replaceable > FILE</replaceable> </arg>
2018-01-04 14:18:07 +01:00
<arg > <option > --header</option> </arg>
<arg > <option > --body</option> </arg>
2018-04-17 15:10:07 +02:00
<arg > <option > --interface-info-header</option> </arg>
<arg > <option > --interface-info-body</option> </arg>
2018-01-04 14:18:07 +01:00
<arg > <option > --output</option> <replaceable > OUTFILE</replaceable> </arg>
2011-04-08 22:57:31 +02:00
<group choice= "plain" rep= "repeat" >
<arg >
<option > --annotate</option>
2011-09-21 12:57:29 +02:00
<replaceable > ELEMENT</replaceable>
<replaceable > KEY</replaceable>
<replaceable > VALUE</replaceable>
2011-04-08 22:57:31 +02:00
</arg>
</group>
2020-01-27 11:11:46 +01:00
<arg > <option > --glib-min-required</option> <replaceable > VERSION</replaceable> </arg>
2020-01-27 11:36:03 +01:00
<arg > <option > --glib-max-allowed</option> <replaceable > VERSION</replaceable> </arg>
2011-04-08 22:57:31 +02:00
<arg choice= "plain" > FILE</arg>
<arg >
<arg choice= "plain" rep= "repeat" > FILE</arg>
</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1 >
<title > Description</title>
<para >
<command > gdbus-codegen</command> is used to generate code and/or
2018-01-02 20:24:56 +01:00
documentation for one or more D-Bus interfaces.
</para>
<para >
<command > gdbus-codegen</command> reads
2011-04-12 17:50:34 +02:00
<ulink
url="http://dbus.freedesktop.org/doc/dbus-specification.html#introspection-format">D-Bus
2018-01-02 20:24:56 +01:00
Introspection XML</ulink> from files passed as additional
arguments on the command line and generates output files.
2018-01-27 13:13:39 +01:00
It currently supports generating C source code (via
<option > --body</option> ) or header (via <option > --header</option> )
2018-04-17 15:10:07 +02:00
and Docbook XML (via <option > --generate-docbook</option> ). Alternatively,
more restricted C source code and headers can be generated, which just
contain the interface information (as <type > GDBusInterfaceInfo</type>
structures) using <option > --interface-info-body</option> and
<option > --interface-info-header</option> .
2011-04-08 22:57:31 +02:00
</para>
2011-04-12 17:50:34 +02:00
</refsect1>
<refsect1 >
<title > Generating C code</title>
2011-04-08 22:57:31 +02:00
<para >
2011-04-29 19:11:22 +02:00
When generating C code, a
#GInterface<!-- --> -derived type is generated for each D-Bus
2011-04-08 22:57:31 +02:00
interface. Additionally, for every generated type,
<type > FooBar</type> , two concrete instantiable types,
2011-04-13 22:33:51 +02:00
<type > FooBarProxy</type> and <type > FooBarSkeleton</type> , implementing
2011-04-08 22:57:31 +02:00
said interface are also generated. The former is derived from
2011-04-12 17:50:34 +02:00
#GDBusProxy and intended for use on the client side
2011-04-08 22:57:31 +02:00
while the latter is derived from the
2011-04-13 22:33:51 +02:00
#GDBusInterfaceSkeleton type making it easy to export on a
2011-04-12 17:50:34 +02:00
#GDBusConnection either directly or via a
#GDBusObjectManagerServer instance.
</para>
2018-01-27 13:13:39 +01:00
<para >
For C code generation either <option > --body</option> that
2018-04-17 15:10:07 +02:00
generates source code, <option > --header</option> that
generates headers, <option > --interface-info-body</option> that generates
interface information source code, or
<option > --interface-info-header</option> that generates interface information
headers, can be used. These options must be used along with
2018-01-27 13:13:39 +01:00
<option > --output</option> , which is used to specify the file to output to.
</para>
<para >
Both files can be generated at the same time by using
<option > --generate-c-code</option> , but this option is deprecated.
In this case <option > --output</option> cannot be used due to the
generation of multiple files. Instead pass
<option > --output-directory</option> to specify the directory to put
the output files in. By default the current directory will be used.
</para>
2011-09-21 13:12:32 +02:00
<para >
The name of each generated C type is derived from the D-Bus
interface name stripped with the prefix given with
<option > --interface-prefix</option> and with the dots removed and
initial characters capitalized. For example, for the D-Bus
interface <literal > com.acme.Coyote</literal> the name used is
<literal > ComAcmeCoyote</literal> . For the D-Bus interface
<literal > org.project.Bar.Frobnicator</literal> with
<option > --interface-prefix</option>
<literal > org.project.</literal> , the name used is
<literal > BarFrobnicator</literal> .
</para>
<para >
For methods, signals and properties, if not specified, the name
defaults to the name of the method, signal or property.
</para>
<para >
Two forms of the name are used - the CamelCase form and the
lower-case form. The CamelCase form is used for the #GType and
struct name, while lower-case form is used in function names. The
lower-case form is calculated by converting from CamelCase to
lower-case and inserting underscores at word boundaries (using
certain heuristics).
</para>
<para >
If the value given by the <literal > org.gtk.GDBus.C.Name</literal>
annotation or the <option > --c-namespace</option> option contains
an underscore (sometimes called <emphasis > Ugly_Case</emphasis> ),
then the camel-case name is derived by removing all underscores,
and the lower-case name is derived by lower-casing the
string. This is useful in some situations where abbreviations are
used. For example, if the annotation is used on the interface
<literal > net.MyCorp.MyApp.iSCSITarget</literal> with the value
<literal > iSCSI_Target</literal> the CamelCase form is
<literal > iSCSITarget</literal> while the lower-case form is
<literal > iscsi_target</literal> . If the annotation is used on the
method <literal > EjectTheiPod</literal> with the value
<literal > Eject_The_iPod</literal> , the lower-case form is
<literal > eject_the_ipod</literal> .
</para>
2011-04-12 17:50:34 +02:00
</refsect1>
<refsect1 >
<title > Generating Docbook documentation</title>
<para >
Each generated Docbook XML file (see the
<option > --generate-docbook</option> option for details) is a <ulink
url="http://www.docbook.org/tdg/en/html/refentry.html"><literal > RefEntry</literal> </ulink>
article describing the D-Bus interface.
2011-04-08 22:57:31 +02:00
</para>
</refsect1>
<refsect1 >
<title > Options</title>
<para >
The following options are supported:
</para>
<variablelist >
2013-05-05 03:01:35 +02:00
<varlistentry >
<term > <option > -h</option> , <option > --help</option> </term>
<listitem >
<para >
Show help and exit.
</para>
</listitem>
</varlistentry>
<varlistentry >
<term > <option > --xml-files</option> <replaceable > FILE</replaceable> </term>
<listitem >
<para >
2018-01-02 20:24:56 +01:00
This option is deprecated; use positional arguments instead.
2013-05-05 03:01:35 +02:00
The D-Bus introspection XML file.
</para>
</listitem>
</varlistentry>
2011-04-08 22:57:31 +02:00
<varlistentry >
<term > <option > --interface-prefix</option> <replaceable > org.project.Prefix.</replaceable> </term>
<listitem >
<para >
A prefix to strip from all D-Bus interface names when
calculating the typename for the C binding and the Docbook
<ulink
url="http://www.docbook.org/tdg/en/html/primary.html">sortas
attribute</ulink> .
</para>
</listitem>
</varlistentry>
<varlistentry >
<term > <option > --generate-docbook</option> <replaceable > OUTFILES</replaceable> </term>
<listitem >
<para >
Generate Docbook Documentation for each D-Bus interface and
2011-04-12 17:50:34 +02:00
put it in <filename > OUTFILES-NAME.xml</filename> where
<literal > NAME</literal> is a place-holder for the interface
name, e.g. <literal > net.Corp.FooBar</literal> and so on.
2011-04-08 22:57:31 +02:00
</para>
2018-01-27 13:13:39 +01:00
<para >
Pass <option > --output-directory</option> to specify the directory
to put the output files in. By default the current directory
will be used.
</para>
2011-04-08 22:57:31 +02:00
</listitem>
</varlistentry>
<varlistentry >
<term > <option > --generate-c-code</option> <replaceable > OUTFILES</replaceable> </term>
<listitem >
<para >
Generate C code for all D-Bus interfaces and put it in
<filename > OUTFILES.c</filename> and
2017-02-17 03:03:18 +01:00
<filename > OUTFILES.h</filename> including any sub-directories. If you want the files to
be output in a different location use <option > --output-directory</option> as <filename > OUTFILES.h</filename>
including sub-directories will be referenced from <filename > OUTFILES.c</filename> .
</para>
<para >
The full paths would then be <literal > $(OUTDIR)/$(dirname $OUTFILES)/$(basename $OUTFILES).{c,h}</literal> .
2011-04-08 22:57:31 +02:00
</para>
</listitem>
</varlistentry>
<varlistentry >
<term > <option > --c-namespace</option> <replaceable > YourProject</replaceable> </term>
<listitem >
<para >
2011-09-21 13:12:32 +02:00
The namespace to use for generated C code. This is expected
to be in <ulink
url="http://en.wikipedia.org/wiki/CamelCase">CamelCase</ulink>
or <emphasis > Ugly_Case</emphasis> (see above).
2011-04-08 22:57:31 +02:00
</para>
</listitem>
2018-01-03 17:01:30 +01:00
</varlistentry>
<varlistentry >
<term > <option > --pragma-once</option> </term>
<listitem >
<para >
If this option is passed, the
<ulink url= "https://en.wikipedia.org/wiki/Pragma_once" > # pragma once</ulink>
preprocessor directive is used instead of include guards.
</para>
</listitem>
2011-04-08 22:57:31 +02:00
</varlistentry>
2011-04-12 17:50:34 +02:00
<varlistentry >
<term > <option > --c-generate-object-manager</option> </term>
<listitem >
<para >
2011-04-25 15:29:18 +02:00
If this option is passed, suitable #GDBusObject,
#GDBusObjectProxy, #GDBusObjectSkeleton and
#GDBusObjectManagerClient subclasses are generated.
2011-04-12 17:50:34 +02:00
</para>
</listitem>
</varlistentry>
2016-05-04 00:11:09 +02:00
<varlistentry >
<term > <option > --c-generate-autocleanup</option> none|objects|all</term>
<listitem >
<para >
This option influences what types autocleanup functions are
generated for. 'none' means to not generate any autocleanup functions.
'objects' means to generate them for object types, and 'all' means to
generate them for object types and interfaces. The default is 'objects'
due to a corner case in backwards compatibility with a few projects,
but you should likely switch your project to use 'all'.
This option was added in GLib 2.50.
</para>
</listitem>
</varlistentry>
2017-02-17 03:03:18 +01:00
<varlistentry >
<term > <option > --output-directory</option> <replaceable > OUTDIR</replaceable> </term>
<listitem >
<para >
Directory to output generated source to. Equivalent to changing directory before generation.
</para>
2018-01-27 13:13:39 +01:00
<para >
2018-04-17 15:10:07 +02:00
This option cannot be used with <option > --body</option> ,
<option > --header</option> , <option > --interface-info-body</option> or
<option > --interface-info-header</option> ; and
<option > --output</option> must be used.
2018-01-27 13:13:39 +01:00
</para>
2017-02-17 03:03:18 +01:00
</listitem>
</varlistentry>
2018-01-04 14:18:07 +01:00
<varlistentry >
<term > <option > --header</option> </term>
<listitem >
<para >
If this option is passed, it will generate the header code and write it to the disk by
using the path and file name provided by <option > --output</option> .
</para>
<para >
Using <option > --generate-c-code</option> , <option > --generate-docbook</option> or
<option > --output-directory</option> are not allowed to be used along with
<option > --header</option> and <option > --body</option> options, because these options
are used to generate only one file.
</para>
</listitem>
</varlistentry>
<varlistentry >
<term > <option > --body</option> </term>
<listitem >
<para >
If this option is passed, it will generate the source code and write it to the disk by
using the path and file name provided by <option > --output</option> .
</para>
<para >
Using <option > --generate-c-code</option> , <option > --generate-docbook</option> or
<option > --output-directory</option> are not allowed to be used along with
<option > --header</option> and <option > --body</option> options, because these options
are used to generate only one file.
</para>
</listitem>
</varlistentry>
2018-04-17 15:10:07 +02:00
<varlistentry >
<term > <option > --interface-info-header</option> </term>
<listitem >
<para >
If this option is passed, it will generate the header code for the
<type > GDBusInterfaceInfo</type> structures only and will write it to
the disk by using the path and file name provided by
<option > --output</option> .
</para>
<para >
Using <option > --generate-c-code</option> , <option > --generate-docbook</option> or
<option > --output-directory</option> are not allowed to be used along with
the <option > --interface-info-header</option> and
<option > --interface-info-body</option> options, because these options
are used to generate only one file.
</para>
</listitem>
</varlistentry>
<varlistentry >
<term > <option > --interface-info-body</option> </term>
<listitem >
<para >
If this option is passed, it will generate the source code for the
<type > GDBusInterfaceInfo</type> structures only and will write it to
the disk by using the path and file name provided by
<option > --output</option> .
</para>
<para >
Using <option > --generate-c-code</option> , <option > --generate-docbook</option> or
<option > --output-directory</option> are not allowed to be used along with
the <option > --interface-info-header</option> and
<option > --interface-info-body</option> options, because these options
are used to generate only one file.
</para>
</listitem>
</varlistentry>
2018-01-04 14:18:07 +01:00
<varlistentry >
<term > <option > --output</option> <replaceable > OUTFILE</replaceable> </term>
<listitem >
<para >
2018-04-17 15:10:07 +02:00
The full path where the header (<option > --header</option> ,
<option > --interface-info-header</option> ) or the source code
(<option > --body</option> , <option > --interface-info-body</option> ) will
be written, using the path and filename provided by
2018-01-04 14:18:07 +01:00
<option > --output</option> . The full path could be something like
<literal > $($OUTFILE).{c,h}</literal> .
</para>
<para >
Using <option > --generate-c-code</option> , <option > --generate-docbook</option> or
<option > --output-directory</option> is not allowed along with
<option > --output</option> , because the latter is used to generate only one file.
</para>
</listitem>
</varlistentry>
2011-04-08 22:57:31 +02:00
<varlistentry >
2011-09-21 12:57:29 +02:00
<term > <option > --annotate</option> <replaceable > ELEMENT</replaceable> <replaceable > KEY</replaceable> <replaceable > VALUE</replaceable> </term>
2011-04-08 22:57:31 +02:00
<listitem >
<para >
2011-09-21 12:57:29 +02:00
Used to inject D-Bus annotations into the given XML
files. It can be used with interfaces, methods, signals,
properties and arguments in the following way:
2011-04-08 22:57:31 +02:00
</para>
<informalexample > <programlisting > < ![CDATA[
gdbus-codegen --c-namespace MyApp \
--generate-c-code myapp-generated \
--annotate "org.project.InterfaceName" \
2011-09-21 12:57:29 +02:00
org.gtk.GDBus.C.Name MyFrobnicator \
2011-04-08 22:57:31 +02:00
--annotate "org.project.InterfaceName:Property" \
2011-09-21 12:57:29 +02:00
bar bat \
2011-04-08 22:57:31 +02:00
--annotate "org.project.InterfaceName.Method()" \
2011-09-21 12:57:29 +02:00
org.freedesktop.DBus.Deprecated true \
2011-04-08 22:57:31 +02:00
--annotate "org.project.InterfaceName.Method()[arg_name]" \
2011-09-21 12:57:29 +02:00
snake hiss \
2011-04-08 22:57:31 +02:00
--annotate "org.project.InterfaceName::Signal" \
2011-09-21 12:57:29 +02:00
cat meow \
2011-04-08 22:57:31 +02:00
--annotate "org.project.InterfaceName::Signal[arg_name]" \
2011-09-21 12:57:29 +02:00
dog wuff \
2011-04-08 22:57:31 +02:00
myapp-dbus-interfaces.xml
]]></programlisting> </informalexample>
2011-04-29 19:11:22 +02:00
<para >
2011-09-21 12:57:29 +02:00
Any UTF-8 string can be used for <replaceable > KEY</replaceable> and <replaceable > VALUE</replaceable> .
2011-04-29 19:11:22 +02:00
</para>
2011-04-08 22:57:31 +02:00
</listitem>
</varlistentry>
2011-04-29 19:11:22 +02:00
2019-12-02 16:53:14 +01:00
<varlistentry >
2020-01-27 11:11:46 +01:00
<term > <option > --glib-min-required</option> <replaceable > VERSION</replaceable> </term>
2019-12-02 16:53:14 +01:00
<listitem >
<para >
Specifies the minimum version of GLib which the code generated by
<command > gdbus-codegen</command> can depend on. This may be used to
make backwards-incompatible changes in the output or behaviour of
<command > gdbus-codegen</command> in future, which users may opt in to
2020-01-27 11:11:46 +01:00
by increasing the value they pass for <option > --glib-min-required</option> .
2019-12-02 16:53:14 +01:00
If this option is not passed, the output from <command > gdbus-codegen</command>
is guaranteed to be compatible with all versions of GLib from 2.30
upwards, as that is when <command > gdbus-codegen</command> was first
released.
</para>
gdbus-codegen: Add call_flags and timeout_msec args
Currently the code generated by gdbus-codegen uses
G_DBUS_CALL_FLAGS_NONE in its D-Bus calls, which occur for each method
defined by the input XML, and for proxy_set_property functions. This
means that if the daemon which implements the methods checks for
G_DBUS_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION and only does interactive
authorization if that flag is present, users of the generated code have
no way to cause the daemon to use interactive authorization (e.g. polkit
dialogs).
If we simply changed the generated code to always use
G_DBUS_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION, its users would have no
way to disallow interactive authorization (except for manually calling
the D-Bus method themselves).
So instead, this commit adds a GDBusCallFlags argument to method call
functions. Since this is an API break which will require changes in
projects using gdbus-codegen code, the change is conditional on the
command line argument --glib-min-version having the value 2.64 or
higher.
The impetus for this change is that I'm changing accountsservice to
properly respect G_DBUS_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION, and
libaccountsservice uses generated code for D-Bus method calls. So
these changes will allow libaccountsservice to continue allowing
interactive authorization, and avoid breaking any users of it which
expect that. See
https://gitlab.freedesktop.org/accountsservice/accountsservice/merge_requests/46
It might make sense to also let GDBusCallFlags be specified for property
set operations, but that is not needed in the case of accountsservice,
and would require significant work and breaking API in multiple places.
Similarly, the generated code currently hard codes -1 as the timeout
value when calling g_dbus_proxy_call*(). Add a timeout_msec argument so
the user of the generated code can specify the timeout as well.
Also, test this new API. In gio/tests/codegen.py we test that the new
arguments are generated if and only of --glib-min-version is used with a
value greater than or equal to 2.64, and in gio/tests/meson.build we
test that the generated code with the new API can be linked against.
The test_unix_fd_list() test also needed modification to continue
working now that we're using gdbus-test-codegen.c with code generated
with --glib-min-version=2.64 in one test.
Finally, update the docs for gdbus-codegen to explain the effect of
using --glib-min-version 2.64, both from this commit and from
"gdbus-codegen: Emit GUnixFDLists if an arg has type `h` w/
min-version".
2019-11-25 20:51:13 +01:00
<para >
Note that some version parameters introduce incompatible changes: all callers
of the generated code might need to be updated, and if the generated code is part of
a library's API or ABI, then increasing the version parameter can result in an API
or ABI break.
</para>
2019-12-02 16:53:14 +01:00
<para >
The version number must be of the form
<literal > <replaceable > MAJOR</replaceable> .<replaceable > MINOR</replaceable> .<replaceable > MICRO</replaceable> </literal> ,
where all parts are integers. <replaceable > MINOR</replaceable> and
<replaceable > MICRO</replaceable> are optional. The version number may not be smaller
than <literal > 2.30</literal> .
</para>
gdbus-codegen: Add call_flags and timeout_msec args
Currently the code generated by gdbus-codegen uses
G_DBUS_CALL_FLAGS_NONE in its D-Bus calls, which occur for each method
defined by the input XML, and for proxy_set_property functions. This
means that if the daemon which implements the methods checks for
G_DBUS_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION and only does interactive
authorization if that flag is present, users of the generated code have
no way to cause the daemon to use interactive authorization (e.g. polkit
dialogs).
If we simply changed the generated code to always use
G_DBUS_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION, its users would have no
way to disallow interactive authorization (except for manually calling
the D-Bus method themselves).
So instead, this commit adds a GDBusCallFlags argument to method call
functions. Since this is an API break which will require changes in
projects using gdbus-codegen code, the change is conditional on the
command line argument --glib-min-version having the value 2.64 or
higher.
The impetus for this change is that I'm changing accountsservice to
properly respect G_DBUS_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION, and
libaccountsservice uses generated code for D-Bus method calls. So
these changes will allow libaccountsservice to continue allowing
interactive authorization, and avoid breaking any users of it which
expect that. See
https://gitlab.freedesktop.org/accountsservice/accountsservice/merge_requests/46
It might make sense to also let GDBusCallFlags be specified for property
set operations, but that is not needed in the case of accountsservice,
and would require significant work and breaking API in multiple places.
Similarly, the generated code currently hard codes -1 as the timeout
value when calling g_dbus_proxy_call*(). Add a timeout_msec argument so
the user of the generated code can specify the timeout as well.
Also, test this new API. In gio/tests/codegen.py we test that the new
arguments are generated if and only of --glib-min-version is used with a
value greater than or equal to 2.64, and in gio/tests/meson.build we
test that the generated code with the new API can be linked against.
The test_unix_fd_list() test also needed modification to continue
working now that we're using gdbus-test-codegen.c with code generated
with --glib-min-version=2.64 in one test.
Finally, update the docs for gdbus-codegen to explain the effect of
using --glib-min-version 2.64, both from this commit and from
"gdbus-codegen: Emit GUnixFDLists if an arg has type `h` w/
min-version".
2019-11-25 20:51:13 +01:00
<para >
If the version number is <literal > 2.64</literal> or greater, the generated code will
have the following features: (1) If a method has <literal > h</literal> (file
descriptor) parameter(s), a <type > GUnixFDList</type> parameter will exist in the
generated code for it (whereas previously the annotation
<literal > org.gtk.GDBus.C.UnixFD</literal> was required), and (2) Method call functions will
have two additional arguments to allow the user to specify <type > GDBusCallFlags</type>
and a timeout value, as is possible when using <function > g_dbus_proxy_call()</function> .
</para>
2019-12-02 16:53:14 +01:00
</listitem>
</varlistentry>
2020-01-27 11:36:03 +01:00
<varlistentry >
<term > <option > --glib-max-allowed</option> <replaceable > VERSION</replaceable> </term>
<listitem >
<para >
Specifies the maximum version of GLib which the code generated by
<command > gdbus-codegen</command> can depend on. This may be used to
ensure that code generated by <command > gdbus-codegen</command> is
compilable with specific older versions of GLib that your software has
to support.
</para>
<para >
The version number must be of the form
<literal > <replaceable > MAJOR</replaceable> .<replaceable > MINOR</replaceable> .<replaceable > MICRO</replaceable> </literal> ,
where all parts are integers. <replaceable > MINOR</replaceable> and
<replaceable > MICRO</replaceable> are optional. The version number must
be greater than or equal to that passed to <option > --glib-min-required</option> .
It defaults to the version of GLib which provides this <command > gdbus-codegen</command> .
</para>
</listitem>
</varlistentry>
2011-04-08 22:57:31 +02:00
</variablelist>
</refsect1>
<refsect1 >
<title > Supported D-Bus Annotations</title>
<para >
The following D-Bus annotations are supported by
<command > gdbus-codegen</command> :
</para>
<variablelist >
2011-04-15 18:56:07 +02:00
<varlistentry >
<term > <literal > org.freedesktop.DBus.Deprecated</literal> </term>
<listitem >
<para >
Can be used on any <literal > < interface> </literal> ,
<literal > < method> </literal> ,
<literal > < signal> </literal> and
<literal > < property> </literal> element to specify that
the element is deprecated if its value is
<literal > true</literal> . Note that this annotation is
defined in the <ulink
url="http://dbus.freedesktop.org/doc/dbus-specification.html#introspection-format">D-Bus
specification</ulink> and can only assume the values
<literal > true</literal> and <literal > false</literal> . In
particular, you cannot specify the version that the element
was deprecated in nor any helpful deprecation message. Such
information should be added to the element documentation
instead.
</para>
<para >
When generating C code, this annotation is used to add
#G_GNUC_DEPRECATED to generated functions for the element.
</para>
<para >
When generating Docbook XML, a deprecation warning will
appear along the documentation for the element.
</para>
</listitem>
</varlistentry>
<varlistentry >
<term > <literal > org.gtk.GDBus.Since</literal> </term>
<listitem >
<para >
Can be used on any <literal > < interface> </literal> ,
<literal > < method> </literal> ,
<literal > < signal> </literal> and
<literal > < property> </literal> element to specify the
version (any free-form string but compared using a
version-aware sort function) the element appeared in.
</para>
<para >
When generating C code, this field is used to ensure
2011-04-29 19:11:22 +02:00
function pointer order for preserving ABI/API, see <xref
linkend="gdbus-code-stability"/>.
2011-04-15 18:56:07 +02:00
</para>
<para >
When generating Docbook XML, the value of this tag appears
in the documentation.
</para>
</listitem>
</varlistentry>
<varlistentry >
<term > <literal > org.gtk.GDBus.DocString</literal> </term>
<listitem >
<para >
A string with Docbook content for documentation. This annotation can
be used on <literal > < interface> </literal> ,
<literal > < method> </literal> ,
<literal > < signal> </literal> ,
<literal > < property> </literal> and
<literal > < arg> </literal> elements.
</para>
</listitem>
</varlistentry>
<varlistentry >
<term > <literal > org.gtk.GDBus.DocString.Short</literal> </term>
<listitem >
<para >
A string with Docbook content for short/brief
documentation. This annotation can only be used on
<literal > < interface> </literal> elements.
</para>
</listitem>
</varlistentry>
2011-04-08 22:57:31 +02:00
<varlistentry >
2011-04-15 14:24:40 +02:00
<term > <literal > org.gtk.GDBus.C.Name</literal> </term>
2011-04-08 22:57:31 +02:00
<listitem >
<para >
Can be used on any <literal > < interface> </literal> ,
<literal > < method> </literal> ,
<literal > < signal> </literal> and
<literal > < property> </literal> element to specify the
2011-09-21 13:12:32 +02:00
name to use when generating C code. The value is expected to
be in <ulink
2011-04-15 14:24:40 +02:00
url="http://en.wikipedia.org/wiki/CamelCase">CamelCase</ulink>
2011-09-21 13:12:32 +02:00
or <emphasis > Ugly_Case</emphasis> (see above).
2011-04-08 22:57:31 +02:00
</para>
</listitem>
</varlistentry>
<varlistentry >
<term > <literal > org.gtk.GDBus.C.ForceGVariant</literal> </term>
<listitem >
<para >
2011-04-12 17:50:34 +02:00
If set to a non-empty string, a #GVariant instance will
2011-04-08 22:57:31 +02:00
be used instead of the natural C type. This annotation can
be used on any <literal > < arg> </literal> and
<literal > < property> </literal> element.
</para>
</listitem>
</varlistentry>
2011-07-21 22:03:27 +02:00
<varlistentry >
<term > <literal > org.gtk.GDBus.C.UnixFD</literal> </term>
<listitem >
<para >
If set to a non-empty string, the generated code will
include parameters to exchange file descriptors using the
#GUnixFDList type. This annotation can be used on
<literal > < method> </literal> elements.
</para>
</listitem>
</varlistentry>
2011-04-08 22:57:31 +02:00
</variablelist>
<para >
As an easier alternative to using the
<literal > org.gtk.GDBus.DocString</literal> annotation, note that
2011-04-29 19:11:22 +02:00
parser used by <command > gdbus-codegen</command> parses XML
2011-04-08 22:57:31 +02:00
comments in a way similar to <ulink
url="http://www.gtk.org/gtk-doc/">gtk-doc</ulink> :
<informalexample > <programlisting > < ![CDATA[
<!--
net.Corp.Bar:
@short_description: A short description
A <emphasis > longer</emphasis> description.
This is a new paragraph.
-->
<interface name= "net.corp.Bar" >
<!--
FooMethod:
@greeting: The docs for greeting parameter.
@response: The docs for response parameter.
The docs for the actual method.
-->
<method name= "FooMethod" >
<arg name= "greeting" direction= "in" type= "s" />
<arg name= "response" direction= "out" type= "s" />
</method>
<!--
BarSignal:
@blah: The docs for blah parameter.
@boo: The docs for boo parameter.
2011-04-12 23:12:26 +02:00
@since: 2.30
2011-04-08 22:57:31 +02:00
The docs for the actual signal.
-->
<signal name= "BarSignal" >
<arg name= "blah" type= "s" />
<arg name= "boo" type= "s" />
</signal>
<!-- BazProperty: The docs for the property. -->
<property name= "BazProperty" type= "s" access= "read" />
</interface>
]]></programlisting> </informalexample>
</para>
<para >
2011-04-13 02:28:06 +02:00
Note that <literal > <![CDATA[@since]]> </literal> can be used in any inline
2011-04-12 23:12:26 +02:00
documentation bit (e.g. for interfaces, methods, signals and
properties) to set the <literal > org.gtk.GDBus.Since</literal>
annotation. For the <literal > org.gtk.GDBus.DocString</literal>
annotation (and inline comments), note that substrings of the form
2011-04-13 02:28:06 +02:00
<literal > <![CDATA[#net.Corp.Bar]]> </literal> ,
<literal > <![CDATA[net.Corp.Bar.FooMethod()]]> </literal> ,
<literal > <![CDATA[#net.Corp.Bar::BarSignal]]> </literal> and
<literal > <![CDATA[#net.Corp.InlineDocs:BazProperty]]> </literal> are all
2011-04-12 23:12:26 +02:00
expanded to links to the respective interface, method, signal and
property.
2011-05-24 06:27:43 +02:00
Additionally, substrings starting with <literal > @</literal> and <literal > %</literal> characters are rendered as
<ulink url= "http://www.docbook.org/tdg/en/html/parameter.html" > parameter</ulink> and
<ulink url= "http://www.docbook.org/tdg/en/html/constant.html" > constant</ulink> respectively.
2011-04-08 22:57:31 +02:00
</para>
2011-04-29 19:11:22 +02:00
<para >
If both XML comments and
<literal > org.gtk.GDBus.DocString</literal> or
<literal > org.gtk.GDBus.DocString.Short</literal> annotations are
present, the latter wins.
</para>
2011-04-08 22:57:31 +02:00
</refsect1>
<refsect1 >
<title > Example</title>
<para >
Consider the following D-Bus Introspection XML.
</para>
<informalexample > <programlisting > < ![CDATA[
2012-02-07 10:02:51 +01:00
<node >
<interface name= "net.Corp.MyApp.Frobber" >
<method name= "HelloWorld" >
<arg name= "greeting" direction= "in" type= "s" />
<arg name= "response" direction= "out" type= "s" />
</method>
<signal name= "Notification" >
<arg name= "icon_blob" type= "ay" />
<arg name= "height" type= "i" />
<arg name= "messages" type= "as" />
</signal>
<property name= "Verbose" type= "b" access= "readwrite" />
</interface>
</node>
2011-04-08 22:57:31 +02:00
]]></programlisting>
</informalexample>
<para >
If <command > gdbus-codegen</command> is used on this file like this:
</para>
<informalexample > <programlisting > < ![CDATA[
gdbus-codegen --generate-c-code myapp-generated \
--c-namespace MyApp \
--interface-prefix net.corp.MyApp. \
net.Corp.MyApp.Frobber.xml
]]></programlisting> </informalexample>
<para >
two files called
<filename > myapp-generated.[ch]</filename> are
generated. The files provide an abstract
2011-04-12 17:50:34 +02:00
#GTypeInterface<!-- --> -derived type called
2011-04-08 22:57:31 +02:00
<type > MyAppFrobber</type> as well as two instantiable types with
the same name but suffixed with <type > Proxy</type> and
2011-04-13 22:33:51 +02:00
<type > Skeleton</type> . The generated file, roughly, contains the
2011-04-08 22:57:31 +02:00
following facilities:
</para>
<informalexample > <programlisting > < ![CDATA[
/* GType macros for the three generated types */
#define MY_APP_TYPE_FROBBER (my_app_frobber_get_type ())
2011-04-13 22:33:51 +02:00
#define MY_APP_TYPE_FROBBER_SKELETON (my_app_frobber_skeleton_get_type ())
2011-04-08 22:57:31 +02:00
#define MY_APP_TYPE_FROBBER_PROXY (my_app_frobber_proxy_get_type ())
typedef struct _MyAppFrobber MyAppFrobber; /* Dummy typedef */
typedef struct
{
GTypeInterface parent_iface;
/* Signal handler for the ::notification signal */
void (*notification) (MyAppFrobber *proxy,
GVariant *icon_blob,
gint height,
const gchar* const *messages);
/* Signal handler for the ::handle-hello-world signal */
gboolean (*handle_hello_world) (MyAppFrobber *proxy,
GDBusMethodInvocation *invocation,
const gchar *greeting);
} MyAppFrobberIface;
/* Asynchronously calls HelloWorld() */
void
my_app_frobber_call_hello_world (MyAppFrobber *proxy,
const gchar *greeting,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean
my_app_frobber_call_hello_world_finish (MyAppFrobber *proxy,
gchar **out_response,
GAsyncResult *res,
GError **error);
/* Synchronously calls HelloWorld(). Blocks calling thread. */
gboolean
my_app_frobber_call_hello_world_sync (MyAppFrobber *proxy,
const gchar *greeting,
gchar **out_response,
GCancellable *cancellable,
GError **error);
/* Completes handling the HelloWorld() method call */
void
my_app_frobber_complete_hello_world (MyAppFrobber *object,
GDBusMethodInvocation *invocation,
const gchar *response);
/* Emits the ::notification signal / Notification() D-Bus signal */
void
my_app_frobber_emit_notification (MyAppFrobber *object,
GVariant *icon_blob,
gint height,
const gchar* const *messages);
/* Gets the :verbose GObject property / Verbose D-Bus property.
* Does no blocking I/O.
*/
gboolean my_app_frobber_get_verbose (MyAppFrobber *object);
/* Sets the :verbose GObject property / Verbose D-Bus property.
* Does no blocking I/O.
*/
void my_app_frobber_set_verbose (MyAppFrobber *object,
gboolean value);
/* Gets the interface info */
GDBusInterfaceInfo *my_app_frobber_interface_info (void);
2011-04-13 22:33:51 +02:00
/* Creates a new skeleton object, ready to be exported */
MyAppFrobber *my_app_frobber_skeleton_new (void);
2011-04-08 22:57:31 +02:00
/* Client-side proxy constructors.
*
* Additionally, _new_for_bus(), _new_for_bus_finish() and
* _new_for_bus_sync() proxy constructors are also generated.
*/
void
my_app_frobber_proxy_new (GDBusConnection *connection,
GDBusProxyFlags flags,
const gchar *name,
const gchar *object_path,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
MyAppFrobber *
my_app_frobber_proxy_new_finish (GAsyncResult *res,
GError **error);
MyAppFrobber *
my_app_frobber_proxy_new_sync (GDBusConnection *connection,
GDBusProxyFlags flags,
const gchar *name,
const gchar *object_path,
GCancellable *cancellable,
GError **error);
]]></programlisting> </informalexample>
<para >
Thus, for every D-Bus method, there will be three C functions for
2011-04-12 17:50:34 +02:00
calling the method, one #GObject signal for handling an incoming
call and one C function for completing an incoming call. For every
D-Bus signal, there's one #GObject signal and one C function for
emitting it. For every D-Bus property, two C functions are
generated (one setter, one getter) and one #GObject property. The
following table summarizes the generated facilities and where they
are applicable:
2011-04-08 22:57:31 +02:00
</para>
<informaltable >
<tgroup cols= "3" >
<thead >
<row >
<entry > </entry>
<entry > Client</entry>
<entry > Server</entry>
</row>
</thead>
<tbody >
<row >
<entry > Types</entry>
<entry > Use <type > MyAppFrobberProxy</type> </entry>
<entry > Any type implementing the <type > MyAppFrobber</type> interface</entry>
</row>
<row >
<entry > Methods</entry>
<entry > Use <function > m_a_f_hello_world()</function> to call.</entry>
<entry > Receive via the <function > handle_hello_world()</function> signal handler. Complete the call with <function > m_a_f_complete_hello_world()</function> </entry>
</row>
<row >
<entry > Signals</entry>
<entry > Connect to the <function > ::notification</function> GObject signal.</entry>
<entry > Use <function > m_a_f_emit_notification()</function> to emit signal.</entry>
</row>
<row >
<entry > Properties (Reading)</entry>
<entry > Use <function > m_a_f_get_verbose()</function> or <parameter > :verbose</parameter> .</entry>
2011-04-12 17:50:34 +02:00
<entry > Implement #GObject<!-- --> 's <function > get_property()</function> vfunc.</entry>
2011-04-08 22:57:31 +02:00
</row>
<row >
<entry > Properties (writing)</entry>
<entry > Use <function > m_a_f_set_verbose()</function> or <parameter > :verbose</parameter> .</entry>
2011-04-12 17:50:34 +02:00
<entry > Implement #GObject<!-- --> 's <function > set_property()</function> vfunc.</entry>
2011-04-08 22:57:31 +02:00
</row>
</tbody>
</tgroup>
</informaltable>
<refsect2 >
<title > Client-side usage</title>
<para >
You can use the generated proxy type with the generated
constructors:
</para>
<informalexample > <programlisting > < ![CDATA[
MyAppFrobber *proxy;
GError *error;
error = NULL;
proxy = my_app_frobber_proxy_new_for_bus_sync (
G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
"net.Corp.MyApp", /* bus name */
"/net/Corp/MyApp/SomeFrobber", /* object */
NULL, /* GCancellable* */
&error);
/* do stuff with proxy */
g_object_unref (proxy);
]]></programlisting> </informalexample>
<para >
2011-04-12 17:50:34 +02:00
Instead of using the generic #GDBusProxy facilities, one can use
the generated methods such as
2011-04-08 22:57:31 +02:00
<function > my_app_frobber_call_hello_world()</function> to invoke
the <function > net.Corp.MyApp.Frobber.HelloWorld()</function>
2016-06-22 15:49:05 +02:00
D-Bus method, connect to the
2011-04-08 22:57:31 +02:00
<function > ::notification</function> GObject signal to receive
2011-04-12 17:50:34 +02:00
the <function > net.Corp.MyApp.Frobber::Notication</function>
D-Bus signal and get/set the
2011-04-08 22:57:31 +02:00
<parameter > net.Corp.MyApp.Frobber:Verbose</parameter> D-Bus
Property using either the GObject property
<parameter > :verbose</parameter> or the
<function > my_app_get_verbose()</function> and
<function > my_app_set_verbose()</function> methods. Use the
2011-04-12 17:50:34 +02:00
standard #GObject::notify signal to listen to property changes.
2011-04-08 22:57:31 +02:00
</para>
<para >
2011-04-12 17:50:34 +02:00
Note that all property access is via #GDBusProxy<!-- --> 's
2011-04-29 19:11:22 +02:00
property cache so no I/O is ever done when reading properties.
2011-04-12 17:50:34 +02:00
Also note that setting a property will cause the
<ulink url= "http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-properties" > org.freedesktop.DBus.Properties.Set</ulink> method to be
2011-04-08 22:57:31 +02:00
called on the remote object. This call, however, is asynchronous
so setting a property won't block. Further, the change is
delayed and no error checking is possible.
</para>
</refsect2>
<refsect2 >
<title > Server-side usage</title>
<para >
The generated <type > MyAppFrobber</type> interface is designed so
2011-04-12 17:50:34 +02:00
it is easy to implement it in a #GObject
2011-04-08 22:57:31 +02:00
subclass. For example, to handle
<function > HelloWorld()</function> method invocations, set the
vfunc for <function > handle_hello_hello_world()</function> in the
2018-04-05 12:22:33 +02:00
<type > MyAppFrobberIface</type> structure. Similarly, to handle
2011-04-08 22:57:31 +02:00
the <parameter > net.Corp.MyApp.Frobber:Verbose</parameter>
2011-04-12 17:50:34 +02:00
property override the <parameter > :verbose</parameter> #GObject
2011-04-08 22:57:31 +02:00
property from the subclass. To emit a signal, use
e.g. <function > my_app_emit_signal()</function> or
2011-04-12 17:50:34 +02:00
g_signal_emit_by_name().
2011-04-08 22:57:31 +02:00
</para>
<para >
Instead of subclassing, it is often easier to use the generated
2011-04-13 22:33:51 +02:00
<type > MyAppFrobberSkeleton</type> subclass. To handle incoming
2011-04-08 22:57:31 +02:00
method calls, use <function > g_signal_connect()</function> with
the <function > ::handle-*</function> signals and instead of
2011-04-12 17:50:34 +02:00
overriding #GObject<!-- --> 's
2011-04-08 22:57:31 +02:00
<function > get_property()</function> and
<function > set_property()</function> vfuncs, use
2011-04-12 17:50:34 +02:00
g_object_get() and
g_object_set() or the generated property
2011-04-08 22:57:31 +02:00
getters and setters (the generated class has an internal
property bag implementation).
</para>
<informalexample > <programlisting > < ![CDATA[
static gboolean
2011-05-24 13:34:30 +02:00
on_handle_hello_world (MyAppFrobber *interface,
2011-04-08 22:57:31 +02:00
GDBusMethodInvocation *invocation,
const gchar *greeting,
gpointer user_data)
{
if (g_strcmp0 (greeting, "Boo") != 0)
{
gchar *response;
response = g_strdup_printf ("Word! You said `%s'.", greeting);
2011-05-24 13:34:30 +02:00
my_app_complete_hello_world (interface, invocation, response);
2011-04-08 22:57:31 +02:00
g_free (response);
}
else
{
2012-06-16 16:38:45 +02:00
g_dbus_method_invocation_return_error (invocation,
MY_APP_ERROR,
2011-04-08 22:57:31 +02:00
MY_APP_ERROR_NO_WHINING,
"Hey, %s, there will be no whining!",
g_dbus_method_invocation_get_sender (invocation));
}
return TRUE;
}
[...]
2011-05-24 13:34:30 +02:00
interface = my_app_frobber_skeleton_new ();
my_app_frobber_set_verbose (interface, TRUE);
2011-04-08 22:57:31 +02:00
2011-05-24 13:34:30 +02:00
g_signal_connect (interface,
2011-04-08 22:57:31 +02:00
"handle-hello-world",
2011-05-06 19:00:38 +02:00
G_CALLBACK (on_handle_hello_world),
2011-04-08 22:57:31 +02:00
some_user_data);
[...]
error = NULL;
2011-05-24 13:34:30 +02:00
if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (interface),
2011-04-08 22:57:31 +02:00
connection,
2011-05-24 13:34:30 +02:00
"/path/of/dbus_object",
& error))
{
/* handle error */
}
2011-04-08 22:57:31 +02:00
]]></programlisting> </informalexample>
<para >
2011-04-29 19:11:22 +02:00
To facilitate atomic changesets (multiple properties changing at
2011-04-12 17:50:34 +02:00
the same time), #GObject::notify signals are queued up when
2011-05-15 17:45:37 +02:00
received. The queue is drained in an idle handler (which is called from the
<link linkend= "g-main-context-push-thread-default" > thread-default main loop</link>
of the thread where the skeleton object was
2018-04-05 12:23:07 +02:00
constructed) and will cause emissions of the <ulink
2011-04-12 17:50:34 +02:00
url="http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-properties">org.freedesktop.DBus.Properties::PropertiesChanged</ulink>
2011-04-29 19:11:22 +02:00
signal with all the properties that have changed. Use
g_dbus_interface_skeleton_flush() or
2011-05-15 17:45:37 +02:00
g_dbus_object_skeleton_flush() to empty the queue
immediately. Use g_object_freeze_notify() and
g_object_thaw_notify() for atomic changesets if on a different
thread.
2011-04-08 22:57:31 +02:00
</para>
</refsect2>
</refsect1>
<refsect1 >
<title > C Type Mapping</title>
<para >
2011-04-12 17:50:34 +02:00
Scalar types
(type-strings
<link linkend= "G-VARIANT-TYPE-BOOLEAN:CAPS" > 'b'</link> ,
<link linkend= "G-VARIANT-TYPE-BYTE:CAPS" > 'y'</link> ,
<link linkend= "G-VARIANT-TYPE-INT16:CAPS" > 'n'</link> ,
<link linkend= "G-VARIANT-TYPE-UINT16:CAPS" > 'q'</link> ,
<link linkend= "G-VARIANT-TYPE-INT32:CAPS" > 'i'</link> ,
<link linkend= "G-VARIANT-TYPE-UINT32:CAPS" > 'u'</link> ,
<link linkend= "G-VARIANT-TYPE-INT64:CAPS" > 'x'</link> ,
2011-07-21 22:03:27 +02:00
<link linkend= "G-VARIANT-TYPE-UINT64:CAPS" > 't'</link> and
2011-04-12 17:50:34 +02:00
<link linkend= "G-VARIANT-TYPE-DOUBLE:CAPS" > 'd'</link> )
),
strings (type-strings
<link linkend= "G-VARIANT-TYPE-STRING:CAPS" > 's'</link> ,
<link linkend= "G-VARIANT-TYPE-BYTESTRING:CAPS" > 'ay'</link> ,
<link linkend= "G-VARIANT-TYPE-OBJECT-PATH:CAPS" > 'o'</link> and
<link linkend= "G-VARIANT-TYPE-SIGNATURE:CAPS" > 'g'</link> ) and
arrays of string (type-strings
2011-07-21 15:32:38 +02:00
<link linkend= "G-VARIANT-TYPE-STRING-ARRAY:CAPS" > 'as'</link> ,
<link linkend= "G-VARIANT-TYPE-OBJECT-PATH-ARRAY:CAPS" > 'ao'</link> and
2011-04-12 17:50:34 +02:00
<link linkend= "G-VARIANT-TYPE-BYTESTRING-ARRAY:CAPS" > 'aay'</link> )
are mapped to the natural types,
e.g. #gboolean, #gdouble, #gint, <link linkend= "gchararray" > gchar*</link> ,
<link linkend= "GStrv" > gchar**</link> and
so on. Everything else is mapped to the #GVariant
2011-04-08 22:57:31 +02:00
type.
</para>
<para >
This automatic mapping can be turned off by using the annotation
<literal > org.gtk.GDBus.C.ForceGVariant</literal> - if used then a
2011-04-12 17:50:34 +02:00
#GVariant is always exchanged instead of the
2011-04-08 22:57:31 +02:00
corresponding native C type. This annotation may be convenient to
2011-04-12 17:50:34 +02:00
use when using
bytestrings (type-string <link linkend= "G-VARIANT-TYPE-BYTESTRING:CAPS" > 'ay'</link> )
for data that could have embedded NUL bytes.
2011-04-08 22:57:31 +02:00
</para>
</refsect1>
2011-04-29 19:11:22 +02:00
<refsect1 id= "gdbus-code-stability" >
2011-04-08 22:57:31 +02:00
<title > Stability Guarantees</title>
<para >
2011-04-29 19:11:22 +02:00
The generated C functions are guaranteed to not change their ABI
that is, if a method, signal or property does not change its
signature in the introspection XML, the generated C functions will
2013-10-14 20:40:53 +02:00
not change its C ABI either. The ABI of the generated instance and
class structures will be preserved as well.
2011-04-29 19:11:22 +02:00
</para>
<para >
The ABI of the generated #GType<!-- --> s will be preserved only if
the <literal > org.gtk.GDBus.Since</literal> annotation is used
judiciously — this is because the VTable for the #GInterface
relies on functions pointers for signal handlers. Specifically, if
a D-Bus method, property or signal or is added to a D-Bus
interface, then ABI of the generated #GInterface type is preserved
if, and only if, each added method, property signal is annotated
with they <literal > org.gtk.GDBus.Since</literal> annotation using
a greater version number than previous versions.
</para>
<para >
The generated C code currently happens to be annotated with <ulink
url="http://www.gtk.org/gtk-doc/">gtk-doc</ulink> / <ulink
2014-07-02 06:52:19 +02:00
url="https://wiki.gnome.org/Projects/GObjectIntrospection">GObject
2011-04-29 19:11:22 +02:00
Introspection</ulink> comments / annotations. The layout and
contents might change in the future so no guarantees about
e.g. <literal > SECTION</literal> usage etc. is given.
2011-04-08 22:57:31 +02:00
</para>
<para >
2011-04-29 19:11:22 +02:00
While the generated Docbook for D-Bus interfaces isn't expected to
change, no guarantees are given at this point.
2011-04-08 22:57:31 +02:00
</para>
2013-10-14 20:41:54 +02:00
<para >
It is important to note that the generated code should not be
checked into revision control systems, nor it should be included
in distributed source archives.
</para>
2011-04-08 22:57:31 +02:00
</refsect1>
<refsect1 >
<title > Bugs</title>
<para >
Please send bug reports to either the distribution bug tracker
or the upstream bug tracker at
2018-05-31 23:44:02 +02:00
<ulink url= "https://gitlab.gnome.org/GNOME/glib/issues/new" > https://gitlab.gnome.org/GNOME/glib/issues/new</ulink> .
2011-04-08 22:57:31 +02:00
</para>
</refsect1>
<refsect1 >
<title > See also</title>
<para >
<citerefentry >
<refentrytitle > gdbus</refentrytitle> <manvolnum > 1</manvolnum>
</citerefentry>
</para>
</refsect1>
</refentry>