1 /* valaccodeswitchstatement.c generated by valac, the Vala compiler
2  * generated from valaccodeswitchstatement.vala, do not modify */
3 
4 /* valaccodeswitchstatement.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 <glib.h>
28 
29 #define _vala_ccode_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_ccode_node_unref (var), NULL)))
30 
31 struct _ValaCCodeSwitchStatementPrivate {
32 	ValaCCodeExpression* _expression;
33 };
34 
35 static gint ValaCCodeSwitchStatement_private_offset;
36 static gpointer vala_ccode_switch_statement_parent_class = NULL;
37 
38 static void vala_ccode_switch_statement_real_write (ValaCCodeNode* base,
39                                              ValaCCodeWriter* writer);
40 static void vala_ccode_switch_statement_finalize (ValaCCodeNode * obj);
41 static GType vala_ccode_switch_statement_get_type_once (void);
42 
43 static inline gpointer
vala_ccode_switch_statement_get_instance_private(ValaCCodeSwitchStatement * self)44 vala_ccode_switch_statement_get_instance_private (ValaCCodeSwitchStatement* self)
45 {
46 	return G_STRUCT_MEMBER_P (self, ValaCCodeSwitchStatement_private_offset);
47 }
48 
49 ValaCCodeExpression*
vala_ccode_switch_statement_get_expression(ValaCCodeSwitchStatement * self)50 vala_ccode_switch_statement_get_expression (ValaCCodeSwitchStatement* self)
51 {
52 	ValaCCodeExpression* result;
53 	ValaCCodeExpression* _tmp0_;
54 	g_return_val_if_fail (self != NULL, NULL);
55 	_tmp0_ = self->priv->_expression;
56 	result = _tmp0_;
57 	return result;
58 }
59 
60 static gpointer
_vala_ccode_node_ref0(gpointer self)61 _vala_ccode_node_ref0 (gpointer self)
62 {
63 	return self ? vala_ccode_node_ref (self) : NULL;
64 }
65 
66 void
vala_ccode_switch_statement_set_expression(ValaCCodeSwitchStatement * self,ValaCCodeExpression * value)67 vala_ccode_switch_statement_set_expression (ValaCCodeSwitchStatement* self,
68                                             ValaCCodeExpression* value)
69 {
70 	ValaCCodeExpression* _tmp0_;
71 	g_return_if_fail (self != NULL);
72 	_tmp0_ = _vala_ccode_node_ref0 (value);
73 	_vala_ccode_node_unref0 (self->priv->_expression);
74 	self->priv->_expression = _tmp0_;
75 }
76 
77 ValaCCodeSwitchStatement*
vala_ccode_switch_statement_construct(GType object_type,ValaCCodeExpression * expression)78 vala_ccode_switch_statement_construct (GType object_type,
79                                        ValaCCodeExpression* expression)
80 {
81 	ValaCCodeSwitchStatement* self = NULL;
82 	g_return_val_if_fail (expression != NULL, NULL);
83 	self = (ValaCCodeSwitchStatement*) vala_ccode_block_construct (object_type);
84 	vala_ccode_switch_statement_set_expression (self, expression);
85 	return self;
86 }
87 
88 ValaCCodeSwitchStatement*
vala_ccode_switch_statement_new(ValaCCodeExpression * expression)89 vala_ccode_switch_statement_new (ValaCCodeExpression* expression)
90 {
91 	return vala_ccode_switch_statement_construct (VALA_TYPE_CCODE_SWITCH_STATEMENT, expression);
92 }
93 
94 static void
vala_ccode_switch_statement_real_write(ValaCCodeNode * base,ValaCCodeWriter * writer)95 vala_ccode_switch_statement_real_write (ValaCCodeNode* base,
96                                         ValaCCodeWriter* writer)
97 {
98 	ValaCCodeSwitchStatement * self;
99 	ValaCCodeLineDirective* _tmp0_;
100 	ValaCCodeLineDirective* _tmp1_;
101 	ValaCCodeExpression* _tmp2_;
102 	self = (ValaCCodeSwitchStatement*) base;
103 	g_return_if_fail (writer != NULL);
104 	_tmp0_ = vala_ccode_node_get_line ((ValaCCodeNode*) self);
105 	_tmp1_ = _tmp0_;
106 	vala_ccode_writer_write_indent (writer, _tmp1_);
107 	vala_ccode_writer_write_string (writer, "switch (");
108 	_tmp2_ = self->priv->_expression;
109 	vala_ccode_node_write ((ValaCCodeNode*) _tmp2_, writer);
110 	vala_ccode_writer_write_string (writer, ")");
111 	VALA_CCODE_NODE_CLASS (vala_ccode_switch_statement_parent_class)->write ((ValaCCodeNode*) G_TYPE_CHECK_INSTANCE_CAST (self, VALA_TYPE_CCODE_BLOCK, ValaCCodeBlock), writer);
112 }
113 
114 static void
vala_ccode_switch_statement_class_init(ValaCCodeSwitchStatementClass * klass,gpointer klass_data)115 vala_ccode_switch_statement_class_init (ValaCCodeSwitchStatementClass * klass,
116                                         gpointer klass_data)
117 {
118 	vala_ccode_switch_statement_parent_class = g_type_class_peek_parent (klass);
119 	((ValaCCodeNodeClass *) klass)->finalize = vala_ccode_switch_statement_finalize;
120 	g_type_class_adjust_private_offset (klass, &ValaCCodeSwitchStatement_private_offset);
121 	((ValaCCodeNodeClass *) klass)->write = (void (*) (ValaCCodeNode*, ValaCCodeWriter*)) vala_ccode_switch_statement_real_write;
122 }
123 
124 static void
vala_ccode_switch_statement_instance_init(ValaCCodeSwitchStatement * self,gpointer klass)125 vala_ccode_switch_statement_instance_init (ValaCCodeSwitchStatement * self,
126                                            gpointer klass)
127 {
128 	self->priv = vala_ccode_switch_statement_get_instance_private (self);
129 }
130 
131 static void
vala_ccode_switch_statement_finalize(ValaCCodeNode * obj)132 vala_ccode_switch_statement_finalize (ValaCCodeNode * obj)
133 {
134 	ValaCCodeSwitchStatement * self;
135 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_CCODE_SWITCH_STATEMENT, ValaCCodeSwitchStatement);
136 	_vala_ccode_node_unref0 (self->priv->_expression);
137 	VALA_CCODE_NODE_CLASS (vala_ccode_switch_statement_parent_class)->finalize (obj);
138 }
139 
140 /**
141  * Represents a switch selection statement in the C code.
142  */
143 static GType
vala_ccode_switch_statement_get_type_once(void)144 vala_ccode_switch_statement_get_type_once (void)
145 {
146 	static const GTypeInfo g_define_type_info = { sizeof (ValaCCodeSwitchStatementClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_ccode_switch_statement_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaCCodeSwitchStatement), 0, (GInstanceInitFunc) vala_ccode_switch_statement_instance_init, NULL };
147 	GType vala_ccode_switch_statement_type_id;
148 	vala_ccode_switch_statement_type_id = g_type_register_static (VALA_TYPE_CCODE_BLOCK, "ValaCCodeSwitchStatement", &g_define_type_info, 0);
149 	ValaCCodeSwitchStatement_private_offset = g_type_add_instance_private (vala_ccode_switch_statement_type_id, sizeof (ValaCCodeSwitchStatementPrivate));
150 	return vala_ccode_switch_statement_type_id;
151 }
152 
153 GType
vala_ccode_switch_statement_get_type(void)154 vala_ccode_switch_statement_get_type (void)
155 {
156 	static volatile gsize vala_ccode_switch_statement_type_id__volatile = 0;
157 	if (g_once_init_enter (&vala_ccode_switch_statement_type_id__volatile)) {
158 		GType vala_ccode_switch_statement_type_id;
159 		vala_ccode_switch_statement_type_id = vala_ccode_switch_statement_get_type_once ();
160 		g_once_init_leave (&vala_ccode_switch_statement_type_id__volatile, vala_ccode_switch_statement_type_id);
161 	}
162 	return vala_ccode_switch_statement_type_id__volatile;
163 }
164 
165