Fix gdk_pixbuf_new_from_stream* bindings, patch by Evan Nemerson, fixes
[vala-lang.git] / gobject / valainterfaceregisterfunction.vala
blob8e9ffb68c2c51a876a5f83e165ae0db7848a755f
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
19 * Author:
20 * Jürg Billeter <j@bitron.ch>
21 * Raffaele Sandrini <raffaele@sandrini.ch>
24 using GLib;
26 /**
27 * C function to register an interface at runtime.
29 public class Vala.InterfaceRegisterFunction : TypeRegisterFunction {
30 /**
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_init_func_name () {
53 return "NULL";
56 public override string get_instance_struct_size () {
57 return "0";
60 public override string get_instance_init_func_name () {
61 return "NULL";
64 public override string get_parent_type_name () {
65 return "G_TYPE_INTERFACE";
68 public override SymbolAccessibility get_accessibility () {
69 return interface_reference.access;
72 public override CCodeFragment get_type_interface_init_statements () {
73 var frag = new CCodeFragment ();
75 /* register all prerequisites */
76 foreach (DataType prereq_ref in interface_reference.get_prerequisites ()) {
77 var prereq = prereq_ref.data_type;
79 var func = new CCodeFunctionCall (new CCodeIdentifier ("g_type_interface_add_prerequisite"));
80 func.add_argument (new CCodeIdentifier ("%s_type_id".printf (interface_reference.get_lower_case_cname (null))));
81 func.add_argument (new CCodeIdentifier (prereq.get_type_id()));
83 frag.append (new CCodeExpressionStatement (func));
86 return frag;