1 /* valaccodefunctioncall.c generated by valac, the Vala compiler
2 * generated from valaccodefunctioncall.vala, do not modify */
3
4 /* valaccodefunctioncall.vala
5 *
6 * Copyright (C) 2006-2007 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_ccode_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_ccode_node_unref (var), NULL)))
32 #define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
33
34 struct _ValaCCodeFunctionCallPrivate {
35 ValaCCodeExpression* _call;
36 ValaList* arguments;
37 };
38
39 static gint ValaCCodeFunctionCall_private_offset;
40 static gpointer vala_ccode_function_call_parent_class = NULL;
41
42 static void vala_ccode_function_call_real_write (ValaCCodeNode* base,
43 ValaCCodeWriter* writer);
44 static void vala_ccode_function_call_finalize (ValaCCodeNode * obj);
45 static GType vala_ccode_function_call_get_type_once (void);
46
47 static inline gpointer
vala_ccode_function_call_get_instance_private(ValaCCodeFunctionCall * self)48 vala_ccode_function_call_get_instance_private (ValaCCodeFunctionCall* self)
49 {
50 return G_STRUCT_MEMBER_P (self, ValaCCodeFunctionCall_private_offset);
51 }
52
53 ValaCCodeExpression*
vala_ccode_function_call_get_call(ValaCCodeFunctionCall * self)54 vala_ccode_function_call_get_call (ValaCCodeFunctionCall* self)
55 {
56 ValaCCodeExpression* result;
57 ValaCCodeExpression* _tmp0_;
58 g_return_val_if_fail (self != NULL, NULL);
59 _tmp0_ = self->priv->_call;
60 result = _tmp0_;
61 return result;
62 }
63
64 static gpointer
_vala_ccode_node_ref0(gpointer self)65 _vala_ccode_node_ref0 (gpointer self)
66 {
67 return self ? vala_ccode_node_ref (self) : NULL;
68 }
69
70 void
vala_ccode_function_call_set_call(ValaCCodeFunctionCall * self,ValaCCodeExpression * value)71 vala_ccode_function_call_set_call (ValaCCodeFunctionCall* self,
72 ValaCCodeExpression* value)
73 {
74 ValaCCodeExpression* _tmp0_;
75 g_return_if_fail (self != NULL);
76 _tmp0_ = _vala_ccode_node_ref0 (value);
77 _vala_ccode_node_unref0 (self->priv->_call);
78 self->priv->_call = _tmp0_;
79 }
80
81 ValaCCodeFunctionCall*
vala_ccode_function_call_construct(GType object_type,ValaCCodeExpression * call)82 vala_ccode_function_call_construct (GType object_type,
83 ValaCCodeExpression* call)
84 {
85 ValaCCodeFunctionCall* self = NULL;
86 self = (ValaCCodeFunctionCall*) vala_ccode_expression_construct (object_type);
87 vala_ccode_function_call_set_call (self, call);
88 return self;
89 }
90
91 ValaCCodeFunctionCall*
vala_ccode_function_call_new(ValaCCodeExpression * call)92 vala_ccode_function_call_new (ValaCCodeExpression* call)
93 {
94 return vala_ccode_function_call_construct (VALA_TYPE_CCODE_FUNCTION_CALL, call);
95 }
96
97 /**
98 * Appends the specified expression to the list of arguments.
99 *
100 * @param expr a C code expression
101 */
102 void
vala_ccode_function_call_add_argument(ValaCCodeFunctionCall * self,ValaCCodeExpression * expr)103 vala_ccode_function_call_add_argument (ValaCCodeFunctionCall* self,
104 ValaCCodeExpression* expr)
105 {
106 ValaList* _tmp0_;
107 g_return_if_fail (self != NULL);
108 g_return_if_fail (expr != NULL);
109 _tmp0_ = self->priv->arguments;
110 vala_collection_add ((ValaCollection*) _tmp0_, expr);
111 }
112
113 void
vala_ccode_function_call_insert_argument(ValaCCodeFunctionCall * self,gint index,ValaCCodeExpression * expr)114 vala_ccode_function_call_insert_argument (ValaCCodeFunctionCall* self,
115 gint index,
116 ValaCCodeExpression* expr)
117 {
118 ValaList* _tmp0_;
119 g_return_if_fail (self != NULL);
120 g_return_if_fail (expr != NULL);
121 _tmp0_ = self->priv->arguments;
122 vala_list_insert (_tmp0_, index, expr);
123 }
124
125 /**
126 * Returns a copy of the list of arguments.
127 *
128 * @return list of arguments
129 */
130 static gpointer
_vala_iterable_ref0(gpointer self)131 _vala_iterable_ref0 (gpointer self)
132 {
133 return self ? vala_iterable_ref (self) : NULL;
134 }
135
136 ValaList*
vala_ccode_function_call_get_arguments(ValaCCodeFunctionCall * self)137 vala_ccode_function_call_get_arguments (ValaCCodeFunctionCall* self)
138 {
139 ValaList* _tmp0_;
140 ValaList* _tmp1_;
141 ValaList* result = NULL;
142 g_return_val_if_fail (self != NULL, NULL);
143 _tmp0_ = self->priv->arguments;
144 _tmp1_ = _vala_iterable_ref0 (_tmp0_);
145 result = _tmp1_;
146 return result;
147 }
148
149 static void
vala_ccode_function_call_real_write(ValaCCodeNode * base,ValaCCodeWriter * writer)150 vala_ccode_function_call_real_write (ValaCCodeNode* base,
151 ValaCCodeWriter* writer)
152 {
153 ValaCCodeFunctionCall * self;
154 ValaCCodeExpression* _tmp0_;
155 gboolean first = FALSE;
156 self = (ValaCCodeFunctionCall*) base;
157 g_return_if_fail (writer != NULL);
158 _tmp0_ = self->priv->_call;
159 vala_ccode_expression_write_inner (_tmp0_, writer);
160 vala_ccode_writer_write_string (writer, " (");
161 first = TRUE;
162 {
163 ValaList* _expr_list = NULL;
164 ValaList* _tmp1_;
165 ValaList* _tmp2_;
166 gint _expr_size = 0;
167 ValaList* _tmp3_;
168 gint _tmp4_;
169 gint _tmp5_;
170 gint _expr_index = 0;
171 _tmp1_ = self->priv->arguments;
172 _tmp2_ = _vala_iterable_ref0 (_tmp1_);
173 _expr_list = _tmp2_;
174 _tmp3_ = _expr_list;
175 _tmp4_ = vala_collection_get_size ((ValaCollection*) _tmp3_);
176 _tmp5_ = _tmp4_;
177 _expr_size = _tmp5_;
178 _expr_index = -1;
179 while (TRUE) {
180 gint _tmp6_;
181 gint _tmp7_;
182 ValaCCodeExpression* expr = NULL;
183 ValaList* _tmp8_;
184 gpointer _tmp9_;
185 ValaCCodeExpression* _tmp10_;
186 _expr_index = _expr_index + 1;
187 _tmp6_ = _expr_index;
188 _tmp7_ = _expr_size;
189 if (!(_tmp6_ < _tmp7_)) {
190 break;
191 }
192 _tmp8_ = _expr_list;
193 _tmp9_ = vala_list_get (_tmp8_, _expr_index);
194 expr = (ValaCCodeExpression*) _tmp9_;
195 if (!first) {
196 vala_ccode_writer_write_string (writer, ", ");
197 } else {
198 first = FALSE;
199 }
200 _tmp10_ = expr;
201 if (_tmp10_ != NULL) {
202 ValaCCodeExpression* _tmp11_;
203 _tmp11_ = expr;
204 vala_ccode_node_write ((ValaCCodeNode*) _tmp11_, writer);
205 }
206 _vala_ccode_node_unref0 (expr);
207 }
208 _vala_iterable_unref0 (_expr_list);
209 }
210 vala_ccode_writer_write_string (writer, ")");
211 }
212
213 static void
vala_ccode_function_call_class_init(ValaCCodeFunctionCallClass * klass,gpointer klass_data)214 vala_ccode_function_call_class_init (ValaCCodeFunctionCallClass * klass,
215 gpointer klass_data)
216 {
217 vala_ccode_function_call_parent_class = g_type_class_peek_parent (klass);
218 ((ValaCCodeNodeClass *) klass)->finalize = vala_ccode_function_call_finalize;
219 g_type_class_adjust_private_offset (klass, &ValaCCodeFunctionCall_private_offset);
220 ((ValaCCodeNodeClass *) klass)->write = (void (*) (ValaCCodeNode*, ValaCCodeWriter*)) vala_ccode_function_call_real_write;
221 }
222
223 static void
vala_ccode_function_call_instance_init(ValaCCodeFunctionCall * self,gpointer klass)224 vala_ccode_function_call_instance_init (ValaCCodeFunctionCall * self,
225 gpointer klass)
226 {
227 GEqualFunc _tmp0_;
228 ValaArrayList* _tmp1_;
229 self->priv = vala_ccode_function_call_get_instance_private (self);
230 _tmp0_ = g_direct_equal;
231 _tmp1_ = vala_array_list_new (VALA_TYPE_CCODE_EXPRESSION, (GBoxedCopyFunc) vala_ccode_node_ref, (GDestroyNotify) vala_ccode_node_unref, _tmp0_);
232 self->priv->arguments = (ValaList*) _tmp1_;
233 }
234
235 static void
vala_ccode_function_call_finalize(ValaCCodeNode * obj)236 vala_ccode_function_call_finalize (ValaCCodeNode * obj)
237 {
238 ValaCCodeFunctionCall * self;
239 self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_CCODE_FUNCTION_CALL, ValaCCodeFunctionCall);
240 _vala_ccode_node_unref0 (self->priv->_call);
241 _vala_iterable_unref0 (self->priv->arguments);
242 VALA_CCODE_NODE_CLASS (vala_ccode_function_call_parent_class)->finalize (obj);
243 }
244
245 /**
246 * Represents a function call in the C code.
247 */
248 static GType
vala_ccode_function_call_get_type_once(void)249 vala_ccode_function_call_get_type_once (void)
250 {
251 static const GTypeInfo g_define_type_info = { sizeof (ValaCCodeFunctionCallClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_ccode_function_call_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaCCodeFunctionCall), 0, (GInstanceInitFunc) vala_ccode_function_call_instance_init, NULL };
252 GType vala_ccode_function_call_type_id;
253 vala_ccode_function_call_type_id = g_type_register_static (VALA_TYPE_CCODE_EXPRESSION, "ValaCCodeFunctionCall", &g_define_type_info, 0);
254 ValaCCodeFunctionCall_private_offset = g_type_add_instance_private (vala_ccode_function_call_type_id, sizeof (ValaCCodeFunctionCallPrivate));
255 return vala_ccode_function_call_type_id;
256 }
257
258 GType
vala_ccode_function_call_get_type(void)259 vala_ccode_function_call_get_type (void)
260 {
261 static volatile gsize vala_ccode_function_call_type_id__volatile = 0;
262 if (g_once_init_enter (&vala_ccode_function_call_type_id__volatile)) {
263 GType vala_ccode_function_call_type_id;
264 vala_ccode_function_call_type_id = vala_ccode_function_call_get_type_once ();
265 g_once_init_leave (&vala_ccode_function_call_type_id__volatile, vala_ccode_function_call_type_id);
266 }
267 return vala_ccode_function_call_type_id__volatile;
268 }
269
270