1 /* valaccodevariabledeclarator.c generated by valac, the Vala compiler
2  * generated from valaccodevariabledeclarator.vala, do not modify */
3 
4 /* valaccodevariabledeclarator.vala
5  *
6  * Copyright (C) 2006-2009  Jürg Billeter
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12 
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17 
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
21  *
22  * Author:
23  * 	Jürg Billeter <j@bitron.ch>
24  */
25 
26 #include "valaccode.h"
27 #include <stdlib.h>
28 #include <string.h>
29 #include <glib.h>
30 #include <valagee.h>
31 #include <glib-object.h>
32 #include <gobject/gvaluecollector.h>
33 
34 #define _g_free0(var) (var = (g_free (var), NULL))
35 #define _vala_ccode_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_ccode_node_unref (var), NULL)))
36 #define _vala_ccode_declarator_suffix_unref0(var) ((var == NULL) ? NULL : (var = (vala_ccode_declarator_suffix_unref (var), NULL)))
37 #define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
38 typedef struct _ValaParamSpecCCodeDeclaratorSuffix ValaParamSpecCCodeDeclaratorSuffix;
39 
40 struct _ValaCCodeVariableDeclaratorPrivate {
41 	gchar* _name;
42 	ValaCCodeExpression* _initializer;
43 	ValaCCodeDeclaratorSuffix* _declarator_suffix;
44 	gboolean _init0;
45 };
46 
47 struct _ValaCCodeDeclaratorSuffixPrivate {
48 	gboolean array;
49 	ValaList* array_length;
50 };
51 
52 struct _ValaParamSpecCCodeDeclaratorSuffix {
53 	GParamSpec parent_instance;
54 };
55 
56 static gint ValaCCodeVariableDeclarator_private_offset;
57 static gpointer vala_ccode_variable_declarator_parent_class = NULL;
58 static gint ValaCCodeDeclaratorSuffix_private_offset;
59 static gpointer vala_ccode_declarator_suffix_parent_class = NULL;
60 
61 static void vala_ccode_variable_declarator_real_write (ValaCCodeNode* base,
62                                                 ValaCCodeWriter* writer);
63 static void vala_ccode_variable_declarator_real_write_declaration (ValaCCodeNode* base,
64                                                             ValaCCodeWriter* writer);
65 static void vala_ccode_variable_declarator_real_write_initialization (ValaCCodeDeclarator* base,
66                                                                ValaCCodeWriter* writer);
67 static void vala_ccode_variable_declarator_finalize (ValaCCodeNode * obj);
68 static GType vala_ccode_variable_declarator_get_type_once (void);
69 static void vala_ccode_declarator_suffix_finalize (ValaCCodeDeclaratorSuffix * obj);
70 static GType vala_ccode_declarator_suffix_get_type_once (void);
71 
72 static inline gpointer
vala_ccode_variable_declarator_get_instance_private(ValaCCodeVariableDeclarator * self)73 vala_ccode_variable_declarator_get_instance_private (ValaCCodeVariableDeclarator* self)
74 {
75 	return G_STRUCT_MEMBER_P (self, ValaCCodeVariableDeclarator_private_offset);
76 }
77 
78 const gchar*
vala_ccode_variable_declarator_get_name(ValaCCodeVariableDeclarator * self)79 vala_ccode_variable_declarator_get_name (ValaCCodeVariableDeclarator* self)
80 {
81 	const gchar* result;
82 	const gchar* _tmp0_;
83 	g_return_val_if_fail (self != NULL, NULL);
84 	_tmp0_ = self->priv->_name;
85 	result = _tmp0_;
86 	return result;
87 }
88 
89 void
vala_ccode_variable_declarator_set_name(ValaCCodeVariableDeclarator * self,const gchar * value)90 vala_ccode_variable_declarator_set_name (ValaCCodeVariableDeclarator* self,
91                                          const gchar* value)
92 {
93 	gchar* _tmp0_;
94 	g_return_if_fail (self != NULL);
95 	_tmp0_ = g_strdup (value);
96 	_g_free0 (self->priv->_name);
97 	self->priv->_name = _tmp0_;
98 }
99 
100 ValaCCodeExpression*
vala_ccode_variable_declarator_get_initializer(ValaCCodeVariableDeclarator * self)101 vala_ccode_variable_declarator_get_initializer (ValaCCodeVariableDeclarator* self)
102 {
103 	ValaCCodeExpression* result;
104 	ValaCCodeExpression* _tmp0_;
105 	g_return_val_if_fail (self != NULL, NULL);
106 	_tmp0_ = self->priv->_initializer;
107 	result = _tmp0_;
108 	return result;
109 }
110 
111 static gpointer
_vala_ccode_node_ref0(gpointer self)112 _vala_ccode_node_ref0 (gpointer self)
113 {
114 	return self ? vala_ccode_node_ref (self) : NULL;
115 }
116 
117 void
vala_ccode_variable_declarator_set_initializer(ValaCCodeVariableDeclarator * self,ValaCCodeExpression * value)118 vala_ccode_variable_declarator_set_initializer (ValaCCodeVariableDeclarator* self,
119                                                 ValaCCodeExpression* value)
120 {
121 	ValaCCodeExpression* _tmp0_;
122 	g_return_if_fail (self != NULL);
123 	_tmp0_ = _vala_ccode_node_ref0 (value);
124 	_vala_ccode_node_unref0 (self->priv->_initializer);
125 	self->priv->_initializer = _tmp0_;
126 }
127 
128 ValaCCodeDeclaratorSuffix*
vala_ccode_variable_declarator_get_declarator_suffix(ValaCCodeVariableDeclarator * self)129 vala_ccode_variable_declarator_get_declarator_suffix (ValaCCodeVariableDeclarator* self)
130 {
131 	ValaCCodeDeclaratorSuffix* result;
132 	ValaCCodeDeclaratorSuffix* _tmp0_;
133 	g_return_val_if_fail (self != NULL, NULL);
134 	_tmp0_ = self->priv->_declarator_suffix;
135 	result = _tmp0_;
136 	return result;
137 }
138 
139 static gpointer
_vala_ccode_declarator_suffix_ref0(gpointer self)140 _vala_ccode_declarator_suffix_ref0 (gpointer self)
141 {
142 	return self ? vala_ccode_declarator_suffix_ref (self) : NULL;
143 }
144 
145 void
vala_ccode_variable_declarator_set_declarator_suffix(ValaCCodeVariableDeclarator * self,ValaCCodeDeclaratorSuffix * value)146 vala_ccode_variable_declarator_set_declarator_suffix (ValaCCodeVariableDeclarator* self,
147                                                       ValaCCodeDeclaratorSuffix* value)
148 {
149 	ValaCCodeDeclaratorSuffix* _tmp0_;
150 	g_return_if_fail (self != NULL);
151 	_tmp0_ = _vala_ccode_declarator_suffix_ref0 (value);
152 	_vala_ccode_declarator_suffix_unref0 (self->priv->_declarator_suffix);
153 	self->priv->_declarator_suffix = _tmp0_;
154 }
155 
156 gboolean
vala_ccode_variable_declarator_get_init0(ValaCCodeVariableDeclarator * self)157 vala_ccode_variable_declarator_get_init0 (ValaCCodeVariableDeclarator* self)
158 {
159 	gboolean result;
160 	g_return_val_if_fail (self != NULL, FALSE);
161 	result = self->priv->_init0;
162 	return result;
163 }
164 
165 void
vala_ccode_variable_declarator_set_init0(ValaCCodeVariableDeclarator * self,gboolean value)166 vala_ccode_variable_declarator_set_init0 (ValaCCodeVariableDeclarator* self,
167                                           gboolean value)
168 {
169 	g_return_if_fail (self != NULL);
170 	self->priv->_init0 = value;
171 }
172 
173 ValaCCodeVariableDeclarator*
vala_ccode_variable_declarator_construct(GType object_type,const gchar * name,ValaCCodeExpression * initializer,ValaCCodeDeclaratorSuffix * declarator_suffix)174 vala_ccode_variable_declarator_construct (GType object_type,
175                                           const gchar* name,
176                                           ValaCCodeExpression* initializer,
177                                           ValaCCodeDeclaratorSuffix* declarator_suffix)
178 {
179 	ValaCCodeVariableDeclarator* self = NULL;
180 	g_return_val_if_fail (name != NULL, NULL);
181 	self = (ValaCCodeVariableDeclarator*) vala_ccode_declarator_construct (object_type);
182 	vala_ccode_variable_declarator_set_name (self, name);
183 	vala_ccode_variable_declarator_set_initializer (self, initializer);
184 	vala_ccode_variable_declarator_set_declarator_suffix (self, declarator_suffix);
185 	return self;
186 }
187 
188 ValaCCodeVariableDeclarator*
vala_ccode_variable_declarator_new(const gchar * name,ValaCCodeExpression * initializer,ValaCCodeDeclaratorSuffix * declarator_suffix)189 vala_ccode_variable_declarator_new (const gchar* name,
190                                     ValaCCodeExpression* initializer,
191                                     ValaCCodeDeclaratorSuffix* declarator_suffix)
192 {
193 	return vala_ccode_variable_declarator_construct (VALA_TYPE_CCODE_VARIABLE_DECLARATOR, name, initializer, declarator_suffix);
194 }
195 
196 ValaCCodeVariableDeclarator*
vala_ccode_variable_declarator_construct_zero(GType object_type,const gchar * name,ValaCCodeExpression * initializer,ValaCCodeDeclaratorSuffix * declarator_suffix)197 vala_ccode_variable_declarator_construct_zero (GType object_type,
198                                                const gchar* name,
199                                                ValaCCodeExpression* initializer,
200                                                ValaCCodeDeclaratorSuffix* declarator_suffix)
201 {
202 	ValaCCodeVariableDeclarator* self = NULL;
203 	g_return_val_if_fail (name != NULL, NULL);
204 	self = (ValaCCodeVariableDeclarator*) vala_ccode_declarator_construct (object_type);
205 	vala_ccode_variable_declarator_set_name (self, name);
206 	vala_ccode_variable_declarator_set_initializer (self, initializer);
207 	vala_ccode_variable_declarator_set_declarator_suffix (self, declarator_suffix);
208 	vala_ccode_variable_declarator_set_init0 (self, TRUE);
209 	return self;
210 }
211 
212 ValaCCodeVariableDeclarator*
vala_ccode_variable_declarator_new_zero(const gchar * name,ValaCCodeExpression * initializer,ValaCCodeDeclaratorSuffix * declarator_suffix)213 vala_ccode_variable_declarator_new_zero (const gchar* name,
214                                          ValaCCodeExpression* initializer,
215                                          ValaCCodeDeclaratorSuffix* declarator_suffix)
216 {
217 	return vala_ccode_variable_declarator_construct_zero (VALA_TYPE_CCODE_VARIABLE_DECLARATOR, name, initializer, declarator_suffix);
218 }
219 
220 static void
vala_ccode_variable_declarator_real_write(ValaCCodeNode * base,ValaCCodeWriter * writer)221 vala_ccode_variable_declarator_real_write (ValaCCodeNode* base,
222                                            ValaCCodeWriter* writer)
223 {
224 	ValaCCodeVariableDeclarator * self;
225 	const gchar* _tmp0_;
226 	ValaCCodeDeclaratorSuffix* _tmp1_;
227 	ValaCCodeExpression* _tmp3_;
228 	self = (ValaCCodeVariableDeclarator*) base;
229 	g_return_if_fail (writer != NULL);
230 	_tmp0_ = self->priv->_name;
231 	vala_ccode_writer_write_string (writer, _tmp0_);
232 	_tmp1_ = self->priv->_declarator_suffix;
233 	if (_tmp1_ != NULL) {
234 		ValaCCodeDeclaratorSuffix* _tmp2_;
235 		_tmp2_ = self->priv->_declarator_suffix;
236 		vala_ccode_declarator_suffix_write (_tmp2_, writer);
237 	}
238 	_tmp3_ = self->priv->_initializer;
239 	if (_tmp3_ != NULL) {
240 		ValaCCodeExpression* _tmp4_;
241 		vala_ccode_writer_write_string (writer, " = ");
242 		_tmp4_ = self->priv->_initializer;
243 		vala_ccode_node_write ((ValaCCodeNode*) _tmp4_, writer);
244 	}
245 }
246 
247 static void
vala_ccode_variable_declarator_real_write_declaration(ValaCCodeNode * base,ValaCCodeWriter * writer)248 vala_ccode_variable_declarator_real_write_declaration (ValaCCodeNode* base,
249                                                        ValaCCodeWriter* writer)
250 {
251 	ValaCCodeVariableDeclarator * self;
252 	const gchar* _tmp0_;
253 	ValaCCodeDeclaratorSuffix* _tmp1_;
254 	gboolean _tmp3_ = FALSE;
255 	ValaCCodeExpression* _tmp4_;
256 	self = (ValaCCodeVariableDeclarator*) base;
257 	g_return_if_fail (writer != NULL);
258 	_tmp0_ = self->priv->_name;
259 	vala_ccode_writer_write_string (writer, _tmp0_);
260 	_tmp1_ = self->priv->_declarator_suffix;
261 	if (_tmp1_ != NULL) {
262 		ValaCCodeDeclaratorSuffix* _tmp2_;
263 		_tmp2_ = self->priv->_declarator_suffix;
264 		vala_ccode_declarator_suffix_write (_tmp2_, writer);
265 	}
266 	_tmp4_ = self->priv->_initializer;
267 	if (_tmp4_ != NULL) {
268 		gboolean _tmp5_;
269 		_tmp5_ = self->priv->_init0;
270 		_tmp3_ = _tmp5_;
271 	} else {
272 		_tmp3_ = FALSE;
273 	}
274 	if (_tmp3_) {
275 		ValaCCodeExpression* _tmp6_;
276 		vala_ccode_writer_write_string (writer, " = ");
277 		_tmp6_ = self->priv->_initializer;
278 		vala_ccode_node_write ((ValaCCodeNode*) _tmp6_, writer);
279 	}
280 }
281 
282 static void
vala_ccode_variable_declarator_real_write_initialization(ValaCCodeDeclarator * base,ValaCCodeWriter * writer)283 vala_ccode_variable_declarator_real_write_initialization (ValaCCodeDeclarator* base,
284                                                           ValaCCodeWriter* writer)
285 {
286 	ValaCCodeVariableDeclarator * self;
287 	gboolean _tmp0_ = FALSE;
288 	ValaCCodeExpression* _tmp1_;
289 	self = (ValaCCodeVariableDeclarator*) base;
290 	g_return_if_fail (writer != NULL);
291 	_tmp1_ = self->priv->_initializer;
292 	if (_tmp1_ != NULL) {
293 		gboolean _tmp2_;
294 		_tmp2_ = self->priv->_init0;
295 		_tmp0_ = !_tmp2_;
296 	} else {
297 		_tmp0_ = FALSE;
298 	}
299 	if (_tmp0_) {
300 		ValaCCodeLineDirective* _tmp3_;
301 		ValaCCodeLineDirective* _tmp4_;
302 		const gchar* _tmp5_;
303 		ValaCCodeExpression* _tmp6_;
304 		_tmp3_ = vala_ccode_node_get_line ((ValaCCodeNode*) self);
305 		_tmp4_ = _tmp3_;
306 		vala_ccode_writer_write_indent (writer, _tmp4_);
307 		_tmp5_ = self->priv->_name;
308 		vala_ccode_writer_write_string (writer, _tmp5_);
309 		vala_ccode_writer_write_string (writer, " = ");
310 		_tmp6_ = self->priv->_initializer;
311 		vala_ccode_node_write ((ValaCCodeNode*) _tmp6_, writer);
312 		vala_ccode_writer_write_string (writer, ";");
313 		vala_ccode_writer_write_newline (writer);
314 	}
315 }
316 
317 static void
vala_ccode_variable_declarator_class_init(ValaCCodeVariableDeclaratorClass * klass,gpointer klass_data)318 vala_ccode_variable_declarator_class_init (ValaCCodeVariableDeclaratorClass * klass,
319                                            gpointer klass_data)
320 {
321 	vala_ccode_variable_declarator_parent_class = g_type_class_peek_parent (klass);
322 	((ValaCCodeNodeClass *) klass)->finalize = vala_ccode_variable_declarator_finalize;
323 	g_type_class_adjust_private_offset (klass, &ValaCCodeVariableDeclarator_private_offset);
324 	((ValaCCodeNodeClass *) klass)->write = (void (*) (ValaCCodeNode*, ValaCCodeWriter*)) vala_ccode_variable_declarator_real_write;
325 	((ValaCCodeNodeClass *) klass)->write_declaration = (void (*) (ValaCCodeNode*, ValaCCodeWriter*)) vala_ccode_variable_declarator_real_write_declaration;
326 	((ValaCCodeDeclaratorClass *) klass)->write_initialization = (void (*) (ValaCCodeDeclarator*, ValaCCodeWriter*)) vala_ccode_variable_declarator_real_write_initialization;
327 }
328 
329 static void
vala_ccode_variable_declarator_instance_init(ValaCCodeVariableDeclarator * self,gpointer klass)330 vala_ccode_variable_declarator_instance_init (ValaCCodeVariableDeclarator * self,
331                                               gpointer klass)
332 {
333 	self->priv = vala_ccode_variable_declarator_get_instance_private (self);
334 }
335 
336 static void
vala_ccode_variable_declarator_finalize(ValaCCodeNode * obj)337 vala_ccode_variable_declarator_finalize (ValaCCodeNode * obj)
338 {
339 	ValaCCodeVariableDeclarator * self;
340 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_CCODE_VARIABLE_DECLARATOR, ValaCCodeVariableDeclarator);
341 	_g_free0 (self->priv->_name);
342 	_vala_ccode_node_unref0 (self->priv->_initializer);
343 	_vala_ccode_declarator_suffix_unref0 (self->priv->_declarator_suffix);
344 	VALA_CCODE_NODE_CLASS (vala_ccode_variable_declarator_parent_class)->finalize (obj);
345 }
346 
347 /**
348  * Represents a variable declarator in the C code.
349  */
350 static GType
vala_ccode_variable_declarator_get_type_once(void)351 vala_ccode_variable_declarator_get_type_once (void)
352 {
353 	static const GTypeInfo g_define_type_info = { sizeof (ValaCCodeVariableDeclaratorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_ccode_variable_declarator_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaCCodeVariableDeclarator), 0, (GInstanceInitFunc) vala_ccode_variable_declarator_instance_init, NULL };
354 	GType vala_ccode_variable_declarator_type_id;
355 	vala_ccode_variable_declarator_type_id = g_type_register_static (VALA_TYPE_CCODE_DECLARATOR, "ValaCCodeVariableDeclarator", &g_define_type_info, 0);
356 	ValaCCodeVariableDeclarator_private_offset = g_type_add_instance_private (vala_ccode_variable_declarator_type_id, sizeof (ValaCCodeVariableDeclaratorPrivate));
357 	return vala_ccode_variable_declarator_type_id;
358 }
359 
360 GType
vala_ccode_variable_declarator_get_type(void)361 vala_ccode_variable_declarator_get_type (void)
362 {
363 	static volatile gsize vala_ccode_variable_declarator_type_id__volatile = 0;
364 	if (g_once_init_enter (&vala_ccode_variable_declarator_type_id__volatile)) {
365 		GType vala_ccode_variable_declarator_type_id;
366 		vala_ccode_variable_declarator_type_id = vala_ccode_variable_declarator_get_type_once ();
367 		g_once_init_leave (&vala_ccode_variable_declarator_type_id__volatile, vala_ccode_variable_declarator_type_id);
368 	}
369 	return vala_ccode_variable_declarator_type_id__volatile;
370 }
371 
372 static inline gpointer
vala_ccode_declarator_suffix_get_instance_private(ValaCCodeDeclaratorSuffix * self)373 vala_ccode_declarator_suffix_get_instance_private (ValaCCodeDeclaratorSuffix* self)
374 {
375 	return G_STRUCT_MEMBER_P (self, ValaCCodeDeclaratorSuffix_private_offset);
376 }
377 
378 ValaCCodeDeclaratorSuffix*
vala_ccode_declarator_suffix_construct_with_array(GType object_type,ValaCCodeExpression * array_length)379 vala_ccode_declarator_suffix_construct_with_array (GType object_type,
380                                                    ValaCCodeExpression* array_length)
381 {
382 	ValaCCodeDeclaratorSuffix* self = NULL;
383 	self = (ValaCCodeDeclaratorSuffix*) g_type_create_instance (object_type);
384 	if (array_length != NULL) {
385 		GEqualFunc _tmp0_;
386 		ValaArrayList* _tmp1_;
387 		ValaList* _tmp2_;
388 		_tmp0_ = g_direct_equal;
389 		_tmp1_ = vala_array_list_new (VALA_TYPE_CCODE_EXPRESSION, (GBoxedCopyFunc) vala_ccode_node_ref, (GDestroyNotify) vala_ccode_node_unref, _tmp0_);
390 		_vala_iterable_unref0 (self->priv->array_length);
391 		self->priv->array_length = (ValaList*) _tmp1_;
392 		_tmp2_ = self->priv->array_length;
393 		vala_collection_add ((ValaCollection*) _tmp2_, array_length);
394 	}
395 	self->priv->array = TRUE;
396 	return self;
397 }
398 
399 ValaCCodeDeclaratorSuffix*
vala_ccode_declarator_suffix_new_with_array(ValaCCodeExpression * array_length)400 vala_ccode_declarator_suffix_new_with_array (ValaCCodeExpression* array_length)
401 {
402 	return vala_ccode_declarator_suffix_construct_with_array (VALA_TYPE_CCODE_DECLARATOR_SUFFIX, array_length);
403 }
404 
405 static gpointer
_vala_iterable_ref0(gpointer self)406 _vala_iterable_ref0 (gpointer self)
407 {
408 	return self ? vala_iterable_ref (self) : NULL;
409 }
410 
411 ValaCCodeDeclaratorSuffix*
vala_ccode_declarator_suffix_construct_with_multi_array(GType object_type,ValaList * array_length)412 vala_ccode_declarator_suffix_construct_with_multi_array (GType object_type,
413                                                          ValaList* array_length)
414 {
415 	ValaCCodeDeclaratorSuffix* self = NULL;
416 	ValaList* _tmp0_;
417 	self = (ValaCCodeDeclaratorSuffix*) g_type_create_instance (object_type);
418 	_tmp0_ = _vala_iterable_ref0 (array_length);
419 	_vala_iterable_unref0 (self->priv->array_length);
420 	self->priv->array_length = _tmp0_;
421 	self->priv->array = TRUE;
422 	return self;
423 }
424 
425 ValaCCodeDeclaratorSuffix*
vala_ccode_declarator_suffix_new_with_multi_array(ValaList * array_length)426 vala_ccode_declarator_suffix_new_with_multi_array (ValaList* array_length)
427 {
428 	return vala_ccode_declarator_suffix_construct_with_multi_array (VALA_TYPE_CCODE_DECLARATOR_SUFFIX, array_length);
429 }
430 
431 void
vala_ccode_declarator_suffix_write(ValaCCodeDeclaratorSuffix * self,ValaCCodeWriter * writer)432 vala_ccode_declarator_suffix_write (ValaCCodeDeclaratorSuffix* self,
433                                     ValaCCodeWriter* writer)
434 {
435 	gboolean _tmp0_ = FALSE;
436 	ValaList* _tmp1_;
437 	g_return_if_fail (self != NULL);
438 	g_return_if_fail (writer != NULL);
439 	_tmp1_ = self->priv->array_length;
440 	if (_tmp1_ != NULL) {
441 		ValaList* _tmp2_;
442 		gint _tmp3_;
443 		gint _tmp4_;
444 		_tmp2_ = self->priv->array_length;
445 		_tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
446 		_tmp4_ = _tmp3_;
447 		_tmp0_ = _tmp4_ > 0;
448 	} else {
449 		_tmp0_ = FALSE;
450 	}
451 	if (_tmp0_) {
452 		{
453 			ValaList* _length_list = NULL;
454 			ValaList* _tmp5_;
455 			ValaList* _tmp6_;
456 			gint _length_size = 0;
457 			ValaList* _tmp7_;
458 			gint _tmp8_;
459 			gint _tmp9_;
460 			gint _length_index = 0;
461 			_tmp5_ = self->priv->array_length;
462 			_tmp6_ = _vala_iterable_ref0 (_tmp5_);
463 			_length_list = _tmp6_;
464 			_tmp7_ = _length_list;
465 			_tmp8_ = vala_collection_get_size ((ValaCollection*) _tmp7_);
466 			_tmp9_ = _tmp8_;
467 			_length_size = _tmp9_;
468 			_length_index = -1;
469 			while (TRUE) {
470 				gint _tmp10_;
471 				gint _tmp11_;
472 				ValaCCodeExpression* length = NULL;
473 				ValaList* _tmp12_;
474 				gpointer _tmp13_;
475 				ValaCCodeExpression* _tmp14_;
476 				_length_index = _length_index + 1;
477 				_tmp10_ = _length_index;
478 				_tmp11_ = _length_size;
479 				if (!(_tmp10_ < _tmp11_)) {
480 					break;
481 				}
482 				_tmp12_ = _length_list;
483 				_tmp13_ = vala_list_get (_tmp12_, _length_index);
484 				length = (ValaCCodeExpression*) _tmp13_;
485 				vala_ccode_writer_write_string (writer, "[");
486 				_tmp14_ = length;
487 				if (_tmp14_ != NULL) {
488 					ValaCCodeExpression* _tmp15_;
489 					_tmp15_ = length;
490 					vala_ccode_node_write ((ValaCCodeNode*) _tmp15_, writer);
491 				}
492 				vala_ccode_writer_write_string (writer, "]");
493 				_vala_ccode_node_unref0 (length);
494 			}
495 			_vala_iterable_unref0 (_length_list);
496 		}
497 	} else {
498 		if (self->priv->array) {
499 			vala_ccode_writer_write_string (writer, "[]");
500 		}
501 	}
502 }
503 
504 ValaCCodeDeclaratorSuffix*
vala_ccode_declarator_suffix_construct(GType object_type)505 vala_ccode_declarator_suffix_construct (GType object_type)
506 {
507 	ValaCCodeDeclaratorSuffix* self = NULL;
508 	self = (ValaCCodeDeclaratorSuffix*) g_type_create_instance (object_type);
509 	return self;
510 }
511 
512 ValaCCodeDeclaratorSuffix*
vala_ccode_declarator_suffix_new(void)513 vala_ccode_declarator_suffix_new (void)
514 {
515 	return vala_ccode_declarator_suffix_construct (VALA_TYPE_CCODE_DECLARATOR_SUFFIX);
516 }
517 
518 static void
vala_value_ccode_declarator_suffix_init(GValue * value)519 vala_value_ccode_declarator_suffix_init (GValue* value)
520 {
521 	value->data[0].v_pointer = NULL;
522 }
523 
524 static void
vala_value_ccode_declarator_suffix_free_value(GValue * value)525 vala_value_ccode_declarator_suffix_free_value (GValue* value)
526 {
527 	if (value->data[0].v_pointer) {
528 		vala_ccode_declarator_suffix_unref (value->data[0].v_pointer);
529 	}
530 }
531 
532 static void
vala_value_ccode_declarator_suffix_copy_value(const GValue * src_value,GValue * dest_value)533 vala_value_ccode_declarator_suffix_copy_value (const GValue* src_value,
534                                                GValue* dest_value)
535 {
536 	if (src_value->data[0].v_pointer) {
537 		dest_value->data[0].v_pointer = vala_ccode_declarator_suffix_ref (src_value->data[0].v_pointer);
538 	} else {
539 		dest_value->data[0].v_pointer = NULL;
540 	}
541 }
542 
543 static gpointer
vala_value_ccode_declarator_suffix_peek_pointer(const GValue * value)544 vala_value_ccode_declarator_suffix_peek_pointer (const GValue* value)
545 {
546 	return value->data[0].v_pointer;
547 }
548 
549 static gchar*
vala_value_ccode_declarator_suffix_collect_value(GValue * value,guint n_collect_values,GTypeCValue * collect_values,guint collect_flags)550 vala_value_ccode_declarator_suffix_collect_value (GValue* value,
551                                                   guint n_collect_values,
552                                                   GTypeCValue* collect_values,
553                                                   guint collect_flags)
554 {
555 	if (collect_values[0].v_pointer) {
556 		ValaCCodeDeclaratorSuffix * object;
557 		object = collect_values[0].v_pointer;
558 		if (object->parent_instance.g_class == NULL) {
559 			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
560 		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
561 			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
562 		}
563 		value->data[0].v_pointer = vala_ccode_declarator_suffix_ref (object);
564 	} else {
565 		value->data[0].v_pointer = NULL;
566 	}
567 	return NULL;
568 }
569 
570 static gchar*
vala_value_ccode_declarator_suffix_lcopy_value(const GValue * value,guint n_collect_values,GTypeCValue * collect_values,guint collect_flags)571 vala_value_ccode_declarator_suffix_lcopy_value (const GValue* value,
572                                                 guint n_collect_values,
573                                                 GTypeCValue* collect_values,
574                                                 guint collect_flags)
575 {
576 	ValaCCodeDeclaratorSuffix ** object_p;
577 	object_p = collect_values[0].v_pointer;
578 	if (!object_p) {
579 		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
580 	}
581 	if (!value->data[0].v_pointer) {
582 		*object_p = NULL;
583 	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
584 		*object_p = value->data[0].v_pointer;
585 	} else {
586 		*object_p = vala_ccode_declarator_suffix_ref (value->data[0].v_pointer);
587 	}
588 	return NULL;
589 }
590 
591 GParamSpec*
vala_param_spec_ccode_declarator_suffix(const gchar * name,const gchar * nick,const gchar * blurb,GType object_type,GParamFlags flags)592 vala_param_spec_ccode_declarator_suffix (const gchar* name,
593                                          const gchar* nick,
594                                          const gchar* blurb,
595                                          GType object_type,
596                                          GParamFlags flags)
597 {
598 	ValaParamSpecCCodeDeclaratorSuffix* spec;
599 	g_return_val_if_fail (g_type_is_a (object_type, VALA_TYPE_CCODE_DECLARATOR_SUFFIX), NULL);
600 	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
601 	G_PARAM_SPEC (spec)->value_type = object_type;
602 	return G_PARAM_SPEC (spec);
603 }
604 
605 gpointer
vala_value_get_ccode_declarator_suffix(const GValue * value)606 vala_value_get_ccode_declarator_suffix (const GValue* value)
607 {
608 	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALA_TYPE_CCODE_DECLARATOR_SUFFIX), NULL);
609 	return value->data[0].v_pointer;
610 }
611 
612 void
vala_value_set_ccode_declarator_suffix(GValue * value,gpointer v_object)613 vala_value_set_ccode_declarator_suffix (GValue* value,
614                                         gpointer v_object)
615 {
616 	ValaCCodeDeclaratorSuffix * old;
617 	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALA_TYPE_CCODE_DECLARATOR_SUFFIX));
618 	old = value->data[0].v_pointer;
619 	if (v_object) {
620 		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VALA_TYPE_CCODE_DECLARATOR_SUFFIX));
621 		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
622 		value->data[0].v_pointer = v_object;
623 		vala_ccode_declarator_suffix_ref (value->data[0].v_pointer);
624 	} else {
625 		value->data[0].v_pointer = NULL;
626 	}
627 	if (old) {
628 		vala_ccode_declarator_suffix_unref (old);
629 	}
630 }
631 
632 void
vala_value_take_ccode_declarator_suffix(GValue * value,gpointer v_object)633 vala_value_take_ccode_declarator_suffix (GValue* value,
634                                          gpointer v_object)
635 {
636 	ValaCCodeDeclaratorSuffix * old;
637 	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALA_TYPE_CCODE_DECLARATOR_SUFFIX));
638 	old = value->data[0].v_pointer;
639 	if (v_object) {
640 		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VALA_TYPE_CCODE_DECLARATOR_SUFFIX));
641 		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
642 		value->data[0].v_pointer = v_object;
643 	} else {
644 		value->data[0].v_pointer = NULL;
645 	}
646 	if (old) {
647 		vala_ccode_declarator_suffix_unref (old);
648 	}
649 }
650 
651 static void
vala_ccode_declarator_suffix_class_init(ValaCCodeDeclaratorSuffixClass * klass,gpointer klass_data)652 vala_ccode_declarator_suffix_class_init (ValaCCodeDeclaratorSuffixClass * klass,
653                                          gpointer klass_data)
654 {
655 	vala_ccode_declarator_suffix_parent_class = g_type_class_peek_parent (klass);
656 	((ValaCCodeDeclaratorSuffixClass *) klass)->finalize = vala_ccode_declarator_suffix_finalize;
657 	g_type_class_adjust_private_offset (klass, &ValaCCodeDeclaratorSuffix_private_offset);
658 }
659 
660 static void
vala_ccode_declarator_suffix_instance_init(ValaCCodeDeclaratorSuffix * self,gpointer klass)661 vala_ccode_declarator_suffix_instance_init (ValaCCodeDeclaratorSuffix * self,
662                                             gpointer klass)
663 {
664 	self->priv = vala_ccode_declarator_suffix_get_instance_private (self);
665 	self->ref_count = 1;
666 }
667 
668 static void
vala_ccode_declarator_suffix_finalize(ValaCCodeDeclaratorSuffix * obj)669 vala_ccode_declarator_suffix_finalize (ValaCCodeDeclaratorSuffix * obj)
670 {
671 	ValaCCodeDeclaratorSuffix * self;
672 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_CCODE_DECLARATOR_SUFFIX, ValaCCodeDeclaratorSuffix);
673 	g_signal_handlers_destroy (self);
674 	_vala_iterable_unref0 (self->priv->array_length);
675 }
676 
677 static GType
vala_ccode_declarator_suffix_get_type_once(void)678 vala_ccode_declarator_suffix_get_type_once (void)
679 {
680 	static const GTypeValueTable g_define_type_value_table = { vala_value_ccode_declarator_suffix_init, vala_value_ccode_declarator_suffix_free_value, vala_value_ccode_declarator_suffix_copy_value, vala_value_ccode_declarator_suffix_peek_pointer, "p", vala_value_ccode_declarator_suffix_collect_value, "p", vala_value_ccode_declarator_suffix_lcopy_value };
681 	static const GTypeInfo g_define_type_info = { sizeof (ValaCCodeDeclaratorSuffixClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_ccode_declarator_suffix_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaCCodeDeclaratorSuffix), 0, (GInstanceInitFunc) vala_ccode_declarator_suffix_instance_init, &g_define_type_value_table };
682 	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
683 	GType vala_ccode_declarator_suffix_type_id;
684 	vala_ccode_declarator_suffix_type_id = g_type_register_fundamental (g_type_fundamental_next (), "ValaCCodeDeclaratorSuffix", &g_define_type_info, &g_define_type_fundamental_info, 0);
685 	ValaCCodeDeclaratorSuffix_private_offset = g_type_add_instance_private (vala_ccode_declarator_suffix_type_id, sizeof (ValaCCodeDeclaratorSuffixPrivate));
686 	return vala_ccode_declarator_suffix_type_id;
687 }
688 
689 GType
vala_ccode_declarator_suffix_get_type(void)690 vala_ccode_declarator_suffix_get_type (void)
691 {
692 	static volatile gsize vala_ccode_declarator_suffix_type_id__volatile = 0;
693 	if (g_once_init_enter (&vala_ccode_declarator_suffix_type_id__volatile)) {
694 		GType vala_ccode_declarator_suffix_type_id;
695 		vala_ccode_declarator_suffix_type_id = vala_ccode_declarator_suffix_get_type_once ();
696 		g_once_init_leave (&vala_ccode_declarator_suffix_type_id__volatile, vala_ccode_declarator_suffix_type_id);
697 	}
698 	return vala_ccode_declarator_suffix_type_id__volatile;
699 }
700 
701 gpointer
vala_ccode_declarator_suffix_ref(gpointer instance)702 vala_ccode_declarator_suffix_ref (gpointer instance)
703 {
704 	ValaCCodeDeclaratorSuffix * self;
705 	self = instance;
706 	g_atomic_int_inc (&self->ref_count);
707 	return instance;
708 }
709 
710 void
vala_ccode_declarator_suffix_unref(gpointer instance)711 vala_ccode_declarator_suffix_unref (gpointer instance)
712 {
713 	ValaCCodeDeclaratorSuffix * self;
714 	self = instance;
715 	if (g_atomic_int_dec_and_test (&self->ref_count)) {
716 		VALA_CCODE_DECLARATOR_SUFFIX_GET_CLASS (self)->finalize (self);
717 		g_type_free_instance ((GTypeInstance *) self);
718 	}
719 }
720 
721