1 /* valaccodeparameter.c generated by valac, the Vala compiler
2  * generated from valaccodeparameter.vala, do not modify */
3 
4 /* valaccodeparameter.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 <stdlib.h>
28 #include <string.h>
29 #include <glib.h>
30 
31 #define _g_free0(var) (var = (g_free (var), NULL))
32 
33 struct _ValaCCodeParameterPrivate {
34 	gchar* _name;
35 	gchar* _type_name;
36 	gboolean _ellipsis;
37 };
38 
39 static gint ValaCCodeParameter_private_offset;
40 static gpointer vala_ccode_parameter_parent_class = NULL;
41 
42 static void vala_ccode_parameter_real_write (ValaCCodeNode* base,
43                                       ValaCCodeWriter* writer);
44 static void vala_ccode_parameter_finalize (ValaCCodeNode * obj);
45 static GType vala_ccode_parameter_get_type_once (void);
46 
47 static inline gpointer
vala_ccode_parameter_get_instance_private(ValaCCodeParameter * self)48 vala_ccode_parameter_get_instance_private (ValaCCodeParameter* self)
49 {
50 	return G_STRUCT_MEMBER_P (self, ValaCCodeParameter_private_offset);
51 }
52 
53 const gchar*
vala_ccode_parameter_get_name(ValaCCodeParameter * self)54 vala_ccode_parameter_get_name (ValaCCodeParameter* self)
55 {
56 	const gchar* result;
57 	const gchar* _tmp0_;
58 	g_return_val_if_fail (self != NULL, NULL);
59 	_tmp0_ = self->priv->_name;
60 	result = _tmp0_;
61 	return result;
62 }
63 
64 void
vala_ccode_parameter_set_name(ValaCCodeParameter * self,const gchar * value)65 vala_ccode_parameter_set_name (ValaCCodeParameter* self,
66                                const gchar* value)
67 {
68 	gchar* _tmp0_;
69 	g_return_if_fail (self != NULL);
70 	_tmp0_ = g_strdup (value);
71 	_g_free0 (self->priv->_name);
72 	self->priv->_name = _tmp0_;
73 }
74 
75 const gchar*
vala_ccode_parameter_get_type_name(ValaCCodeParameter * self)76 vala_ccode_parameter_get_type_name (ValaCCodeParameter* self)
77 {
78 	const gchar* result;
79 	const gchar* _tmp0_;
80 	g_return_val_if_fail (self != NULL, NULL);
81 	_tmp0_ = self->priv->_type_name;
82 	result = _tmp0_;
83 	return result;
84 }
85 
86 void
vala_ccode_parameter_set_type_name(ValaCCodeParameter * self,const gchar * value)87 vala_ccode_parameter_set_type_name (ValaCCodeParameter* self,
88                                     const gchar* value)
89 {
90 	gchar* _tmp0_;
91 	g_return_if_fail (self != NULL);
92 	_tmp0_ = g_strdup (value);
93 	_g_free0 (self->priv->_type_name);
94 	self->priv->_type_name = _tmp0_;
95 }
96 
97 gboolean
vala_ccode_parameter_get_ellipsis(ValaCCodeParameter * self)98 vala_ccode_parameter_get_ellipsis (ValaCCodeParameter* self)
99 {
100 	gboolean result;
101 	g_return_val_if_fail (self != NULL, FALSE);
102 	result = self->priv->_ellipsis;
103 	return result;
104 }
105 
106 void
vala_ccode_parameter_set_ellipsis(ValaCCodeParameter * self,gboolean value)107 vala_ccode_parameter_set_ellipsis (ValaCCodeParameter* self,
108                                    gboolean value)
109 {
110 	g_return_if_fail (self != NULL);
111 	self->priv->_ellipsis = value;
112 }
113 
114 ValaCCodeParameter*
vala_ccode_parameter_construct(GType object_type,const gchar * n,const gchar * type)115 vala_ccode_parameter_construct (GType object_type,
116                                 const gchar* n,
117                                 const gchar* type)
118 {
119 	ValaCCodeParameter* self = NULL;
120 	g_return_val_if_fail (n != NULL, NULL);
121 	g_return_val_if_fail (type != NULL, NULL);
122 	self = (ValaCCodeParameter*) vala_ccode_node_construct (object_type);
123 	vala_ccode_parameter_set_name (self, n);
124 	vala_ccode_parameter_set_type_name (self, type);
125 	return self;
126 }
127 
128 ValaCCodeParameter*
vala_ccode_parameter_new(const gchar * n,const gchar * type)129 vala_ccode_parameter_new (const gchar* n,
130                           const gchar* type)
131 {
132 	return vala_ccode_parameter_construct (VALA_TYPE_CCODE_PARAMETER, n, type);
133 }
134 
135 ValaCCodeParameter*
vala_ccode_parameter_construct_with_ellipsis(GType object_type)136 vala_ccode_parameter_construct_with_ellipsis (GType object_type)
137 {
138 	ValaCCodeParameter* self = NULL;
139 	self = (ValaCCodeParameter*) vala_ccode_node_construct (object_type);
140 	vala_ccode_parameter_set_ellipsis (self, TRUE);
141 	return self;
142 }
143 
144 ValaCCodeParameter*
vala_ccode_parameter_new_with_ellipsis(void)145 vala_ccode_parameter_new_with_ellipsis (void)
146 {
147 	return vala_ccode_parameter_construct_with_ellipsis (VALA_TYPE_CCODE_PARAMETER);
148 }
149 
150 static void
vala_ccode_parameter_real_write(ValaCCodeNode * base,ValaCCodeWriter * writer)151 vala_ccode_parameter_real_write (ValaCCodeNode* base,
152                                  ValaCCodeWriter* writer)
153 {
154 	ValaCCodeParameter * self;
155 	gboolean _tmp0_;
156 	self = (ValaCCodeParameter*) base;
157 	g_return_if_fail (writer != NULL);
158 	_tmp0_ = self->priv->_ellipsis;
159 	if (!_tmp0_) {
160 		const gchar* _tmp1_;
161 		const gchar* _tmp2_;
162 		_tmp1_ = self->priv->_type_name;
163 		vala_ccode_writer_write_string (writer, _tmp1_);
164 		vala_ccode_writer_write_string (writer, " ");
165 		_tmp2_ = self->priv->_name;
166 		vala_ccode_writer_write_string (writer, _tmp2_);
167 	} else {
168 		vala_ccode_writer_write_string (writer, "...");
169 	}
170 }
171 
172 static void
vala_ccode_parameter_class_init(ValaCCodeParameterClass * klass,gpointer klass_data)173 vala_ccode_parameter_class_init (ValaCCodeParameterClass * klass,
174                                  gpointer klass_data)
175 {
176 	vala_ccode_parameter_parent_class = g_type_class_peek_parent (klass);
177 	((ValaCCodeNodeClass *) klass)->finalize = vala_ccode_parameter_finalize;
178 	g_type_class_adjust_private_offset (klass, &ValaCCodeParameter_private_offset);
179 	((ValaCCodeNodeClass *) klass)->write = (void (*) (ValaCCodeNode*, ValaCCodeWriter*)) vala_ccode_parameter_real_write;
180 }
181 
182 static void
vala_ccode_parameter_instance_init(ValaCCodeParameter * self,gpointer klass)183 vala_ccode_parameter_instance_init (ValaCCodeParameter * self,
184                                     gpointer klass)
185 {
186 	self->priv = vala_ccode_parameter_get_instance_private (self);
187 }
188 
189 static void
vala_ccode_parameter_finalize(ValaCCodeNode * obj)190 vala_ccode_parameter_finalize (ValaCCodeNode * obj)
191 {
192 	ValaCCodeParameter * self;
193 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_CCODE_PARAMETER, ValaCCodeParameter);
194 	_g_free0 (self->priv->_name);
195 	_g_free0 (self->priv->_type_name);
196 	VALA_CCODE_NODE_CLASS (vala_ccode_parameter_parent_class)->finalize (obj);
197 }
198 
199 /**
200  * Represents a formal parameter in a C method signature.
201  */
202 static GType
vala_ccode_parameter_get_type_once(void)203 vala_ccode_parameter_get_type_once (void)
204 {
205 	static const GTypeInfo g_define_type_info = { sizeof (ValaCCodeParameterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_ccode_parameter_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaCCodeParameter), 0, (GInstanceInitFunc) vala_ccode_parameter_instance_init, NULL };
206 	GType vala_ccode_parameter_type_id;
207 	vala_ccode_parameter_type_id = g_type_register_static (VALA_TYPE_CCODE_NODE, "ValaCCodeParameter", &g_define_type_info, 0);
208 	ValaCCodeParameter_private_offset = g_type_add_instance_private (vala_ccode_parameter_type_id, sizeof (ValaCCodeParameterPrivate));
209 	return vala_ccode_parameter_type_id;
210 }
211 
212 GType
vala_ccode_parameter_get_type(void)213 vala_ccode_parameter_get_type (void)
214 {
215 	static volatile gsize vala_ccode_parameter_type_id__volatile = 0;
216 	if (g_once_init_enter (&vala_ccode_parameter_type_id__volatile)) {
217 		GType vala_ccode_parameter_type_id;
218 		vala_ccode_parameter_type_id = vala_ccode_parameter_get_type_once ();
219 		g_once_init_leave (&vala_ccode_parameter_type_id__volatile, vala_ccode_parameter_type_id);
220 	}
221 	return vala_ccode_parameter_type_id__volatile;
222 }
223 
224