File: attribute.c

package info (click to toggle)
vala 0.56.18-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 57,520 kB
  • sloc: ansic: 581,293; sh: 5,357; makefile: 3,980; xml: 3,161; yacc: 1,219; lex: 374; javascript: 23
file content (446 lines) | stat: -rw-r--r-- 15,444 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
/* attribute.c generated by valac, the Vala compiler
 * generated from attribute.vala, do not modify */

/* attribute.vala
 *
 * Copyright (C) 2011 Florian Brosch
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 * Author:
 * 	Florian Brosch <flo.brosch@gmail.com>
 */

#include "valadoc.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include <vala.h>
#include <valagee.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	VALADOC_API_ATTRIBUTE_0_PROPERTY,
	VALADOC_API_ATTRIBUTE_NAME_PROPERTY,
	VALADOC_API_ATTRIBUTE_NUM_PROPERTIES
};
static GParamSpec* valadoc_api_attribute_properties[VALADOC_API_ATTRIBUTE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
#define _vala_iterator_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterator_unref (var), NULL)))
#define _g_sequence_free0(var) ((var == NULL) ? NULL : (var = (g_sequence_free (var), NULL)))
#define _valadoc_api_signature_builder_unref0(var) ((var == NULL) ? NULL : (var = (valadoc_api_signature_builder_unref (var), NULL)))

struct _ValadocApiAttributePrivate {
	ValadocApiSourceFile* file;
	gchar* _name;
};

static gint ValadocApiAttribute_private_offset;
static gpointer valadoc_api_attribute_parent_class = NULL;

static void valadoc_api_attribute_set_name (ValadocApiAttribute* self,
                                     const gchar* value);
static ValadocContentInline* valadoc_api_attribute_real_build_signature (ValadocApiItem* base);
static void _g_free0_ (gpointer var);
static void valadoc_api_attribute_finalize (GObject * obj);
static GType valadoc_api_attribute_get_type_once (void);
static void _vala_valadoc_api_attribute_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec);
static void _vala_valadoc_api_attribute_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec);

static inline gpointer
valadoc_api_attribute_get_instance_private (ValadocApiAttribute* self)
{
	return G_STRUCT_MEMBER_P (self, ValadocApiAttribute_private_offset);
}

const gchar*
valadoc_api_attribute_get_name (ValadocApiAttribute* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_name;
	result = _tmp0_;
	return result;
}

static void
valadoc_api_attribute_set_name (ValadocApiAttribute* self,
                                const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = valadoc_api_attribute_get_name (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_name);
		self->priv->_name = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, valadoc_api_attribute_properties[VALADOC_API_ATTRIBUTE_NAME_PROPERTY]);
	}
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

ValadocApiAttribute*
valadoc_api_attribute_construct (GType object_type,
                                 ValadocApiNode* parent,
                                 ValadocApiSourceFile* file,
                                 const gchar* name,
                                 ValaAttribute* data)
{
	ValadocApiAttribute * self = NULL;
	ValadocApiSourceFile* _tmp0_;
	g_return_val_if_fail (parent != NULL, NULL);
	g_return_val_if_fail (file != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (data != NULL, NULL);
	self = (ValadocApiAttribute*) valadoc_api_item_construct (object_type, (ValaCodeNode*) data);
	valadoc_api_item_set_parent ((ValadocApiItem*) self, (ValadocApiItem*) parent);
	valadoc_api_attribute_set_name (self, name);
	_tmp0_ = _g_object_ref0 (file);
	_g_object_unref0 (self->priv->file);
	self->priv->file = _tmp0_;
	return self;
}

ValadocApiAttribute*
valadoc_api_attribute_new (ValadocApiNode* parent,
                           ValadocApiSourceFile* file,
                           const gchar* name,
                           ValaAttribute* data)
{
	return valadoc_api_attribute_construct (VALADOC_API_TYPE_ATTRIBUTE, parent, file, name, data);
}

ValadocApiSourceFile*
valadoc_api_attribute_get_source_file (ValadocApiAttribute* self)
{
	ValadocApiSourceFile* _tmp0_;
	ValadocApiSourceFile* _tmp1_;
	ValadocApiSourceFile* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->file;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

static ValadocContentInline*
valadoc_api_attribute_real_build_signature (ValadocApiItem* base)
{
	ValadocApiAttribute * self;
	ValadocApiSignatureBuilder* builder = NULL;
	ValadocApiSignatureBuilder* _tmp0_;
	ValaAttribute* attr = NULL;
	ValaCodeNode* _tmp1_;
	ValaCodeNode* _tmp2_;
	GSequence* keys = NULL;
	GSequence* _tmp3_;
	gboolean _tmp20_ = FALSE;
	ValaAttribute* _tmp21_;
	const gchar* _tmp22_;
	const gchar* _tmp23_;
	ValadocApiSignatureBuilder* _tmp27_;
	ValadocApiSignatureBuilder* _tmp28_;
	ValaAttribute* _tmp29_;
	const gchar* _tmp30_;
	const gchar* _tmp31_;
	GSequence* _tmp32_;
	ValadocApiSignatureBuilder* _tmp55_;
	ValadocApiSignatureBuilder* _tmp56_;
	ValadocContentRun* _tmp57_;
	ValadocContentInline* result;
	self = (ValadocApiAttribute*) base;
	_tmp0_ = valadoc_api_signature_builder_new ();
	builder = _tmp0_;
	_tmp1_ = valadoc_api_item_get_data ((ValadocApiItem*) self);
	_tmp2_ = _tmp1_;
	attr = G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, VALA_TYPE_ATTRIBUTE, ValaAttribute);
	_tmp3_ = g_sequence_new (_g_free0_);
	keys = _tmp3_;
	{
		ValaIterator* _key_it = NULL;
		ValaAttribute* _tmp4_;
		ValaMap* _tmp5_;
		ValaMap* _tmp6_;
		ValaSet* _tmp7_;
		ValaSet* _tmp8_;
		ValaIterator* _tmp9_;
		ValaIterator* _tmp10_;
		_tmp4_ = attr;
		_tmp5_ = vala_attribute_get_args (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = vala_map_get_keys (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp9_ = vala_iterable_iterator ((ValaIterable*) _tmp8_);
		_tmp10_ = _tmp9_;
		_vala_iterable_unref0 (_tmp8_);
		_key_it = _tmp10_;
		while (TRUE) {
			ValaIterator* _tmp11_;
			gchar* key = NULL;
			ValaIterator* _tmp12_;
			gpointer _tmp13_;
			const gchar* _tmp14_;
			GSequence* _tmp15_;
			const gchar* _tmp16_;
			gchar* _tmp17_;
			GCompareFunc _tmp18_;
			GSequenceIter* _tmp19_;
			_tmp11_ = _key_it;
			if (!vala_iterator_next (_tmp11_)) {
				break;
			}
			_tmp12_ = _key_it;
			_tmp13_ = vala_iterator_get (_tmp12_);
			key = (gchar*) _tmp13_;
			_tmp14_ = key;
			if (g_strcmp0 (_tmp14_, "cheader_filename") == 0) {
				_g_free0 (key);
				continue;
			}
			_tmp15_ = keys;
			_tmp16_ = key;
			_tmp17_ = g_strdup (_tmp16_);
			_tmp18_ = ((GCompareFunc) g_strcmp0);
			_tmp19_ = g_sequence_insert_sorted (_tmp15_, _tmp17_, (GCompareDataFunc) _tmp18_, NULL);
			_g_free0 (key);
		}
		_vala_iterator_unref0 (_key_it);
	}
	_tmp21_ = attr;
	_tmp22_ = vala_attribute_get_name (_tmp21_);
	_tmp23_ = _tmp22_;
	if (g_strcmp0 (_tmp23_, "CCode") == 0) {
		GSequence* _tmp24_;
		_tmp24_ = keys;
		_tmp20_ = g_sequence_get_length (_tmp24_) == 0;
	} else {
		_tmp20_ = FALSE;
	}
	if (_tmp20_) {
		ValadocApiSignatureBuilder* _tmp25_;
		ValadocContentRun* _tmp26_;
		_tmp25_ = builder;
		_tmp26_ = valadoc_api_signature_builder_get (_tmp25_);
		result = (ValadocContentInline*) _tmp26_;
		_g_sequence_free0 (keys);
		_valadoc_api_signature_builder_unref0 (builder);
		return result;
	}
	_tmp27_ = builder;
	valadoc_api_signature_builder_append_attribute (_tmp27_, "[", TRUE);
	_tmp28_ = builder;
	_tmp29_ = attr;
	_tmp30_ = vala_attribute_get_name (_tmp29_);
	_tmp31_ = _tmp30_;
	valadoc_api_signature_builder_append_type_name (_tmp28_, _tmp31_, TRUE);
	_tmp32_ = keys;
	if (g_sequence_get_length (_tmp32_) > 0) {
		ValadocApiSignatureBuilder* _tmp33_;
		const gchar* separator = NULL;
		GSequenceIter* arg_iter = NULL;
		GSequence* _tmp34_;
		GSequenceIter* _tmp35_;
		ValadocApiSignatureBuilder* _tmp54_;
		_tmp33_ = builder;
		valadoc_api_signature_builder_append_attribute (_tmp33_, "(", TRUE);
		separator = "";
		_tmp34_ = keys;
		_tmp35_ = g_sequence_get_begin_iter (_tmp34_);
		arg_iter = _tmp35_;
		while (TRUE) {
			GSequenceIter* _tmp36_;
			const gchar* arg_name = NULL;
			GSequenceIter* _tmp37_;
			gconstpointer _tmp38_;
			GSequenceIter* _tmp39_;
			GSequenceIter* _tmp40_;
			const gchar* _tmp41_;
			const gchar* _tmp43_;
			_tmp36_ = arg_iter;
			if (!(!g_sequence_iter_is_end (_tmp36_))) {
				break;
			}
			_tmp37_ = arg_iter;
			_tmp38_ = g_sequence_get (_tmp37_);
			arg_name = (const gchar*) _tmp38_;
			_tmp39_ = arg_iter;
			_tmp40_ = g_sequence_iter_next (_tmp39_);
			arg_iter = _tmp40_;
			_tmp41_ = separator;
			if (g_strcmp0 (_tmp41_, "") != 0) {
				ValadocApiSignatureBuilder* _tmp42_;
				_tmp42_ = builder;
				valadoc_api_signature_builder_append_attribute (_tmp42_, ", ", TRUE);
			}
			_tmp43_ = arg_name;
			if (g_strcmp0 (_tmp43_, "cheader_filename") != 0) {
				ValadocApiSignatureBuilder* _tmp44_;
				const gchar* _tmp45_;
				ValadocApiSignatureBuilder* _tmp46_;
				ValadocApiSignatureBuilder* _tmp47_;
				ValaAttribute* _tmp48_;
				ValaMap* _tmp49_;
				ValaMap* _tmp50_;
				const gchar* _tmp51_;
				gpointer _tmp52_;
				gchar* _tmp53_;
				_tmp44_ = builder;
				_tmp45_ = arg_name;
				valadoc_api_signature_builder_append_attribute (_tmp44_, _tmp45_, TRUE);
				_tmp46_ = builder;
				valadoc_api_signature_builder_append_attribute (_tmp46_, "=", TRUE);
				_tmp47_ = builder;
				_tmp48_ = attr;
				_tmp49_ = vala_attribute_get_args (_tmp48_);
				_tmp50_ = _tmp49_;
				_tmp51_ = arg_name;
				_tmp52_ = vala_map_get (_tmp50_, _tmp51_);
				_tmp53_ = (gchar*) _tmp52_;
				valadoc_api_signature_builder_append_literal (_tmp47_, _tmp53_, TRUE);
				_g_free0 (_tmp53_);
			}
			separator = ", ";
		}
		_tmp54_ = builder;
		valadoc_api_signature_builder_append_attribute (_tmp54_, ")", TRUE);
	}
	_tmp55_ = builder;
	valadoc_api_signature_builder_append_attribute (_tmp55_, "]", TRUE);
	_tmp56_ = builder;
	_tmp57_ = valadoc_api_signature_builder_get (_tmp56_);
	result = (ValadocContentInline*) _tmp57_;
	_g_sequence_free0 (keys);
	_valadoc_api_signature_builder_unref0 (builder);
	return result;
}

static void
valadoc_api_attribute_class_init (ValadocApiAttributeClass * klass,
                                  gpointer klass_data)
{
	valadoc_api_attribute_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ValadocApiAttribute_private_offset);
	((ValadocApiItemClass *) klass)->build_signature = (ValadocContentInline* (*) (ValadocApiItem*)) valadoc_api_attribute_real_build_signature;
	G_OBJECT_CLASS (klass)->get_property = _vala_valadoc_api_attribute_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_valadoc_api_attribute_set_property;
	G_OBJECT_CLASS (klass)->finalize = valadoc_api_attribute_finalize;
	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));
}

static void
valadoc_api_attribute_instance_init (ValadocApiAttribute * self,
                                     gpointer klass)
{
	self->priv = valadoc_api_attribute_get_instance_private (self);
}

static void
valadoc_api_attribute_finalize (GObject * obj)
{
	ValadocApiAttribute * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_API_TYPE_ATTRIBUTE, ValadocApiAttribute);
	_g_object_unref0 (self->priv->file);
	_g_free0 (self->priv->_name);
	G_OBJECT_CLASS (valadoc_api_attribute_parent_class)->finalize (obj);
}

static GType
valadoc_api_attribute_get_type_once (void)
{
	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 };
	GType valadoc_api_attribute_type_id;
	valadoc_api_attribute_type_id = g_type_register_static (VALADOC_API_TYPE_ITEM, "ValadocApiAttribute", &g_define_type_info, 0);
	ValadocApiAttribute_private_offset = g_type_add_instance_private (valadoc_api_attribute_type_id, sizeof (ValadocApiAttributePrivate));
	return valadoc_api_attribute_type_id;
}

GType
valadoc_api_attribute_get_type (void)
{
	static volatile gsize valadoc_api_attribute_type_id__once = 0;
	if (g_once_init_enter (&valadoc_api_attribute_type_id__once)) {
		GType valadoc_api_attribute_type_id;
		valadoc_api_attribute_type_id = valadoc_api_attribute_get_type_once ();
		g_once_init_leave (&valadoc_api_attribute_type_id__once, valadoc_api_attribute_type_id);
	}
	return valadoc_api_attribute_type_id__once;
}

static void
_vala_valadoc_api_attribute_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec)
{
	ValadocApiAttribute * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, VALADOC_API_TYPE_ATTRIBUTE, ValadocApiAttribute);
	switch (property_id) {
		case VALADOC_API_ATTRIBUTE_NAME_PROPERTY:
		g_value_set_string (value, valadoc_api_attribute_get_name (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_valadoc_api_attribute_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec)
{
	ValadocApiAttribute * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, VALADOC_API_TYPE_ATTRIBUTE, ValadocApiAttribute);
	switch (property_id) {
		case VALADOC_API_ATTRIBUTE_NAME_PROPERTY:
		valadoc_api_attribute_set_name (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}