1 /* valainterfaceregisterfunction.vala
3 * Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini
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>
21 * Raffaele Sandrini <raffaele@sandrini.ch>
27 * C function to register an interface at runtime.
29 public class Vala
.InterfaceRegisterFunction
: TypeRegisterFunction
{
31 * Specifies the interface to be registered.
33 public weak Interface interface_reference
{ get; set; }
35 public InterfaceRegisterFunction (Interface iface
, CodeContext context
) {
36 interface_reference
= iface
;
37 this
.context
= context
;
40 public override TypeSymbol
get_type_declaration () {
41 return interface_reference
;
44 public override string get_type_struct_name () {
45 return interface_reference
.get_type_cname ();
48 public override string get_base_init_func_name () {
49 return "%s_base_init".printf (interface_reference
.get_lower_case_cname (null));
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 CCodeFragment
get_type_interface_init_statements () {
81 var frag
= new
CCodeFragment ();
83 /* register all prerequisites */
84 foreach (DataType prereq_ref
in interface_reference
.get_prerequisites ()) {
85 var prereq
= prereq_ref
.data_type
;
87 var func
= new
CCodeFunctionCall (new
CCodeIdentifier ("g_type_interface_add_prerequisite"));
88 func
.add_argument (new
CCodeIdentifier ("%s_type_id".printf (interface_reference
.get_lower_case_cname (null))));
89 func
.add_argument (new
CCodeIdentifier (prereq
.get_type_id()));
91 frag
.append (new
CCodeExpressionStatement (func
));