File: token.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 (502 lines) | stat: -rw-r--r-- 15,430 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
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
/* token.c generated by valac, the Vala compiler
 * generated from token.vala, do not modify */

/* token.vala
 *
 * Copyright (C) 2008-2009 Florian Brosch, Didier Villevalois
 *
 * 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:
 * 	Didier 'Ptitjes Villevalois <ptitjes@free.fr>
 */

#include "valadoc.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <vala.h>
#include <glib-object.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_TOKEN_0_PROPERTY,
	VALADOC_TOKEN_IS_WORD_PROPERTY,
	VALADOC_TOKEN_IS_NUMBER_PROPERTY,
	VALADOC_TOKEN_WORD_PROPERTY,
	VALADOC_TOKEN_VALUE_PROPERTY,
	VALADOC_TOKEN_TOKEN_TYPE_PROPERTY,
	VALADOC_TOKEN_BEGIN_PROPERTY,
	VALADOC_TOKEN_END_PROPERTY,
	VALADOC_TOKEN_NUM_PROPERTIES
};
static GParamSpec* valadoc_token_properties[VALADOC_TOKEN_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_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _ValadocTokenPrivate {
	ValadocTokenType* _type;
	gchar* _word;
	ValaSourceLocation _begin;
	ValaSourceLocation _end;
	gchar* _value;
};

static gint ValadocToken_private_offset;
static gpointer valadoc_token_parent_class = NULL;

static void valadoc_token_finalize (GObject * obj);
static GType valadoc_token_get_type_once (void);
static void _vala_valadoc_token_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec);

static inline gpointer
valadoc_token_get_instance_private (ValadocToken* self)
{
	return G_STRUCT_MEMBER_P (self, ValadocToken_private_offset);
}

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

ValadocToken*
valadoc_token_construct_from_type (GType object_type,
                                   ValadocTokenType* type,
                                   ValaSourceLocation* begin,
                                   ValaSourceLocation* end,
                                   const gchar* val)
{
	ValadocToken * self = NULL;
	ValadocTokenType* _tmp0_;
	ValaSourceLocation _tmp1_;
	ValaSourceLocation _tmp2_;
	gchar* _tmp3_;
	g_return_val_if_fail (type != NULL, NULL);
	g_return_val_if_fail (begin != NULL, NULL);
	g_return_val_if_fail (end != NULL, NULL);
	self = (ValadocToken*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (type);
	_g_object_unref0 (self->priv->_type);
	self->priv->_type = _tmp0_;
	_tmp1_ = *begin;
	self->priv->_begin = _tmp1_;
	_tmp2_ = *end;
	self->priv->_end = _tmp2_;
	_tmp3_ = g_strdup (val);
	_g_free0 (self->priv->_value);
	self->priv->_value = _tmp3_;
	return self;
}

ValadocToken*
valadoc_token_new_from_type (ValadocTokenType* type,
                             ValaSourceLocation* begin,
                             ValaSourceLocation* end,
                             const gchar* val)
{
	return valadoc_token_construct_from_type (VALADOC_TYPE_TOKEN, type, begin, end, val);
}

ValadocToken*
valadoc_token_construct_from_word (GType object_type,
                                   const gchar* word,
                                   ValaSourceLocation* begin,
                                   ValaSourceLocation* end)
{
	ValadocToken * self = NULL;
	gchar* _tmp0_;
	ValaSourceLocation _tmp1_;
	ValaSourceLocation _tmp2_;
	g_return_val_if_fail (word != NULL, NULL);
	g_return_val_if_fail (begin != NULL, NULL);
	g_return_val_if_fail (end != NULL, NULL);
	self = (ValadocToken*) g_object_new (object_type, NULL);
	_tmp0_ = g_strdup (word);
	_g_free0 (self->priv->_word);
	self->priv->_word = _tmp0_;
	_tmp1_ = *begin;
	self->priv->_begin = _tmp1_;
	_tmp2_ = *end;
	self->priv->_end = _tmp2_;
	return self;
}

ValadocToken*
valadoc_token_new_from_word (const gchar* word,
                             ValaSourceLocation* begin,
                             ValaSourceLocation* end)
{
	return valadoc_token_construct_from_word (VALADOC_TYPE_TOKEN, word, begin, end);
}

gboolean
valadoc_token_get_is_word (ValadocToken* self)
{
	gboolean result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_word;
	result = _tmp0_ != NULL;
	return result;
}

static gchar
string_get (const gchar* self,
            glong index)
{
	gchar _tmp0_;
	gchar result;
	g_return_val_if_fail (self != NULL, '\0');
	_tmp0_ = ((gchar*) self)[index];
	result = _tmp0_;
	return result;
}

gboolean
valadoc_token_get_is_number (ValadocToken* self)
{
	gboolean result;
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp1_ = self->priv->_word;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		const gchar* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		_tmp2_ = self->priv->_word;
		_tmp3_ = strlen (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_ == 0;
	}
	if (_tmp0_) {
		result = FALSE;
		return result;
	} else {
		gboolean _tmp5_ = FALSE;
		const gchar* _tmp6_;
		_tmp6_ = self->priv->_word;
		if (string_get (_tmp6_, (glong) 0) == '0') {
			const gchar* _tmp7_;
			gint _tmp8_;
			gint _tmp9_;
			_tmp7_ = self->priv->_word;
			_tmp8_ = strlen (_tmp7_);
			_tmp9_ = _tmp8_;
			_tmp5_ = _tmp9_ > 1;
		} else {
			_tmp5_ = FALSE;
		}
		if (_tmp5_) {
			result = FALSE;
			return result;
		}
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp10_ = FALSE;
			_tmp10_ = TRUE;
			while (TRUE) {
				const gchar* _tmp12_;
				gint _tmp13_;
				gint _tmp14_;
				gboolean _tmp15_ = FALSE;
				const gchar* _tmp16_;
				if (!_tmp10_) {
					gint _tmp11_;
					_tmp11_ = i;
					i = _tmp11_ + 1;
				}
				_tmp10_ = FALSE;
				_tmp12_ = self->priv->_word;
				_tmp13_ = strlen (_tmp12_);
				_tmp14_ = _tmp13_;
				if (!(i < _tmp14_)) {
					break;
				}
				_tmp16_ = self->priv->_word;
				if (string_get (_tmp16_, (glong) i) < '0') {
					_tmp15_ = TRUE;
				} else {
					const gchar* _tmp17_;
					_tmp17_ = self->priv->_word;
					_tmp15_ = string_get (_tmp17_, (glong) i) > '9';
				}
				if (_tmp15_) {
					result = FALSE;
					return result;
				}
			}
		}
	}
	result = TRUE;
	return result;
}

const gchar*
valadoc_token_get_word (ValadocToken* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_word;
	result = _tmp0_;
	return result;
}

const gchar*
valadoc_token_get_value (ValadocToken* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_value;
	result = _tmp0_;
	return result;
}

ValadocTokenType*
valadoc_token_get_token_type (ValadocToken* self)
{
	ValadocTokenType* result;
	ValadocTokenType* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_type;
	result = _tmp0_;
	return result;
}

void
valadoc_token_get_begin (ValadocToken* self,
                         ValaSourceLocation * result)
{
	ValaSourceLocation _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_begin;
	*result = _tmp0_;
	return;
}

void
valadoc_token_get_end (ValadocToken* self,
                       ValaSourceLocation * result)
{
	ValaSourceLocation _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_end;
	*result = _tmp0_;
	return;
}

const gchar*
valadoc_token_to_string (ValadocToken* self)
{
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_;
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp1_ = self->priv->_word;
	if (_tmp1_ == NULL) {
		ValadocTokenType* _tmp2_;
		const gchar* _tmp3_;
		_tmp2_ = self->priv->_type;
		_tmp3_ = valadoc_token_type_to_string (_tmp2_);
		_tmp0_ = _tmp3_;
	} else {
		const gchar* _tmp4_;
		_tmp4_ = self->priv->_word;
		_tmp0_ = _tmp4_;
	}
	result = _tmp0_;
	return result;
}

const gchar*
valadoc_token_to_pretty_string (ValadocToken* self)
{
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_;
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp1_ = self->priv->_word;
	if (_tmp1_ == NULL) {
		ValadocTokenType* _tmp2_;
		const gchar* _tmp3_;
		_tmp2_ = self->priv->_type;
		_tmp3_ = valadoc_token_type_to_pretty_string (_tmp2_);
		_tmp0_ = _tmp3_;
	} else {
		const gchar* _tmp4_;
		_tmp4_ = self->priv->_word;
		_tmp0_ = _tmp4_;
	}
	result = _tmp0_;
	return result;
}

gint
valadoc_token_to_int (ValadocToken* self)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	const gchar* _tmp2_;
	gint result;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = valadoc_token_get_is_number (self);
	_tmp1_ = _tmp0_;
	_vala_assert (_tmp1_, "is_number");
	_tmp2_ = self->priv->_word;
	result = atoi (_tmp2_);
	return result;
}

ValadocToken*
valadoc_token_construct (GType object_type)
{
	ValadocToken * self = NULL;
	self = (ValadocToken*) g_object_new (object_type, NULL);
	return self;
}

ValadocToken*
valadoc_token_new (void)
{
	return valadoc_token_construct (VALADOC_TYPE_TOKEN);
}

static void
valadoc_token_class_init (ValadocTokenClass * klass,
                          gpointer klass_data)
{
	valadoc_token_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ValadocToken_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_valadoc_token_get_property;
	G_OBJECT_CLASS (klass)->finalize = valadoc_token_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_TOKEN_IS_WORD_PROPERTY, valadoc_token_properties[VALADOC_TOKEN_IS_WORD_PROPERTY] = g_param_spec_boolean ("is-word", "is-word", "is-word", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_TOKEN_IS_NUMBER_PROPERTY, valadoc_token_properties[VALADOC_TOKEN_IS_NUMBER_PROPERTY] = g_param_spec_boolean ("is-number", "is-number", "is-number", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_TOKEN_WORD_PROPERTY, valadoc_token_properties[VALADOC_TOKEN_WORD_PROPERTY] = g_param_spec_string ("word", "word", "word", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_TOKEN_VALUE_PROPERTY, valadoc_token_properties[VALADOC_TOKEN_VALUE_PROPERTY] = g_param_spec_string ("value", "value", "value", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_TOKEN_TOKEN_TYPE_PROPERTY, valadoc_token_properties[VALADOC_TOKEN_TOKEN_TYPE_PROPERTY] = g_param_spec_object ("token-type", "token-type", "token-type", VALADOC_TYPE_TOKEN_TYPE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_TOKEN_BEGIN_PROPERTY, valadoc_token_properties[VALADOC_TOKEN_BEGIN_PROPERTY] = g_param_spec_boxed ("begin", "begin", "begin", VALA_TYPE_SOURCE_LOCATION, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_TOKEN_END_PROPERTY, valadoc_token_properties[VALADOC_TOKEN_END_PROPERTY] = g_param_spec_boxed ("end", "end", "end", VALA_TYPE_SOURCE_LOCATION, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
valadoc_token_instance_init (ValadocToken * self,
                             gpointer klass)
{
	self->priv = valadoc_token_get_instance_private (self);
	self->priv->_type = NULL;
	self->priv->_word = NULL;
}

static void
valadoc_token_finalize (GObject * obj)
{
	ValadocToken * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_TYPE_TOKEN, ValadocToken);
	_g_object_unref0 (self->priv->_type);
	_g_free0 (self->priv->_word);
	_g_free0 (self->priv->_value);
	G_OBJECT_CLASS (valadoc_token_parent_class)->finalize (obj);
}

static GType
valadoc_token_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ValadocTokenClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_token_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocToken), 0, (GInstanceInitFunc) valadoc_token_instance_init, NULL };
	GType valadoc_token_type_id;
	valadoc_token_type_id = g_type_register_static (G_TYPE_OBJECT, "ValadocToken", &g_define_type_info, 0);
	ValadocToken_private_offset = g_type_add_instance_private (valadoc_token_type_id, sizeof (ValadocTokenPrivate));
	return valadoc_token_type_id;
}

GType
valadoc_token_get_type (void)
{
	static volatile gsize valadoc_token_type_id__once = 0;
	if (g_once_init_enter (&valadoc_token_type_id__once)) {
		GType valadoc_token_type_id;
		valadoc_token_type_id = valadoc_token_get_type_once ();
		g_once_init_leave (&valadoc_token_type_id__once, valadoc_token_type_id);
	}
	return valadoc_token_type_id__once;
}

static void
_vala_valadoc_token_get_property (GObject * object,
                                  guint property_id,
                                  GValue * value,
                                  GParamSpec * pspec)
{
	ValadocToken * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, VALADOC_TYPE_TOKEN, ValadocToken);
	switch (property_id) {
		case VALADOC_TOKEN_IS_WORD_PROPERTY:
		g_value_set_boolean (value, valadoc_token_get_is_word (self));
		break;
		case VALADOC_TOKEN_IS_NUMBER_PROPERTY:
		g_value_set_boolean (value, valadoc_token_get_is_number (self));
		break;
		case VALADOC_TOKEN_WORD_PROPERTY:
		g_value_set_string (value, valadoc_token_get_word (self));
		break;
		case VALADOC_TOKEN_VALUE_PROPERTY:
		g_value_set_string (value, valadoc_token_get_value (self));
		break;
		case VALADOC_TOKEN_TOKEN_TYPE_PROPERTY:
		g_value_set_object (value, valadoc_token_get_token_type (self));
		break;
		case VALADOC_TOKEN_BEGIN_PROPERTY:
		{
			ValaSourceLocation boxed;
			valadoc_token_get_begin (self, &boxed);
			g_value_set_boxed (value, &boxed);
		}
		break;
		case VALADOC_TOKEN_END_PROPERTY:
		{
			ValaSourceLocation boxed;
			valadoc_token_get_end (self, &boxed);
			g_value_set_boxed (value, &boxed);
		}
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}