1 /* valaccodewhilestatement.c generated by valac, the Vala compiler
2  * generated from valaccodewhilestatement.vala, do not modify */
3 
4 /* valaccodewhilestatement.vala
5  *
6  * Copyright (C) 2006-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 "valaccode.h"
27 #include <glib.h>
28 
29 #define _vala_ccode_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_ccode_node_unref (var), NULL)))
30 
31 struct _ValaCCodeWhileStatementPrivate {
32 	ValaCCodeExpression* _condition;
33 	ValaCCodeStatement* _body;
34 };
35 
36 static gint ValaCCodeWhileStatement_private_offset;
37 static gpointer vala_ccode_while_statement_parent_class = NULL;
38 
39 static void vala_ccode_while_statement_real_write (ValaCCodeNode* base,
40                                             ValaCCodeWriter* writer);
41 static void vala_ccode_while_statement_finalize (ValaCCodeNode * obj);
42 static GType vala_ccode_while_statement_get_type_once (void);
43 
44 static inline gpointer
vala_ccode_while_statement_get_instance_private(ValaCCodeWhileStatement * self)45 vala_ccode_while_statement_get_instance_private (ValaCCodeWhileStatement* self)
46 {
47 	return G_STRUCT_MEMBER_P (self, ValaCCodeWhileStatement_private_offset);
48 }
49 
50 ValaCCodeExpression*
vala_ccode_while_statement_get_condition(ValaCCodeWhileStatement * self)51 vala_ccode_while_statement_get_condition (ValaCCodeWhileStatement* self)
52 {
53 	ValaCCodeExpression* result;
54 	ValaCCodeExpression* _tmp0_;
55 	g_return_val_if_fail (self != NULL, NULL);
56 	_tmp0_ = self->priv->_condition;
57 	result = _tmp0_;
58 	return result;
59 }
60 
61 static gpointer
_vala_ccode_node_ref0(gpointer self)62 _vala_ccode_node_ref0 (gpointer self)
63 {
64 	return self ? vala_ccode_node_ref (self) : NULL;
65 }
66 
67 void
vala_ccode_while_statement_set_condition(ValaCCodeWhileStatement * self,ValaCCodeExpression * value)68 vala_ccode_while_statement_set_condition (ValaCCodeWhileStatement* self,
69                                           ValaCCodeExpression* value)
70 {
71 	ValaCCodeExpression* _tmp0_;
72 	g_return_if_fail (self != NULL);
73 	_tmp0_ = _vala_ccode_node_ref0 (value);
74 	_vala_ccode_node_unref0 (self->priv->_condition);
75 	self->priv->_condition = _tmp0_;
76 }
77 
78 ValaCCodeStatement*
vala_ccode_while_statement_get_body(ValaCCodeWhileStatement * self)79 vala_ccode_while_statement_get_body (ValaCCodeWhileStatement* self)
80 {
81 	ValaCCodeStatement* result;
82 	ValaCCodeStatement* _tmp0_;
83 	g_return_val_if_fail (self != NULL, NULL);
84 	_tmp0_ = self->priv->_body;
85 	result = _tmp0_;
86 	return result;
87 }
88 
89 void
vala_ccode_while_statement_set_body(ValaCCodeWhileStatement * self,ValaCCodeStatement * value)90 vala_ccode_while_statement_set_body (ValaCCodeWhileStatement* self,
91                                      ValaCCodeStatement* value)
92 {
93 	ValaCCodeStatement* _tmp0_;
94 	g_return_if_fail (self != NULL);
95 	_tmp0_ = _vala_ccode_node_ref0 (value);
96 	_vala_ccode_node_unref0 (self->priv->_body);
97 	self->priv->_body = _tmp0_;
98 }
99 
100 ValaCCodeWhileStatement*
vala_ccode_while_statement_construct(GType object_type,ValaCCodeExpression * cond,ValaCCodeStatement * stmt)101 vala_ccode_while_statement_construct (GType object_type,
102                                       ValaCCodeExpression* cond,
103                                       ValaCCodeStatement* stmt)
104 {
105 	ValaCCodeWhileStatement* self = NULL;
106 	g_return_val_if_fail (cond != NULL, NULL);
107 	self = (ValaCCodeWhileStatement*) vala_ccode_statement_construct (object_type);
108 	vala_ccode_while_statement_set_condition (self, cond);
109 	vala_ccode_while_statement_set_body (self, stmt);
110 	return self;
111 }
112 
113 ValaCCodeWhileStatement*
vala_ccode_while_statement_new(ValaCCodeExpression * cond,ValaCCodeStatement * stmt)114 vala_ccode_while_statement_new (ValaCCodeExpression* cond,
115                                 ValaCCodeStatement* stmt)
116 {
117 	return vala_ccode_while_statement_construct (VALA_TYPE_CCODE_WHILE_STATEMENT, cond, stmt);
118 }
119 
120 static void
vala_ccode_while_statement_real_write(ValaCCodeNode * base,ValaCCodeWriter * writer)121 vala_ccode_while_statement_real_write (ValaCCodeNode* base,
122                                        ValaCCodeWriter* writer)
123 {
124 	ValaCCodeWhileStatement * self;
125 	ValaCCodeLineDirective* _tmp0_;
126 	ValaCCodeLineDirective* _tmp1_;
127 	ValaCCodeExpression* _tmp2_;
128 	ValaCCodeStatement* _tmp3_;
129 	self = (ValaCCodeWhileStatement*) base;
130 	g_return_if_fail (writer != NULL);
131 	_tmp0_ = vala_ccode_node_get_line ((ValaCCodeNode*) self);
132 	_tmp1_ = _tmp0_;
133 	vala_ccode_writer_write_indent (writer, _tmp1_);
134 	vala_ccode_writer_write_string (writer, "while (");
135 	_tmp2_ = self->priv->_condition;
136 	vala_ccode_node_write ((ValaCCodeNode*) _tmp2_, writer);
137 	vala_ccode_writer_write_string (writer, ")");
138 	_tmp3_ = self->priv->_body;
139 	vala_ccode_node_write ((ValaCCodeNode*) _tmp3_, writer);
140 }
141 
142 static void
vala_ccode_while_statement_class_init(ValaCCodeWhileStatementClass * klass,gpointer klass_data)143 vala_ccode_while_statement_class_init (ValaCCodeWhileStatementClass * klass,
144                                        gpointer klass_data)
145 {
146 	vala_ccode_while_statement_parent_class = g_type_class_peek_parent (klass);
147 	((ValaCCodeNodeClass *) klass)->finalize = vala_ccode_while_statement_finalize;
148 	g_type_class_adjust_private_offset (klass, &ValaCCodeWhileStatement_private_offset);
149 	((ValaCCodeNodeClass *) klass)->write = (void (*) (ValaCCodeNode*, ValaCCodeWriter*)) vala_ccode_while_statement_real_write;
150 }
151 
152 static void
vala_ccode_while_statement_instance_init(ValaCCodeWhileStatement * self,gpointer klass)153 vala_ccode_while_statement_instance_init (ValaCCodeWhileStatement * self,
154                                           gpointer klass)
155 {
156 	self->priv = vala_ccode_while_statement_get_instance_private (self);
157 }
158 
159 static void
vala_ccode_while_statement_finalize(ValaCCodeNode * obj)160 vala_ccode_while_statement_finalize (ValaCCodeNode * obj)
161 {
162 	ValaCCodeWhileStatement * self;
163 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_CCODE_WHILE_STATEMENT, ValaCCodeWhileStatement);
164 	_vala_ccode_node_unref0 (self->priv->_condition);
165 	_vala_ccode_node_unref0 (self->priv->_body);
166 	VALA_CCODE_NODE_CLASS (vala_ccode_while_statement_parent_class)->finalize (obj);
167 }
168 
169 /**
170  * Represents a while iteration statement in the C code.
171  */
172 static GType
vala_ccode_while_statement_get_type_once(void)173 vala_ccode_while_statement_get_type_once (void)
174 {
175 	static const GTypeInfo g_define_type_info = { sizeof (ValaCCodeWhileStatementClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_ccode_while_statement_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaCCodeWhileStatement), 0, (GInstanceInitFunc) vala_ccode_while_statement_instance_init, NULL };
176 	GType vala_ccode_while_statement_type_id;
177 	vala_ccode_while_statement_type_id = g_type_register_static (VALA_TYPE_CCODE_STATEMENT, "ValaCCodeWhileStatement", &g_define_type_info, 0);
178 	ValaCCodeWhileStatement_private_offset = g_type_add_instance_private (vala_ccode_while_statement_type_id, sizeof (ValaCCodeWhileStatementPrivate));
179 	return vala_ccode_while_statement_type_id;
180 }
181 
182 GType
vala_ccode_while_statement_get_type(void)183 vala_ccode_while_statement_get_type (void)
184 {
185 	static volatile gsize vala_ccode_while_statement_type_id__volatile = 0;
186 	if (g_once_init_enter (&vala_ccode_while_statement_type_id__volatile)) {
187 		GType vala_ccode_while_statement_type_id;
188 		vala_ccode_while_statement_type_id = vala_ccode_while_statement_get_type_once ();
189 		g_once_init_leave (&vala_ccode_while_statement_type_id__volatile, vala_ccode_while_statement_type_id);
190 	}
191 	return vala_ccode_while_statement_type_id__volatile;
192 }
193 
194