summaryrefslogtreecommitdiff
path: root/doc/dbus-binding-tool.1
blob: 391c87cd648ffa908666999c12d64269303f2204 (plain)
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
'\" te
.TH dbus-binding-tool 1 "26 Feb 2009" "SunOS 5.11" "User Commands"
.SH "NAME"
dbus-binding-tool \- C language GLib bindings generation utility\&.
.SH "SYNOPSIS"
.PP
\fBdbus-binding-tool\fR [-\fB-force\fR] [-\fB-help\fR] [-\fB-ignore-unsupported\fR] [-\fB-mode=\fIpretty|glib-client|glib-server\fR\fR] [-\fB-output=\fIfile\fR\fR] [-\fB-prefix=\fIsymbol-prefix\fR\fR] [-\fB-version\fR] [\fB\fIfile\fR\fR\&...]
.SH "DESCRIPTION"
.PP
\fBdbus-binding-tool\fR is used to expose a GObject via D\-Bus\&.  As input, 
\fBdbus-binding-tool\fR uses a D\-Bus Introspection XML file\&.  As output,
the client-side or server-side bindings is generated\&.  This output is a header
file which eases the use of a remote D\-Bus object\&.  Output is sent to standard
out or to the filename specified with the -\fB-output\fR argument\&.
.SH "EXTENDED DESCRIPTION"
.SS ""
.PP
The following is a sample D\-Bus Introspection XML file which describes an
object that exposes one method, named ManyArgs:
.PP
.nf
<?xml version="1\&.0" encoding="UTF-8" ?>
<node name="/com/example/MyObject">
  <interface name="com\&.example\&.MyObject">
    <method name="ManyArgs">
      <arg type="u" name="x" direction="in" />
      <arg type="s" name="str" direction="in" />
      <arg type="d" name="trouble" direction="in" />
      <arg type="d" name="d_ret" direction="out" />
      <arg type="s" name="str_ret" direction="out" />
    </method>
  </interface>
</node>
.fi
.PP
\fBdbus-binding-tool\fR supports annotations in the XML format to further
control how the bindings are generated\&.
.SS "client-side bindings"
.PP
When building client-side bindings, the -\fB-mode=glib-client\fR
argument is used\&.  The client-side bindings support the
"org\&.freedesktop\&.DBus\&.Glib\&.NoReply" annotation\&.  This is specified
within the <method> tag to indicate that the client is not expecting
a reply to the method call, so a reply should not be sent\&.  This is
often used to speed up rapid method calls where there are no "out"
arguments, and not knowing if the method succeeded is an acceptable compromise
to halve the traffic on the bus\&.  For example:
.PP
.nf
<method name "FooMethod">
  [\&.\&.\&.]
  <annotation name="org\&.freedesktop\&.DBus\&.GLib\&.NoReply" value="yes"/>
  [\&.\&.\&.]
</method>
.fi
.SS "server-side bindings"
.PP
When building server-side bindings, the -\fB-mode=glib-server\fR
argument is used\&.  Also the -\fB-prefix\fR argument must be used when
building server-side bindings so that functions in the generated output are
prefexed with the specified value\&.  The server-side bindings support the
following annotations:
.PP
"org\&.freedesktop\&.DBus\&.GLib\&.CSymbol"
.PP
This annotation is used to specify the C symbol names for the various types
(interface, method, etc\&.), if it differs from the name D\-Bus generates\&. 
.PP
.PP
.nf
<interface name="com\&.example\&.MyObject">
  <annotation name="org\&.freedesktop\&.DBus\&.GLib\&.CSymbol" value="my_object"/>
  [\&.\&.\&.]
  <method name "ManyArgs">
    <annotation name="org\&.freedesktop\&.DBus\&.GLib\&.CSymbol" value="my_object_many_args"/>
    [\&.\&.\&.]
  </method>
</interface>
.fi
.PP
"org\&.freedesktop\&.DBus\&.GLib\&.Async"
.PP
This annotation marks the method implementation as an asynchronous function,
which does not return a response straight away but will send the response at
some later point to complete the call\&. This is used to implement non-blocking
services where method calls can take time\&.
.PP
When a method is asynchronous, the function prototype is different\&. It is
required that the function conform to the following rules:
.sp
.in +2
\(bu
.mk
.in +3
.rt
The function must return a value of type gboolean; TRUE on success,
and FALSE otherwise\&.
.in -3
\(bu
.mk
.in +3
.rt
The first parameter is a pointer to an instance of the object\&.
.in -3
\(bu
.mk
.in +3
.rt
Following the object instance pointer are the method input values\&.
.in -3
\(bu
.mk
.in +3
.rt
The final parameter must be a (DBusGMethodInvocation *)\&. This is used
when sending the response message back to the client, by calling
dbus_g_method_return or dbus_g_method_return_error\&.
.in -3
.in -2
.PP
For example:
.PP
.nf
<method name "FooMethod">
  [\&.\&.\&.]
  <annotation name="org\&.freedesktop\&.DBus\&.GLib\&.Async" value="yes"/>
  [\&.\&.\&.]
</method>
.fi
.PP
"org\&.freedesktop\&.DBus\&.GLib\&.Const"
.PP
This attribute can only be applied to "out" <arg> nodes, and
specifies that the parameter is not being copied when returned\&. For example,
this turns a \&'s\&' argument from a (char **) to a (const char **), and results in
the argument not being freed by D\-Bus after the message is sent\&.  For example:
.PP
.nf
  <arg type="u" name="x" direction="out">
    <annotation name="org\&.freedesktop\&.DBus\&.GLib\&.Const" value=""/>
  </arg>
.fi
.PP
"org\&.freedesktop\&.DBus\&.GLib\&.ReturnVal"
.PP
This attribute can only be applied to "out" <arg> nodes, and
alters the expected function signature\&. It currently can be set to two values:
"" or "error"\&. The argument marked with this attribute is
not returned via a pointer argument, but by the function\&'s return value\&. If the
attribute\&'s value is the empty string, the (GError *) argument is also omitted
so there is no standard way to return an error value\&. This is very useful for
interfacing with existing code, as it is possible to match existing APIs\&. If
the attribute\&'s value is "error", then the final argument is a
(GError *) as usual\&.  For example:
.PP
.nf
  <arg type="u" name="x" direction="out">
    <annotation name="org\&.freedesktop\&.DBus\&.GLib\&.ReturnVal" value=""/>
  </arg>
.fi
.SH "OPTIONS"
.PP
The following options are supported:
.sp
.ne 2
.mk
\fB-\fB-force\fR\fR
.sp .6
.in +4
Overwrite the output file if it already exists with a newer timestamp than the
source files\&.
.sp
.sp 1
.in -4
.sp
.ne 2
.mk
\fB-\fB-help\fR\fR
.sp .6
.in +4
Display usage information\&.
.sp
.sp 1
.in -4
.sp
.ne 2
.mk
\fB-\fB-ignore-unsupported\fR\fR
.sp .6
.in +4
If set, then unsupported signatures for <method> parameters are
ignored\&.
.sp
.sp 1
.in -4
.sp
.ne 2
.mk
\fB-\fB-mode=\fIpretty|glib-client|glib-server\fR\fR\fR
.sp .6
.in +4
If the value is "glib-client", then client bindings are generated\&.
If the value is "glib-server", then server bindings are generated\&.
If the value is "pretty", then the output is in a more human readable
format\&.
.sp
.sp 1
.in -4
.sp
.ne 2
.mk
\fB-\fB-output=\fIfile\fR\fR\fR
.sp .6
.in +4
Specify the output \fIfile\fR\&.
.sp
.sp 1
.in -4
.sp
.ne 2
.mk
\fB-\fB-prefix=\fIsymbol-prefix\fR\fR\fR
.sp .6
.in +4
Functions in the generated output are prefixed with the
\fIsymbol-prefix\fR value\&.
.sp
.sp 1
.in -4
.sp
.ne 2
.mk
\fB-\fB-version\fR\fR
.sp .6
.in +4
Display the version number of the \fBdbus-binding-tool\fR command\&.
.sp
.sp 1
.in -4
.SH "OPERANDS"
.PP
The following operands are supported:
.sp
.ne 2
.mk
\fB\fB\fIfile\fR\fR\fR
.in +16n
.rt
A list of one or more input D\-Bus Introspection XML files to include in the
generated output\&.
.sp
.sp 1
.in -16n
.SH "FILES"
.PP
The following files are used by this application:
.sp
.ne 2
.mk
\fB\fB/usr/bin/dbus-binding-tool\fR \fR
.in +32n
.rt
Executable for the D\-Bus Binding Tool application\&.
.sp
.sp 1
.in -32n
.SH "ATTRIBUTES"
.PP
See \fBattributes\fR(5)
for descriptions of the following attributes:
.sp
.TS
tab() allbox;
cw(2.750000i)| cw(2.750000i)
lw(2.750000i)| lw(2.750000i).
ATTRIBUTE TYPEATTRIBUTE VALUE
AvailabilitySUNWdbus-bindings
Interface stabilityVolatile
.TE
.sp
.SH "SEE ALSO"
.PP
\fBdbus-cleanup-sockets\fR(1),
\fBdbus-daemon\fR(1),
\fBdbus-monitor\fR(1),
\fBdbus-send\fR(1),
\fBdbus-uuidgen\fR(1),
\fBlibdbus-glib-1\fR(3),
\fBattributes\fR(5)
.SH "NOTES"
.PP
Written by Brian Cameron, Sun Microsystems Inc\&., 2009\&.
...\" created by instant / solbook-to-man, Thu 26 Feb 2009, 19:15
...\" LSARC 2006/368 D-BUS Message Bus System