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
21 * Jürg Billeter <j@bitron.ch>
22 * Raffaele Sandrini <raffaele@sandrini.ch>
28 * C function to register an interface at runtime.
30 public class Vala
.InterfaceRegisterFunction
: TypeRegisterFunction
{
32 * Specifies the interface to be registered.
34 public weak Interface interface_reference
{ get; set; }
36 public InterfaceRegisterFunction (Interface iface
) {
37 interface_reference
= iface
;
40 public override TypeSymbol
get_type_declaration () {
41 return interface_reference
;
44 public override string get_type_struct_name () {
45 return get_ccode_type_name (interface_reference
);
48 public override string get_base_init_func_name () {
49 return "%s_base_init".printf (get_ccode_lower_case_name (interface_reference
));
52 public override string get_class_finalize_func_name () {
56 public override string get_base_finalize_func_name () {
60 public override string get_class_init_func_name () {
64 public override string get_instance_struct_size () {
68 public override string get_instance_init_func_name () {
72 public override string get_parent_type_name () {
73 return "G_TYPE_INTERFACE";
76 public override SymbolAccessibility
get_accessibility () {
77 return interface_reference
.access
;
80 public override void get_type_interface_init_statements (CodeContext context
, CCodeBlock block
, bool plugin
) {
81 /* register all prerequisites */
82 foreach (DataType prereq_ref
in interface_reference
.get_prerequisites ()) {
83 var prereq
= prereq_ref
.data_type
;
85 var func
= new
CCodeFunctionCall (new
CCodeIdentifier ("g_type_interface_add_prerequisite"));
86 func
.add_argument (new
CCodeIdentifier ("%s_type_id".printf (get_ccode_lower_case_name (interface_reference
))));
87 func
.add_argument (new
CCodeIdentifier (get_ccode_type_id (prereq
)));
89 block
.add_statement (new
CCodeExpressionStatement (func
));
92 ((CCodeBaseModule
) context
.codegen
).register_dbus_info (block
, interface_reference
);