1 /* valasourcefile.c generated by valac, the Vala compiler
2  * generated from valasourcefile.vala, do not modify */
3 
4 /* valasourcefile.vala
5  *
6  * Copyright (C) 2006-2009  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 "vala.h"
27 #include <stdlib.h>
28 #include <string.h>
29 #include <glib.h>
30 #include <valagee.h>
31 #include <glib-object.h>
32 #include <glib/gstdio.h>
33 #include <gobject/gvaluecollector.h>
34 
35 #define _g_free0(var) (var = (g_free (var), NULL))
36 #define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
37 #define _g_mapped_file_unref0(var) ((var == NULL) ? NULL : (var = (g_mapped_file_unref (var), NULL)))
38 #define _vala_code_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_node_unref (var), NULL)))
39 #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
40 typedef struct _ValaParamSpecSourceFile ValaParamSpecSourceFile;
41 
42 struct _ValaSourceFilePrivate {
43 	gchar* _filename;
44 	gchar* _package_name;
45 	gchar* _installed_version;
46 	gboolean _version_requested;
47 	ValaSourceFileType _file_type;
48 	gboolean _from_commandline;
49 	gchar* _gir_namespace;
50 	gchar* _gir_version;
51 	ValaCodeContext* _context;
52 	gboolean _used;
53 	ValaArrayList* comments;
54 	ValaList* _current_using_directives;
55 	ValaList* nodes;
56 	gchar* _relative_filename;
57 	gchar* csource_filename;
58 	gchar* cinclude_filename;
59 	ValaArrayList* source_array;
60 	GMappedFile* mapped_file;
61 	gchar* _content;
62 };
63 
64 struct _ValaParamSpecSourceFile {
65 	GParamSpec parent_instance;
66 };
67 
68 static gint ValaSourceFile_private_offset;
69 static gpointer vala_source_file_parent_class = NULL;
70 
71 static void vala_source_file_set_filename (ValaSourceFile* self,
72                                     const gchar* value);
73 static gchar* vala_source_file_get_subdir (ValaSourceFile* self);
74 static gchar* vala_source_file_get_destination_directory (ValaSourceFile* self);
75 static gchar* vala_source_file_get_basename (ValaSourceFile* self);
76 static void vala_source_file_read_source_lines (ValaSourceFile* self,
77                                          const gchar* cont);
78 static void vala_source_file_read_source_file (ValaSourceFile* self);
79 static void vala_source_file_finalize (ValaSourceFile * obj);
80 static GType vala_source_file_get_type_once (void);
81 static void _vala_array_destroy (gpointer array,
82                           gint array_length,
83                           GDestroyNotify destroy_func);
84 static void _vala_array_free (gpointer array,
85                        gint array_length,
86                        GDestroyNotify destroy_func);
87 static gint _vala_array_length (gpointer array);
88 
89 static inline gpointer
vala_source_file_get_instance_private(ValaSourceFile * self)90 vala_source_file_get_instance_private (ValaSourceFile* self)
91 {
92 	return G_STRUCT_MEMBER_P (self, ValaSourceFile_private_offset);
93 }
94 
95 const gchar*
vala_source_file_get_filename(ValaSourceFile * self)96 vala_source_file_get_filename (ValaSourceFile* self)
97 {
98 	const gchar* result;
99 	const gchar* _tmp0_;
100 	g_return_val_if_fail (self != NULL, NULL);
101 	_tmp0_ = self->priv->_filename;
102 	result = _tmp0_;
103 	return result;
104 }
105 
106 static void
vala_source_file_set_filename(ValaSourceFile * self,const gchar * value)107 vala_source_file_set_filename (ValaSourceFile* self,
108                                const gchar* value)
109 {
110 	gchar* _tmp0_;
111 	g_return_if_fail (self != NULL);
112 	_tmp0_ = g_strdup (value);
113 	_g_free0 (self->priv->_filename);
114 	self->priv->_filename = _tmp0_;
115 }
116 
117 void
vala_source_file_set_relative_filename(ValaSourceFile * self,const gchar * value)118 vala_source_file_set_relative_filename (ValaSourceFile* self,
119                                         const gchar* value)
120 {
121 	gchar* _tmp0_;
122 	g_return_if_fail (self != NULL);
123 	_tmp0_ = g_strdup (value);
124 	_g_free0 (self->priv->_relative_filename);
125 	self->priv->_relative_filename = _tmp0_;
126 }
127 
128 static gchar*
string_slice(const gchar * self,glong start,glong end)129 string_slice (const gchar* self,
130               glong start,
131               glong end)
132 {
133 	glong string_length = 0L;
134 	gint _tmp0_;
135 	gint _tmp1_;
136 	gboolean _tmp2_ = FALSE;
137 	gboolean _tmp3_ = FALSE;
138 	gchar* _tmp4_;
139 	gchar* result = NULL;
140 	g_return_val_if_fail (self != NULL, NULL);
141 	_tmp0_ = strlen (self);
142 	_tmp1_ = _tmp0_;
143 	string_length = (glong) _tmp1_;
144 	if (start < ((glong) 0)) {
145 		start = string_length + start;
146 	}
147 	if (end < ((glong) 0)) {
148 		end = string_length + end;
149 	}
150 	if (start >= ((glong) 0)) {
151 		_tmp2_ = start <= string_length;
152 	} else {
153 		_tmp2_ = FALSE;
154 	}
155 	g_return_val_if_fail (_tmp2_, NULL);
156 	if (end >= ((glong) 0)) {
157 		_tmp3_ = end <= string_length;
158 	} else {
159 		_tmp3_ = FALSE;
160 	}
161 	g_return_val_if_fail (_tmp3_, NULL);
162 	g_return_val_if_fail (start <= end, NULL);
163 	_tmp4_ = g_strndup (((gchar*) self) + start, (gsize) (end - start));
164 	result = _tmp4_;
165 	return result;
166 }
167 
168 static gint
string_last_index_of_char(const gchar * self,gunichar c,gint start_index)169 string_last_index_of_char (const gchar* self,
170                            gunichar c,
171                            gint start_index)
172 {
173 	gchar* _result_ = NULL;
174 	gchar* _tmp0_;
175 	gchar* _tmp1_;
176 	gint result = 0;
177 	g_return_val_if_fail (self != NULL, 0);
178 	_tmp0_ = g_utf8_strrchr (((gchar*) self) + start_index, (gssize) -1, c);
179 	_result_ = _tmp0_;
180 	_tmp1_ = _result_;
181 	if (_tmp1_ != NULL) {
182 		gchar* _tmp2_;
183 		_tmp2_ = _result_;
184 		result = (gint) (_tmp2_ - ((gchar*) self));
185 		return result;
186 	} else {
187 		result = -1;
188 		return result;
189 	}
190 }
191 
192 const gchar*
vala_source_file_get_package_name(ValaSourceFile * self)193 vala_source_file_get_package_name (ValaSourceFile* self)
194 {
195 	const gchar* result;
196 	ValaSourceFileType _tmp0_;
197 	const gchar* _tmp1_;
198 	const gchar* _tmp7_;
199 	g_return_val_if_fail (self != NULL, NULL);
200 	_tmp0_ = self->priv->_file_type;
201 	if (_tmp0_ != VALA_SOURCE_FILE_TYPE_PACKAGE) {
202 		result = NULL;
203 		return result;
204 	}
205 	_tmp1_ = self->priv->_package_name;
206 	if (_tmp1_ == NULL) {
207 		const gchar* _tmp2_;
208 		const gchar* _tmp3_;
209 		gchar* _tmp4_;
210 		gchar* _tmp5_;
211 		gchar* _tmp6_;
212 		_tmp2_ = self->priv->_filename;
213 		_tmp3_ = self->priv->_filename;
214 		_tmp4_ = string_slice (_tmp2_, (glong) 0, (glong) string_last_index_of_char (_tmp3_, (gunichar) '.', 0));
215 		_tmp5_ = _tmp4_;
216 		_tmp6_ = g_path_get_basename (_tmp5_);
217 		_g_free0 (self->priv->_package_name);
218 		self->priv->_package_name = _tmp6_;
219 		_g_free0 (_tmp5_);
220 	}
221 	_tmp7_ = self->priv->_package_name;
222 	result = _tmp7_;
223 	return result;
224 }
225 
226 void
vala_source_file_set_package_name(ValaSourceFile * self,const gchar * value)227 vala_source_file_set_package_name (ValaSourceFile* self,
228                                    const gchar* value)
229 {
230 	gchar* _tmp0_;
231 	g_return_if_fail (self != NULL);
232 	_tmp0_ = g_strdup (value);
233 	_g_free0 (self->priv->_package_name);
234 	self->priv->_package_name = _tmp0_;
235 }
236 
237 const gchar*
vala_source_file_get_installed_version(ValaSourceFile * self)238 vala_source_file_get_installed_version (ValaSourceFile* self)
239 {
240 	const gchar* result;
241 	const gchar* _tmp1_;
242 	const gchar* _tmp2_;
243 	const gchar* _tmp7_;
244 	g_return_val_if_fail (self != NULL, NULL);
245 	if (self->priv->_version_requested) {
246 		const gchar* _tmp0_;
247 		_tmp0_ = self->priv->_installed_version;
248 		result = _tmp0_;
249 		return result;
250 	}
251 	self->priv->_version_requested = TRUE;
252 	_tmp1_ = vala_source_file_get_package_name (self);
253 	_tmp2_ = _tmp1_;
254 	if (_tmp2_ != NULL) {
255 		ValaCodeContext* _tmp3_;
256 		const gchar* _tmp4_;
257 		const gchar* _tmp5_;
258 		gchar* _tmp6_;
259 		_tmp3_ = self->priv->_context;
260 		_tmp4_ = vala_source_file_get_package_name (self);
261 		_tmp5_ = _tmp4_;
262 		_tmp6_ = vala_code_context_pkg_config_modversion (_tmp3_, _tmp5_);
263 		_g_free0 (self->priv->_installed_version);
264 		self->priv->_installed_version = _tmp6_;
265 	}
266 	_tmp7_ = self->priv->_installed_version;
267 	result = _tmp7_;
268 	return result;
269 }
270 
271 void
vala_source_file_set_installed_version(ValaSourceFile * self,const gchar * value)272 vala_source_file_set_installed_version (ValaSourceFile* self,
273                                         const gchar* value)
274 {
275 	gchar* _tmp0_;
276 	g_return_if_fail (self != NULL);
277 	self->priv->_version_requested = value != NULL;
278 	_tmp0_ = g_strdup (value);
279 	_g_free0 (self->priv->_installed_version);
280 	self->priv->_installed_version = _tmp0_;
281 }
282 
283 ValaSourceFileType
vala_source_file_get_file_type(ValaSourceFile * self)284 vala_source_file_get_file_type (ValaSourceFile* self)
285 {
286 	ValaSourceFileType result;
287 	ValaSourceFileType _tmp0_;
288 	g_return_val_if_fail (self != NULL, 0);
289 	_tmp0_ = self->priv->_file_type;
290 	result = _tmp0_;
291 	return result;
292 }
293 
294 void
vala_source_file_set_file_type(ValaSourceFile * self,ValaSourceFileType value)295 vala_source_file_set_file_type (ValaSourceFile* self,
296                                 ValaSourceFileType value)
297 {
298 	g_return_if_fail (self != NULL);
299 	self->priv->_file_type = value;
300 }
301 
302 gboolean
vala_source_file_get_from_commandline(ValaSourceFile * self)303 vala_source_file_get_from_commandline (ValaSourceFile* self)
304 {
305 	gboolean result;
306 	g_return_val_if_fail (self != NULL, FALSE);
307 	result = self->priv->_from_commandline;
308 	return result;
309 }
310 
311 void
vala_source_file_set_from_commandline(ValaSourceFile * self,gboolean value)312 vala_source_file_set_from_commandline (ValaSourceFile* self,
313                                        gboolean value)
314 {
315 	g_return_if_fail (self != NULL);
316 	self->priv->_from_commandline = value;
317 }
318 
319 const gchar*
vala_source_file_get_gir_namespace(ValaSourceFile * self)320 vala_source_file_get_gir_namespace (ValaSourceFile* self)
321 {
322 	const gchar* result;
323 	const gchar* _tmp0_;
324 	g_return_val_if_fail (self != NULL, NULL);
325 	_tmp0_ = self->priv->_gir_namespace;
326 	result = _tmp0_;
327 	return result;
328 }
329 
330 void
vala_source_file_set_gir_namespace(ValaSourceFile * self,const gchar * value)331 vala_source_file_set_gir_namespace (ValaSourceFile* self,
332                                     const gchar* value)
333 {
334 	gchar* _tmp0_;
335 	g_return_if_fail (self != NULL);
336 	_tmp0_ = g_strdup (value);
337 	_g_free0 (self->priv->_gir_namespace);
338 	self->priv->_gir_namespace = _tmp0_;
339 }
340 
341 const gchar*
vala_source_file_get_gir_version(ValaSourceFile * self)342 vala_source_file_get_gir_version (ValaSourceFile* self)
343 {
344 	const gchar* result;
345 	const gchar* _tmp0_;
346 	g_return_val_if_fail (self != NULL, NULL);
347 	_tmp0_ = self->priv->_gir_version;
348 	result = _tmp0_;
349 	return result;
350 }
351 
352 void
vala_source_file_set_gir_version(ValaSourceFile * self,const gchar * value)353 vala_source_file_set_gir_version (ValaSourceFile* self,
354                                   const gchar* value)
355 {
356 	gchar* _tmp0_;
357 	g_return_if_fail (self != NULL);
358 	_tmp0_ = g_strdup (value);
359 	_g_free0 (self->priv->_gir_version);
360 	self->priv->_gir_version = _tmp0_;
361 }
362 
363 ValaCodeContext*
vala_source_file_get_context(ValaSourceFile * self)364 vala_source_file_get_context (ValaSourceFile* self)
365 {
366 	ValaCodeContext* result;
367 	ValaCodeContext* _tmp0_;
368 	g_return_val_if_fail (self != NULL, NULL);
369 	_tmp0_ = self->priv->_context;
370 	result = _tmp0_;
371 	return result;
372 }
373 
374 void
vala_source_file_set_context(ValaSourceFile * self,ValaCodeContext * value)375 vala_source_file_set_context (ValaSourceFile* self,
376                               ValaCodeContext* value)
377 {
378 	g_return_if_fail (self != NULL);
379 	self->priv->_context = value;
380 }
381 
382 const gchar*
vala_source_file_get_content(ValaSourceFile * self)383 vala_source_file_get_content (ValaSourceFile* self)
384 {
385 	const gchar* result;
386 	const gchar* _tmp0_;
387 	g_return_val_if_fail (self != NULL, NULL);
388 	_tmp0_ = self->priv->_content;
389 	result = _tmp0_;
390 	return result;
391 }
392 
393 void
vala_source_file_set_content(ValaSourceFile * self,const gchar * value)394 vala_source_file_set_content (ValaSourceFile* self,
395                               const gchar* value)
396 {
397 	gchar* _tmp0_;
398 	g_return_if_fail (self != NULL);
399 	_tmp0_ = g_strdup (value);
400 	_g_free0 (self->priv->_content);
401 	self->priv->_content = _tmp0_;
402 	_vala_iterable_unref0 (self->priv->source_array);
403 	self->priv->source_array = NULL;
404 }
405 
406 gboolean
vala_source_file_get_used(ValaSourceFile * self)407 vala_source_file_get_used (ValaSourceFile* self)
408 {
409 	gboolean result;
410 	g_return_val_if_fail (self != NULL, FALSE);
411 	result = self->priv->_used;
412 	return result;
413 }
414 
415 void
vala_source_file_set_used(ValaSourceFile * self,gboolean value)416 vala_source_file_set_used (ValaSourceFile* self,
417                            gboolean value)
418 {
419 	g_return_if_fail (self != NULL);
420 	self->priv->_used = value;
421 }
422 
423 ValaList*
vala_source_file_get_current_using_directives(ValaSourceFile * self)424 vala_source_file_get_current_using_directives (ValaSourceFile* self)
425 {
426 	ValaList* result;
427 	ValaList* _tmp0_;
428 	g_return_val_if_fail (self != NULL, NULL);
429 	_tmp0_ = self->priv->_current_using_directives;
430 	result = _tmp0_;
431 	return result;
432 }
433 
434 static gpointer
_vala_iterable_ref0(gpointer self)435 _vala_iterable_ref0 (gpointer self)
436 {
437 	return self ? vala_iterable_ref (self) : NULL;
438 }
439 
440 void
vala_source_file_set_current_using_directives(ValaSourceFile * self,ValaList * value)441 vala_source_file_set_current_using_directives (ValaSourceFile* self,
442                                                ValaList* value)
443 {
444 	ValaList* _tmp0_;
445 	g_return_if_fail (self != NULL);
446 	_tmp0_ = _vala_iterable_ref0 (value);
447 	_vala_iterable_unref0 (self->priv->_current_using_directives);
448 	self->priv->_current_using_directives = _tmp0_;
449 }
450 
451 /**
452  * Creates a new source file.
453  *
454  * @param filename source file name
455  * @return         newly created source file
456  */
457 ValaSourceFile*
vala_source_file_construct(GType object_type,ValaCodeContext * context,ValaSourceFileType type,const gchar * filename,const gchar * content,gboolean cmdline)458 vala_source_file_construct (GType object_type,
459                             ValaCodeContext* context,
460                             ValaSourceFileType type,
461                             const gchar* filename,
462                             const gchar* content,
463                             gboolean cmdline)
464 {
465 	ValaSourceFile* self = NULL;
466 	g_return_val_if_fail (context != NULL, NULL);
467 	g_return_val_if_fail (filename != NULL, NULL);
468 	self = (ValaSourceFile*) g_type_create_instance (object_type);
469 	vala_source_file_set_context (self, context);
470 	vala_source_file_set_file_type (self, type);
471 	vala_source_file_set_filename (self, filename);
472 	vala_source_file_set_content (self, content);
473 	vala_source_file_set_from_commandline (self, cmdline);
474 	return self;
475 }
476 
477 ValaSourceFile*
vala_source_file_new(ValaCodeContext * context,ValaSourceFileType type,const gchar * filename,const gchar * content,gboolean cmdline)478 vala_source_file_new (ValaCodeContext* context,
479                       ValaSourceFileType type,
480                       const gchar* filename,
481                       const gchar* content,
482                       gboolean cmdline)
483 {
484 	return vala_source_file_construct (VALA_TYPE_SOURCE_FILE, context, type, filename, content, cmdline);
485 }
486 
487 /**
488  * Adds a header comment to this source file.
489  */
490 void
vala_source_file_add_comment(ValaSourceFile * self,ValaComment * comment)491 vala_source_file_add_comment (ValaSourceFile* self,
492                               ValaComment* comment)
493 {
494 	ValaArrayList* _tmp0_;
495 	g_return_if_fail (self != NULL);
496 	g_return_if_fail (comment != NULL);
497 	_tmp0_ = self->priv->comments;
498 	vala_collection_add ((ValaCollection*) _tmp0_, comment);
499 }
500 
501 /**
502  * Returns the list of header comments.
503  *
504  * @return list of comments
505  */
506 ValaList*
vala_source_file_get_comments(ValaSourceFile * self)507 vala_source_file_get_comments (ValaSourceFile* self)
508 {
509 	ValaArrayList* _tmp0_;
510 	ValaList* result = NULL;
511 	g_return_val_if_fail (self != NULL, NULL);
512 	_tmp0_ = self->priv->comments;
513 	result = (ValaList*) _tmp0_;
514 	return result;
515 }
516 
517 /**
518  * Adds a new using directive with the specified namespace.
519  *
520  * @param ns reference to namespace
521  */
522 void
vala_source_file_add_using_directive(ValaSourceFile * self,ValaUsingDirective * ns)523 vala_source_file_add_using_directive (ValaSourceFile* self,
524                                       ValaUsingDirective* ns)
525 {
526 	ValaList* old_using_directives = NULL;
527 	ValaList* _tmp0_;
528 	ValaList* _tmp1_;
529 	GEqualFunc _tmp2_;
530 	ValaArrayList* _tmp3_;
531 	ValaArrayList* _tmp4_;
532 	ValaList* _tmp16_;
533 	g_return_if_fail (self != NULL);
534 	g_return_if_fail (ns != NULL);
535 	_tmp0_ = self->priv->_current_using_directives;
536 	_tmp1_ = _vala_iterable_ref0 (_tmp0_);
537 	old_using_directives = _tmp1_;
538 	_tmp2_ = g_direct_equal;
539 	_tmp3_ = vala_array_list_new (VALA_TYPE_USING_DIRECTIVE, (GBoxedCopyFunc) vala_code_node_ref, (GDestroyNotify) vala_code_node_unref, _tmp2_);
540 	_tmp4_ = _tmp3_;
541 	vala_source_file_set_current_using_directives (self, (ValaList*) _tmp4_);
542 	_vala_iterable_unref0 (_tmp4_);
543 	{
544 		ValaList* _using_directive_list = NULL;
545 		ValaList* _tmp5_;
546 		ValaList* _tmp6_;
547 		gint _using_directive_size = 0;
548 		ValaList* _tmp7_;
549 		gint _tmp8_;
550 		gint _tmp9_;
551 		gint _using_directive_index = 0;
552 		_tmp5_ = old_using_directives;
553 		_tmp6_ = _vala_iterable_ref0 (_tmp5_);
554 		_using_directive_list = _tmp6_;
555 		_tmp7_ = _using_directive_list;
556 		_tmp8_ = vala_collection_get_size ((ValaCollection*) _tmp7_);
557 		_tmp9_ = _tmp8_;
558 		_using_directive_size = _tmp9_;
559 		_using_directive_index = -1;
560 		while (TRUE) {
561 			gint _tmp10_;
562 			gint _tmp11_;
563 			ValaUsingDirective* using_directive = NULL;
564 			ValaList* _tmp12_;
565 			gpointer _tmp13_;
566 			ValaList* _tmp14_;
567 			ValaUsingDirective* _tmp15_;
568 			_using_directive_index = _using_directive_index + 1;
569 			_tmp10_ = _using_directive_index;
570 			_tmp11_ = _using_directive_size;
571 			if (!(_tmp10_ < _tmp11_)) {
572 				break;
573 			}
574 			_tmp12_ = _using_directive_list;
575 			_tmp13_ = vala_list_get (_tmp12_, _using_directive_index);
576 			using_directive = (ValaUsingDirective*) _tmp13_;
577 			_tmp14_ = self->priv->_current_using_directives;
578 			_tmp15_ = using_directive;
579 			vala_collection_add ((ValaCollection*) _tmp14_, _tmp15_);
580 			_vala_code_node_unref0 (using_directive);
581 		}
582 		_vala_iterable_unref0 (_using_directive_list);
583 	}
584 	_tmp16_ = self->priv->_current_using_directives;
585 	vala_collection_add ((ValaCollection*) _tmp16_, ns);
586 	_vala_iterable_unref0 (old_using_directives);
587 }
588 
589 /**
590  * Adds the specified code node to this source file.
591  *
592  * @param node a code node
593  */
594 void
vala_source_file_add_node(ValaSourceFile * self,ValaCodeNode * node)595 vala_source_file_add_node (ValaSourceFile* self,
596                            ValaCodeNode* node)
597 {
598 	ValaList* _tmp0_;
599 	g_return_if_fail (self != NULL);
600 	g_return_if_fail (node != NULL);
601 	_tmp0_ = self->priv->nodes;
602 	vala_collection_add ((ValaCollection*) _tmp0_, node);
603 }
604 
605 void
vala_source_file_remove_node(ValaSourceFile * self,ValaCodeNode * node)606 vala_source_file_remove_node (ValaSourceFile* self,
607                               ValaCodeNode* node)
608 {
609 	ValaList* _tmp0_;
610 	g_return_if_fail (self != NULL);
611 	g_return_if_fail (node != NULL);
612 	_tmp0_ = self->priv->nodes;
613 	vala_collection_remove ((ValaCollection*) _tmp0_, node);
614 }
615 
616 /**
617  * Returns the list of code nodes.
618  *
619  * @return code node list
620  */
621 ValaList*
vala_source_file_get_nodes(ValaSourceFile * self)622 vala_source_file_get_nodes (ValaSourceFile* self)
623 {
624 	ValaList* _tmp0_;
625 	ValaList* result = NULL;
626 	g_return_val_if_fail (self != NULL, NULL);
627 	_tmp0_ = self->priv->nodes;
628 	result = _tmp0_;
629 	return result;
630 }
631 
632 void
vala_source_file_accept(ValaSourceFile * self,ValaCodeVisitor * visitor)633 vala_source_file_accept (ValaSourceFile* self,
634                          ValaCodeVisitor* visitor)
635 {
636 	g_return_if_fail (self != NULL);
637 	g_return_if_fail (visitor != NULL);
638 	vala_code_visitor_visit_source_file (visitor, self);
639 }
640 
641 void
vala_source_file_accept_children(ValaSourceFile * self,ValaCodeVisitor * visitor)642 vala_source_file_accept_children (ValaSourceFile* self,
643                                   ValaCodeVisitor* visitor)
644 {
645 	g_return_if_fail (self != NULL);
646 	g_return_if_fail (visitor != NULL);
647 	{
648 		ValaList* _node_list = NULL;
649 		ValaList* _tmp0_;
650 		ValaList* _tmp1_;
651 		gint _node_size = 0;
652 		ValaList* _tmp2_;
653 		gint _tmp3_;
654 		gint _tmp4_;
655 		gint _node_index = 0;
656 		_tmp0_ = self->priv->nodes;
657 		_tmp1_ = _vala_iterable_ref0 (_tmp0_);
658 		_node_list = _tmp1_;
659 		_tmp2_ = _node_list;
660 		_tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
661 		_tmp4_ = _tmp3_;
662 		_node_size = _tmp4_;
663 		_node_index = -1;
664 		while (TRUE) {
665 			gint _tmp5_;
666 			gint _tmp6_;
667 			ValaCodeNode* node = NULL;
668 			ValaList* _tmp7_;
669 			gpointer _tmp8_;
670 			ValaCodeNode* _tmp9_;
671 			_node_index = _node_index + 1;
672 			_tmp5_ = _node_index;
673 			_tmp6_ = _node_size;
674 			if (!(_tmp5_ < _tmp6_)) {
675 				break;
676 			}
677 			_tmp7_ = _node_list;
678 			_tmp8_ = vala_list_get (_tmp7_, _node_index);
679 			node = (ValaCodeNode*) _tmp8_;
680 			_tmp9_ = node;
681 			vala_code_node_accept (_tmp9_, visitor);
682 			_vala_code_node_unref0 (node);
683 		}
684 		_vala_iterable_unref0 (_node_list);
685 	}
686 }
687 
688 static glong
string_strnlen(gchar * str,glong maxlen)689 string_strnlen (gchar* str,
690                 glong maxlen)
691 {
692 	gchar* end = NULL;
693 	gchar* _tmp0_;
694 	gchar* _tmp1_;
695 	glong result = 0L;
696 	_tmp0_ = memchr (str, 0, (gsize) maxlen);
697 	end = _tmp0_;
698 	_tmp1_ = end;
699 	if (_tmp1_ == NULL) {
700 		result = maxlen;
701 		return result;
702 	} else {
703 		gchar* _tmp2_;
704 		_tmp2_ = end;
705 		result = (glong) (_tmp2_ - str);
706 		return result;
707 	}
708 }
709 
710 static gchar*
string_substring(const gchar * self,glong offset,glong len)711 string_substring (const gchar* self,
712                   glong offset,
713                   glong len)
714 {
715 	glong string_length = 0L;
716 	gboolean _tmp0_ = FALSE;
717 	gchar* _tmp3_;
718 	gchar* result = NULL;
719 	g_return_val_if_fail (self != NULL, NULL);
720 	if (offset >= ((glong) 0)) {
721 		_tmp0_ = len >= ((glong) 0);
722 	} else {
723 		_tmp0_ = FALSE;
724 	}
725 	if (_tmp0_) {
726 		string_length = string_strnlen ((gchar*) self, offset + len);
727 	} else {
728 		gint _tmp1_;
729 		gint _tmp2_;
730 		_tmp1_ = strlen (self);
731 		_tmp2_ = _tmp1_;
732 		string_length = (glong) _tmp2_;
733 	}
734 	if (offset < ((glong) 0)) {
735 		offset = string_length + offset;
736 		g_return_val_if_fail (offset >= ((glong) 0), NULL);
737 	} else {
738 		g_return_val_if_fail (offset <= string_length, NULL);
739 	}
740 	if (len < ((glong) 0)) {
741 		len = string_length - offset;
742 	}
743 	g_return_val_if_fail ((offset + len) <= string_length, NULL);
744 	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
745 	result = _tmp3_;
746 	return result;
747 }
748 
749 static gchar
string_get(const gchar * self,glong index)750 string_get (const gchar* self,
751             glong index)
752 {
753 	gchar _tmp0_;
754 	gchar result = '\0';
755 	g_return_val_if_fail (self != NULL, '\0');
756 	_tmp0_ = ((gchar*) self)[index];
757 	result = _tmp0_;
758 	return result;
759 }
760 
761 static gchar*
vala_source_file_get_subdir(ValaSourceFile * self)762 vala_source_file_get_subdir (ValaSourceFile* self)
763 {
764 	ValaCodeContext* _tmp0_;
765 	const gchar* _tmp1_;
766 	const gchar* _tmp2_;
767 	const gchar* _tmp4_;
768 	ValaCodeContext* _tmp5_;
769 	const gchar* _tmp6_;
770 	const gchar* _tmp7_;
771 	gchar* _tmp8_;
772 	gchar* _tmp9_;
773 	gboolean _tmp10_;
774 	gchar* _tmp34_;
775 	gchar* result = NULL;
776 	g_return_val_if_fail (self != NULL, NULL);
777 	_tmp0_ = self->priv->_context;
778 	_tmp1_ = vala_code_context_get_basedir (_tmp0_);
779 	_tmp2_ = _tmp1_;
780 	if (_tmp2_ == NULL) {
781 		gchar* _tmp3_;
782 		_tmp3_ = g_strdup ("");
783 		result = _tmp3_;
784 		return result;
785 	}
786 	_tmp4_ = self->priv->_filename;
787 	_tmp5_ = self->priv->_context;
788 	_tmp6_ = vala_code_context_get_basedir (_tmp5_);
789 	_tmp7_ = _tmp6_;
790 	_tmp8_ = g_strconcat (_tmp7_, "/", NULL);
791 	_tmp9_ = _tmp8_;
792 	_tmp10_ = g_str_has_prefix (_tmp4_, _tmp9_);
793 	_g_free0 (_tmp9_);
794 	if (_tmp10_) {
795 		gchar* basename = NULL;
796 		const gchar* _tmp11_;
797 		gchar* _tmp12_;
798 		gchar* subdir = NULL;
799 		const gchar* _tmp13_;
800 		ValaCodeContext* _tmp14_;
801 		const gchar* _tmp15_;
802 		const gchar* _tmp16_;
803 		gint _tmp17_;
804 		gint _tmp18_;
805 		const gchar* _tmp19_;
806 		gint _tmp20_;
807 		gint _tmp21_;
808 		ValaCodeContext* _tmp22_;
809 		const gchar* _tmp23_;
810 		const gchar* _tmp24_;
811 		gint _tmp25_;
812 		gint _tmp26_;
813 		const gchar* _tmp27_;
814 		gint _tmp28_;
815 		gint _tmp29_;
816 		gchar* _tmp30_;
817 		_tmp11_ = self->priv->_filename;
818 		_tmp12_ = g_path_get_basename (_tmp11_);
819 		basename = _tmp12_;
820 		_tmp13_ = self->priv->_filename;
821 		_tmp14_ = self->priv->_context;
822 		_tmp15_ = vala_code_context_get_basedir (_tmp14_);
823 		_tmp16_ = _tmp15_;
824 		_tmp17_ = strlen (_tmp16_);
825 		_tmp18_ = _tmp17_;
826 		_tmp19_ = self->priv->_filename;
827 		_tmp20_ = strlen (_tmp19_);
828 		_tmp21_ = _tmp20_;
829 		_tmp22_ = self->priv->_context;
830 		_tmp23_ = vala_code_context_get_basedir (_tmp22_);
831 		_tmp24_ = _tmp23_;
832 		_tmp25_ = strlen (_tmp24_);
833 		_tmp26_ = _tmp25_;
834 		_tmp27_ = basename;
835 		_tmp28_ = strlen (_tmp27_);
836 		_tmp29_ = _tmp28_;
837 		_tmp30_ = string_substring (_tmp13_, (glong) _tmp18_, (glong) ((_tmp21_ - _tmp26_) - _tmp29_));
838 		subdir = _tmp30_;
839 		while (TRUE) {
840 			const gchar* _tmp31_;
841 			const gchar* _tmp32_;
842 			gchar* _tmp33_;
843 			_tmp31_ = subdir;
844 			if (!(string_get (_tmp31_, (glong) 0) == '/')) {
845 				break;
846 			}
847 			_tmp32_ = subdir;
848 			_tmp33_ = string_substring (_tmp32_, (glong) 1, (glong) -1);
849 			_g_free0 (subdir);
850 			subdir = _tmp33_;
851 		}
852 		result = subdir;
853 		_g_free0 (basename);
854 		return result;
855 	}
856 	_tmp34_ = g_strdup ("");
857 	result = _tmp34_;
858 	return result;
859 }
860 
861 static gchar*
vala_source_file_get_destination_directory(ValaSourceFile * self)862 vala_source_file_get_destination_directory (ValaSourceFile* self)
863 {
864 	ValaCodeContext* _tmp0_;
865 	const gchar* _tmp1_;
866 	const gchar* _tmp2_;
867 	ValaCodeContext* _tmp4_;
868 	const gchar* _tmp5_;
869 	const gchar* _tmp6_;
870 	gchar* _tmp7_;
871 	gchar* _tmp8_;
872 	gchar* _tmp9_;
873 	gchar* _tmp10_;
874 	gchar* result = NULL;
875 	g_return_val_if_fail (self != NULL, NULL);
876 	_tmp0_ = self->priv->_context;
877 	_tmp1_ = vala_code_context_get_directory (_tmp0_);
878 	_tmp2_ = _tmp1_;
879 	if (_tmp2_ == NULL) {
880 		gchar* _tmp3_;
881 		_tmp3_ = vala_source_file_get_subdir (self);
882 		result = _tmp3_;
883 		return result;
884 	}
885 	_tmp4_ = self->priv->_context;
886 	_tmp5_ = vala_code_context_get_directory (_tmp4_);
887 	_tmp6_ = _tmp5_;
888 	_tmp7_ = vala_source_file_get_subdir (self);
889 	_tmp8_ = _tmp7_;
890 	_tmp9_ = g_build_path ("/", _tmp6_, _tmp8_, NULL);
891 	_tmp10_ = _tmp9_;
892 	_g_free0 (_tmp8_);
893 	result = _tmp10_;
894 	return result;
895 }
896 
897 static gchar*
vala_source_file_get_basename(ValaSourceFile * self)898 vala_source_file_get_basename (ValaSourceFile* self)
899 {
900 	gint dot = 0;
901 	const gchar* _tmp0_;
902 	const gchar* _tmp1_;
903 	gchar* _tmp2_;
904 	gchar* _tmp3_;
905 	gchar* _tmp4_;
906 	gchar* _tmp5_;
907 	gchar* result = NULL;
908 	g_return_val_if_fail (self != NULL, NULL);
909 	_tmp0_ = self->priv->_filename;
910 	dot = string_last_index_of_char (_tmp0_, (gunichar) '.', 0);
911 	_tmp1_ = self->priv->_filename;
912 	_tmp2_ = string_substring (_tmp1_, (glong) 0, (glong) dot);
913 	_tmp3_ = _tmp2_;
914 	_tmp4_ = g_path_get_basename (_tmp3_);
915 	_tmp5_ = _tmp4_;
916 	_g_free0 (_tmp3_);
917 	result = _tmp5_;
918 	return result;
919 }
920 
921 gchar*
vala_source_file_get_relative_filename(ValaSourceFile * self)922 vala_source_file_get_relative_filename (ValaSourceFile* self)
923 {
924 	const gchar* _tmp0_;
925 	gchar* result = NULL;
926 	g_return_val_if_fail (self != NULL, NULL);
927 	_tmp0_ = self->priv->_relative_filename;
928 	if (_tmp0_ != NULL) {
929 		const gchar* _tmp1_;
930 		gchar* _tmp2_;
931 		_tmp1_ = self->priv->_relative_filename;
932 		_tmp2_ = g_strdup (_tmp1_);
933 		result = _tmp2_;
934 		return result;
935 	} else {
936 		const gchar* _tmp3_;
937 		gchar* _tmp4_;
938 		_tmp3_ = self->priv->_filename;
939 		_tmp4_ = g_path_get_basename (_tmp3_);
940 		result = _tmp4_;
941 		return result;
942 	}
943 }
944 
945 /**
946  * Returns the filename to use when generating C source files.
947  *
948  * @return generated C source filename
949  */
950 gchar*
vala_source_file_get_csource_filename(ValaSourceFile * self)951 vala_source_file_get_csource_filename (ValaSourceFile* self)
952 {
953 	const gchar* _tmp0_;
954 	const gchar* _tmp29_;
955 	gchar* _tmp30_;
956 	gchar* result = NULL;
957 	g_return_val_if_fail (self != NULL, NULL);
958 	_tmp0_ = self->priv->csource_filename;
959 	if (_tmp0_ == NULL) {
960 		ValaCodeContext* _tmp1_;
961 		gboolean _tmp2_;
962 		gboolean _tmp3_;
963 		_tmp1_ = self->priv->_context;
964 		_tmp2_ = vala_code_context_get_run_output (_tmp1_);
965 		_tmp3_ = _tmp2_;
966 		if (_tmp3_) {
967 			ValaCodeContext* _tmp4_;
968 			const gchar* _tmp5_;
969 			const gchar* _tmp6_;
970 			gchar* _tmp7_;
971 			_tmp4_ = self->priv->_context;
972 			_tmp5_ = vala_code_context_get_output (_tmp4_);
973 			_tmp6_ = _tmp5_;
974 			_tmp7_ = g_strconcat (_tmp6_, ".c", NULL);
975 			_g_free0 (self->priv->csource_filename);
976 			self->priv->csource_filename = _tmp7_;
977 		} else {
978 			gboolean _tmp8_ = FALSE;
979 			ValaCodeContext* _tmp9_;
980 			gboolean _tmp10_;
981 			gboolean _tmp11_;
982 			_tmp9_ = self->priv->_context;
983 			_tmp10_ = vala_code_context_get_ccode_only (_tmp9_);
984 			_tmp11_ = _tmp10_;
985 			if (_tmp11_) {
986 				_tmp8_ = TRUE;
987 			} else {
988 				ValaCodeContext* _tmp12_;
989 				gboolean _tmp13_;
990 				gboolean _tmp14_;
991 				_tmp12_ = self->priv->_context;
992 				_tmp13_ = vala_code_context_get_save_csources (_tmp12_);
993 				_tmp14_ = _tmp13_;
994 				_tmp8_ = _tmp14_;
995 			}
996 			if (_tmp8_) {
997 				gchar* _tmp15_;
998 				gchar* _tmp16_;
999 				gchar* _tmp17_;
1000 				gchar* _tmp18_;
1001 				gchar* _tmp19_;
1002 				gchar* _tmp20_;
1003 				gchar* _tmp21_;
1004 				_tmp15_ = vala_source_file_get_destination_directory (self);
1005 				_tmp16_ = _tmp15_;
1006 				_tmp17_ = vala_source_file_get_basename (self);
1007 				_tmp18_ = _tmp17_;
1008 				_tmp19_ = g_strconcat (_tmp18_, ".c", NULL);
1009 				_tmp20_ = _tmp19_;
1010 				_tmp21_ = g_build_path ("/", _tmp16_, _tmp20_, NULL);
1011 				_g_free0 (self->priv->csource_filename);
1012 				self->priv->csource_filename = _tmp21_;
1013 				_g_free0 (_tmp20_);
1014 				_g_free0 (_tmp18_);
1015 				_g_free0 (_tmp16_);
1016 			} else {
1017 				gchar* _tmp22_;
1018 				gchar* _tmp23_;
1019 				gchar* _tmp24_;
1020 				gchar* _tmp25_;
1021 				gchar* _tmp26_;
1022 				gchar* _tmp27_;
1023 				gchar* _tmp28_;
1024 				_tmp22_ = vala_source_file_get_destination_directory (self);
1025 				_tmp23_ = _tmp22_;
1026 				_tmp24_ = vala_source_file_get_basename (self);
1027 				_tmp25_ = _tmp24_;
1028 				_tmp26_ = g_strconcat (_tmp25_, ".vala.c", NULL);
1029 				_tmp27_ = _tmp26_;
1030 				_tmp28_ = g_build_path ("/", _tmp23_, _tmp27_, NULL);
1031 				_g_free0 (self->priv->csource_filename);
1032 				self->priv->csource_filename = _tmp28_;
1033 				_g_free0 (_tmp27_);
1034 				_g_free0 (_tmp25_);
1035 				_g_free0 (_tmp23_);
1036 			}
1037 		}
1038 	}
1039 	_tmp29_ = self->priv->csource_filename;
1040 	_tmp30_ = g_strdup (_tmp29_);
1041 	result = _tmp30_;
1042 	return result;
1043 }
1044 
1045 /**
1046  * Returns the filename to use when including the generated C header
1047  * file.
1048  *
1049  * @return C header filename to include
1050  */
1051 gchar*
vala_source_file_get_cinclude_filename(ValaSourceFile * self)1052 vala_source_file_get_cinclude_filename (ValaSourceFile* self)
1053 {
1054 	const gchar* _tmp0_;
1055 	const gchar* _tmp23_;
1056 	gchar* _tmp24_;
1057 	gchar* result = NULL;
1058 	g_return_val_if_fail (self != NULL, NULL);
1059 	_tmp0_ = self->priv->cinclude_filename;
1060 	if (_tmp0_ == NULL) {
1061 		ValaCodeContext* _tmp1_;
1062 		const gchar* _tmp2_;
1063 		const gchar* _tmp3_;
1064 		_tmp1_ = self->priv->_context;
1065 		_tmp2_ = vala_code_context_get_header_filename (_tmp1_);
1066 		_tmp3_ = _tmp2_;
1067 		if (_tmp3_ != NULL) {
1068 			ValaCodeContext* _tmp4_;
1069 			const gchar* _tmp5_;
1070 			const gchar* _tmp6_;
1071 			gchar* _tmp7_;
1072 			ValaCodeContext* _tmp8_;
1073 			const gchar* _tmp9_;
1074 			const gchar* _tmp10_;
1075 			_tmp4_ = self->priv->_context;
1076 			_tmp5_ = vala_code_context_get_header_filename (_tmp4_);
1077 			_tmp6_ = _tmp5_;
1078 			_tmp7_ = g_path_get_basename (_tmp6_);
1079 			_g_free0 (self->priv->cinclude_filename);
1080 			self->priv->cinclude_filename = _tmp7_;
1081 			_tmp8_ = self->priv->_context;
1082 			_tmp9_ = vala_code_context_get_includedir (_tmp8_);
1083 			_tmp10_ = _tmp9_;
1084 			if (_tmp10_ != NULL) {
1085 				ValaCodeContext* _tmp11_;
1086 				const gchar* _tmp12_;
1087 				const gchar* _tmp13_;
1088 				const gchar* _tmp14_;
1089 				gchar* _tmp15_;
1090 				_tmp11_ = self->priv->_context;
1091 				_tmp12_ = vala_code_context_get_includedir (_tmp11_);
1092 				_tmp13_ = _tmp12_;
1093 				_tmp14_ = self->priv->cinclude_filename;
1094 				_tmp15_ = g_build_path ("/", _tmp13_, _tmp14_, NULL);
1095 				_g_free0 (self->priv->cinclude_filename);
1096 				self->priv->cinclude_filename = _tmp15_;
1097 			}
1098 		} else {
1099 			gchar* _tmp16_;
1100 			gchar* _tmp17_;
1101 			gchar* _tmp18_;
1102 			gchar* _tmp19_;
1103 			gchar* _tmp20_;
1104 			gchar* _tmp21_;
1105 			gchar* _tmp22_;
1106 			_tmp16_ = vala_source_file_get_subdir (self);
1107 			_tmp17_ = _tmp16_;
1108 			_tmp18_ = vala_source_file_get_basename (self);
1109 			_tmp19_ = _tmp18_;
1110 			_tmp20_ = g_strconcat (_tmp19_, ".h", NULL);
1111 			_tmp21_ = _tmp20_;
1112 			_tmp22_ = g_build_path ("/", _tmp17_, _tmp21_, NULL);
1113 			_g_free0 (self->priv->cinclude_filename);
1114 			self->priv->cinclude_filename = _tmp22_;
1115 			_g_free0 (_tmp21_);
1116 			_g_free0 (_tmp19_);
1117 			_g_free0 (_tmp17_);
1118 		}
1119 	}
1120 	_tmp23_ = self->priv->cinclude_filename;
1121 	_tmp24_ = g_strdup (_tmp23_);
1122 	result = _tmp24_;
1123 	return result;
1124 }
1125 
1126 /**
1127  * Returns the requested line from this file, loading it if needed.
1128  *
1129  * @param lineno 1-based line number
1130  * @return       the specified source line
1131  */
1132 gchar*
vala_source_file_get_source_line(ValaSourceFile * self,gint lineno)1133 vala_source_file_get_source_line (ValaSourceFile* self,
1134                                   gint lineno)
1135 {
1136 	ValaArrayList* _tmp0_;
1137 	gboolean _tmp5_ = FALSE;
1138 	ValaArrayList* _tmp9_;
1139 	gpointer _tmp10_;
1140 	gchar* result = NULL;
1141 	g_return_val_if_fail (self != NULL, NULL);
1142 	_tmp0_ = self->priv->source_array;
1143 	if (_tmp0_ == NULL) {
1144 		const gchar* _tmp1_;
1145 		const gchar* _tmp2_;
1146 		_tmp1_ = vala_source_file_get_content (self);
1147 		_tmp2_ = _tmp1_;
1148 		if (_tmp2_ != NULL) {
1149 			const gchar* _tmp3_;
1150 			const gchar* _tmp4_;
1151 			_tmp3_ = vala_source_file_get_content (self);
1152 			_tmp4_ = _tmp3_;
1153 			vala_source_file_read_source_lines (self, _tmp4_);
1154 		} else {
1155 			vala_source_file_read_source_file (self);
1156 		}
1157 	}
1158 	if (lineno < 1) {
1159 		_tmp5_ = TRUE;
1160 	} else {
1161 		ValaArrayList* _tmp6_;
1162 		gint _tmp7_;
1163 		gint _tmp8_;
1164 		_tmp6_ = self->priv->source_array;
1165 		_tmp7_ = vala_collection_get_size ((ValaCollection*) _tmp6_);
1166 		_tmp8_ = _tmp7_;
1167 		_tmp5_ = lineno > _tmp8_;
1168 	}
1169 	if (_tmp5_) {
1170 		result = NULL;
1171 		return result;
1172 	}
1173 	_tmp9_ = self->priv->source_array;
1174 	_tmp10_ = vala_list_get ((ValaList*) _tmp9_, lineno - 1);
1175 	result = (gchar*) _tmp10_;
1176 	return result;
1177 }
1178 
1179 /**
1180  * Parses the input file into ::source_array.
1181  */
1182 static void
vala_source_file_read_source_file(ValaSourceFile * self)1183 vala_source_file_read_source_file (ValaSourceFile* self)
1184 {
1185 	gchar* cont = NULL;
1186 	const gchar* _tmp2_;
1187 	GError* _inner_error0_ = NULL;
1188 	g_return_if_fail (self != NULL);
1189 	{
1190 		const gchar* _tmp0_;
1191 		gchar* _tmp1_ = NULL;
1192 		_tmp0_ = self->priv->_filename;
1193 		g_file_get_contents (_tmp0_, &_tmp1_, NULL, &_inner_error0_);
1194 		_g_free0 (cont);
1195 		cont = _tmp1_;
1196 		if (G_UNLIKELY (_inner_error0_ != NULL)) {
1197 			if (_inner_error0_->domain == G_FILE_ERROR) {
1198 				goto __catch0_g_file_error;
1199 			}
1200 			_g_free0 (cont);
1201 			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
1202 			g_clear_error (&_inner_error0_);
1203 			return;
1204 		}
1205 	}
1206 	goto __finally0;
1207 	__catch0_g_file_error:
1208 	{
1209 		g_clear_error (&_inner_error0_);
1210 		_g_free0 (cont);
1211 		return;
1212 	}
1213 	__finally0:
1214 	if (G_UNLIKELY (_inner_error0_ != NULL)) {
1215 		_g_free0 (cont);
1216 		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
1217 		g_clear_error (&_inner_error0_);
1218 		return;
1219 	}
1220 	_tmp2_ = cont;
1221 	vala_source_file_read_source_lines (self, _tmp2_);
1222 	_g_free0 (cont);
1223 }
1224 
1225 static void
vala_source_file_read_source_lines(ValaSourceFile * self,const gchar * cont)1226 vala_source_file_read_source_lines (ValaSourceFile* self,
1227                                     const gchar* cont)
1228 {
1229 	GEqualFunc _tmp0_;
1230 	ValaArrayList* _tmp1_;
1231 	gchar** lines = NULL;
1232 	gchar** _tmp2_;
1233 	gchar** _tmp3_;
1234 	gint lines_length1;
1235 	gint _lines_size_;
1236 	gint idx = 0;
1237 	g_return_if_fail (self != NULL);
1238 	g_return_if_fail (cont != NULL);
1239 	_tmp0_ = g_direct_equal;
1240 	_tmp1_ = vala_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp0_);
1241 	_vala_iterable_unref0 (self->priv->source_array);
1242 	self->priv->source_array = _tmp1_;
1243 	_tmp3_ = _tmp2_ = g_strsplit (cont, "\n", 0);
1244 	lines = _tmp3_;
1245 	lines_length1 = _vala_array_length (_tmp2_);
1246 	_lines_size_ = lines_length1;
1247 	{
1248 		gboolean _tmp4_ = FALSE;
1249 		idx = 0;
1250 		_tmp4_ = TRUE;
1251 		while (TRUE) {
1252 			gchar** _tmp6_;
1253 			gint _tmp6__length1;
1254 			const gchar* _tmp7_;
1255 			ValaArrayList* _tmp8_;
1256 			gchar** _tmp9_;
1257 			gint _tmp9__length1;
1258 			const gchar* _tmp10_;
1259 			if (!_tmp4_) {
1260 				gint _tmp5_;
1261 				idx = idx + 1;
1262 				_tmp5_ = idx;
1263 			}
1264 			_tmp4_ = FALSE;
1265 			_tmp6_ = lines;
1266 			_tmp6__length1 = lines_length1;
1267 			_tmp7_ = _tmp6_[idx];
1268 			if (!(_tmp7_ != NULL)) {
1269 				break;
1270 			}
1271 			_tmp8_ = self->priv->source_array;
1272 			_tmp9_ = lines;
1273 			_tmp9__length1 = lines_length1;
1274 			_tmp10_ = _tmp9_[idx];
1275 			vala_collection_add ((ValaCollection*) _tmp8_, _tmp10_);
1276 		}
1277 	}
1278 	lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
1279 }
1280 
1281 gchar*
vala_source_file_get_mapped_contents(ValaSourceFile * self)1282 vala_source_file_get_mapped_contents (ValaSourceFile* self)
1283 {
1284 	const gchar* _tmp0_;
1285 	const gchar* _tmp1_;
1286 	GMappedFile* _tmp4_;
1287 	GMappedFile* _tmp14_;
1288 	gchar* _tmp15_;
1289 	GError* _inner_error0_ = NULL;
1290 	gchar* result = NULL;
1291 	g_return_val_if_fail (self != NULL, NULL);
1292 	_tmp0_ = vala_source_file_get_content (self);
1293 	_tmp1_ = _tmp0_;
1294 	if (_tmp1_ != NULL) {
1295 		const gchar* _tmp2_;
1296 		const gchar* _tmp3_;
1297 		_tmp2_ = vala_source_file_get_content (self);
1298 		_tmp3_ = _tmp2_;
1299 		result = (gchar*) _tmp3_;
1300 		return result;
1301 	}
1302 	_tmp4_ = self->priv->mapped_file;
1303 	if (_tmp4_ == NULL) {
1304 		{
1305 			GMappedFile* _tmp5_ = NULL;
1306 			const gchar* _tmp6_;
1307 			GMappedFile* _tmp7_;
1308 			GMappedFile* _tmp8_;
1309 			_tmp6_ = self->priv->_filename;
1310 			_tmp7_ = g_mapped_file_new (_tmp6_, FALSE, &_inner_error0_);
1311 			_tmp5_ = _tmp7_;
1312 			if (G_UNLIKELY (_inner_error0_ != NULL)) {
1313 				if (_inner_error0_->domain == G_FILE_ERROR) {
1314 					goto __catch0_g_file_error;
1315 				}
1316 				g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
1317 				g_clear_error (&_inner_error0_);
1318 				return NULL;
1319 			}
1320 			_tmp8_ = _tmp5_;
1321 			_tmp5_ = NULL;
1322 			_g_mapped_file_unref0 (self->priv->mapped_file);
1323 			self->priv->mapped_file = _tmp8_;
1324 			_g_mapped_file_unref0 (_tmp5_);
1325 		}
1326 		goto __finally0;
1327 		__catch0_g_file_error:
1328 		{
1329 			GError* e = NULL;
1330 			const gchar* _tmp9_;
1331 			GError* _tmp10_;
1332 			const gchar* _tmp11_;
1333 			gchar* _tmp12_;
1334 			gchar* _tmp13_;
1335 			e = _inner_error0_;
1336 			_inner_error0_ = NULL;
1337 			_tmp9_ = self->priv->_filename;
1338 			_tmp10_ = e;
1339 			_tmp11_ = _tmp10_->message;
1340 			_tmp12_ = g_strdup_printf ("Unable to map file `%s': %s", _tmp9_, _tmp11_);
1341 			_tmp13_ = _tmp12_;
1342 			vala_report_error (NULL, _tmp13_);
1343 			_g_free0 (_tmp13_);
1344 			result = NULL;
1345 			_g_error_free0 (e);
1346 			return result;
1347 		}
1348 		__finally0:
1349 		if (G_UNLIKELY (_inner_error0_ != NULL)) {
1350 			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
1351 			g_clear_error (&_inner_error0_);
1352 			return NULL;
1353 		}
1354 	}
1355 	_tmp14_ = self->priv->mapped_file;
1356 	_tmp15_ = g_mapped_file_get_contents (_tmp14_);
1357 	result = _tmp15_;
1358 	return result;
1359 }
1360 
1361 gsize
vala_source_file_get_mapped_length(ValaSourceFile * self)1362 vala_source_file_get_mapped_length (ValaSourceFile* self)
1363 {
1364 	const gchar* _tmp0_;
1365 	const gchar* _tmp1_;
1366 	GMappedFile* _tmp6_;
1367 	gsize result = 0UL;
1368 	g_return_val_if_fail (self != NULL, 0UL);
1369 	_tmp0_ = vala_source_file_get_content (self);
1370 	_tmp1_ = _tmp0_;
1371 	if (_tmp1_ != NULL) {
1372 		const gchar* _tmp2_;
1373 		const gchar* _tmp3_;
1374 		gint _tmp4_;
1375 		gint _tmp5_;
1376 		_tmp2_ = vala_source_file_get_content (self);
1377 		_tmp3_ = _tmp2_;
1378 		_tmp4_ = strlen (_tmp3_);
1379 		_tmp5_ = _tmp4_;
1380 		result = (gsize) _tmp5_;
1381 		return result;
1382 	}
1383 	_tmp6_ = self->priv->mapped_file;
1384 	result = g_mapped_file_get_length (_tmp6_);
1385 	return result;
1386 }
1387 
1388 gboolean
vala_source_file_check(ValaSourceFile * self,ValaCodeContext * context)1389 vala_source_file_check (ValaSourceFile* self,
1390                         ValaCodeContext* context)
1391 {
1392 	gboolean result = FALSE;
1393 	g_return_val_if_fail (self != NULL, FALSE);
1394 	g_return_val_if_fail (context != NULL, FALSE);
1395 	{
1396 		ValaList* _node_list = NULL;
1397 		ValaList* _tmp0_;
1398 		ValaList* _tmp1_;
1399 		gint _node_size = 0;
1400 		ValaList* _tmp2_;
1401 		gint _tmp3_;
1402 		gint _tmp4_;
1403 		gint _node_index = 0;
1404 		_tmp0_ = self->priv->nodes;
1405 		_tmp1_ = _vala_iterable_ref0 (_tmp0_);
1406 		_node_list = _tmp1_;
1407 		_tmp2_ = _node_list;
1408 		_tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
1409 		_tmp4_ = _tmp3_;
1410 		_node_size = _tmp4_;
1411 		_node_index = -1;
1412 		while (TRUE) {
1413 			gint _tmp5_;
1414 			gint _tmp6_;
1415 			ValaCodeNode* node = NULL;
1416 			ValaList* _tmp7_;
1417 			gpointer _tmp8_;
1418 			ValaCodeNode* _tmp9_;
1419 			_node_index = _node_index + 1;
1420 			_tmp5_ = _node_index;
1421 			_tmp6_ = _node_size;
1422 			if (!(_tmp5_ < _tmp6_)) {
1423 				break;
1424 			}
1425 			_tmp7_ = _node_list;
1426 			_tmp8_ = vala_list_get (_tmp7_, _node_index);
1427 			node = (ValaCodeNode*) _tmp8_;
1428 			_tmp9_ = node;
1429 			vala_code_node_check (_tmp9_, context);
1430 			_vala_code_node_unref0 (node);
1431 		}
1432 		_vala_iterable_unref0 (_node_list);
1433 	}
1434 	result = TRUE;
1435 	return result;
1436 }
1437 
1438 static void
vala_value_source_file_init(GValue * value)1439 vala_value_source_file_init (GValue* value)
1440 {
1441 	value->data[0].v_pointer = NULL;
1442 }
1443 
1444 static void
vala_value_source_file_free_value(GValue * value)1445 vala_value_source_file_free_value (GValue* value)
1446 {
1447 	if (value->data[0].v_pointer) {
1448 		vala_source_file_unref (value->data[0].v_pointer);
1449 	}
1450 }
1451 
1452 static void
vala_value_source_file_copy_value(const GValue * src_value,GValue * dest_value)1453 vala_value_source_file_copy_value (const GValue* src_value,
1454                                    GValue* dest_value)
1455 {
1456 	if (src_value->data[0].v_pointer) {
1457 		dest_value->data[0].v_pointer = vala_source_file_ref (src_value->data[0].v_pointer);
1458 	} else {
1459 		dest_value->data[0].v_pointer = NULL;
1460 	}
1461 }
1462 
1463 static gpointer
vala_value_source_file_peek_pointer(const GValue * value)1464 vala_value_source_file_peek_pointer (const GValue* value)
1465 {
1466 	return value->data[0].v_pointer;
1467 }
1468 
1469 static gchar*
vala_value_source_file_collect_value(GValue * value,guint n_collect_values,GTypeCValue * collect_values,guint collect_flags)1470 vala_value_source_file_collect_value (GValue* value,
1471                                       guint n_collect_values,
1472                                       GTypeCValue* collect_values,
1473                                       guint collect_flags)
1474 {
1475 	if (collect_values[0].v_pointer) {
1476 		ValaSourceFile * object;
1477 		object = collect_values[0].v_pointer;
1478 		if (object->parent_instance.g_class == NULL) {
1479 			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
1480 		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
1481 			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
1482 		}
1483 		value->data[0].v_pointer = vala_source_file_ref (object);
1484 	} else {
1485 		value->data[0].v_pointer = NULL;
1486 	}
1487 	return NULL;
1488 }
1489 
1490 static gchar*
vala_value_source_file_lcopy_value(const GValue * value,guint n_collect_values,GTypeCValue * collect_values,guint collect_flags)1491 vala_value_source_file_lcopy_value (const GValue* value,
1492                                     guint n_collect_values,
1493                                     GTypeCValue* collect_values,
1494                                     guint collect_flags)
1495 {
1496 	ValaSourceFile ** object_p;
1497 	object_p = collect_values[0].v_pointer;
1498 	if (!object_p) {
1499 		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
1500 	}
1501 	if (!value->data[0].v_pointer) {
1502 		*object_p = NULL;
1503 	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
1504 		*object_p = value->data[0].v_pointer;
1505 	} else {
1506 		*object_p = vala_source_file_ref (value->data[0].v_pointer);
1507 	}
1508 	return NULL;
1509 }
1510 
1511 GParamSpec*
vala_param_spec_source_file(const gchar * name,const gchar * nick,const gchar * blurb,GType object_type,GParamFlags flags)1512 vala_param_spec_source_file (const gchar* name,
1513                              const gchar* nick,
1514                              const gchar* blurb,
1515                              GType object_type,
1516                              GParamFlags flags)
1517 {
1518 	ValaParamSpecSourceFile* spec;
1519 	g_return_val_if_fail (g_type_is_a (object_type, VALA_TYPE_SOURCE_FILE), NULL);
1520 	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
1521 	G_PARAM_SPEC (spec)->value_type = object_type;
1522 	return G_PARAM_SPEC (spec);
1523 }
1524 
1525 gpointer
vala_value_get_source_file(const GValue * value)1526 vala_value_get_source_file (const GValue* value)
1527 {
1528 	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALA_TYPE_SOURCE_FILE), NULL);
1529 	return value->data[0].v_pointer;
1530 }
1531 
1532 void
vala_value_set_source_file(GValue * value,gpointer v_object)1533 vala_value_set_source_file (GValue* value,
1534                             gpointer v_object)
1535 {
1536 	ValaSourceFile * old;
1537 	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALA_TYPE_SOURCE_FILE));
1538 	old = value->data[0].v_pointer;
1539 	if (v_object) {
1540 		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VALA_TYPE_SOURCE_FILE));
1541 		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
1542 		value->data[0].v_pointer = v_object;
1543 		vala_source_file_ref (value->data[0].v_pointer);
1544 	} else {
1545 		value->data[0].v_pointer = NULL;
1546 	}
1547 	if (old) {
1548 		vala_source_file_unref (old);
1549 	}
1550 }
1551 
1552 void
vala_value_take_source_file(GValue * value,gpointer v_object)1553 vala_value_take_source_file (GValue* value,
1554                              gpointer v_object)
1555 {
1556 	ValaSourceFile * old;
1557 	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALA_TYPE_SOURCE_FILE));
1558 	old = value->data[0].v_pointer;
1559 	if (v_object) {
1560 		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VALA_TYPE_SOURCE_FILE));
1561 		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
1562 		value->data[0].v_pointer = v_object;
1563 	} else {
1564 		value->data[0].v_pointer = NULL;
1565 	}
1566 	if (old) {
1567 		vala_source_file_unref (old);
1568 	}
1569 }
1570 
1571 static void
vala_source_file_class_init(ValaSourceFileClass * klass,gpointer klass_data)1572 vala_source_file_class_init (ValaSourceFileClass * klass,
1573                              gpointer klass_data)
1574 {
1575 	vala_source_file_parent_class = g_type_class_peek_parent (klass);
1576 	((ValaSourceFileClass *) klass)->finalize = vala_source_file_finalize;
1577 	g_type_class_adjust_private_offset (klass, &ValaSourceFile_private_offset);
1578 }
1579 
1580 static void
vala_source_file_instance_init(ValaSourceFile * self,gpointer klass)1581 vala_source_file_instance_init (ValaSourceFile * self,
1582                                 gpointer klass)
1583 {
1584 	GEqualFunc _tmp0_;
1585 	ValaArrayList* _tmp1_;
1586 	GEqualFunc _tmp2_;
1587 	ValaArrayList* _tmp3_;
1588 	GEqualFunc _tmp4_;
1589 	ValaArrayList* _tmp5_;
1590 	self->priv = vala_source_file_get_instance_private (self);
1591 	self->priv->_installed_version = NULL;
1592 	self->priv->_version_requested = FALSE;
1593 	_tmp0_ = g_direct_equal;
1594 	_tmp1_ = vala_array_list_new (VALA_TYPE_COMMENT, (GBoxedCopyFunc) vala_comment_ref, (GDestroyNotify) vala_comment_unref, _tmp0_);
1595 	self->priv->comments = _tmp1_;
1596 	_tmp2_ = g_direct_equal;
1597 	_tmp3_ = vala_array_list_new (VALA_TYPE_USING_DIRECTIVE, (GBoxedCopyFunc) vala_code_node_ref, (GDestroyNotify) vala_code_node_unref, _tmp2_);
1598 	self->priv->_current_using_directives = (ValaList*) _tmp3_;
1599 	_tmp4_ = g_direct_equal;
1600 	_tmp5_ = vala_array_list_new (VALA_TYPE_CODE_NODE, (GBoxedCopyFunc) vala_code_node_ref, (GDestroyNotify) vala_code_node_unref, _tmp4_);
1601 	self->priv->nodes = (ValaList*) _tmp5_;
1602 	self->priv->csource_filename = NULL;
1603 	self->priv->cinclude_filename = NULL;
1604 	self->priv->source_array = NULL;
1605 	self->priv->mapped_file = NULL;
1606 	self->priv->_content = NULL;
1607 	self->ref_count = 1;
1608 }
1609 
1610 static void
vala_source_file_finalize(ValaSourceFile * obj)1611 vala_source_file_finalize (ValaSourceFile * obj)
1612 {
1613 	ValaSourceFile * self;
1614 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_SOURCE_FILE, ValaSourceFile);
1615 	g_signal_handlers_destroy (self);
1616 	_g_free0 (self->priv->_filename);
1617 	_g_free0 (self->priv->_package_name);
1618 	_g_free0 (self->priv->_installed_version);
1619 	_g_free0 (self->priv->_gir_namespace);
1620 	_g_free0 (self->priv->_gir_version);
1621 	_vala_iterable_unref0 (self->priv->comments);
1622 	_vala_iterable_unref0 (self->priv->_current_using_directives);
1623 	_vala_iterable_unref0 (self->priv->nodes);
1624 	_g_free0 (self->priv->_relative_filename);
1625 	_g_free0 (self->priv->csource_filename);
1626 	_g_free0 (self->priv->cinclude_filename);
1627 	_vala_iterable_unref0 (self->priv->source_array);
1628 	_g_mapped_file_unref0 (self->priv->mapped_file);
1629 	_g_free0 (self->priv->_content);
1630 }
1631 
1632 /**
1633  * Represents a Vala source or VAPI package file.
1634  */
1635 static GType
vala_source_file_get_type_once(void)1636 vala_source_file_get_type_once (void)
1637 {
1638 	static const GTypeValueTable g_define_type_value_table = { vala_value_source_file_init, vala_value_source_file_free_value, vala_value_source_file_copy_value, vala_value_source_file_peek_pointer, "p", vala_value_source_file_collect_value, "p", vala_value_source_file_lcopy_value };
1639 	static const GTypeInfo g_define_type_info = { sizeof (ValaSourceFileClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_source_file_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaSourceFile), 0, (GInstanceInitFunc) vala_source_file_instance_init, &g_define_type_value_table };
1640 	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
1641 	GType vala_source_file_type_id;
1642 	vala_source_file_type_id = g_type_register_fundamental (g_type_fundamental_next (), "ValaSourceFile", &g_define_type_info, &g_define_type_fundamental_info, 0);
1643 	ValaSourceFile_private_offset = g_type_add_instance_private (vala_source_file_type_id, sizeof (ValaSourceFilePrivate));
1644 	return vala_source_file_type_id;
1645 }
1646 
1647 GType
vala_source_file_get_type(void)1648 vala_source_file_get_type (void)
1649 {
1650 	static volatile gsize vala_source_file_type_id__volatile = 0;
1651 	if (g_once_init_enter (&vala_source_file_type_id__volatile)) {
1652 		GType vala_source_file_type_id;
1653 		vala_source_file_type_id = vala_source_file_get_type_once ();
1654 		g_once_init_leave (&vala_source_file_type_id__volatile, vala_source_file_type_id);
1655 	}
1656 	return vala_source_file_type_id__volatile;
1657 }
1658 
1659 gpointer
vala_source_file_ref(gpointer instance)1660 vala_source_file_ref (gpointer instance)
1661 {
1662 	ValaSourceFile * self;
1663 	self = instance;
1664 	g_atomic_int_inc (&self->ref_count);
1665 	return instance;
1666 }
1667 
1668 void
vala_source_file_unref(gpointer instance)1669 vala_source_file_unref (gpointer instance)
1670 {
1671 	ValaSourceFile * self;
1672 	self = instance;
1673 	if (g_atomic_int_dec_and_test (&self->ref_count)) {
1674 		VALA_SOURCE_FILE_GET_CLASS (self)->finalize (self);
1675 		g_type_free_instance ((GTypeInstance *) self);
1676 	}
1677 }
1678 
1679 static GType
vala_source_file_type_get_type_once(void)1680 vala_source_file_type_get_type_once (void)
1681 {
1682 	static const GEnumValue values[] = {{VALA_SOURCE_FILE_TYPE_NONE, "VALA_SOURCE_FILE_TYPE_NONE", "none"}, {VALA_SOURCE_FILE_TYPE_SOURCE, "VALA_SOURCE_FILE_TYPE_SOURCE", "source"}, {VALA_SOURCE_FILE_TYPE_PACKAGE, "VALA_SOURCE_FILE_TYPE_PACKAGE", "package"}, {VALA_SOURCE_FILE_TYPE_FAST, "VALA_SOURCE_FILE_TYPE_FAST", "fast"}, {0, NULL, NULL}};
1683 	GType vala_source_file_type_type_id;
1684 	vala_source_file_type_type_id = g_enum_register_static ("ValaSourceFileType", values);
1685 	return vala_source_file_type_type_id;
1686 }
1687 
1688 GType
vala_source_file_type_get_type(void)1689 vala_source_file_type_get_type (void)
1690 {
1691 	static volatile gsize vala_source_file_type_type_id__volatile = 0;
1692 	if (g_once_init_enter (&vala_source_file_type_type_id__volatile)) {
1693 		GType vala_source_file_type_type_id;
1694 		vala_source_file_type_type_id = vala_source_file_type_get_type_once ();
1695 		g_once_init_leave (&vala_source_file_type_type_id__volatile, vala_source_file_type_type_id);
1696 	}
1697 	return vala_source_file_type_type_id__volatile;
1698 }
1699 
1700 static void
_vala_array_destroy(gpointer array,gint array_length,GDestroyNotify destroy_func)1701 _vala_array_destroy (gpointer array,
1702                      gint array_length,
1703                      GDestroyNotify destroy_func)
1704 {
1705 	if ((array != NULL) && (destroy_func != NULL)) {
1706 		gint i;
1707 		for (i = 0; i < array_length; i = i + 1) {
1708 			if (((gpointer*) array)[i] != NULL) {
1709 				destroy_func (((gpointer*) array)[i]);
1710 			}
1711 		}
1712 	}
1713 }
1714 
1715 static void
_vala_array_free(gpointer array,gint array_length,GDestroyNotify destroy_func)1716 _vala_array_free (gpointer array,
1717                   gint array_length,
1718                   GDestroyNotify destroy_func)
1719 {
1720 	_vala_array_destroy (array, array_length, destroy_func);
1721 	g_free (array);
1722 }
1723 
1724 static gint
_vala_array_length(gpointer array)1725 _vala_array_length (gpointer array)
1726 {
1727 	gint length;
1728 	length = 0;
1729 	if (array) {
1730 		while (((gpointer*) array)[length]) {
1731 			length++;
1732 		}
1733 	}
1734 	return length;
1735 }
1736 
1737