1 /* valaerrorcode.c generated by valac, the Vala compiler
2  * generated from valaerrorcode.vala, do not modify */
3 
4 /* valaerrorcode.vala
5  *
6  * Copyright (C) 2008  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 "vala.h"
27 #include <glib.h>
28 #include <stdlib.h>
29 #include <string.h>
30 
31 #define _vala_code_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_node_unref (var), NULL)))
32 
33 struct _ValaErrorCodePrivate {
34 	ValaExpression* _value;
35 	ValaConstant* _code;
36 };
37 
38 static gint ValaErrorCode_private_offset;
39 static gpointer vala_error_code_parent_class = NULL;
40 
41 static void vala_error_code_set_code (ValaErrorCode* self,
42                                ValaConstant* value);
43 static void vala_error_code_real_accept (ValaCodeNode* base,
44                                   ValaCodeVisitor* visitor);
45 static void vala_error_code_real_accept_children (ValaCodeNode* base,
46                                            ValaCodeVisitor* visitor);
47 static gboolean vala_error_code_real_check (ValaCodeNode* base,
48                                      ValaCodeContext* context);
49 static void vala_error_code_finalize (ValaCodeNode * obj);
50 static GType vala_error_code_get_type_once (void);
51 
52 static inline gpointer
vala_error_code_get_instance_private(ValaErrorCode * self)53 vala_error_code_get_instance_private (ValaErrorCode* self)
54 {
55 	return G_STRUCT_MEMBER_P (self, ValaErrorCode_private_offset);
56 }
57 
58 ValaExpression*
vala_error_code_get_value(ValaErrorCode * self)59 vala_error_code_get_value (ValaErrorCode* self)
60 {
61 	ValaExpression* result;
62 	ValaExpression* _tmp0_;
63 	g_return_val_if_fail (self != NULL, NULL);
64 	_tmp0_ = self->priv->_value;
65 	result = _tmp0_;
66 	return result;
67 }
68 
69 static gpointer
_vala_code_node_ref0(gpointer self)70 _vala_code_node_ref0 (gpointer self)
71 {
72 	return self ? vala_code_node_ref (self) : NULL;
73 }
74 
75 void
vala_error_code_set_value(ValaErrorCode * self,ValaExpression * value)76 vala_error_code_set_value (ValaErrorCode* self,
77                            ValaExpression* value)
78 {
79 	ValaExpression* _tmp0_;
80 	ValaExpression* _tmp1_;
81 	g_return_if_fail (self != NULL);
82 	_tmp0_ = _vala_code_node_ref0 (value);
83 	_vala_code_node_unref0 (self->priv->_value);
84 	self->priv->_value = _tmp0_;
85 	_tmp1_ = self->priv->_value;
86 	if (_tmp1_ != NULL) {
87 		ValaExpression* _tmp2_;
88 		_tmp2_ = self->priv->_value;
89 		vala_code_node_set_parent_node ((ValaCodeNode*) _tmp2_, (ValaCodeNode*) self);
90 	}
91 }
92 
93 ValaConstant*
vala_error_code_get_code(ValaErrorCode * self)94 vala_error_code_get_code (ValaErrorCode* self)
95 {
96 	ValaConstant* result;
97 	ValaConstant* _tmp0_;
98 	g_return_val_if_fail (self != NULL, NULL);
99 	_tmp0_ = self->priv->_code;
100 	result = _tmp0_;
101 	return result;
102 }
103 
104 static void
vala_error_code_set_code(ValaErrorCode * self,ValaConstant * value)105 vala_error_code_set_code (ValaErrorCode* self,
106                           ValaConstant* value)
107 {
108 	ValaConstant* _tmp0_;
109 	ValaConstant* _tmp1_;
110 	g_return_if_fail (self != NULL);
111 	_tmp0_ = _vala_code_node_ref0 (value);
112 	_vala_code_node_unref0 (self->priv->_code);
113 	self->priv->_code = _tmp0_;
114 	_tmp1_ = self->priv->_code;
115 	if (_tmp1_ != NULL) {
116 		ValaConstant* _tmp2_;
117 		ValaScope* _tmp3_;
118 		ValaScope* _tmp4_;
119 		_tmp2_ = self->priv->_code;
120 		_tmp3_ = vala_symbol_get_owner ((ValaSymbol*) self);
121 		_tmp4_ = _tmp3_;
122 		vala_symbol_set_owner ((ValaSymbol*) _tmp2_, _tmp4_);
123 	}
124 }
125 
126 /**
127  * Creates a new enum value.
128  *
129  * @param name enum value name
130  * @return     newly created enum value
131  */
132 ValaErrorCode*
vala_error_code_construct(GType object_type,const gchar * name,ValaSourceReference * source_reference,ValaComment * comment)133 vala_error_code_construct (GType object_type,
134                            const gchar* name,
135                            ValaSourceReference* source_reference,
136                            ValaComment* comment)
137 {
138 	ValaErrorCode* self = NULL;
139 	g_return_val_if_fail (name != NULL, NULL);
140 	self = (ValaErrorCode*) vala_typesymbol_construct (object_type, name, source_reference, comment);
141 	return self;
142 }
143 
144 ValaErrorCode*
vala_error_code_new(const gchar * name,ValaSourceReference * source_reference,ValaComment * comment)145 vala_error_code_new (const gchar* name,
146                      ValaSourceReference* source_reference,
147                      ValaComment* comment)
148 {
149 	return vala_error_code_construct (VALA_TYPE_ERROR_CODE, name, source_reference, comment);
150 }
151 
152 /**
153  * Creates a new enum value with the specified numerical representation.
154  *
155  * @param name  enum value name
156  * @param value numerical representation
157  * @return      newly created enum value
158  */
159 ValaErrorCode*
vala_error_code_construct_with_value(GType object_type,const gchar * name,ValaExpression * value,ValaSourceReference * source_reference)160 vala_error_code_construct_with_value (GType object_type,
161                                       const gchar* name,
162                                       ValaExpression* value,
163                                       ValaSourceReference* source_reference)
164 {
165 	ValaErrorCode* self = NULL;
166 	g_return_val_if_fail (name != NULL, NULL);
167 	g_return_val_if_fail (value != NULL, NULL);
168 	self = (ValaErrorCode*) vala_error_code_construct (object_type, name, source_reference, NULL);
169 	vala_error_code_set_value (self, value);
170 	return self;
171 }
172 
173 ValaErrorCode*
vala_error_code_new_with_value(const gchar * name,ValaExpression * value,ValaSourceReference * source_reference)174 vala_error_code_new_with_value (const gchar* name,
175                                 ValaExpression* value,
176                                 ValaSourceReference* source_reference)
177 {
178 	return vala_error_code_construct_with_value (VALA_TYPE_ERROR_CODE, name, value, source_reference);
179 }
180 
181 static void
vala_error_code_real_accept(ValaCodeNode * base,ValaCodeVisitor * visitor)182 vala_error_code_real_accept (ValaCodeNode* base,
183                              ValaCodeVisitor* visitor)
184 {
185 	ValaErrorCode * self;
186 	self = (ValaErrorCode*) base;
187 	g_return_if_fail (visitor != NULL);
188 	vala_code_visitor_visit_error_code (visitor, self);
189 }
190 
191 static void
vala_error_code_real_accept_children(ValaCodeNode * base,ValaCodeVisitor * visitor)192 vala_error_code_real_accept_children (ValaCodeNode* base,
193                                       ValaCodeVisitor* visitor)
194 {
195 	ValaErrorCode * self;
196 	ValaExpression* _tmp0_;
197 	ValaExpression* _tmp1_;
198 	self = (ValaErrorCode*) base;
199 	g_return_if_fail (visitor != NULL);
200 	_tmp0_ = vala_error_code_get_value (self);
201 	_tmp1_ = _tmp0_;
202 	if (_tmp1_ != NULL) {
203 		ValaExpression* _tmp2_;
204 		ValaExpression* _tmp3_;
205 		_tmp2_ = vala_error_code_get_value (self);
206 		_tmp3_ = _tmp2_;
207 		vala_code_node_accept ((ValaCodeNode*) _tmp3_, visitor);
208 	}
209 }
210 
211 static gboolean
vala_error_code_real_check(ValaCodeNode * base,ValaCodeContext * context)212 vala_error_code_real_check (ValaCodeNode* base,
213                             ValaCodeContext* context)
214 {
215 	ValaErrorCode * self;
216 	gboolean _tmp0_;
217 	gboolean _tmp1_;
218 	ValaExpression* _tmp4_;
219 	ValaExpression* _tmp5_;
220 	const gchar* _tmp8_;
221 	const gchar* _tmp9_;
222 	ValaSemanticAnalyzer* _tmp10_;
223 	ValaSemanticAnalyzer* _tmp11_;
224 	ValaDataType* _tmp12_;
225 	ValaDataType* _tmp13_;
226 	ValaDataType* _tmp14_;
227 	ValaSourceReference* _tmp15_;
228 	ValaSourceReference* _tmp16_;
229 	ValaComment* _tmp17_;
230 	ValaComment* _tmp18_;
231 	ValaConstant* _tmp19_;
232 	ValaConstant* _tmp20_;
233 	ValaConstant* _tmp21_;
234 	ValaConstant* _tmp22_;
235 	ValaConstant* _tmp23_;
236 	ValaConstant* _tmp24_;
237 	gboolean _tmp25_;
238 	gboolean _tmp26_;
239 	gboolean result = FALSE;
240 	self = (ValaErrorCode*) base;
241 	g_return_val_if_fail (context != NULL, FALSE);
242 	_tmp0_ = vala_code_node_get_checked ((ValaCodeNode*) self);
243 	_tmp1_ = _tmp0_;
244 	if (_tmp1_) {
245 		gboolean _tmp2_;
246 		gboolean _tmp3_;
247 		_tmp2_ = vala_code_node_get_error ((ValaCodeNode*) self);
248 		_tmp3_ = _tmp2_;
249 		result = !_tmp3_;
250 		return result;
251 	}
252 	vala_code_node_set_checked ((ValaCodeNode*) self, TRUE);
253 	_tmp4_ = vala_error_code_get_value (self);
254 	_tmp5_ = _tmp4_;
255 	if (_tmp5_ != NULL) {
256 		ValaExpression* _tmp6_;
257 		ValaExpression* _tmp7_;
258 		_tmp6_ = vala_error_code_get_value (self);
259 		_tmp7_ = _tmp6_;
260 		vala_code_node_check ((ValaCodeNode*) _tmp7_, context);
261 	}
262 	_tmp8_ = vala_symbol_get_name ((ValaSymbol*) self);
263 	_tmp9_ = _tmp8_;
264 	_tmp10_ = vala_code_context_get_analyzer (context);
265 	_tmp11_ = _tmp10_;
266 	_tmp12_ = _tmp11_->int_type;
267 	_tmp13_ = vala_data_type_copy (_tmp12_);
268 	_tmp14_ = _tmp13_;
269 	_tmp15_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
270 	_tmp16_ = _tmp15_;
271 	_tmp17_ = vala_symbol_get_comment ((ValaSymbol*) self);
272 	_tmp18_ = _tmp17_;
273 	_tmp19_ = vala_constant_new (_tmp9_, _tmp14_, NULL, _tmp16_, _tmp18_);
274 	_tmp20_ = _tmp19_;
275 	vala_error_code_set_code (self, _tmp20_);
276 	_vala_code_node_unref0 (_tmp20_);
277 	_vala_code_node_unref0 (_tmp14_);
278 	_tmp21_ = vala_error_code_get_code (self);
279 	_tmp22_ = _tmp21_;
280 	vala_symbol_set_external ((ValaSymbol*) _tmp22_, TRUE);
281 	_tmp23_ = vala_error_code_get_code (self);
282 	_tmp24_ = _tmp23_;
283 	vala_code_node_check ((ValaCodeNode*) _tmp24_, context);
284 	_tmp25_ = vala_code_node_get_error ((ValaCodeNode*) self);
285 	_tmp26_ = _tmp25_;
286 	result = !_tmp26_;
287 	return result;
288 }
289 
290 static void
vala_error_code_class_init(ValaErrorCodeClass * klass,gpointer klass_data)291 vala_error_code_class_init (ValaErrorCodeClass * klass,
292                             gpointer klass_data)
293 {
294 	vala_error_code_parent_class = g_type_class_peek_parent (klass);
295 	((ValaCodeNodeClass *) klass)->finalize = vala_error_code_finalize;
296 	g_type_class_adjust_private_offset (klass, &ValaErrorCode_private_offset);
297 	((ValaCodeNodeClass *) klass)->accept = (void (*) (ValaCodeNode*, ValaCodeVisitor*)) vala_error_code_real_accept;
298 	((ValaCodeNodeClass *) klass)->accept_children = (void (*) (ValaCodeNode*, ValaCodeVisitor*)) vala_error_code_real_accept_children;
299 	((ValaCodeNodeClass *) klass)->check = (gboolean (*) (ValaCodeNode*, ValaCodeContext*)) vala_error_code_real_check;
300 }
301 
302 static void
vala_error_code_instance_init(ValaErrorCode * self,gpointer klass)303 vala_error_code_instance_init (ValaErrorCode * self,
304                                gpointer klass)
305 {
306 	self->priv = vala_error_code_get_instance_private (self);
307 }
308 
309 static void
vala_error_code_finalize(ValaCodeNode * obj)310 vala_error_code_finalize (ValaCodeNode * obj)
311 {
312 	ValaErrorCode * self;
313 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_ERROR_CODE, ValaErrorCode);
314 	_vala_code_node_unref0 (self->priv->_value);
315 	_vala_code_node_unref0 (self->priv->_code);
316 	VALA_CODE_NODE_CLASS (vala_error_code_parent_class)->finalize (obj);
317 }
318 
319 /**
320  * Represents an error value member in the source code.
321  */
322 static GType
vala_error_code_get_type_once(void)323 vala_error_code_get_type_once (void)
324 {
325 	static const GTypeInfo g_define_type_info = { sizeof (ValaErrorCodeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_error_code_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaErrorCode), 0, (GInstanceInitFunc) vala_error_code_instance_init, NULL };
326 	GType vala_error_code_type_id;
327 	vala_error_code_type_id = g_type_register_static (VALA_TYPE_TYPESYMBOL, "ValaErrorCode", &g_define_type_info, 0);
328 	ValaErrorCode_private_offset = g_type_add_instance_private (vala_error_code_type_id, sizeof (ValaErrorCodePrivate));
329 	return vala_error_code_type_id;
330 }
331 
332 GType
vala_error_code_get_type(void)333 vala_error_code_get_type (void)
334 {
335 	static volatile gsize vala_error_code_type_id__volatile = 0;
336 	if (g_once_init_enter (&vala_error_code_type_id__volatile)) {
337 		GType vala_error_code_type_id;
338 		vala_error_code_type_id = vala_error_code_get_type_once ();
339 		g_once_init_leave (&vala_error_code_type_id__volatile, vala_error_code_type_id);
340 	}
341 	return vala_error_code_type_id__volatile;
342 }
343 
344