1 /* valaccodecommaexpression.c generated by valac, the Vala compiler
2  * generated from valaccodecommaexpression.vala, do not modify */
3 
4 /* valaccodecommaexpression.vala
5  *
6  * Copyright (C) 2006-2010  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 <valagee.h>
28 #include <glib-object.h>
29 #include <glib.h>
30 
31 #define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
32 #define _vala_ccode_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_ccode_node_unref (var), NULL)))
33 
34 struct _ValaCCodeCommaExpressionPrivate {
35 	ValaList* inner;
36 };
37 
38 static gint ValaCCodeCommaExpression_private_offset;
39 static gpointer vala_ccode_comma_expression_parent_class = NULL;
40 
41 static void vala_ccode_comma_expression_real_write (ValaCCodeNode* base,
42                                              ValaCCodeWriter* writer);
43 static void vala_ccode_comma_expression_finalize (ValaCCodeNode * obj);
44 static GType vala_ccode_comma_expression_get_type_once (void);
45 
46 static inline gpointer
vala_ccode_comma_expression_get_instance_private(ValaCCodeCommaExpression * self)47 vala_ccode_comma_expression_get_instance_private (ValaCCodeCommaExpression* self)
48 {
49 	return G_STRUCT_MEMBER_P (self, ValaCCodeCommaExpression_private_offset);
50 }
51 
52 /**
53  * Appends the specified expression to the expression list.
54  *
55  * @param expr a C code expression
56  */
57 void
vala_ccode_comma_expression_append_expression(ValaCCodeCommaExpression * self,ValaCCodeExpression * expr)58 vala_ccode_comma_expression_append_expression (ValaCCodeCommaExpression* self,
59                                                ValaCCodeExpression* expr)
60 {
61 	ValaList* _tmp0_;
62 	g_return_if_fail (self != NULL);
63 	g_return_if_fail (expr != NULL);
64 	_tmp0_ = self->priv->inner;
65 	vala_collection_add ((ValaCollection*) _tmp0_, expr);
66 }
67 
68 void
vala_ccode_comma_expression_set_expression(ValaCCodeCommaExpression * self,gint index,ValaCCodeExpression * expr)69 vala_ccode_comma_expression_set_expression (ValaCCodeCommaExpression* self,
70                                             gint index,
71                                             ValaCCodeExpression* expr)
72 {
73 	ValaList* _tmp0_;
74 	g_return_if_fail (self != NULL);
75 	g_return_if_fail (expr != NULL);
76 	_tmp0_ = self->priv->inner;
77 	vala_list_set (_tmp0_, index, expr);
78 }
79 
80 static gpointer
_vala_iterable_ref0(gpointer self)81 _vala_iterable_ref0 (gpointer self)
82 {
83 	return self ? vala_iterable_ref (self) : NULL;
84 }
85 
86 ValaList*
vala_ccode_comma_expression_get_inner(ValaCCodeCommaExpression * self)87 vala_ccode_comma_expression_get_inner (ValaCCodeCommaExpression* self)
88 {
89 	ValaList* _tmp0_;
90 	ValaList* _tmp1_;
91 	ValaList* result = NULL;
92 	g_return_val_if_fail (self != NULL, NULL);
93 	_tmp0_ = self->priv->inner;
94 	_tmp1_ = _vala_iterable_ref0 (_tmp0_);
95 	result = _tmp1_;
96 	return result;
97 }
98 
99 static void
vala_ccode_comma_expression_real_write(ValaCCodeNode * base,ValaCCodeWriter * writer)100 vala_ccode_comma_expression_real_write (ValaCCodeNode* base,
101                                         ValaCCodeWriter* writer)
102 {
103 	ValaCCodeCommaExpression * self;
104 	gboolean first = FALSE;
105 	self = (ValaCCodeCommaExpression*) base;
106 	g_return_if_fail (writer != NULL);
107 	first = TRUE;
108 	vala_ccode_writer_write_string (writer, "(");
109 	{
110 		ValaList* _expr_list = NULL;
111 		ValaList* _tmp0_;
112 		ValaList* _tmp1_;
113 		gint _expr_size = 0;
114 		ValaList* _tmp2_;
115 		gint _tmp3_;
116 		gint _tmp4_;
117 		gint _expr_index = 0;
118 		_tmp0_ = self->priv->inner;
119 		_tmp1_ = _vala_iterable_ref0 (_tmp0_);
120 		_expr_list = _tmp1_;
121 		_tmp2_ = _expr_list;
122 		_tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
123 		_tmp4_ = _tmp3_;
124 		_expr_size = _tmp4_;
125 		_expr_index = -1;
126 		while (TRUE) {
127 			gint _tmp5_;
128 			gint _tmp6_;
129 			ValaCCodeExpression* expr = NULL;
130 			ValaList* _tmp7_;
131 			gpointer _tmp8_;
132 			ValaCCodeExpression* _tmp9_;
133 			_expr_index = _expr_index + 1;
134 			_tmp5_ = _expr_index;
135 			_tmp6_ = _expr_size;
136 			if (!(_tmp5_ < _tmp6_)) {
137 				break;
138 			}
139 			_tmp7_ = _expr_list;
140 			_tmp8_ = vala_list_get (_tmp7_, _expr_index);
141 			expr = (ValaCCodeExpression*) _tmp8_;
142 			if (!first) {
143 				vala_ccode_writer_write_string (writer, ", ");
144 			} else {
145 				first = FALSE;
146 			}
147 			_tmp9_ = expr;
148 			vala_ccode_node_write ((ValaCCodeNode*) _tmp9_, writer);
149 			_vala_ccode_node_unref0 (expr);
150 		}
151 		_vala_iterable_unref0 (_expr_list);
152 	}
153 	vala_ccode_writer_write_string (writer, ")");
154 }
155 
156 ValaCCodeCommaExpression*
vala_ccode_comma_expression_construct(GType object_type)157 vala_ccode_comma_expression_construct (GType object_type)
158 {
159 	ValaCCodeCommaExpression* self = NULL;
160 	self = (ValaCCodeCommaExpression*) vala_ccode_expression_construct (object_type);
161 	return self;
162 }
163 
164 ValaCCodeCommaExpression*
vala_ccode_comma_expression_new(void)165 vala_ccode_comma_expression_new (void)
166 {
167 	return vala_ccode_comma_expression_construct (VALA_TYPE_CCODE_COMMA_EXPRESSION);
168 }
169 
170 static void
vala_ccode_comma_expression_class_init(ValaCCodeCommaExpressionClass * klass,gpointer klass_data)171 vala_ccode_comma_expression_class_init (ValaCCodeCommaExpressionClass * klass,
172                                         gpointer klass_data)
173 {
174 	vala_ccode_comma_expression_parent_class = g_type_class_peek_parent (klass);
175 	((ValaCCodeNodeClass *) klass)->finalize = vala_ccode_comma_expression_finalize;
176 	g_type_class_adjust_private_offset (klass, &ValaCCodeCommaExpression_private_offset);
177 	((ValaCCodeNodeClass *) klass)->write = (void (*) (ValaCCodeNode*, ValaCCodeWriter*)) vala_ccode_comma_expression_real_write;
178 }
179 
180 static void
vala_ccode_comma_expression_instance_init(ValaCCodeCommaExpression * self,gpointer klass)181 vala_ccode_comma_expression_instance_init (ValaCCodeCommaExpression * self,
182                                            gpointer klass)
183 {
184 	GEqualFunc _tmp0_;
185 	ValaArrayList* _tmp1_;
186 	self->priv = vala_ccode_comma_expression_get_instance_private (self);
187 	_tmp0_ = g_direct_equal;
188 	_tmp1_ = vala_array_list_new (VALA_TYPE_CCODE_EXPRESSION, (GBoxedCopyFunc) vala_ccode_node_ref, (GDestroyNotify) vala_ccode_node_unref, _tmp0_);
189 	self->priv->inner = (ValaList*) _tmp1_;
190 }
191 
192 static void
vala_ccode_comma_expression_finalize(ValaCCodeNode * obj)193 vala_ccode_comma_expression_finalize (ValaCCodeNode * obj)
194 {
195 	ValaCCodeCommaExpression * self;
196 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_CCODE_COMMA_EXPRESSION, ValaCCodeCommaExpression);
197 	_vala_iterable_unref0 (self->priv->inner);
198 	VALA_CCODE_NODE_CLASS (vala_ccode_comma_expression_parent_class)->finalize (obj);
199 }
200 
201 /**
202  * Represents a comma separated expression list in the C code.
203  */
204 static GType
vala_ccode_comma_expression_get_type_once(void)205 vala_ccode_comma_expression_get_type_once (void)
206 {
207 	static const GTypeInfo g_define_type_info = { sizeof (ValaCCodeCommaExpressionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_ccode_comma_expression_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaCCodeCommaExpression), 0, (GInstanceInitFunc) vala_ccode_comma_expression_instance_init, NULL };
208 	GType vala_ccode_comma_expression_type_id;
209 	vala_ccode_comma_expression_type_id = g_type_register_static (VALA_TYPE_CCODE_EXPRESSION, "ValaCCodeCommaExpression", &g_define_type_info, 0);
210 	ValaCCodeCommaExpression_private_offset = g_type_add_instance_private (vala_ccode_comma_expression_type_id, sizeof (ValaCCodeCommaExpressionPrivate));
211 	return vala_ccode_comma_expression_type_id;
212 }
213 
214 GType
vala_ccode_comma_expression_get_type(void)215 vala_ccode_comma_expression_get_type (void)
216 {
217 	static volatile gsize vala_ccode_comma_expression_type_id__volatile = 0;
218 	if (g_once_init_enter (&vala_ccode_comma_expression_type_id__volatile)) {
219 		GType vala_ccode_comma_expression_type_id;
220 		vala_ccode_comma_expression_type_id = vala_ccode_comma_expression_get_type_once ();
221 		g_once_init_leave (&vala_ccode_comma_expression_type_id__volatile, vala_ccode_comma_expression_type_id);
222 	}
223 	return vala_ccode_comma_expression_type_id__volatile;
224 }
225 
226