D-Bus: Remove extra semicolon to avoid C warning
[vala-lang.git] / codegen / valainterfaceregisterfunction.vala
blobcec7cbdd136580ac0153d274e4ba6ed16f80bcf5
1 /* valainterfaceregisterfunction.vala
3 * Copyright (C) 2006-2011 Jürg Billeter
4 * Copyright (C) 2006-2007 Raffaele Sandrini
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * Author:
21 * Jürg Billeter <j@bitron.ch>
22 * Raffaele Sandrini <raffaele@sandrini.ch>
25 using GLib;
27 /**
28 * C function to register an interface at runtime.
30 public class Vala.InterfaceRegisterFunction : TypeRegisterFunction {
31 /**
32 * Specifies the interface to be registered.
34 public weak Interface interface_reference { get; set; }
36 public InterfaceRegisterFunction (Interface iface, CodeContext context) {
37 interface_reference = iface;
38 this.context = context;
41 public override TypeSymbol get_type_declaration () {
42 return interface_reference;
45 public override string get_type_struct_name () {
46 return interface_reference.get_type_cname ();
49 public override string get_base_init_func_name () {
50 return "%s_base_init".printf (interface_reference.get_lower_case_cname (null));
53 public override string get_class_finalize_func_name () {
54 return "NULL";
57 public override string get_base_finalize_func_name () {
58 return "NULL";
61 public override string get_class_init_func_name () {
62 return "NULL";
65 public override string get_instance_struct_size () {
66 return "0";
69 public override string get_instance_init_func_name () {
70 return "NULL";
73 public override string get_parent_type_name () {
74 return "G_TYPE_INTERFACE";
77 public override SymbolAccessibility get_accessibility () {
78 return interface_reference.access;
81 public override void get_type_interface_init_statements (CCodeBlock block, bool plugin) {
82 /* register all prerequisites */
83 foreach (DataType prereq_ref in interface_reference.get_prerequisites ()) {
84 var prereq = prereq_ref.data_type;
86 var func = new CCodeFunctionCall (new CCodeIdentifier ("g_type_interface_add_prerequisite"));
87 func.add_argument (new CCodeIdentifier ("%s_type_id".printf (interface_reference.get_lower_case_cname (null))));
88 func.add_argument (new CCodeIdentifier (prereq.get_type_id()));
90 block.add_statement (new CCodeExpressionStatement (func));
93 ((CCodeBaseModule) context.codegen).register_dbus_info (block, interface_reference);