1 /* valagdbusmodule.vala
3 * Copyright (C) 2010-2012 Jürg Billeter
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * Jürg Billeter <j@bitron.ch>
23 public class Vala
.GDBusModule
: GVariantModule
{
24 public static string?
get_dbus_name (TypeSymbol symbol
) {
25 return symbol
.get_attribute_string ("DBus", "name");
28 public static string get_dbus_name_for_member (Symbol symbol
) {
29 var dbus_name
= symbol
.get_attribute_string ("DBus", "name");
30 if (dbus_name
!= null) {
34 return Symbol
.lower_case_to_camel_case (symbol
.name
);
37 public static int get_dbus_timeout_for_member (Symbol symbol
) {
38 return symbol
.get_attribute_integer ("DBus", "timeout", -1);
41 public static bool is_dbus_visible (CodeNode node
) {
42 var dbus_attribute
= node
.get_attribute ("DBus");
43 if (dbus_attribute
!= null
44 && dbus_attribute
.has_argument ("visible")
45 && !dbus_attribute
.get_bool ("visible")) {
52 public static bool is_dbus_no_reply (Method m
) {
53 return m
.get_attribute_bool ("DBus", "no_reply");
56 public static string dbus_result_name (Method m
) {
57 var dbus_name
= m
.get_attribute_string ("DBus", "result");
58 if (dbus_name
!= null && dbus_name
!= "") {
65 public override void visit_error_domain (ErrorDomain edomain
) {
66 var edomain_dbus_name
= get_dbus_name (edomain
);
67 if (edomain_dbus_name
== null) {
68 base.visit_error_domain (edomain
);
72 cfile
.add_include ("gio/gio.h");
74 generate_error_domain_declaration (edomain
, cfile
);
76 if (!edomain
.is_internal_symbol ()) {
77 generate_error_domain_declaration (edomain
, header_file
);
79 if (!edomain
.is_private_symbol ()) {
80 generate_error_domain_declaration (edomain
, internal_header_file
);
83 var error_entries
= new
CCodeInitializerList ();
84 foreach (ErrorCode ecode
in edomain
.get_codes ()) {
85 var ecode_dbus_name
= get_dbus_name (ecode
);
86 if (ecode_dbus_name
== null) {
87 ecode_dbus_name
= Symbol
.lower_case_to_camel_case (ecode
.name
.down ());
90 var error_entry
= new
CCodeInitializerList ();
91 error_entry
.append (new
CCodeIdentifier (get_ccode_name (ecode
)));
92 error_entry
.append (new
CCodeConstant ("\"%s.%s\"".printf (edomain_dbus_name
, ecode_dbus_name
)));
93 error_entries
.append (error_entry
);
96 var cdecl
= new
CCodeDeclaration ("const GDBusErrorEntry");
97 cdecl
.add_declarator (new
CCodeVariableDeclarator (get_ccode_lower_case_name (edomain
) + "_entries[]", error_entries
));
98 cdecl
.modifiers
= CCodeModifiers
.STATIC
;
99 cfile
.add_constant_declaration (cdecl
);
101 string quark_fun_name
= get_ccode_lower_case_prefix (edomain
) + "quark";
103 var cquark_fun
= new
CCodeFunction (quark_fun_name
, get_ccode_name (gquark_type
.data_type
));
104 push_function (cquark_fun
);
106 string quark_name
= "%squark_volatile".printf (get_ccode_lower_case_prefix (edomain
));
108 ccode
.add_declaration ("gsize", new
CCodeVariableDeclarator (quark_name
, new
CCodeConstant ("0")), CCodeModifiers
.STATIC
| CCodeModifiers
.VOLATILE
);
110 var register_call
= new
CCodeFunctionCall (new
CCodeIdentifier ("g_dbus_error_register_error_domain"));
111 register_call
.add_argument (new
CCodeConstant ("\"" + CCodeBaseModule
.get_quark_name (edomain
) + "\""));
112 register_call
.add_argument (new
CCodeUnaryExpression (CCodeUnaryOperator
.ADDRESS_OF
, new
CCodeIdentifier (quark_name
)));
113 register_call
.add_argument (new
CCodeIdentifier (get_ccode_lower_case_name (edomain
) + "_entries"));
114 var nentries
= new
CCodeFunctionCall (new
CCodeIdentifier ("G_N_ELEMENTS"));
115 nentries
.add_argument (new
CCodeIdentifier (get_ccode_lower_case_name (edomain
) + "_entries"));
116 register_call
.add_argument (nentries
);
117 ccode
.add_expression (register_call
);
119 ccode
.add_return (new
CCodeCastExpression (new
CCodeIdentifier (quark_name
), "GQuark"));
122 cfile
.add_function (cquark_fun
);
125 bool is_file_descriptor (DataType type
) {
126 if (type is ObjectType
) {
127 if (type
.data_type
.get_full_name () == "GLib.UnixInputStream" ||
128 type
.data_type
.get_full_name () == "GLib.UnixOutputStream" ||
129 type
.data_type
.get_full_name () == "GLib.Socket" ||
130 type
.data_type
.get_full_name () == "GLib.FileDescriptorBased") {
138 public bool dbus_method_uses_file_descriptor (Method method
) {
139 foreach (Parameter param
in method
.get_parameters ()) {
140 if (is_file_descriptor (param
.variable_type
)) {
145 if (is_file_descriptor (method
.return_type
)) {
152 CCodeExpression?
get_file_descriptor (DataType type
, CCodeExpression expr
) {
153 if (type is ObjectType
) {
154 if (type
.data_type
.get_full_name () == "GLib.UnixInputStream") {
155 var result
= new
CCodeFunctionCall (new
CCodeIdentifier ("g_unix_input_stream_get_fd"));
156 result
.add_argument (expr
);
158 } else if (type
.data_type
.get_full_name () == "GLib.UnixOutputStream") {
159 var result
= new
CCodeFunctionCall (new
CCodeIdentifier ("g_unix_output_stream_get_fd"));
160 result
.add_argument (expr
);
162 } else if (type
.data_type
.get_full_name () == "GLib.Socket") {
163 var result
= new
CCodeFunctionCall (new
CCodeIdentifier ("g_socket_get_fd"));
164 result
.add_argument (expr
);
166 } else if (type
.data_type
.get_full_name () == "GLib.FileDescriptorBased") {
167 var result
= new
CCodeFunctionCall (new
CCodeIdentifier ("g_file_descriptor_based_get_fd"));
168 result
.add_argument (expr
);
176 public void send_dbus_value (DataType type
, CCodeExpression builder_expr
, CCodeExpression expr
, Symbol? sym
) {
177 var fd
= get_file_descriptor (type
, expr
);
179 // add file descriptor to the file descriptor list
180 var fd_append
= new
CCodeFunctionCall (new
CCodeIdentifier ("g_unix_fd_list_append"));
181 fd_append
.add_argument (new
CCodeIdentifier ("_fd_list"));
182 fd_append
.add_argument (fd
);
183 fd_append
.add_argument (new
CCodeConstant ("NULL"));
185 // add index to file descriptor to gvariant
186 var builder_add
= new
CCodeFunctionCall (new
CCodeIdentifier ("g_variant_builder_add"));
187 builder_add
.add_argument (new
CCodeUnaryExpression (CCodeUnaryOperator
.ADDRESS_OF
, builder_expr
));
188 builder_add
.add_argument (new
CCodeConstant ("\"h\""));
189 builder_add
.add_argument (fd_append
);
190 ccode
.add_expression (builder_add
);
192 write_expression (type
, builder_expr
, expr
, sym
);
196 CCodeExpression?
create_from_file_descriptor (DataType type
, CCodeExpression expr
) {
197 if (type is ObjectType
) {
198 if (type
.data_type
.get_full_name () == "GLib.UnixInputStream") {
199 var result
= new
CCodeFunctionCall (new
CCodeIdentifier ("g_unix_input_stream_new"));
200 result
.add_argument (expr
);
201 result
.add_argument (new
CCodeConstant ("TRUE"));
202 return new
CCodeCastExpression (result
, "GUnixInputStream *");
203 } else if (type
.data_type
.get_full_name () == "GLib.UnixOutputStream") {
204 var result
= new
CCodeFunctionCall (new
CCodeIdentifier ("g_unix_output_stream_new"));
205 result
.add_argument (expr
);
206 result
.add_argument (new
CCodeConstant ("TRUE"));
207 return new
CCodeCastExpression (result
, "GUnixOutputStream *");
208 } else if (type
.data_type
.get_full_name () == "GLib.Socket") {
209 var result
= new
CCodeFunctionCall (new
CCodeIdentifier ("g_socket_new_from_fd"));
210 result
.add_argument (expr
);
211 result
.add_argument (new
CCodeConstant ("NULL"));
219 public void receive_dbus_value (DataType type
, CCodeExpression message_expr
, CCodeExpression iter_expr
, CCodeExpression target_expr
, Symbol? sym
, CCodeExpression? error_expr
= null, out bool may_fail
= null) {
220 var fd_list
= new
CCodeFunctionCall (new
CCodeIdentifier ("g_dbus_message_get_unix_fd_list"));
221 fd_list
.add_argument (message_expr
);
223 var fd_var
= new
CCodeIdentifier ("_fd");
225 var stream
= create_from_file_descriptor (type
, fd_var
);
226 if (stream
!= null) {
227 var fd_list_var
= new
CCodeIdentifier ("_fd_list");
229 var fd
= new
CCodeFunctionCall (new
CCodeIdentifier ("g_unix_fd_list_get"));
230 fd
.add_argument (fd_list_var
);
231 fd
.add_argument (new
CCodeIdentifier ("_fd_index"));
232 fd
.add_argument (error_expr
);
234 ccode
.add_assignment (fd_list_var
, fd_list
);
235 ccode
.open_if (fd_list_var
);
237 var get_fd
= new
CCodeFunctionCall (new
CCodeIdentifier ("g_variant_iter_next"));
238 get_fd
.add_argument (new
CCodeUnaryExpression (CCodeUnaryOperator
.ADDRESS_OF
, iter_expr
));
239 get_fd
.add_argument (new
CCodeConstant ("\"h\""));
240 get_fd
.add_argument (new
CCodeUnaryExpression (CCodeUnaryOperator
.ADDRESS_OF
, new
CCodeIdentifier ("_fd_index")));
241 ccode
.add_expression (get_fd
);
243 ccode
.add_assignment (fd_var
, fd
);
244 ccode
.open_if (new
CCodeBinaryExpression (CCodeBinaryOperator
.GREATER_THAN_OR_EQUAL
, fd_var
, new
CCodeConstant ("0")));
246 ccode
.add_assignment (target_expr
, stream
);
252 var set_error
= new
CCodeFunctionCall (new
CCodeIdentifier ("g_set_error_literal"));
253 set_error
.add_argument (error_expr
);
254 set_error
.add_argument (new
CCodeIdentifier ("G_IO_ERROR"));
255 set_error
.add_argument (new
CCodeIdentifier ("G_IO_ERROR_FAILED"));
256 set_error
.add_argument (new
CCodeConstant ("\"FD List is NULL\""));
257 ccode
.add_expression (set_error
);
260 read_expression (type
, iter_expr
, target_expr
, sym
, error_expr
, out may_fail
);
263 CCodeExpression
get_method_info (ObjectTypeSymbol sym
) {
264 var infos
= new
CCodeInitializerList ();
266 foreach (Method m
in sym
.get_methods ()) {
267 if (m is CreationMethod
|| m
.binding
!= MemberBinding
.INSTANCE
268 || m
.overrides
|| m
.access
!= SymbolAccessibility
.PUBLIC
) {
271 if (!is_dbus_visible (m
)) {
275 var in_args_info
= new
CCodeInitializerList ();
276 var out_args_info
= new
CCodeInitializerList ();
278 foreach (Parameter param
in m
.get_parameters ()) {
279 if (param
.variable_type is ObjectType
&& param
.variable_type
.data_type
.get_full_name () == "GLib.Cancellable") {
282 if (param
.variable_type is ObjectType
&& param
.variable_type
.data_type
.get_full_name () == "GLib.BusName") {
286 var info
= new
CCodeInitializerList ();
287 info
.append (new
CCodeConstant ("-1"));
288 info
.append (new
CCodeConstant ("\"%s\"".printf (param
.name
)));
289 info
.append (new
CCodeConstant ("\"%s\"".printf (get_type_signature (param
.variable_type
, param
))));
291 var cdecl
= new
CCodeDeclaration ("const GDBusArgInfo");
292 cdecl
.add_declarator (new
CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_arg_info_" + m
.name
+ "_" + param
.name
, info
));
293 cdecl
.modifiers
= CCodeModifiers
.STATIC
;
294 cfile
.add_constant_declaration (cdecl
);
296 if (param
.direction
== ParameterDirection
.IN
) {
297 in_args_info
.append (new
CCodeUnaryExpression (CCodeUnaryOperator
.ADDRESS_OF
, new
CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_arg_info_" + m
.name
+ "_" + param
.name
)));
299 out_args_info
.append (new
CCodeUnaryExpression (CCodeUnaryOperator
.ADDRESS_OF
, new
CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_arg_info_" + m
.name
+ "_" + param
.name
)));
303 if (!(m
.return_type is VoidType
)) {
304 var info
= new
CCodeInitializerList ();
305 info
.append (new
CCodeConstant ("-1"));
306 info
.append (new
CCodeConstant ("\"%s\"".printf (dbus_result_name (m
))));
307 info
.append (new
CCodeConstant ("\"%s\"".printf (get_type_signature (m
.return_type
, m
))));
309 var cdecl
= new
CCodeDeclaration ("const GDBusArgInfo");
310 cdecl
.add_declarator (new
CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_arg_info_" + m
.name
+ "_result", info
));
311 cdecl
.modifiers
= CCodeModifiers
.STATIC
;
312 cfile
.add_constant_declaration (cdecl
);
314 out_args_info
.append (new
CCodeUnaryExpression (CCodeUnaryOperator
.ADDRESS_OF
, new
CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_arg_info_" + m
.name
+ "_result")));
317 in_args_info
.append (new
CCodeConstant ("NULL"));
318 out_args_info
.append (new
CCodeConstant ("NULL"));
320 var cdecl
= new
CCodeDeclaration ("const GDBusArgInfo * const");
321 cdecl
.add_declarator (new
CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_arg_info_" + m
.name
+ "_in[]", in_args_info
));
322 cdecl
.modifiers
= CCodeModifiers
.STATIC
;
323 cfile
.add_constant_declaration (cdecl
);
325 cdecl
= new
CCodeDeclaration ("const GDBusArgInfo * const");
326 cdecl
.add_declarator (new
CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_arg_info_" + m
.name
+ "_out[]", out_args_info
));
327 cdecl
.modifiers
= CCodeModifiers
.STATIC
;
328 cfile
.add_constant_declaration (cdecl
);
330 var info
= new
CCodeInitializerList ();
331 info
.append (new
CCodeConstant ("-1"));
332 info
.append (new
CCodeConstant ("\"%s\"".printf (get_dbus_name_for_member (m
))));
333 info
.append (new
CCodeCastExpression (new
CCodeUnaryExpression (CCodeUnaryOperator
.ADDRESS_OF
, new
CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_arg_info_" + m
.name
+ "_in")), "GDBusArgInfo **"));
334 info
.append (new
CCodeCastExpression (new
CCodeUnaryExpression (CCodeUnaryOperator
.ADDRESS_OF
, new
CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_arg_info_" + m
.name
+ "_out")), "GDBusArgInfo **"));
336 cdecl
= new
CCodeDeclaration ("const GDBusMethodInfo");
337 cdecl
.add_declarator (new
CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_method_info_" + m
.name
, info
));
338 cdecl
.modifiers
= CCodeModifiers
.STATIC
;
339 cfile
.add_constant_declaration (cdecl
);
341 infos
.append (new
CCodeUnaryExpression (CCodeUnaryOperator
.ADDRESS_OF
, new
CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_method_info_" + m
.name
)));
344 infos
.append (new
CCodeConstant ("NULL"));
346 var cdecl
= new
CCodeDeclaration ("const GDBusMethodInfo * const");
347 cdecl
.add_declarator (new
CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_method_info[]", infos
));
348 cdecl
.modifiers
= CCodeModifiers
.STATIC
;
349 cfile
.add_constant_declaration (cdecl
);
351 return new
CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_method_info");
354 CCodeExpression
get_signal_info (ObjectTypeSymbol sym
) {
355 var infos
= new
CCodeInitializerList ();
357 foreach (Signal sig
in sym
.get_signals ()) {
358 if (sig
.access
!= SymbolAccessibility
.PUBLIC
) {
361 if (!is_dbus_visible (sig
)) {
365 var args_info
= new
CCodeInitializerList ();
367 foreach (Parameter param
in sig
.get_parameters ()) {
368 var info
= new
CCodeInitializerList ();
369 info
.append (new
CCodeConstant ("-1"));
370 info
.append (new
CCodeConstant ("\"%s\"".printf (param
.name
)));
371 info
.append (new
CCodeConstant ("\"%s\"".printf (get_type_signature (param
.variable_type
, param
))));
373 var cdecl
= new
CCodeDeclaration ("const GDBusArgInfo");
374 cdecl
.add_declarator (new
CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_arg_info_" + get_ccode_lower_case_name (sig
) + "_" + param
.name
, info
));
375 cdecl
.modifiers
= CCodeModifiers
.STATIC
;
376 cfile
.add_constant_declaration (cdecl
);
378 args_info
.append (new
CCodeUnaryExpression (CCodeUnaryOperator
.ADDRESS_OF
, new
CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_arg_info_" + get_ccode_lower_case_name (sig
) + "_" + param
.name
)));
381 args_info
.append (new
CCodeConstant ("NULL"));
383 var cdecl
= new
CCodeDeclaration ("const GDBusArgInfo * const");
384 cdecl
.add_declarator (new
CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_arg_info_" + get_ccode_lower_case_name (sig
) + "[]", args_info
));
385 cdecl
.modifiers
= CCodeModifiers
.STATIC
;
386 cfile
.add_constant_declaration (cdecl
);
388 var info
= new
CCodeInitializerList ();
389 info
.append (new
CCodeConstant ("-1"));
390 info
.append (new
CCodeConstant ("\"%s\"".printf (get_dbus_name_for_member (sig
))));
391 info
.append (new
CCodeCastExpression (new
CCodeUnaryExpression (CCodeUnaryOperator
.ADDRESS_OF
, new
CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_arg_info_" + get_ccode_lower_case_name (sig
))), "GDBusArgInfo **"));
393 cdecl
= new
CCodeDeclaration ("const GDBusSignalInfo");
394 cdecl
.add_declarator (new
CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_signal_info_" + get_ccode_lower_case_name (sig
), info
));
395 cdecl
.modifiers
= CCodeModifiers
.STATIC
;
396 cfile
.add_constant_declaration (cdecl
);
398 infos
.append (new
CCodeUnaryExpression (CCodeUnaryOperator
.ADDRESS_OF
, new
CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_signal_info_" + get_ccode_lower_case_name (sig
))));
401 infos
.append (new
CCodeConstant ("NULL"));
403 var cdecl
= new
CCodeDeclaration ("const GDBusSignalInfo * const");
404 cdecl
.add_declarator (new
CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_signal_info[]", infos
));
405 cdecl
.modifiers
= CCodeModifiers
.STATIC
;
406 cfile
.add_constant_declaration (cdecl
);
408 return new
CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_signal_info");
411 CCodeExpression
get_property_info (ObjectTypeSymbol sym
) {
412 var infos
= new
CCodeInitializerList ();
414 foreach (Property prop
in sym
.get_properties ()) {
415 if (prop
.binding
!= MemberBinding
.INSTANCE
416 || prop
.overrides
|| prop
.access
!= SymbolAccessibility
.PUBLIC
) {
419 if (!is_dbus_visible (prop
)) {
423 var info
= new
CCodeInitializerList ();
424 info
.append (new
CCodeConstant ("-1"));
425 info
.append (new
CCodeConstant ("\"%s\"".printf (get_dbus_name_for_member (prop
))));
426 info
.append (new
CCodeConstant ("\"%s\"".printf (get_type_signature (prop
.property_type
, prop
))));
427 if (prop
.get_accessor
!= null && prop
.set_accessor
!= null) {
428 info
.append (new
CCodeConstant ("G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE"));
429 } else if (prop
.get_accessor
!= null) {
430 info
.append (new
CCodeConstant ("G_DBUS_PROPERTY_INFO_FLAGS_READABLE"));
431 } else if (prop
.set_accessor
!= null) {
432 info
.append (new
CCodeConstant ("G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE"));
434 info
.append (new
CCodeConstant ("G_DBUS_PROPERTY_INFO_FLAGS_NONE"));
437 var cdecl
= new
CCodeDeclaration ("const GDBusPropertyInfo");
438 cdecl
.add_declarator (new
CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_property_info_" + prop
.name
, info
));
439 cdecl
.modifiers
= CCodeModifiers
.STATIC
;
440 cfile
.add_constant_declaration (cdecl
);
442 infos
.append (new
CCodeUnaryExpression (CCodeUnaryOperator
.ADDRESS_OF
, new
CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_property_info_" + prop
.name
)));
445 infos
.append (new
CCodeConstant ("NULL"));
447 var cdecl
= new
CCodeDeclaration ("const GDBusPropertyInfo * const");
448 cdecl
.add_declarator (new
CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_property_info[]", infos
));
449 cdecl
.modifiers
= CCodeModifiers
.STATIC
;
450 cfile
.add_constant_declaration (cdecl
);
452 return new
CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_property_info");
455 void declare_interface_info (ObjectTypeSymbol sym
) {
456 var info
= new
CCodeInitializerList ();
457 info
.append (new
CCodeConstant ("-1"));
458 info
.append (new
CCodeConstant ("\"%s\"".printf (get_dbus_name (sym
))));
459 info
.append (new
CCodeCastExpression (new
CCodeUnaryExpression (CCodeUnaryOperator
.ADDRESS_OF
, get_method_info (sym
)), "GDBusMethodInfo **"));
460 info
.append (new
CCodeCastExpression (new
CCodeUnaryExpression (CCodeUnaryOperator
.ADDRESS_OF
, get_signal_info (sym
)), "GDBusSignalInfo **"));
461 info
.append (new
CCodeCastExpression (new
CCodeUnaryExpression (CCodeUnaryOperator
.ADDRESS_OF
, get_property_info (sym
)), "GDBusPropertyInfo **"));
463 var cdecl
= new
CCodeDeclaration ("const GDBusInterfaceInfo");
464 cdecl
.add_declarator (new
CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_interface_info", info
));
465 cdecl
.modifiers
= CCodeModifiers
.STATIC
;
466 cfile
.add_constant_declaration (cdecl
);
469 protected CCodeExpression
get_interface_info (ObjectTypeSymbol sym
) {
470 return new
CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym
) + "dbus_interface_info");
473 public override void visit_class (Class cl
) {
474 base.visit_class (cl
);
476 visit_object_type_symbol (cl
);
479 public override void visit_interface (Interface iface
) {
480 base.visit_interface (iface
);
482 visit_object_type_symbol (iface
);
485 void visit_object_type_symbol (ObjectTypeSymbol sym
) {
486 if (get_dbus_name (sym
) == null) {
490 declare_interface_info(sym
);