1 /* valaccodereturnstatement.c generated by valac, the Vala compiler
2  * generated from valaccodereturnstatement.vala, do not modify */
3 
4 /* valaccodereturnstatement.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 _ValaCCodeReturnStatementPrivate {
32 	ValaCCodeExpression* _return_expression;
33 };
34 
35 static gint ValaCCodeReturnStatement_private_offset;
36 static gpointer vala_ccode_return_statement_parent_class = NULL;
37 
38 static void vala_ccode_return_statement_real_write (ValaCCodeNode* base,
39                                              ValaCCodeWriter* writer);
40 static void vala_ccode_return_statement_finalize (ValaCCodeNode * obj);
41 static GType vala_ccode_return_statement_get_type_once (void);
42 
43 static inline gpointer
vala_ccode_return_statement_get_instance_private(ValaCCodeReturnStatement * self)44 vala_ccode_return_statement_get_instance_private (ValaCCodeReturnStatement* self)
45 {
46 	return G_STRUCT_MEMBER_P (self, ValaCCodeReturnStatement_private_offset);
47 }
48 
49 ValaCCodeExpression*
vala_ccode_return_statement_get_return_expression(ValaCCodeReturnStatement * self)50 vala_ccode_return_statement_get_return_expression (ValaCCodeReturnStatement* self)
51 {
52 	ValaCCodeExpression* result;
53 	ValaCCodeExpression* _tmp0_;
54 	g_return_val_if_fail (self != NULL, NULL);
55 	_tmp0_ = self->priv->_return_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_return_statement_set_return_expression(ValaCCodeReturnStatement * self,ValaCCodeExpression * value)67 vala_ccode_return_statement_set_return_expression (ValaCCodeReturnStatement* 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->_return_expression);
74 	self->priv->_return_expression = _tmp0_;
75 }
76 
77 ValaCCodeReturnStatement*
vala_ccode_return_statement_construct(GType object_type,ValaCCodeExpression * expr)78 vala_ccode_return_statement_construct (GType object_type,
79                                        ValaCCodeExpression* expr)
80 {
81 	ValaCCodeReturnStatement* self = NULL;
82 	self = (ValaCCodeReturnStatement*) vala_ccode_statement_construct (object_type);
83 	vala_ccode_return_statement_set_return_expression (self, expr);
84 	return self;
85 }
86 
87 ValaCCodeReturnStatement*
vala_ccode_return_statement_new(ValaCCodeExpression * expr)88 vala_ccode_return_statement_new (ValaCCodeExpression* expr)
89 {
90 	return vala_ccode_return_statement_construct (VALA_TYPE_CCODE_RETURN_STATEMENT, expr);
91 }
92 
93 static void
vala_ccode_return_statement_real_write(ValaCCodeNode * base,ValaCCodeWriter * writer)94 vala_ccode_return_statement_real_write (ValaCCodeNode* base,
95                                         ValaCCodeWriter* writer)
96 {
97 	ValaCCodeReturnStatement * self;
98 	ValaCCodeLineDirective* _tmp0_;
99 	ValaCCodeLineDirective* _tmp1_;
100 	ValaCCodeExpression* _tmp2_;
101 	self = (ValaCCodeReturnStatement*) base;
102 	g_return_if_fail (writer != NULL);
103 	_tmp0_ = vala_ccode_node_get_line ((ValaCCodeNode*) self);
104 	_tmp1_ = _tmp0_;
105 	vala_ccode_writer_write_indent (writer, _tmp1_);
106 	vala_ccode_writer_write_string (writer, "return");
107 	_tmp2_ = self->priv->_return_expression;
108 	if (_tmp2_ != NULL) {
109 		ValaCCodeExpression* _tmp3_;
110 		vala_ccode_writer_write_string (writer, " ");
111 		_tmp3_ = self->priv->_return_expression;
112 		vala_ccode_node_write ((ValaCCodeNode*) _tmp3_, writer);
113 	}
114 	vala_ccode_writer_write_string (writer, ";");
115 	vala_ccode_writer_write_newline (writer);
116 }
117 
118 static void
vala_ccode_return_statement_class_init(ValaCCodeReturnStatementClass * klass,gpointer klass_data)119 vala_ccode_return_statement_class_init (ValaCCodeReturnStatementClass * klass,
120                                         gpointer klass_data)
121 {
122 	vala_ccode_return_statement_parent_class = g_type_class_peek_parent (klass);
123 	((ValaCCodeNodeClass *) klass)->finalize = vala_ccode_return_statement_finalize;
124 	g_type_class_adjust_private_offset (klass, &ValaCCodeReturnStatement_private_offset);
125 	((ValaCCodeNodeClass *) klass)->write = (void (*) (ValaCCodeNode*, ValaCCodeWriter*)) vala_ccode_return_statement_real_write;
126 }
127 
128 static void
vala_ccode_return_statement_instance_init(ValaCCodeReturnStatement * self,gpointer klass)129 vala_ccode_return_statement_instance_init (ValaCCodeReturnStatement * self,
130                                            gpointer klass)
131 {
132 	self->priv = vala_ccode_return_statement_get_instance_private (self);
133 }
134 
135 static void
vala_ccode_return_statement_finalize(ValaCCodeNode * obj)136 vala_ccode_return_statement_finalize (ValaCCodeNode * obj)
137 {
138 	ValaCCodeReturnStatement * self;
139 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_CCODE_RETURN_STATEMENT, ValaCCodeReturnStatement);
140 	_vala_ccode_node_unref0 (self->priv->_return_expression);
141 	VALA_CCODE_NODE_CLASS (vala_ccode_return_statement_parent_class)->finalize (obj);
142 }
143 
144 /**
145  * Represents a return statement in the C code.
146  */
147 static GType
vala_ccode_return_statement_get_type_once(void)148 vala_ccode_return_statement_get_type_once (void)
149 {
150 	static const GTypeInfo g_define_type_info = { sizeof (ValaCCodeReturnStatementClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_ccode_return_statement_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaCCodeReturnStatement), 0, (GInstanceInitFunc) vala_ccode_return_statement_instance_init, NULL };
151 	GType vala_ccode_return_statement_type_id;
152 	vala_ccode_return_statement_type_id = g_type_register_static (VALA_TYPE_CCODE_STATEMENT, "ValaCCodeReturnStatement", &g_define_type_info, 0);
153 	ValaCCodeReturnStatement_private_offset = g_type_add_instance_private (vala_ccode_return_statement_type_id, sizeof (ValaCCodeReturnStatementPrivate));
154 	return vala_ccode_return_statement_type_id;
155 }
156 
157 GType
vala_ccode_return_statement_get_type(void)158 vala_ccode_return_statement_get_type (void)
159 {
160 	static volatile gsize vala_ccode_return_statement_type_id__volatile = 0;
161 	if (g_once_init_enter (&vala_ccode_return_statement_type_id__volatile)) {
162 		GType vala_ccode_return_statement_type_id;
163 		vala_ccode_return_statement_type_id = vala_ccode_return_statement_get_type_once ();
164 		g_once_init_leave (&vala_ccode_return_statement_type_id__volatile, vala_ccode_return_statement_type_id);
165 	}
166 	return vala_ccode_return_statement_type_id__volatile;
167 }
168 
169