1 /* attribute.c generated by valac, the Vala compiler
2  * generated from attribute.vala, do not modify */
3 
4 /* attribute.vala
5  *
6  * Copyright (C) 2011 Florian Brosch
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  * 	Florian Brosch <flo.brosch@gmail.com>
24  */
25 
26 #include "valadoc.h"
27 #include <stdlib.h>
28 #include <string.h>
29 #include <glib.h>
30 #include <vala.h>
31 #include <valagee.h>
32 #include <glib-object.h>
33 
34 enum  {
35 	VALADOC_API_ATTRIBUTE_0_PROPERTY,
36 	VALADOC_API_ATTRIBUTE_NAME_PROPERTY,
37 	VALADOC_API_ATTRIBUTE_NUM_PROPERTIES
38 };
39 static GParamSpec* valadoc_api_attribute_properties[VALADOC_API_ATTRIBUTE_NUM_PROPERTIES];
40 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
41 #define _g_free0(var) (var = (g_free (var), NULL))
42 #define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
43 #define _vala_iterator_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterator_unref (var), NULL)))
44 #define _g_sequence_free0(var) ((var == NULL) ? NULL : (var = (g_sequence_free (var), NULL)))
45 #define _valadoc_api_signature_builder_unref0(var) ((var == NULL) ? NULL : (var = (valadoc_api_signature_builder_unref (var), NULL)))
46 
47 struct _ValadocApiAttributePrivate {
48 	ValadocApiSourceFile* file;
49 	gchar* _name;
50 };
51 
52 static gint ValadocApiAttribute_private_offset;
53 static gpointer valadoc_api_attribute_parent_class = NULL;
54 
55 static void valadoc_api_attribute_set_name (ValadocApiAttribute* self,
56                                      const gchar* value);
57 static ValadocContentInline* valadoc_api_attribute_real_build_signature (ValadocApiItem* base);
58 static void _g_free0_ (gpointer var);
59 static void valadoc_api_attribute_finalize (GObject * obj);
60 static GType valadoc_api_attribute_get_type_once (void);
61 static void _vala_valadoc_api_attribute_get_property (GObject * object,
62                                                guint property_id,
63                                                GValue * value,
64                                                GParamSpec * pspec);
65 static void _vala_valadoc_api_attribute_set_property (GObject * object,
66                                                guint property_id,
67                                                const GValue * value,
68                                                GParamSpec * pspec);
69 
70 static inline gpointer
valadoc_api_attribute_get_instance_private(ValadocApiAttribute * self)71 valadoc_api_attribute_get_instance_private (ValadocApiAttribute* self)
72 {
73 	return G_STRUCT_MEMBER_P (self, ValadocApiAttribute_private_offset);
74 }
75 
76 const gchar*
valadoc_api_attribute_get_name(ValadocApiAttribute * self)77 valadoc_api_attribute_get_name (ValadocApiAttribute* self)
78 {
79 	const gchar* result;
80 	const gchar* _tmp0_;
81 	g_return_val_if_fail (self != NULL, NULL);
82 	_tmp0_ = self->priv->_name;
83 	result = _tmp0_;
84 	return result;
85 }
86 
87 static void
valadoc_api_attribute_set_name(ValadocApiAttribute * self,const gchar * value)88 valadoc_api_attribute_set_name (ValadocApiAttribute* self,
89                                 const gchar* value)
90 {
91 	gchar* old_value;
92 	g_return_if_fail (self != NULL);
93 	old_value = valadoc_api_attribute_get_name (self);
94 	if (g_strcmp0 (value, old_value) != 0) {
95 		gchar* _tmp0_;
96 		_tmp0_ = g_strdup (value);
97 		_g_free0 (self->priv->_name);
98 		self->priv->_name = _tmp0_;
99 		g_object_notify_by_pspec ((GObject *) self, valadoc_api_attribute_properties[VALADOC_API_ATTRIBUTE_NAME_PROPERTY]);
100 	}
101 }
102 
103 static gpointer
_g_object_ref0(gpointer self)104 _g_object_ref0 (gpointer self)
105 {
106 	return self ? g_object_ref (self) : NULL;
107 }
108 
109 ValadocApiAttribute*
valadoc_api_attribute_construct(GType object_type,ValadocApiNode * parent,ValadocApiSourceFile * file,const gchar * name,ValaAttribute * data)110 valadoc_api_attribute_construct (GType object_type,
111                                  ValadocApiNode* parent,
112                                  ValadocApiSourceFile* file,
113                                  const gchar* name,
114                                  ValaAttribute* data)
115 {
116 	ValadocApiAttribute * self = NULL;
117 	ValadocApiSourceFile* _tmp0_;
118 	g_return_val_if_fail (parent != NULL, NULL);
119 	g_return_val_if_fail (file != NULL, NULL);
120 	g_return_val_if_fail (name != NULL, NULL);
121 	g_return_val_if_fail (data != NULL, NULL);
122 	self = (ValadocApiAttribute*) valadoc_api_item_construct (object_type, (ValaCodeNode*) data);
123 	valadoc_api_item_set_parent ((ValadocApiItem*) self, (ValadocApiItem*) parent);
124 	valadoc_api_attribute_set_name (self, name);
125 	_tmp0_ = _g_object_ref0 (file);
126 	_g_object_unref0 (self->priv->file);
127 	self->priv->file = _tmp0_;
128 	return self;
129 }
130 
131 ValadocApiAttribute*
valadoc_api_attribute_new(ValadocApiNode * parent,ValadocApiSourceFile * file,const gchar * name,ValaAttribute * data)132 valadoc_api_attribute_new (ValadocApiNode* parent,
133                            ValadocApiSourceFile* file,
134                            const gchar* name,
135                            ValaAttribute* data)
136 {
137 	return valadoc_api_attribute_construct (VALADOC_API_TYPE_ATTRIBUTE, parent, file, name, data);
138 }
139 
140 ValadocApiSourceFile*
valadoc_api_attribute_get_source_file(ValadocApiAttribute * self)141 valadoc_api_attribute_get_source_file (ValadocApiAttribute* self)
142 {
143 	ValadocApiSourceFile* _tmp0_;
144 	ValadocApiSourceFile* _tmp1_;
145 	ValadocApiSourceFile* result = NULL;
146 	g_return_val_if_fail (self != NULL, NULL);
147 	_tmp0_ = self->priv->file;
148 	_tmp1_ = _g_object_ref0 (_tmp0_);
149 	result = _tmp1_;
150 	return result;
151 }
152 
153 static void
_g_free0_(gpointer var)154 _g_free0_ (gpointer var)
155 {
156 	var = (g_free (var), NULL);
157 }
158 
159 static ValadocContentInline*
valadoc_api_attribute_real_build_signature(ValadocApiItem * base)160 valadoc_api_attribute_real_build_signature (ValadocApiItem* base)
161 {
162 	ValadocApiAttribute * self;
163 	ValadocApiSignatureBuilder* builder = NULL;
164 	ValadocApiSignatureBuilder* _tmp0_;
165 	ValaAttribute* attr = NULL;
166 	ValaCodeNode* _tmp1_;
167 	ValaCodeNode* _tmp2_;
168 	GSequence* keys = NULL;
169 	GSequence* _tmp3_;
170 	gboolean _tmp20_ = FALSE;
171 	ValaAttribute* _tmp21_;
172 	const gchar* _tmp22_;
173 	const gchar* _tmp23_;
174 	ValadocApiSignatureBuilder* _tmp27_;
175 	ValadocApiSignatureBuilder* _tmp28_;
176 	ValaAttribute* _tmp29_;
177 	const gchar* _tmp30_;
178 	const gchar* _tmp31_;
179 	GSequence* _tmp32_;
180 	ValadocApiSignatureBuilder* _tmp55_;
181 	ValadocApiSignatureBuilder* _tmp56_;
182 	ValadocContentRun* _tmp57_;
183 	ValadocContentInline* result = NULL;
184 	self = (ValadocApiAttribute*) base;
185 	_tmp0_ = valadoc_api_signature_builder_new ();
186 	builder = _tmp0_;
187 	_tmp1_ = valadoc_api_item_get_data ((ValadocApiItem*) self);
188 	_tmp2_ = _tmp1_;
189 	attr = G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, VALA_TYPE_ATTRIBUTE, ValaAttribute);
190 	_tmp3_ = g_sequence_new (_g_free0_);
191 	keys = _tmp3_;
192 	{
193 		ValaIterator* _key_it = NULL;
194 		ValaAttribute* _tmp4_;
195 		ValaMap* _tmp5_;
196 		ValaMap* _tmp6_;
197 		ValaSet* _tmp7_;
198 		ValaSet* _tmp8_;
199 		ValaIterator* _tmp9_;
200 		ValaIterator* _tmp10_;
201 		_tmp4_ = attr;
202 		_tmp5_ = vala_attribute_get_args (_tmp4_);
203 		_tmp6_ = _tmp5_;
204 		_tmp7_ = vala_map_get_keys (_tmp6_);
205 		_tmp8_ = _tmp7_;
206 		_tmp9_ = vala_iterable_iterator ((ValaIterable*) _tmp8_);
207 		_tmp10_ = _tmp9_;
208 		_vala_iterable_unref0 (_tmp8_);
209 		_key_it = _tmp10_;
210 		while (TRUE) {
211 			ValaIterator* _tmp11_;
212 			gchar* key = NULL;
213 			ValaIterator* _tmp12_;
214 			gpointer _tmp13_;
215 			const gchar* _tmp14_;
216 			GSequence* _tmp15_;
217 			const gchar* _tmp16_;
218 			gchar* _tmp17_;
219 			GCompareFunc _tmp18_;
220 			GSequenceIter* _tmp19_;
221 			_tmp11_ = _key_it;
222 			if (!vala_iterator_next (_tmp11_)) {
223 				break;
224 			}
225 			_tmp12_ = _key_it;
226 			_tmp13_ = vala_iterator_get (_tmp12_);
227 			key = (gchar*) _tmp13_;
228 			_tmp14_ = key;
229 			if (g_strcmp0 (_tmp14_, "cheader_filename") == 0) {
230 				_g_free0 (key);
231 				continue;
232 			}
233 			_tmp15_ = keys;
234 			_tmp16_ = key;
235 			_tmp17_ = g_strdup (_tmp16_);
236 			_tmp18_ = ((GCompareFunc) g_strcmp0);
237 			_tmp19_ = g_sequence_insert_sorted (_tmp15_, _tmp17_, (GCompareDataFunc) _tmp18_, NULL);
238 			_g_free0 (key);
239 		}
240 		_vala_iterator_unref0 (_key_it);
241 	}
242 	_tmp21_ = attr;
243 	_tmp22_ = vala_attribute_get_name (_tmp21_);
244 	_tmp23_ = _tmp22_;
245 	if (g_strcmp0 (_tmp23_, "CCode") == 0) {
246 		GSequence* _tmp24_;
247 		_tmp24_ = keys;
248 		_tmp20_ = g_sequence_get_length (_tmp24_) == 0;
249 	} else {
250 		_tmp20_ = FALSE;
251 	}
252 	if (_tmp20_) {
253 		ValadocApiSignatureBuilder* _tmp25_;
254 		ValadocContentRun* _tmp26_;
255 		_tmp25_ = builder;
256 		_tmp26_ = valadoc_api_signature_builder_get (_tmp25_);
257 		result = (ValadocContentInline*) _tmp26_;
258 		_g_sequence_free0 (keys);
259 		_valadoc_api_signature_builder_unref0 (builder);
260 		return result;
261 	}
262 	_tmp27_ = builder;
263 	valadoc_api_signature_builder_append_attribute (_tmp27_, "[", TRUE);
264 	_tmp28_ = builder;
265 	_tmp29_ = attr;
266 	_tmp30_ = vala_attribute_get_name (_tmp29_);
267 	_tmp31_ = _tmp30_;
268 	valadoc_api_signature_builder_append_type_name (_tmp28_, _tmp31_, TRUE);
269 	_tmp32_ = keys;
270 	if (g_sequence_get_length (_tmp32_) > 0) {
271 		ValadocApiSignatureBuilder* _tmp33_;
272 		const gchar* separator = NULL;
273 		GSequenceIter* arg_iter = NULL;
274 		GSequence* _tmp34_;
275 		GSequenceIter* _tmp35_;
276 		ValadocApiSignatureBuilder* _tmp54_;
277 		_tmp33_ = builder;
278 		valadoc_api_signature_builder_append_attribute (_tmp33_, "(", TRUE);
279 		separator = "";
280 		_tmp34_ = keys;
281 		_tmp35_ = g_sequence_get_begin_iter (_tmp34_);
282 		arg_iter = _tmp35_;
283 		while (TRUE) {
284 			GSequenceIter* _tmp36_;
285 			const gchar* arg_name = NULL;
286 			GSequenceIter* _tmp37_;
287 			gconstpointer _tmp38_;
288 			GSequenceIter* _tmp39_;
289 			GSequenceIter* _tmp40_;
290 			const gchar* _tmp41_;
291 			const gchar* _tmp43_;
292 			_tmp36_ = arg_iter;
293 			if (!(!g_sequence_iter_is_end (_tmp36_))) {
294 				break;
295 			}
296 			_tmp37_ = arg_iter;
297 			_tmp38_ = g_sequence_get (_tmp37_);
298 			arg_name = (const gchar*) _tmp38_;
299 			_tmp39_ = arg_iter;
300 			_tmp40_ = g_sequence_iter_next (_tmp39_);
301 			arg_iter = _tmp40_;
302 			_tmp41_ = separator;
303 			if (g_strcmp0 (_tmp41_, "") != 0) {
304 				ValadocApiSignatureBuilder* _tmp42_;
305 				_tmp42_ = builder;
306 				valadoc_api_signature_builder_append_attribute (_tmp42_, ", ", TRUE);
307 			}
308 			_tmp43_ = arg_name;
309 			if (g_strcmp0 (_tmp43_, "cheader_filename") != 0) {
310 				ValadocApiSignatureBuilder* _tmp44_;
311 				const gchar* _tmp45_;
312 				ValadocApiSignatureBuilder* _tmp46_;
313 				ValadocApiSignatureBuilder* _tmp47_;
314 				ValaAttribute* _tmp48_;
315 				ValaMap* _tmp49_;
316 				ValaMap* _tmp50_;
317 				const gchar* _tmp51_;
318 				gpointer _tmp52_;
319 				gchar* _tmp53_;
320 				_tmp44_ = builder;
321 				_tmp45_ = arg_name;
322 				valadoc_api_signature_builder_append_attribute (_tmp44_, _tmp45_, TRUE);
323 				_tmp46_ = builder;
324 				valadoc_api_signature_builder_append_attribute (_tmp46_, "=", TRUE);
325 				_tmp47_ = builder;
326 				_tmp48_ = attr;
327 				_tmp49_ = vala_attribute_get_args (_tmp48_);
328 				_tmp50_ = _tmp49_;
329 				_tmp51_ = arg_name;
330 				_tmp52_ = vala_map_get (_tmp50_, _tmp51_);
331 				_tmp53_ = (gchar*) _tmp52_;
332 				valadoc_api_signature_builder_append_literal (_tmp47_, _tmp53_, TRUE);
333 				_g_free0 (_tmp53_);
334 			}
335 			separator = ", ";
336 		}
337 		_tmp54_ = builder;
338 		valadoc_api_signature_builder_append_attribute (_tmp54_, ")", TRUE);
339 	}
340 	_tmp55_ = builder;
341 	valadoc_api_signature_builder_append_attribute (_tmp55_, "]", TRUE);
342 	_tmp56_ = builder;
343 	_tmp57_ = valadoc_api_signature_builder_get (_tmp56_);
344 	result = (ValadocContentInline*) _tmp57_;
345 	_g_sequence_free0 (keys);
346 	_valadoc_api_signature_builder_unref0 (builder);
347 	return result;
348 }
349 
350 static void
valadoc_api_attribute_class_init(ValadocApiAttributeClass * klass,gpointer klass_data)351 valadoc_api_attribute_class_init (ValadocApiAttributeClass * klass,
352                                   gpointer klass_data)
353 {
354 	valadoc_api_attribute_parent_class = g_type_class_peek_parent (klass);
355 	g_type_class_adjust_private_offset (klass, &ValadocApiAttribute_private_offset);
356 	((ValadocApiItemClass *) klass)->build_signature = (ValadocContentInline* (*) (ValadocApiItem*)) valadoc_api_attribute_real_build_signature;
357 	G_OBJECT_CLASS (klass)->get_property = _vala_valadoc_api_attribute_get_property;
358 	G_OBJECT_CLASS (klass)->set_property = _vala_valadoc_api_attribute_set_property;
359 	G_OBJECT_CLASS (klass)->finalize = valadoc_api_attribute_finalize;
360 	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_API_ATTRIBUTE_NAME_PROPERTY, valadoc_api_attribute_properties[VALADOC_API_ATTRIBUTE_NAME_PROPERTY] = g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
361 }
362 
363 static void
valadoc_api_attribute_instance_init(ValadocApiAttribute * self,gpointer klass)364 valadoc_api_attribute_instance_init (ValadocApiAttribute * self,
365                                      gpointer klass)
366 {
367 	self->priv = valadoc_api_attribute_get_instance_private (self);
368 }
369 
370 static void
valadoc_api_attribute_finalize(GObject * obj)371 valadoc_api_attribute_finalize (GObject * obj)
372 {
373 	ValadocApiAttribute * self;
374 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_API_TYPE_ATTRIBUTE, ValadocApiAttribute);
375 	_g_object_unref0 (self->priv->file);
376 	_g_free0 (self->priv->_name);
377 	G_OBJECT_CLASS (valadoc_api_attribute_parent_class)->finalize (obj);
378 }
379 
380 static GType
valadoc_api_attribute_get_type_once(void)381 valadoc_api_attribute_get_type_once (void)
382 {
383 	static const GTypeInfo g_define_type_info = { sizeof (ValadocApiAttributeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_api_attribute_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocApiAttribute), 0, (GInstanceInitFunc) valadoc_api_attribute_instance_init, NULL };
384 	GType valadoc_api_attribute_type_id;
385 	valadoc_api_attribute_type_id = g_type_register_static (VALADOC_API_TYPE_ITEM, "ValadocApiAttribute", &g_define_type_info, 0);
386 	ValadocApiAttribute_private_offset = g_type_add_instance_private (valadoc_api_attribute_type_id, sizeof (ValadocApiAttributePrivate));
387 	return valadoc_api_attribute_type_id;
388 }
389 
390 GType
valadoc_api_attribute_get_type(void)391 valadoc_api_attribute_get_type (void)
392 {
393 	static volatile gsize valadoc_api_attribute_type_id__volatile = 0;
394 	if (g_once_init_enter (&valadoc_api_attribute_type_id__volatile)) {
395 		GType valadoc_api_attribute_type_id;
396 		valadoc_api_attribute_type_id = valadoc_api_attribute_get_type_once ();
397 		g_once_init_leave (&valadoc_api_attribute_type_id__volatile, valadoc_api_attribute_type_id);
398 	}
399 	return valadoc_api_attribute_type_id__volatile;
400 }
401 
402 static void
_vala_valadoc_api_attribute_get_property(GObject * object,guint property_id,GValue * value,GParamSpec * pspec)403 _vala_valadoc_api_attribute_get_property (GObject * object,
404                                           guint property_id,
405                                           GValue * value,
406                                           GParamSpec * pspec)
407 {
408 	ValadocApiAttribute * self;
409 	self = G_TYPE_CHECK_INSTANCE_CAST (object, VALADOC_API_TYPE_ATTRIBUTE, ValadocApiAttribute);
410 	switch (property_id) {
411 		case VALADOC_API_ATTRIBUTE_NAME_PROPERTY:
412 		g_value_set_string (value, valadoc_api_attribute_get_name (self));
413 		break;
414 		default:
415 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
416 		break;
417 	}
418 }
419 
420 static void
_vala_valadoc_api_attribute_set_property(GObject * object,guint property_id,const GValue * value,GParamSpec * pspec)421 _vala_valadoc_api_attribute_set_property (GObject * object,
422                                           guint property_id,
423                                           const GValue * value,
424                                           GParamSpec * pspec)
425 {
426 	ValadocApiAttribute * self;
427 	self = G_TYPE_CHECK_INSTANCE_CAST (object, VALADOC_API_TYPE_ATTRIBUTE, ValadocApiAttribute);
428 	switch (property_id) {
429 		case VALADOC_API_ATTRIBUTE_NAME_PROPERTY:
430 		valadoc_api_attribute_set_name (self, g_value_get_string (value));
431 		break;
432 		default:
433 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
434 		break;
435 	}
436 }
437 
438