1 /* valaenumregisterfunction.c generated by valac, the Vala compiler
2  * generated from valaenumregisterfunction.vala, do not modify */
3 
4 /* valaenumregisterfunction.vala
5  *
6  * Copyright (C) 2008  Jürg Billeter
7  * Copyright (C) 2010  Marc-Andre Lureau
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13 
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18 
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
22  *
23  * Author:
24  * 	Jürg Billeter <j@bitron.ch>
25  */
26 
27 #include "valacodegen.h"
28 #include <vala.h>
29 #include <glib.h>
30 
31 struct _ValaEnumRegisterFunctionPrivate {
32 	ValaEnum* _enum_reference;
33 };
34 
35 static gint ValaEnumRegisterFunction_private_offset;
36 static gpointer vala_enum_register_function_parent_class = NULL;
37 
38 static ValaTypeSymbol* vala_enum_register_function_real_get_type_declaration (ValaTypeRegisterFunction* base);
39 static ValaSymbolAccessibility vala_enum_register_function_real_get_accessibility (ValaTypeRegisterFunction* base);
40 static void vala_enum_register_function_finalize (ValaTypeRegisterFunction * obj);
41 static GType vala_enum_register_function_get_type_once (void);
42 
43 static inline gpointer
vala_enum_register_function_get_instance_private(ValaEnumRegisterFunction * self)44 vala_enum_register_function_get_instance_private (ValaEnumRegisterFunction* self)
45 {
46 	return G_STRUCT_MEMBER_P (self, ValaEnumRegisterFunction_private_offset);
47 }
48 
49 ValaEnum*
vala_enum_register_function_get_enum_reference(ValaEnumRegisterFunction * self)50 vala_enum_register_function_get_enum_reference (ValaEnumRegisterFunction* self)
51 {
52 	ValaEnum* result;
53 	ValaEnum* _tmp0_;
54 	g_return_val_if_fail (self != NULL, NULL);
55 	_tmp0_ = self->priv->_enum_reference;
56 	result = _tmp0_;
57 	return result;
58 }
59 
60 void
vala_enum_register_function_set_enum_reference(ValaEnumRegisterFunction * self,ValaEnum * value)61 vala_enum_register_function_set_enum_reference (ValaEnumRegisterFunction* self,
62                                                 ValaEnum* value)
63 {
64 	g_return_if_fail (self != NULL);
65 	self->priv->_enum_reference = value;
66 }
67 
68 /**
69  * Creates a new C function to register the specified enum at runtime.
70  *
71  * @param en an enum
72  * @return   newly created enum register function
73  */
74 ValaEnumRegisterFunction*
vala_enum_register_function_construct(GType object_type,ValaEnum * en)75 vala_enum_register_function_construct (GType object_type,
76                                        ValaEnum* en)
77 {
78 	ValaEnumRegisterFunction* self = NULL;
79 	g_return_val_if_fail (en != NULL, NULL);
80 	self = (ValaEnumRegisterFunction*) vala_typeregister_function_construct (object_type);
81 	vala_enum_register_function_set_enum_reference (self, en);
82 	return self;
83 }
84 
85 ValaEnumRegisterFunction*
vala_enum_register_function_new(ValaEnum * en)86 vala_enum_register_function_new (ValaEnum* en)
87 {
88 	return vala_enum_register_function_construct (VALA_TYPE_ENUM_REGISTER_FUNCTION, en);
89 }
90 
91 static gpointer
_vala_code_node_ref0(gpointer self)92 _vala_code_node_ref0 (gpointer self)
93 {
94 	return self ? vala_code_node_ref (self) : NULL;
95 }
96 
97 static ValaTypeSymbol*
vala_enum_register_function_real_get_type_declaration(ValaTypeRegisterFunction * base)98 vala_enum_register_function_real_get_type_declaration (ValaTypeRegisterFunction* base)
99 {
100 	ValaEnumRegisterFunction * self;
101 	ValaEnum* _tmp0_;
102 	ValaTypeSymbol* _tmp1_;
103 	ValaTypeSymbol* result = NULL;
104 	self = (ValaEnumRegisterFunction*) base;
105 	_tmp0_ = self->priv->_enum_reference;
106 	_tmp1_ = _vala_code_node_ref0 ((ValaTypeSymbol*) _tmp0_);
107 	result = _tmp1_;
108 	return result;
109 }
110 
111 static ValaSymbolAccessibility
vala_enum_register_function_real_get_accessibility(ValaTypeRegisterFunction * base)112 vala_enum_register_function_real_get_accessibility (ValaTypeRegisterFunction* base)
113 {
114 	ValaEnumRegisterFunction * self;
115 	ValaEnum* _tmp0_;
116 	ValaSymbolAccessibility _tmp1_;
117 	ValaSymbolAccessibility _tmp2_;
118 	ValaSymbolAccessibility result = 0;
119 	self = (ValaEnumRegisterFunction*) base;
120 	_tmp0_ = self->priv->_enum_reference;
121 	_tmp1_ = vala_symbol_get_access ((ValaSymbol*) _tmp0_);
122 	_tmp2_ = _tmp1_;
123 	result = _tmp2_;
124 	return result;
125 }
126 
127 static void
vala_enum_register_function_class_init(ValaEnumRegisterFunctionClass * klass,gpointer klass_data)128 vala_enum_register_function_class_init (ValaEnumRegisterFunctionClass * klass,
129                                         gpointer klass_data)
130 {
131 	vala_enum_register_function_parent_class = g_type_class_peek_parent (klass);
132 	((ValaTypeRegisterFunctionClass *) klass)->finalize = vala_enum_register_function_finalize;
133 	g_type_class_adjust_private_offset (klass, &ValaEnumRegisterFunction_private_offset);
134 	((ValaTypeRegisterFunctionClass *) klass)->get_type_declaration = (ValaTypeSymbol* (*) (ValaTypeRegisterFunction*)) vala_enum_register_function_real_get_type_declaration;
135 	((ValaTypeRegisterFunctionClass *) klass)->get_accessibility = (ValaSymbolAccessibility (*) (ValaTypeRegisterFunction*)) vala_enum_register_function_real_get_accessibility;
136 }
137 
138 static void
vala_enum_register_function_instance_init(ValaEnumRegisterFunction * self,gpointer klass)139 vala_enum_register_function_instance_init (ValaEnumRegisterFunction * self,
140                                            gpointer klass)
141 {
142 	self->priv = vala_enum_register_function_get_instance_private (self);
143 }
144 
145 static void
vala_enum_register_function_finalize(ValaTypeRegisterFunction * obj)146 vala_enum_register_function_finalize (ValaTypeRegisterFunction * obj)
147 {
148 	ValaEnumRegisterFunction * self;
149 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_ENUM_REGISTER_FUNCTION, ValaEnumRegisterFunction);
150 	VALA_TYPEREGISTER_FUNCTION_CLASS (vala_enum_register_function_parent_class)->finalize (obj);
151 }
152 
153 /**
154  * C function to register an enum at runtime.
155  */
156 static GType
vala_enum_register_function_get_type_once(void)157 vala_enum_register_function_get_type_once (void)
158 {
159 	static const GTypeInfo g_define_type_info = { sizeof (ValaEnumRegisterFunctionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_enum_register_function_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaEnumRegisterFunction), 0, (GInstanceInitFunc) vala_enum_register_function_instance_init, NULL };
160 	GType vala_enum_register_function_type_id;
161 	vala_enum_register_function_type_id = g_type_register_static (VALA_TYPE_TYPEREGISTER_FUNCTION, "ValaEnumRegisterFunction", &g_define_type_info, 0);
162 	ValaEnumRegisterFunction_private_offset = g_type_add_instance_private (vala_enum_register_function_type_id, sizeof (ValaEnumRegisterFunctionPrivate));
163 	return vala_enum_register_function_type_id;
164 }
165 
166 GType
vala_enum_register_function_get_type(void)167 vala_enum_register_function_get_type (void)
168 {
169 	static volatile gsize vala_enum_register_function_type_id__volatile = 0;
170 	if (g_once_init_enter (&vala_enum_register_function_type_id__volatile)) {
171 		GType vala_enum_register_function_type_id;
172 		vala_enum_register_function_type_id = vala_enum_register_function_get_type_once ();
173 		g_once_init_leave (&vala_enum_register_function_type_id__volatile, vala_enum_register_function_type_id);
174 	}
175 	return vala_enum_register_function_type_id__volatile;
176 }
177 
178