1 /* valadbusinterfaceregisterfunction.vala
3 * Copyright (C) 2009 Didier Villevalois
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 * Didier Villevalois <ptitjes@free.fr>
26 * C function to register an interface at runtime.
28 public class Vala
.DBusInterfaceRegisterFunction
: InterfaceRegisterFunction
{
30 public DBusInterfaceRegisterFunction (Interface iface
, CodeContext context
) {
34 public override CCodeFragment
get_type_interface_init_statements () {
35 var frag
= base.get_type_interface_init_statements ();
37 var quark_dbus_proxy
= new
CCodeFunctionCall (new
CCodeIdentifier ("g_quark_from_string"));
38 quark_dbus_proxy
.add_argument (new
CCodeConstant ("\"ValaDBusInterfaceProxyType\""));
40 var func
= new
CCodeFunctionCall (new
CCodeIdentifier ("g_type_set_qdata"));
41 func
.add_argument (new
CCodeIdentifier ("%s_type_id".printf (interface_reference
.get_lower_case_cname
43 func
.add_argument (quark_dbus_proxy
);
44 func
.add_argument (new
CCodeUnaryExpression (CCodeUnaryOperator
.ADDRESS_OF
, new CCodeIdentifier
45 ("%s_dbus_proxy_get_type".printf (interface_reference
.get_lower_case_cname (null)))));
47 frag
.append (new
CCodeExpressionStatement (func
));