File: valainterfaceregisterfunction.c

package info (click to toggle)
vala 0.3.4-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 13,756 kB
  • ctags: 12,353
  • sloc: ansic: 116,516; sh: 9,897; yacc: 1,218; makefile: 837; xml: 657; lex: 285
file content (267 lines) | stat: -rw-r--r-- 12,927 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
/* valainterfaceregisterfunction.vala
 *
 * Copyright (C) 2006-2007  Jürg Billeter, Raffaele Sandrini
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.

 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 * Author:
 * 	Jürg Billeter <j@bitron.ch>
 *	Raffaele Sandrini <raffaele@sandrini.ch>
 */

#include <gobject/valainterfaceregisterfunction.h>
#include <vala/valadatatype.h>
#include <ccode/valaccodefunctioncall.h>
#include <ccode/valaccodeidentifier.h>
#include <ccode/valaccodeexpression.h>
#include <ccode/valaccodeexpressionstatement.h>
#include <ccode/valaccodenode.h>




struct _ValaInterfaceRegisterFunctionPrivate {
	ValaInterface* _interface_reference;
};

#define VALA_INTERFACE_REGISTER_FUNCTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VALA_TYPE_INTERFACE_REGISTER_FUNCTION, ValaInterfaceRegisterFunctionPrivate))
enum  {
	VALA_INTERFACE_REGISTER_FUNCTION_DUMMY_PROPERTY,
	VALA_INTERFACE_REGISTER_FUNCTION_INTERFACE_REFERENCE
};
static ValaTypeSymbol* vala_interface_register_function_real_get_type_declaration (ValaTypeRegisterFunction* base);
static char* vala_interface_register_function_real_get_type_struct_name (ValaTypeRegisterFunction* base);
static char* vala_interface_register_function_real_get_base_init_func_name (ValaTypeRegisterFunction* base);
static char* vala_interface_register_function_real_get_class_init_func_name (ValaTypeRegisterFunction* base);
static char* vala_interface_register_function_real_get_instance_struct_size (ValaTypeRegisterFunction* base);
static char* vala_interface_register_function_real_get_instance_init_func_name (ValaTypeRegisterFunction* base);
static char* vala_interface_register_function_real_get_parent_type_name (ValaTypeRegisterFunction* base);
static ValaSymbolAccessibility vala_interface_register_function_real_get_accessibility (ValaTypeRegisterFunction* base);
static ValaCCodeFragment* vala_interface_register_function_real_get_type_interface_init_statements (ValaTypeRegisterFunction* base);
static gpointer vala_interface_register_function_parent_class = NULL;
static void vala_interface_register_function_dispose (GObject * obj);



ValaInterfaceRegisterFunction* vala_interface_register_function_new (ValaInterface* iface) {
	ValaInterfaceRegisterFunction * self;
	g_return_val_if_fail (VALA_IS_INTERFACE (iface), NULL);
	self = g_object_newv (VALA_TYPE_INTERFACE_REGISTER_FUNCTION, 0, NULL);
	vala_interface_register_function_set_interface_reference (self, iface);
	return self;
}


static ValaTypeSymbol* vala_interface_register_function_real_get_type_declaration (ValaTypeRegisterFunction* base) {
	ValaInterfaceRegisterFunction * self;
	ValaTypeSymbol* _tmp0;
	self = VALA_INTERFACE_REGISTER_FUNCTION (base);
	_tmp0 = NULL;
	return (_tmp0 = VALA_TYPESYMBOL (self->priv->_interface_reference), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
}


static char* vala_interface_register_function_real_get_type_struct_name (ValaTypeRegisterFunction* base) {
	ValaInterfaceRegisterFunction * self;
	self = VALA_INTERFACE_REGISTER_FUNCTION (base);
	return vala_interface_get_type_cname (self->priv->_interface_reference);
}


static char* vala_interface_register_function_real_get_base_init_func_name (ValaTypeRegisterFunction* base) {
	ValaInterfaceRegisterFunction * self;
	char* _tmp0;
	char* _tmp1;
	self = VALA_INTERFACE_REGISTER_FUNCTION (base);
	_tmp0 = NULL;
	_tmp1 = NULL;
	return (_tmp1 = g_strdup_printf ("%s_base_init", (_tmp0 = vala_symbol_get_lower_case_cname (VALA_SYMBOL (self->priv->_interface_reference), NULL))), (_tmp0 = (g_free (_tmp0), NULL)), _tmp1);
}


static char* vala_interface_register_function_real_get_class_init_func_name (ValaTypeRegisterFunction* base) {
	ValaInterfaceRegisterFunction * self;
	self = VALA_INTERFACE_REGISTER_FUNCTION (base);
	return g_strdup ("NULL");
}


static char* vala_interface_register_function_real_get_instance_struct_size (ValaTypeRegisterFunction* base) {
	ValaInterfaceRegisterFunction * self;
	self = VALA_INTERFACE_REGISTER_FUNCTION (base);
	return g_strdup ("0");
}


static char* vala_interface_register_function_real_get_instance_init_func_name (ValaTypeRegisterFunction* base) {
	ValaInterfaceRegisterFunction * self;
	self = VALA_INTERFACE_REGISTER_FUNCTION (base);
	return g_strdup ("NULL");
}


static char* vala_interface_register_function_real_get_parent_type_name (ValaTypeRegisterFunction* base) {
	ValaInterfaceRegisterFunction * self;
	self = VALA_INTERFACE_REGISTER_FUNCTION (base);
	return g_strdup ("G_TYPE_INTERFACE");
}


static ValaSymbolAccessibility vala_interface_register_function_real_get_accessibility (ValaTypeRegisterFunction* base) {
	ValaInterfaceRegisterFunction * self;
	self = VALA_INTERFACE_REGISTER_FUNCTION (base);
	return vala_symbol_get_access (VALA_SYMBOL (self->priv->_interface_reference));
}


static ValaCCodeFragment* vala_interface_register_function_real_get_type_interface_init_statements (ValaTypeRegisterFunction* base) {
	ValaInterfaceRegisterFunction * self;
	ValaCCodeFragment* frag;
	self = VALA_INTERFACE_REGISTER_FUNCTION (base);
	frag = vala_ccode_fragment_new ();
	/* register all prerequisites */
	{
		GeeList* prereq_ref_collection;
		int prereq_ref_it;
		prereq_ref_collection = vala_interface_get_prerequisites (self->priv->_interface_reference);
		for (prereq_ref_it = 0; prereq_ref_it < gee_collection_get_size (GEE_COLLECTION (prereq_ref_collection)); prereq_ref_it = prereq_ref_it + 1) {
			ValaDataType* prereq_ref;
			prereq_ref = ((ValaDataType*) (gee_list_get (GEE_LIST (prereq_ref_collection), prereq_ref_it)));
			{
				ValaTypeSymbol* _tmp0;
				ValaTypeSymbol* prereq;
				ValaCCodeIdentifier* _tmp1;
				ValaCCodeFunctionCall* _tmp2;
				ValaCCodeFunctionCall* func;
				ValaCCodeIdentifier* _tmp5;
				char* _tmp4;
				char* _tmp3;
				ValaCCodeIdentifier* _tmp7;
				char* _tmp6;
				ValaCCodeExpressionStatement* _tmp8;
				_tmp0 = NULL;
				prereq = (_tmp0 = vala_data_type_get_data_type (prereq_ref), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
				_tmp1 = NULL;
				_tmp2 = NULL;
				func = (_tmp2 = vala_ccode_function_call_new (VALA_CCODE_EXPRESSION ((_tmp1 = vala_ccode_identifier_new ("g_type_interface_add_prerequisite")))), (_tmp1 == NULL ? NULL : (_tmp1 = (g_object_unref (_tmp1), NULL))), _tmp2);
				_tmp5 = NULL;
				_tmp4 = NULL;
				_tmp3 = NULL;
				vala_ccode_function_call_add_argument (func, VALA_CCODE_EXPRESSION ((_tmp5 = vala_ccode_identifier_new ((_tmp4 = g_strdup_printf ("%s_type_id", (_tmp3 = vala_symbol_get_lower_case_cname (VALA_SYMBOL (self->priv->_interface_reference), NULL))))))));
				(_tmp5 == NULL ? NULL : (_tmp5 = (g_object_unref (_tmp5), NULL)));
				_tmp4 = (g_free (_tmp4), NULL);
				_tmp3 = (g_free (_tmp3), NULL);
				_tmp7 = NULL;
				_tmp6 = NULL;
				vala_ccode_function_call_add_argument (func, VALA_CCODE_EXPRESSION ((_tmp7 = vala_ccode_identifier_new ((_tmp6 = vala_typesymbol_get_type_id (prereq))))));
				(_tmp7 == NULL ? NULL : (_tmp7 = (g_object_unref (_tmp7), NULL)));
				_tmp6 = (g_free (_tmp6), NULL);
				_tmp8 = NULL;
				vala_ccode_fragment_append (frag, VALA_CCODE_NODE ((_tmp8 = vala_ccode_expression_statement_new (VALA_CCODE_EXPRESSION (func)))));
				(_tmp8 == NULL ? NULL : (_tmp8 = (g_object_unref (_tmp8), NULL)));
				(prereq_ref == NULL ? NULL : (prereq_ref = (g_object_unref (prereq_ref), NULL)));
				(prereq == NULL ? NULL : (prereq = (g_object_unref (prereq), NULL)));
				(func == NULL ? NULL : (func = (g_object_unref (func), NULL)));
			}
		}
		(prereq_ref_collection == NULL ? NULL : (prereq_ref_collection = (g_object_unref (prereq_ref_collection), NULL)));
	}
	return frag;
}


ValaInterface* vala_interface_register_function_get_interface_reference (ValaInterfaceRegisterFunction* self) {
	g_return_val_if_fail (VALA_IS_INTERFACE_REGISTER_FUNCTION (self), NULL);
	return self->priv->_interface_reference;
}


void vala_interface_register_function_set_interface_reference (ValaInterfaceRegisterFunction* self, ValaInterface* value) {
	g_return_if_fail (VALA_IS_INTERFACE_REGISTER_FUNCTION (self));
	self->priv->_interface_reference = value;
}


static void vala_interface_register_function_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	ValaInterfaceRegisterFunction * self;
	self = VALA_INTERFACE_REGISTER_FUNCTION (object);
	switch (property_id) {
		case VALA_INTERFACE_REGISTER_FUNCTION_INTERFACE_REFERENCE:
		g_value_set_object (value, vala_interface_register_function_get_interface_reference (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void vala_interface_register_function_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	ValaInterfaceRegisterFunction * self;
	self = VALA_INTERFACE_REGISTER_FUNCTION (object);
	switch (property_id) {
		case VALA_INTERFACE_REGISTER_FUNCTION_INTERFACE_REFERENCE:
		vala_interface_register_function_set_interface_reference (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void vala_interface_register_function_class_init (ValaInterfaceRegisterFunctionClass * klass) {
	vala_interface_register_function_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (ValaInterfaceRegisterFunctionPrivate));
	G_OBJECT_CLASS (klass)->get_property = vala_interface_register_function_get_property;
	G_OBJECT_CLASS (klass)->set_property = vala_interface_register_function_set_property;
	G_OBJECT_CLASS (klass)->dispose = vala_interface_register_function_dispose;
	VALA_TYPEREGISTER_FUNCTION_CLASS (klass)->get_type_declaration = vala_interface_register_function_real_get_type_declaration;
	VALA_TYPEREGISTER_FUNCTION_CLASS (klass)->get_type_struct_name = vala_interface_register_function_real_get_type_struct_name;
	VALA_TYPEREGISTER_FUNCTION_CLASS (klass)->get_base_init_func_name = vala_interface_register_function_real_get_base_init_func_name;
	VALA_TYPEREGISTER_FUNCTION_CLASS (klass)->get_class_init_func_name = vala_interface_register_function_real_get_class_init_func_name;
	VALA_TYPEREGISTER_FUNCTION_CLASS (klass)->get_instance_struct_size = vala_interface_register_function_real_get_instance_struct_size;
	VALA_TYPEREGISTER_FUNCTION_CLASS (klass)->get_instance_init_func_name = vala_interface_register_function_real_get_instance_init_func_name;
	VALA_TYPEREGISTER_FUNCTION_CLASS (klass)->get_parent_type_name = vala_interface_register_function_real_get_parent_type_name;
	VALA_TYPEREGISTER_FUNCTION_CLASS (klass)->get_accessibility = vala_interface_register_function_real_get_accessibility;
	VALA_TYPEREGISTER_FUNCTION_CLASS (klass)->get_type_interface_init_statements = vala_interface_register_function_real_get_type_interface_init_statements;
	g_object_class_install_property (G_OBJECT_CLASS (klass), VALA_INTERFACE_REGISTER_FUNCTION_INTERFACE_REFERENCE, g_param_spec_object ("interface-reference", "interface-reference", "interface-reference", VALA_TYPE_INTERFACE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
}


static void vala_interface_register_function_instance_init (ValaInterfaceRegisterFunction * self) {
	self->priv = VALA_INTERFACE_REGISTER_FUNCTION_GET_PRIVATE (self);
}


static void vala_interface_register_function_dispose (GObject * obj) {
	ValaInterfaceRegisterFunction * self;
	self = VALA_INTERFACE_REGISTER_FUNCTION (obj);
	G_OBJECT_CLASS (vala_interface_register_function_parent_class)->dispose (obj);
}


GType vala_interface_register_function_get_type (void) {
	static GType vala_interface_register_function_type_id = 0;
	if (G_UNLIKELY (vala_interface_register_function_type_id == 0)) {
		static const GTypeInfo g_define_type_info = { sizeof (ValaInterfaceRegisterFunctionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_interface_register_function_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaInterfaceRegisterFunction), 0, (GInstanceInitFunc) vala_interface_register_function_instance_init };
		vala_interface_register_function_type_id = g_type_register_static (VALA_TYPE_TYPEREGISTER_FUNCTION, "ValaInterfaceRegisterFunction", &g_define_type_info, 0);
	}
	return vala_interface_register_function_type_id;
}