1 /* node.c generated by valac, the Vala compiler
2  * generated from node.vala, do not modify */
3 
4 /* node.vala
5  *
6  * Copyright (C) 2008-2009 Florian Brosch, Didier Villevalois
7  * Copyright (C) 2011 Florian Brosch
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
22  *
23  * Author:
24  * 	Didier 'Ptitjes Villevalois <ptitjes@free.fr>
25  */
26 
27 #include "valadoc.h"
28 #include <stdlib.h>
29 #include <string.h>
30 #include <glib.h>
31 #include <valagee.h>
32 #include <glib-object.h>
33 #include <vala.h>
34 
35 enum  {
36 	VALADOC_API_NODE_0_PROPERTY,
37 	VALADOC_API_NODE_NAME_PROPERTY,
38 	VALADOC_API_NODE_NODE_TYPE_PROPERTY,
39 	VALADOC_API_NODE_NSPACE_PROPERTY,
40 	VALADOC_API_NODE_PACKAGE_PROPERTY,
41 	VALADOC_API_NODE_DOCUMENTATION_PROPERTY,
42 	VALADOC_API_NODE_NUM_PROPERTIES
43 };
44 static GParamSpec* valadoc_api_node_properties[VALADOC_API_NODE_NUM_PROPERTIES];
45 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
46 #define _g_free0(var) (var = (g_free (var), NULL))
47 #define _vala_map_unref0(var) ((var == NULL) ? NULL : (var = (vala_map_unref (var), NULL)))
48 #define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
49 #define _vala_iterator_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterator_unref (var), NULL)))
50 #define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
51 
52 struct _ValadocApiNodePrivate {
53 	ValadocApiSourceFile* file;
54 	gchar* _name;
55 	ValaMap* per_name_children;
56 	ValaMap* per_type_children;
57 	ValadocApiNamespace* _nspace;
58 	ValadocApiPackage* _package;
59 	gchar* _full_name;
60 	ValadocContentComment* _documentation;
61 };
62 
63 static gint ValadocApiNode_private_offset;
64 static gpointer valadoc_api_node_parent_class = NULL;
65 static ValadocDocumentationIface * valadoc_api_node_valadoc_documentation_parent_iface = NULL;
66 
67 G_GNUC_INTERNAL void valadoc_api_item_parse_comments (ValadocApiItem* self,
68                                       ValadocSettings* settings,
69                                       ValadocDocumentationParser* parser);
70 G_GNUC_INTERNAL void valadoc_api_item_check_comments (ValadocApiItem* self,
71                                       ValadocSettings* settings,
72                                       ValadocDocumentationParser* parser);
73 static void valadoc_api_node_set_name (ValadocApiNode* self,
74                                 const gchar* value);
75 static void valadoc_api_node_real_accept (ValadocApiNode* self,
76                                    ValadocApiVisitor* visitor);
77 static gboolean valadoc_api_node_real_is_browsable (ValadocApiNode* self,
78                                              ValadocSettings* settings);
79 static gchar* valadoc_api_node_real_get_filename (ValadocDocumentation* base);
80 static void valadoc_api_node_real_parse_comments (ValadocApiItem* base,
81                                            ValadocSettings* settings,
82                                            ValadocDocumentationParser* parser);
83 static void valadoc_api_node_real_check_comments (ValadocApiItem* base,
84                                            ValadocSettings* settings,
85                                            ValadocDocumentationParser* parser);
86 G_GNUC_INTERNAL void valadoc_api_node_set_documentation (ValadocApiNode* self,
87                                          ValadocContentComment* value);
88 static void valadoc_api_node_finalize (GObject * obj);
89 static GType valadoc_api_node_get_type_once (void);
90 static void _vala_valadoc_api_node_get_property (GObject * object,
91                                           guint property_id,
92                                           GValue * value,
93                                           GParamSpec * pspec);
94 static void _vala_valadoc_api_node_set_property (GObject * object,
95                                           guint property_id,
96                                           const GValue * value,
97                                           GParamSpec * pspec);
98 
99 static inline gpointer
valadoc_api_node_get_instance_private(ValadocApiNode * self)100 valadoc_api_node_get_instance_private (ValadocApiNode* self)
101 {
102 	return G_STRUCT_MEMBER_P (self, ValadocApiNode_private_offset);
103 }
104 
105 const gchar*
valadoc_api_node_get_name(ValadocApiNode * self)106 valadoc_api_node_get_name (ValadocApiNode* self)
107 {
108 	const gchar* result;
109 	const gchar* _tmp0_;
110 	g_return_val_if_fail (self != NULL, NULL);
111 	_tmp0_ = self->priv->_name;
112 	result = _tmp0_;
113 	return result;
114 }
115 
116 static void
valadoc_api_node_set_name(ValadocApiNode * self,const gchar * value)117 valadoc_api_node_set_name (ValadocApiNode* self,
118                            const gchar* value)
119 {
120 	gchar* old_value;
121 	g_return_if_fail (self != NULL);
122 	old_value = valadoc_api_node_get_name (self);
123 	if (g_strcmp0 (value, old_value) != 0) {
124 		gchar* _tmp0_;
125 		_tmp0_ = g_strdup (value);
126 		_g_free0 (self->priv->_name);
127 		self->priv->_name = _tmp0_;
128 		g_object_notify_by_pspec ((GObject *) self, valadoc_api_node_properties[VALADOC_API_NODE_NAME_PROPERTY]);
129 	}
130 }
131 
132 static gpointer
_g_object_ref0(gpointer self)133 _g_object_ref0 (gpointer self)
134 {
135 	return self ? g_object_ref (self) : NULL;
136 }
137 
138 ValadocApiSourceFile*
valadoc_api_node_get_source_file(ValadocApiNode * self)139 valadoc_api_node_get_source_file (ValadocApiNode* self)
140 {
141 	ValadocApiSourceFile* _tmp0_;
142 	ValadocApiSourceFile* _tmp1_;
143 	ValadocApiSourceFile* result = NULL;
144 	g_return_val_if_fail (self != NULL, NULL);
145 	_tmp0_ = self->priv->file;
146 	_tmp1_ = _g_object_ref0 (_tmp0_);
147 	result = _tmp1_;
148 	return result;
149 }
150 
151 ValadocApiNodeType
valadoc_api_node_get_node_type(ValadocApiNode * self)152 valadoc_api_node_get_node_type (ValadocApiNode* self)
153 {
154 	g_return_val_if_fail (self != NULL, 0);
155 	return VALADOC_API_NODE_GET_CLASS (self)->get_node_type (self);
156 }
157 
158 static gchar
string_get(const gchar * self,glong index)159 string_get (const gchar* self,
160             glong index)
161 {
162 	gchar _tmp0_;
163 	gchar result = '\0';
164 	g_return_val_if_fail (self != NULL, '\0');
165 	_tmp0_ = ((gchar*) self)[index];
166 	result = _tmp0_;
167 	return result;
168 }
169 
170 ValadocApiNode*
valadoc_api_node_construct(GType object_type,ValadocApiNode * parent,ValadocApiSourceFile * file,const gchar * name,ValaCodeNode * data)171 valadoc_api_node_construct (GType object_type,
172                             ValadocApiNode* parent,
173                             ValadocApiSourceFile* file,
174                             const gchar* name,
175                             ValaCodeNode* data)
176 {
177 	ValadocApiNode * self = NULL;
178 	GHashFunc _tmp0_;
179 	GEqualFunc _tmp1_;
180 	GEqualFunc _tmp2_;
181 	ValaHashMap* _tmp3_;
182 	GHashFunc _tmp4_;
183 	GEqualFunc _tmp5_;
184 	GEqualFunc _tmp6_;
185 	ValaHashMap* _tmp7_;
186 	gboolean _tmp8_ = FALSE;
187 	ValadocApiSourceFile* _tmp14_;
188 	self = (ValadocApiNode*) valadoc_api_item_construct (object_type, data);
189 	_tmp0_ = g_str_hash;
190 	_tmp1_ = g_str_equal;
191 	_tmp2_ = g_direct_equal;
192 	_tmp3_ = vala_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, VALADOC_API_TYPE_NODE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp0_, _tmp1_, _tmp2_);
193 	_vala_map_unref0 (self->priv->per_name_children);
194 	self->priv->per_name_children = (ValaMap*) _tmp3_;
195 	_tmp4_ = g_direct_hash;
196 	_tmp5_ = g_direct_equal;
197 	_tmp6_ = g_direct_equal;
198 	_tmp7_ = vala_hash_map_new (VALADOC_API_TYPE_NODE_TYPE, NULL, NULL, VALA_TYPE_LIST, (GBoxedCopyFunc) vala_iterable_ref, (GDestroyNotify) vala_iterable_unref, _tmp4_, _tmp5_, _tmp6_);
199 	_vala_map_unref0 (self->priv->per_type_children);
200 	self->priv->per_type_children = (ValaMap*) _tmp7_;
201 	if (name != NULL) {
202 		gboolean _tmp9_ = FALSE;
203 		gint _tmp10_;
204 		gint _tmp11_;
205 		_tmp10_ = strlen (name);
206 		_tmp11_ = _tmp10_;
207 		if (vala_scanner_get_identifier_or_keyword (name, _tmp11_) != VALA_TOKEN_TYPE_IDENTIFIER) {
208 			_tmp9_ = TRUE;
209 		} else {
210 			_tmp9_ = g_ascii_isdigit (string_get (name, (glong) 0));
211 		}
212 		_tmp8_ = _tmp9_;
213 	} else {
214 		_tmp8_ = FALSE;
215 	}
216 	if (_tmp8_) {
217 		gchar* _tmp12_;
218 		gchar* _tmp13_;
219 		_tmp12_ = g_strconcat ("@", name, NULL);
220 		_tmp13_ = _tmp12_;
221 		valadoc_api_node_set_name (self, _tmp13_);
222 		_g_free0 (_tmp13_);
223 	} else {
224 		valadoc_api_node_set_name (self, name);
225 	}
226 	valadoc_api_item_set_parent ((ValadocApiItem*) self, (ValadocApiItem*) parent);
227 	_tmp14_ = _g_object_ref0 (file);
228 	_g_object_unref0 (self->priv->file);
229 	self->priv->file = _tmp14_;
230 	return self;
231 }
232 
233 /**
234  * Visits this node with the specified Visitor.
235  *
236  * @param visitor the visitor to be called while traversing
237  */
238 static void
valadoc_api_node_real_accept(ValadocApiNode * self,ValadocApiVisitor * visitor)239 valadoc_api_node_real_accept (ValadocApiNode* self,
240                               ValadocApiVisitor* visitor)
241 {
242 	g_critical ("Type `%s' does not implement abstract method `valadoc_api_node_accept'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
243 	return;
244 }
245 
246 void
valadoc_api_node_accept(ValadocApiNode * self,ValadocApiVisitor * visitor)247 valadoc_api_node_accept (ValadocApiNode* self,
248                          ValadocApiVisitor* visitor)
249 {
250 	g_return_if_fail (self != NULL);
251 	VALADOC_API_NODE_GET_CLASS (self)->accept (self, visitor);
252 }
253 
254 /**
255  * {@inheritDoc}
256  */
257 static gboolean
valadoc_api_node_real_is_browsable(ValadocApiNode * self,ValadocSettings * settings)258 valadoc_api_node_real_is_browsable (ValadocApiNode* self,
259                                     ValadocSettings* settings)
260 {
261 	gboolean _tmp0_ = FALSE;
262 	g_critical ("Type `%s' does not implement abstract method `valadoc_api_node_is_browsable'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
263 	return _tmp0_;
264 }
265 
266 gboolean
valadoc_api_node_is_browsable(ValadocApiNode * self,ValadocSettings * settings)267 valadoc_api_node_is_browsable (ValadocApiNode* self,
268                                ValadocSettings* settings)
269 {
270 	g_return_val_if_fail (self != NULL, FALSE);
271 	return VALADOC_API_NODE_GET_CLASS (self)->is_browsable (self, settings);
272 }
273 
274 /**
275  * {@inheritDoc}
276  */
277 static gchar*
valadoc_api_node_real_get_filename(ValadocDocumentation * base)278 valadoc_api_node_real_get_filename (ValadocDocumentation* base)
279 {
280 	ValadocApiNode * self;
281 	ValadocApiSourceFile* _tmp0_;
282 	ValadocApiSourceFile* _tmp1_;
283 	const gchar* _tmp2_;
284 	const gchar* _tmp3_;
285 	gchar* _tmp4_;
286 	gchar* result = NULL;
287 	self = (ValadocApiNode*) base;
288 	_tmp0_ = self->priv->file;
289 	if (_tmp0_ == NULL) {
290 		result = NULL;
291 		return result;
292 	}
293 	_tmp1_ = self->priv->file;
294 	_tmp2_ = valadoc_api_source_file_get_relative_path (_tmp1_);
295 	_tmp3_ = _tmp2_;
296 	_tmp4_ = g_strdup (_tmp3_);
297 	result = _tmp4_;
298 	return result;
299 }
300 
301 void
valadoc_api_node_add_child(ValadocApiNode * self,ValadocApiSymbol * child)302 valadoc_api_node_add_child (ValadocApiNode* self,
303                             ValadocApiSymbol* child)
304 {
305 	const gchar* _tmp0_;
306 	ValaList* children = NULL;
307 	ValaMap* _tmp8_;
308 	ValadocApiNodeType _tmp9_;
309 	ValadocApiNodeType _tmp10_;
310 	gpointer _tmp11_;
311 	ValaList* _tmp12_;
312 	ValaList* _tmp19_;
313 	g_return_if_fail (self != NULL);
314 	g_return_if_fail (child != NULL);
315 	_tmp0_ = ((ValadocApiNode*) child)->priv->_name;
316 	if (_tmp0_ != NULL) {
317 		const gchar* _tmp1_;
318 		_tmp1_ = ((ValadocApiNode*) child)->priv->_name;
319 		if (string_get (_tmp1_, (glong) 0) == '@') {
320 			ValaMap* _tmp2_;
321 			const gchar* _tmp3_;
322 			const gchar* _tmp4_;
323 			_tmp2_ = self->priv->per_name_children;
324 			_tmp3_ = ((ValadocApiNode*) child)->priv->_name;
325 			_tmp4_ = g_utf8_next_char (_tmp3_);
326 			vala_map_set (_tmp2_, _tmp4_, (ValadocApiNode*) child);
327 		} else {
328 			ValaMap* _tmp5_;
329 			const gchar* _tmp6_;
330 			_tmp5_ = self->priv->per_name_children;
331 			_tmp6_ = ((ValadocApiNode*) child)->priv->_name;
332 			vala_map_set (_tmp5_, _tmp6_, (ValadocApiNode*) child);
333 		}
334 	} else {
335 		ValaMap* _tmp7_;
336 		_tmp7_ = self->priv->per_name_children;
337 		vala_map_set (_tmp7_, "", (ValadocApiNode*) child);
338 	}
339 	_tmp8_ = self->priv->per_type_children;
340 	_tmp9_ = valadoc_api_node_get_node_type ((ValadocApiNode*) child);
341 	_tmp10_ = _tmp9_;
342 	_tmp11_ = vala_map_get (_tmp8_, (gpointer) ((gintptr) _tmp10_));
343 	children = (ValaList*) _tmp11_;
344 	_tmp12_ = children;
345 	if (_tmp12_ == NULL) {
346 		GEqualFunc _tmp13_;
347 		ValaArrayList* _tmp14_;
348 		ValaMap* _tmp15_;
349 		ValadocApiNodeType _tmp16_;
350 		ValadocApiNodeType _tmp17_;
351 		ValaList* _tmp18_;
352 		_tmp13_ = g_direct_equal;
353 		_tmp14_ = vala_array_list_new (VALADOC_API_TYPE_NODE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp13_);
354 		_vala_iterable_unref0 (children);
355 		children = (ValaList*) _tmp14_;
356 		_tmp15_ = self->priv->per_type_children;
357 		_tmp16_ = valadoc_api_node_get_node_type ((ValadocApiNode*) child);
358 		_tmp17_ = _tmp16_;
359 		_tmp18_ = children;
360 		vala_map_set (_tmp15_, (gpointer) ((gintptr) _tmp17_), _tmp18_);
361 	}
362 	_tmp19_ = children;
363 	vala_collection_add ((ValaCollection*) _tmp19_, (ValadocApiNode*) child);
364 	_vala_iterable_unref0 (children);
365 }
366 
367 /**
368  * {@inheritDoc}
369  */
370 static void
valadoc_api_node_real_parse_comments(ValadocApiItem * base,ValadocSettings * settings,ValadocDocumentationParser * parser)371 valadoc_api_node_real_parse_comments (ValadocApiItem* base,
372                                       ValadocSettings* settings,
373                                       ValadocDocumentationParser* parser)
374 {
375 	ValadocApiNode * self;
376 	self = (ValadocApiNode*) base;
377 	g_return_if_fail (settings != NULL);
378 	g_return_if_fail (parser != NULL);
379 	self->do_document = TRUE;
380 	{
381 		ValaIterator* _node_it = NULL;
382 		ValaMap* _tmp0_;
383 		ValaCollection* _tmp1_;
384 		ValaCollection* _tmp2_;
385 		ValaIterator* _tmp3_;
386 		ValaIterator* _tmp4_;
387 		_tmp0_ = self->priv->per_name_children;
388 		_tmp1_ = vala_map_get_values (_tmp0_);
389 		_tmp2_ = _tmp1_;
390 		_tmp3_ = vala_iterable_iterator ((ValaIterable*) _tmp2_);
391 		_tmp4_ = _tmp3_;
392 		_vala_iterable_unref0 (_tmp2_);
393 		_node_it = _tmp4_;
394 		while (TRUE) {
395 			ValaIterator* _tmp5_;
396 			ValadocApiNode* node = NULL;
397 			ValaIterator* _tmp6_;
398 			gpointer _tmp7_;
399 			ValadocApiItem* _tmp8_;
400 			ValadocApiItem* _tmp9_;
401 			ValadocApiNode* _tmp10_;
402 			ValadocApiNode* _tmp11_;
403 			_tmp5_ = _node_it;
404 			if (!vala_iterator_next (_tmp5_)) {
405 				break;
406 			}
407 			_tmp6_ = _node_it;
408 			_tmp7_ = vala_iterator_get (_tmp6_);
409 			node = (ValadocApiNode*) _tmp7_;
410 			_tmp8_ = valadoc_api_item_get_parent ((ValadocApiItem*) self);
411 			_tmp9_ = _tmp8_;
412 			_tmp10_ = node;
413 			if (_tmp9_ == G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, VALADOC_API_TYPE_ITEM, ValadocApiItem)) {
414 				_g_object_unref0 (node);
415 				continue;
416 			}
417 			_tmp11_ = node;
418 			if (valadoc_api_node_is_browsable (_tmp11_, settings)) {
419 				ValadocApiNode* _tmp12_;
420 				_tmp12_ = node;
421 				valadoc_api_item_parse_comments ((ValadocApiItem*) _tmp12_, settings, parser);
422 			}
423 			_g_object_unref0 (node);
424 		}
425 		_vala_iterator_unref0 (_node_it);
426 	}
427 }
428 
429 /**
430  * {@inheritDoc}
431  */
432 static void
valadoc_api_node_real_check_comments(ValadocApiItem * base,ValadocSettings * settings,ValadocDocumentationParser * parser)433 valadoc_api_node_real_check_comments (ValadocApiItem* base,
434                                       ValadocSettings* settings,
435                                       ValadocDocumentationParser* parser)
436 {
437 	ValadocApiNode * self;
438 	self = (ValadocApiNode*) base;
439 	g_return_if_fail (settings != NULL);
440 	g_return_if_fail (parser != NULL);
441 	{
442 		ValaIterator* _node_it = NULL;
443 		ValaMap* _tmp0_;
444 		ValaCollection* _tmp1_;
445 		ValaCollection* _tmp2_;
446 		ValaIterator* _tmp3_;
447 		ValaIterator* _tmp4_;
448 		_tmp0_ = self->priv->per_name_children;
449 		_tmp1_ = vala_map_get_values (_tmp0_);
450 		_tmp2_ = _tmp1_;
451 		_tmp3_ = vala_iterable_iterator ((ValaIterable*) _tmp2_);
452 		_tmp4_ = _tmp3_;
453 		_vala_iterable_unref0 (_tmp2_);
454 		_node_it = _tmp4_;
455 		while (TRUE) {
456 			ValaIterator* _tmp5_;
457 			ValadocApiNode* node = NULL;
458 			ValaIterator* _tmp6_;
459 			gpointer _tmp7_;
460 			ValadocApiItem* _tmp8_;
461 			ValadocApiItem* _tmp9_;
462 			ValadocApiNode* _tmp10_;
463 			ValadocApiNode* _tmp11_;
464 			_tmp5_ = _node_it;
465 			if (!vala_iterator_next (_tmp5_)) {
466 				break;
467 			}
468 			_tmp6_ = _node_it;
469 			_tmp7_ = vala_iterator_get (_tmp6_);
470 			node = (ValadocApiNode*) _tmp7_;
471 			_tmp8_ = valadoc_api_item_get_parent ((ValadocApiItem*) self);
472 			_tmp9_ = _tmp8_;
473 			_tmp10_ = node;
474 			if (_tmp9_ == G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, VALADOC_API_TYPE_ITEM, ValadocApiItem)) {
475 				_g_object_unref0 (node);
476 				continue;
477 			}
478 			_tmp11_ = node;
479 			if (valadoc_api_node_is_browsable (_tmp11_, settings)) {
480 				ValadocApiNode* _tmp12_;
481 				_tmp12_ = node;
482 				valadoc_api_item_check_comments ((ValadocApiItem*) _tmp12_, settings, parser);
483 			}
484 			_g_object_unref0 (node);
485 		}
486 		_vala_iterator_unref0 (_node_it);
487 	}
488 }
489 
490 /**
491  * Specifies whether this node has at least one visible child with the given type
492  *
493  * @param type a node type
494  */
495 static gpointer
_vala_iterable_ref0(gpointer self)496 _vala_iterable_ref0 (gpointer self)
497 {
498 	return self ? vala_iterable_ref (self) : NULL;
499 }
500 
501 gboolean
valadoc_api_node_has_visible_children_by_type(ValadocApiNode * self,ValadocApiNodeType type,ValadocSettings * settings)502 valadoc_api_node_has_visible_children_by_type (ValadocApiNode* self,
503                                                ValadocApiNodeType type,
504                                                ValadocSettings* settings)
505 {
506 	ValaList* all_children = NULL;
507 	ValaMap* _tmp0_;
508 	gpointer _tmp1_;
509 	ValaList* _tmp2_;
510 	gboolean result = FALSE;
511 	g_return_val_if_fail (self != NULL, FALSE);
512 	g_return_val_if_fail (settings != NULL, FALSE);
513 	_tmp0_ = self->priv->per_type_children;
514 	_tmp1_ = vala_map_get (_tmp0_, (gpointer) ((gintptr) type));
515 	all_children = (ValaList*) _tmp1_;
516 	_tmp2_ = all_children;
517 	if (_tmp2_ != NULL) {
518 		{
519 			ValaList* _node_list = NULL;
520 			ValaList* _tmp3_;
521 			ValaList* _tmp4_;
522 			gint _node_size = 0;
523 			ValaList* _tmp5_;
524 			gint _tmp6_;
525 			gint _tmp7_;
526 			gint _node_index = 0;
527 			_tmp3_ = all_children;
528 			_tmp4_ = _vala_iterable_ref0 (_tmp3_);
529 			_node_list = _tmp4_;
530 			_tmp5_ = _node_list;
531 			_tmp6_ = vala_collection_get_size ((ValaCollection*) _tmp5_);
532 			_tmp7_ = _tmp6_;
533 			_node_size = _tmp7_;
534 			_node_index = -1;
535 			while (TRUE) {
536 				gint _tmp8_;
537 				gint _tmp9_;
538 				ValadocApiNode* node = NULL;
539 				ValaList* _tmp10_;
540 				gpointer _tmp11_;
541 				ValadocApiNode* _tmp12_;
542 				_node_index = _node_index + 1;
543 				_tmp8_ = _node_index;
544 				_tmp9_ = _node_size;
545 				if (!(_tmp8_ < _tmp9_)) {
546 					break;
547 				}
548 				_tmp10_ = _node_list;
549 				_tmp11_ = vala_list_get (_tmp10_, _node_index);
550 				node = (ValadocApiNode*) _tmp11_;
551 				_tmp12_ = node;
552 				if (valadoc_api_node_is_browsable (_tmp12_, settings)) {
553 					result = TRUE;
554 					_g_object_unref0 (node);
555 					_vala_iterable_unref0 (_node_list);
556 					_vala_iterable_unref0 (all_children);
557 					return result;
558 				}
559 				_g_object_unref0 (node);
560 			}
561 			_vala_iterable_unref0 (_node_list);
562 		}
563 	}
564 	result = FALSE;
565 	_vala_iterable_unref0 (all_children);
566 	return result;
567 }
568 
569 /**
570  * Specifies whether this node has at least one visible child with the given types
571  *
572  * @param types a list of node types
573  */
574 gboolean
valadoc_api_node_has_visible_children_by_types(ValadocApiNode * self,ValadocApiNodeType * types,gint types_length1,ValadocSettings * settings)575 valadoc_api_node_has_visible_children_by_types (ValadocApiNode* self,
576                                                 ValadocApiNodeType* types,
577                                                 gint types_length1,
578                                                 ValadocSettings* settings)
579 {
580 	gboolean result = FALSE;
581 	g_return_val_if_fail (self != NULL, FALSE);
582 	g_return_val_if_fail (settings != NULL, FALSE);
583 	{
584 		ValadocApiNodeType* type_collection = NULL;
585 		gint type_collection_length1 = 0;
586 		gint _type_collection_size_ = 0;
587 		gint type_it = 0;
588 		type_collection = types;
589 		type_collection_length1 = types_length1;
590 		for (type_it = 0; type_it < type_collection_length1; type_it = type_it + 1) {
591 			ValadocApiNodeType type = 0;
592 			type = type_collection[type_it];
593 			{
594 				ValadocApiNodeType _tmp0_;
595 				_tmp0_ = type;
596 				if (valadoc_api_node_has_visible_children_by_type (self, _tmp0_, settings)) {
597 					result = TRUE;
598 					return result;
599 				}
600 			}
601 		}
602 	}
603 	result = FALSE;
604 	return result;
605 }
606 
607 /**
608  * Specifies whether this node has at least one visible child
609  */
610 gboolean
valadoc_api_node_has_visible_children(ValadocApiNode * self,ValadocSettings * settings)611 valadoc_api_node_has_visible_children (ValadocApiNode* self,
612                                        ValadocSettings* settings)
613 {
614 	ValaMap* _tmp0_;
615 	ValaSet* _tmp1_;
616 	ValaSet* _tmp2_;
617 	gint _tmp3_ = 0;
618 	gpointer* _tmp4_;
619 	ValadocApiNodeType* _tmp5_;
620 	gint _tmp5__length1;
621 	gboolean _tmp6_;
622 	gboolean result = FALSE;
623 	g_return_val_if_fail (self != NULL, FALSE);
624 	g_return_val_if_fail (settings != NULL, FALSE);
625 	_tmp0_ = self->priv->per_type_children;
626 	_tmp1_ = vala_map_get_keys (_tmp0_);
627 	_tmp2_ = _tmp1_;
628 	_tmp4_ = vala_collection_to_array ((ValaCollection*) _tmp2_, &_tmp3_);
629 	_tmp5_ = _tmp4_;
630 	_tmp5__length1 = _tmp3_;
631 	_tmp6_ = valadoc_api_node_has_visible_children_by_types (self, _tmp5_, (gint) _tmp3_, settings);
632 	_tmp5_ = (g_free (_tmp5_), NULL);
633 	_vala_iterable_unref0 (_tmp2_);
634 	result = _tmp6_;
635 	return result;
636 }
637 
638 /**
639  * Specifies whether this node has at least one child with the given type
640  *
641  * @param type a node type
642  */
643 gboolean
valadoc_api_node_has_children_by_type(ValadocApiNode * self,ValadocApiNodeType type)644 valadoc_api_node_has_children_by_type (ValadocApiNode* self,
645                                        ValadocApiNodeType type)
646 {
647 	ValaList* all_children = NULL;
648 	ValaMap* _tmp0_;
649 	gpointer _tmp1_;
650 	gboolean _tmp2_ = FALSE;
651 	ValaList* _tmp3_;
652 	gboolean result = FALSE;
653 	g_return_val_if_fail (self != NULL, FALSE);
654 	_tmp0_ = self->priv->per_type_children;
655 	_tmp1_ = vala_map_get (_tmp0_, (gpointer) ((gintptr) type));
656 	all_children = (ValaList*) _tmp1_;
657 	_tmp3_ = all_children;
658 	if (_tmp3_ != NULL) {
659 		ValaList* _tmp4_;
660 		gboolean _tmp5_;
661 		gboolean _tmp6_;
662 		_tmp4_ = all_children;
663 		_tmp5_ = vala_collection_get_is_empty ((ValaCollection*) _tmp4_);
664 		_tmp6_ = _tmp5_;
665 		_tmp2_ = !_tmp6_;
666 	} else {
667 		_tmp2_ = FALSE;
668 	}
669 	result = _tmp2_;
670 	_vala_iterable_unref0 (all_children);
671 	return result;
672 }
673 
674 /**
675  * Specifies whether this node has at least one child with the given types
676  *
677  * @param types a list of node types
678  */
679 gboolean
valadoc_api_node_has_children(ValadocApiNode * self,ValadocApiNodeType * types,gint types_length1)680 valadoc_api_node_has_children (ValadocApiNode* self,
681                                ValadocApiNodeType* types,
682                                gint types_length1)
683 {
684 	gboolean result = FALSE;
685 	g_return_val_if_fail (self != NULL, FALSE);
686 	{
687 		ValadocApiNodeType* type_collection = NULL;
688 		gint type_collection_length1 = 0;
689 		gint _type_collection_size_ = 0;
690 		gint type_it = 0;
691 		type_collection = types;
692 		type_collection_length1 = types_length1;
693 		for (type_it = 0; type_it < type_collection_length1; type_it = type_it + 1) {
694 			ValadocApiNodeType type = 0;
695 			type = type_collection[type_it];
696 			{
697 				ValadocApiNodeType _tmp0_;
698 				_tmp0_ = type;
699 				if (valadoc_api_node_has_children_by_type (self, _tmp0_)) {
700 					result = TRUE;
701 					return result;
702 				}
703 			}
704 		}
705 	}
706 	result = FALSE;
707 	return result;
708 }
709 
710 /**
711  * Returns a list of all children with the given type.
712  *
713  * @param type a node type
714  * @param filtered specifies whether nodes which are not browsable should appear in the list
715  */
716 ValaList*
valadoc_api_node_get_children_by_type(ValadocApiNode * self,ValadocApiNodeType type,gboolean filtered)717 valadoc_api_node_get_children_by_type (ValadocApiNode* self,
718                                        ValadocApiNodeType type,
719                                        gboolean filtered)
720 {
721 	ValaArrayList* children = NULL;
722 	GEqualFunc _tmp0_;
723 	ValaArrayList* _tmp1_;
724 	ValaList* all_children = NULL;
725 	ValaMap* _tmp2_;
726 	gpointer _tmp3_;
727 	ValaList* _tmp4_;
728 	ValaList* result = NULL;
729 	g_return_val_if_fail (self != NULL, NULL);
730 	_tmp0_ = g_direct_equal;
731 	_tmp1_ = vala_array_list_new (VALADOC_API_TYPE_NODE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp0_);
732 	children = _tmp1_;
733 	_tmp2_ = self->priv->per_type_children;
734 	_tmp3_ = vala_map_get (_tmp2_, (gpointer) ((gintptr) type));
735 	all_children = (ValaList*) _tmp3_;
736 	_tmp4_ = all_children;
737 	if (_tmp4_ != NULL) {
738 		{
739 			ValaList* _node_list = NULL;
740 			ValaList* _tmp5_;
741 			ValaList* _tmp6_;
742 			gint _node_size = 0;
743 			ValaList* _tmp7_;
744 			gint _tmp8_;
745 			gint _tmp9_;
746 			gint _node_index = 0;
747 			_tmp5_ = all_children;
748 			_tmp6_ = _vala_iterable_ref0 (_tmp5_);
749 			_node_list = _tmp6_;
750 			_tmp7_ = _node_list;
751 			_tmp8_ = vala_collection_get_size ((ValaCollection*) _tmp7_);
752 			_tmp9_ = _tmp8_;
753 			_node_size = _tmp9_;
754 			_node_index = -1;
755 			while (TRUE) {
756 				gint _tmp10_;
757 				gint _tmp11_;
758 				ValadocApiNode* node = NULL;
759 				ValaList* _tmp12_;
760 				gpointer _tmp13_;
761 				gboolean _tmp14_ = FALSE;
762 				ValadocApiNode* _tmp15_;
763 				_node_index = _node_index + 1;
764 				_tmp10_ = _node_index;
765 				_tmp11_ = _node_size;
766 				if (!(_tmp10_ < _tmp11_)) {
767 					break;
768 				}
769 				_tmp12_ = _node_list;
770 				_tmp13_ = vala_list_get (_tmp12_, _node_index);
771 				node = (ValadocApiNode*) _tmp13_;
772 				_tmp15_ = node;
773 				if (_tmp15_->do_document) {
774 					_tmp14_ = TRUE;
775 				} else {
776 					_tmp14_ = !filtered;
777 				}
778 				if (_tmp14_) {
779 					ValaArrayList* _tmp16_;
780 					ValadocApiNode* _tmp17_;
781 					_tmp16_ = children;
782 					_tmp17_ = node;
783 					vala_collection_add ((ValaCollection*) _tmp16_, _tmp17_);
784 				}
785 				_g_object_unref0 (node);
786 			}
787 			_vala_iterable_unref0 (_node_list);
788 		}
789 	}
790 	result = (ValaList*) children;
791 	_vala_iterable_unref0 (all_children);
792 	return result;
793 }
794 
795 /**
796  * Returns a list of all children with the given types.
797  *
798  * @param types a list of node types
799  * @param filtered specifies whether nodes which are not browsable should appear in the list
800  */
801 ValaList*
valadoc_api_node_get_children_by_types(ValadocApiNode * self,ValadocApiNodeType * types,gint types_length1,gboolean filtered)802 valadoc_api_node_get_children_by_types (ValadocApiNode* self,
803                                         ValadocApiNodeType* types,
804                                         gint types_length1,
805                                         gboolean filtered)
806 {
807 	ValaArrayList* children = NULL;
808 	GEqualFunc _tmp0_;
809 	ValaArrayList* _tmp1_;
810 	ValaList* result = NULL;
811 	g_return_val_if_fail (self != NULL, NULL);
812 	_tmp0_ = g_direct_equal;
813 	_tmp1_ = vala_array_list_new (VALADOC_API_TYPE_NODE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp0_);
814 	children = _tmp1_;
815 	{
816 		ValadocApiNodeType* type_collection = NULL;
817 		gint type_collection_length1 = 0;
818 		gint _type_collection_size_ = 0;
819 		gint type_it = 0;
820 		type_collection = types;
821 		type_collection_length1 = types_length1;
822 		for (type_it = 0; type_it < type_collection_length1; type_it = type_it + 1) {
823 			ValadocApiNodeType type = 0;
824 			type = type_collection[type_it];
825 			{
826 				ValaArrayList* _tmp2_;
827 				ValadocApiNodeType _tmp3_;
828 				ValaList* _tmp4_;
829 				ValaList* _tmp5_;
830 				_tmp2_ = children;
831 				_tmp3_ = type;
832 				_tmp4_ = valadoc_api_node_get_children_by_type (self, _tmp3_, filtered);
833 				_tmp5_ = _tmp4_;
834 				vala_collection_add_all ((ValaCollection*) _tmp2_, (ValaCollection*) _tmp5_);
835 				_vala_iterable_unref0 (_tmp5_);
836 			}
837 		}
838 	}
839 	result = (ValaList*) children;
840 	return result;
841 }
842 
843 /**
844  * Visits all children of this node with the given type with the specified Visitor.
845  *
846  * @param type a node type
847  * @param visitor the visitor to be called while traversing
848  * @param filtered specifies whether nodes which are not browsable should appear in the list
849  */
850 void
valadoc_api_node_accept_children_by_type(ValadocApiNode * self,ValadocApiNodeType type,ValadocApiVisitor * visitor,gboolean filtered)851 valadoc_api_node_accept_children_by_type (ValadocApiNode* self,
852                                           ValadocApiNodeType type,
853                                           ValadocApiVisitor* visitor,
854                                           gboolean filtered)
855 {
856 	ValaList* all_children = NULL;
857 	ValaMap* _tmp0_;
858 	gpointer _tmp1_;
859 	ValaList* _tmp2_;
860 	g_return_if_fail (self != NULL);
861 	g_return_if_fail (visitor != NULL);
862 	_tmp0_ = self->priv->per_type_children;
863 	_tmp1_ = vala_map_get (_tmp0_, (gpointer) ((gintptr) type));
864 	all_children = (ValaList*) _tmp1_;
865 	_tmp2_ = all_children;
866 	if (_tmp2_ != NULL) {
867 		{
868 			ValaList* _node_list = NULL;
869 			ValaList* _tmp3_;
870 			ValaList* _tmp4_;
871 			gint _node_size = 0;
872 			ValaList* _tmp5_;
873 			gint _tmp6_;
874 			gint _tmp7_;
875 			gint _node_index = 0;
876 			_tmp3_ = all_children;
877 			_tmp4_ = _vala_iterable_ref0 (_tmp3_);
878 			_node_list = _tmp4_;
879 			_tmp5_ = _node_list;
880 			_tmp6_ = vala_collection_get_size ((ValaCollection*) _tmp5_);
881 			_tmp7_ = _tmp6_;
882 			_node_size = _tmp7_;
883 			_node_index = -1;
884 			while (TRUE) {
885 				gint _tmp8_;
886 				gint _tmp9_;
887 				ValadocApiNode* node = NULL;
888 				ValaList* _tmp10_;
889 				gpointer _tmp11_;
890 				gboolean _tmp12_ = FALSE;
891 				ValadocApiNode* _tmp13_;
892 				_node_index = _node_index + 1;
893 				_tmp8_ = _node_index;
894 				_tmp9_ = _node_size;
895 				if (!(_tmp8_ < _tmp9_)) {
896 					break;
897 				}
898 				_tmp10_ = _node_list;
899 				_tmp11_ = vala_list_get (_tmp10_, _node_index);
900 				node = (ValadocApiNode*) _tmp11_;
901 				_tmp13_ = node;
902 				if (_tmp13_->do_document) {
903 					_tmp12_ = TRUE;
904 				} else {
905 					_tmp12_ = !filtered;
906 				}
907 				if (_tmp12_) {
908 					ValadocApiNode* _tmp14_;
909 					_tmp14_ = node;
910 					valadoc_api_node_accept (_tmp14_, visitor);
911 				}
912 				_g_object_unref0 (node);
913 			}
914 			_vala_iterable_unref0 (_node_list);
915 		}
916 	}
917 	_vala_iterable_unref0 (all_children);
918 }
919 
920 /**
921  * Visits all children of this node with the given types with the specified Visitor.
922  *
923  * @param types a list of node types
924  * @param visitor the visitor to be called while traversing
925  * @param filtered specifies whether nodes which are not browsable should appear in the list
926  */
927 void
valadoc_api_node_accept_children(ValadocApiNode * self,ValadocApiNodeType * types,gint types_length1,ValadocApiVisitor * visitor,gboolean filtered)928 valadoc_api_node_accept_children (ValadocApiNode* self,
929                                   ValadocApiNodeType* types,
930                                   gint types_length1,
931                                   ValadocApiVisitor* visitor,
932                                   gboolean filtered)
933 {
934 	g_return_if_fail (self != NULL);
935 	g_return_if_fail (visitor != NULL);
936 	{
937 		ValadocApiNodeType* type_collection = NULL;
938 		gint type_collection_length1 = 0;
939 		gint _type_collection_size_ = 0;
940 		gint type_it = 0;
941 		type_collection = types;
942 		type_collection_length1 = types_length1;
943 		for (type_it = 0; type_it < type_collection_length1; type_it = type_it + 1) {
944 			ValadocApiNodeType type = 0;
945 			type = type_collection[type_it];
946 			{
947 				ValadocApiNodeType _tmp0_;
948 				_tmp0_ = type;
949 				valadoc_api_node_accept_children_by_type (self, _tmp0_, visitor, filtered);
950 			}
951 		}
952 	}
953 }
954 
955 /**
956  * Visits all children of this node with the specified Visitor.
957  *
958  * @param visitor the visitor to be called while traversing
959  * @param filtered specifies whether nodes which are not browsable should appear in the list
960  */
961 void
valadoc_api_node_accept_all_children(ValadocApiNode * self,ValadocApiVisitor * visitor,gboolean filtered)962 valadoc_api_node_accept_all_children (ValadocApiNode* self,
963                                       ValadocApiVisitor* visitor,
964                                       gboolean filtered)
965 {
966 	g_return_if_fail (self != NULL);
967 	g_return_if_fail (visitor != NULL);
968 	{
969 		ValaIterator* _children_it = NULL;
970 		ValaMap* _tmp0_;
971 		ValaCollection* _tmp1_;
972 		ValaCollection* _tmp2_;
973 		ValaIterator* _tmp3_;
974 		ValaIterator* _tmp4_;
975 		_tmp0_ = self->priv->per_type_children;
976 		_tmp1_ = vala_map_get_values (_tmp0_);
977 		_tmp2_ = _tmp1_;
978 		_tmp3_ = vala_iterable_iterator ((ValaIterable*) _tmp2_);
979 		_tmp4_ = _tmp3_;
980 		_vala_iterable_unref0 (_tmp2_);
981 		_children_it = _tmp4_;
982 		while (TRUE) {
983 			ValaIterator* _tmp5_;
984 			ValaList* children = NULL;
985 			ValaIterator* _tmp6_;
986 			gpointer _tmp7_;
987 			ValadocApiItem* _tmp8_;
988 			ValadocApiItem* _tmp9_;
989 			ValaList* _tmp10_;
990 			gpointer _tmp11_;
991 			ValadocApiNode* _tmp12_;
992 			gboolean _tmp13_;
993 			_tmp5_ = _children_it;
994 			if (!vala_iterator_next (_tmp5_)) {
995 				break;
996 			}
997 			_tmp6_ = _children_it;
998 			_tmp7_ = vala_iterator_get (_tmp6_);
999 			children = (ValaList*) _tmp7_;
1000 			_tmp8_ = valadoc_api_item_get_parent ((ValadocApiItem*) self);
1001 			_tmp9_ = _tmp8_;
1002 			_tmp10_ = children;
1003 			_tmp11_ = vala_list_get (_tmp10_, 0);
1004 			_tmp12_ = (ValadocApiNode*) _tmp11_;
1005 			_tmp13_ = _tmp9_ == G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, VALADOC_API_TYPE_ITEM, ValadocApiItem);
1006 			_g_object_unref0 (_tmp12_);
1007 			if (_tmp13_) {
1008 				_vala_iterable_unref0 (children);
1009 				continue;
1010 			}
1011 			{
1012 				ValaList* _node_list = NULL;
1013 				ValaList* _tmp14_;
1014 				ValaList* _tmp15_;
1015 				gint _node_size = 0;
1016 				ValaList* _tmp16_;
1017 				gint _tmp17_;
1018 				gint _tmp18_;
1019 				gint _node_index = 0;
1020 				_tmp14_ = children;
1021 				_tmp15_ = _vala_iterable_ref0 (_tmp14_);
1022 				_node_list = _tmp15_;
1023 				_tmp16_ = _node_list;
1024 				_tmp17_ = vala_collection_get_size ((ValaCollection*) _tmp16_);
1025 				_tmp18_ = _tmp17_;
1026 				_node_size = _tmp18_;
1027 				_node_index = -1;
1028 				while (TRUE) {
1029 					gint _tmp19_;
1030 					gint _tmp20_;
1031 					ValadocApiNode* node = NULL;
1032 					ValaList* _tmp21_;
1033 					gpointer _tmp22_;
1034 					gboolean _tmp23_ = FALSE;
1035 					ValadocApiNode* _tmp24_;
1036 					_node_index = _node_index + 1;
1037 					_tmp19_ = _node_index;
1038 					_tmp20_ = _node_size;
1039 					if (!(_tmp19_ < _tmp20_)) {
1040 						break;
1041 					}
1042 					_tmp21_ = _node_list;
1043 					_tmp22_ = vala_list_get (_tmp21_, _node_index);
1044 					node = (ValadocApiNode*) _tmp22_;
1045 					_tmp24_ = node;
1046 					if (_tmp24_->do_document) {
1047 						_tmp23_ = TRUE;
1048 					} else {
1049 						_tmp23_ = !filtered;
1050 					}
1051 					if (_tmp23_) {
1052 						ValadocApiNode* _tmp25_;
1053 						_tmp25_ = node;
1054 						valadoc_api_node_accept (_tmp25_, visitor);
1055 					}
1056 					_g_object_unref0 (node);
1057 				}
1058 				_vala_iterable_unref0 (_node_list);
1059 			}
1060 			_vala_iterable_unref0 (children);
1061 		}
1062 		_vala_iterator_unref0 (_children_it);
1063 	}
1064 }
1065 
1066 ValadocApiNode*
valadoc_api_node_find_by_name(ValadocApiNode * self,const gchar * name)1067 valadoc_api_node_find_by_name (ValadocApiNode* self,
1068                                const gchar* name)
1069 {
1070 	ValadocApiNode* result = NULL;
1071 	g_return_val_if_fail (self != NULL, NULL);
1072 	g_return_val_if_fail (name != NULL, NULL);
1073 	if (string_get (name, (glong) 0) == '@') {
1074 		ValaMap* _tmp0_;
1075 		const gchar* _tmp1_;
1076 		gpointer _tmp2_;
1077 		_tmp0_ = self->priv->per_name_children;
1078 		_tmp1_ = g_utf8_next_char (name);
1079 		_tmp2_ = vala_map_get (_tmp0_, _tmp1_);
1080 		result = (ValadocApiNode*) _tmp2_;
1081 		return result;
1082 	} else {
1083 		ValaMap* _tmp3_;
1084 		gpointer _tmp4_;
1085 		_tmp3_ = self->priv->per_name_children;
1086 		_tmp4_ = vala_map_get (_tmp3_, name);
1087 		result = (ValadocApiNode*) _tmp4_;
1088 		return result;
1089 	}
1090 }
1091 
1092 ValadocApiNamespace*
valadoc_api_node_get_nspace(ValadocApiNode * self)1093 valadoc_api_node_get_nspace (ValadocApiNode* self)
1094 {
1095 	ValadocApiNamespace* result;
1096 	ValadocApiNamespace* _tmp0_;
1097 	ValadocApiNamespace* _tmp10_;
1098 	g_return_val_if_fail (self != NULL, NULL);
1099 	_tmp0_ = self->priv->_nspace;
1100 	if (_tmp0_ == NULL) {
1101 		ValadocApiItem* ast = NULL;
1102 		ValadocApiItem* _tmp1_;
1103 		ValadocApiItem* _tmp8_;
1104 		ValadocApiNamespace* _tmp9_;
1105 		_tmp1_ = _g_object_ref0 ((ValadocApiItem*) self);
1106 		ast = _tmp1_;
1107 		while (TRUE) {
1108 			ValadocApiItem* _tmp2_;
1109 			ValadocApiItem* _tmp3_;
1110 			ValadocApiItem* _tmp4_;
1111 			ValadocApiItem* _tmp5_;
1112 			ValadocApiItem* _tmp6_;
1113 			ValadocApiItem* _tmp7_;
1114 			_tmp2_ = ast;
1115 			if (!(VALADOC_API_IS_NAMESPACE (_tmp2_) == FALSE)) {
1116 				break;
1117 			}
1118 			_tmp3_ = ast;
1119 			_tmp4_ = valadoc_api_item_get_parent (_tmp3_);
1120 			_tmp5_ = _tmp4_;
1121 			_tmp6_ = _g_object_ref0 (_tmp5_);
1122 			_g_object_unref0 (ast);
1123 			ast = _tmp6_;
1124 			_tmp7_ = ast;
1125 			if (_tmp7_ == NULL) {
1126 				result = NULL;
1127 				_g_object_unref0 (ast);
1128 				return result;
1129 			}
1130 		}
1131 		_tmp8_ = ast;
1132 		_tmp9_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, VALADOC_API_TYPE_NAMESPACE, ValadocApiNamespace));
1133 		_g_object_unref0 (self->priv->_nspace);
1134 		self->priv->_nspace = _tmp9_;
1135 		_g_object_unref0 (ast);
1136 	}
1137 	_tmp10_ = self->priv->_nspace;
1138 	result = _tmp10_;
1139 	return result;
1140 }
1141 
1142 static ValadocApiPackage*
valadoc_api_node_real_get_package(ValadocDocumentation * base)1143 valadoc_api_node_real_get_package (ValadocDocumentation* base)
1144 {
1145 	ValadocApiPackage* result;
1146 	ValadocApiNode* self;
1147 	ValadocApiPackage* _tmp0_;
1148 	ValadocApiPackage* _tmp10_;
1149 	self = (ValadocApiNode*) base;
1150 	_tmp0_ = self->priv->_package;
1151 	if (_tmp0_ == NULL) {
1152 		ValadocApiItem* ast = NULL;
1153 		ValadocApiItem* _tmp1_;
1154 		ValadocApiItem* _tmp8_;
1155 		ValadocApiPackage* _tmp9_;
1156 		_tmp1_ = _g_object_ref0 ((ValadocApiItem*) self);
1157 		ast = _tmp1_;
1158 		while (TRUE) {
1159 			ValadocApiItem* _tmp2_;
1160 			ValadocApiItem* _tmp3_;
1161 			ValadocApiItem* _tmp4_;
1162 			ValadocApiItem* _tmp5_;
1163 			ValadocApiItem* _tmp6_;
1164 			ValadocApiItem* _tmp7_;
1165 			_tmp2_ = ast;
1166 			if (!(VALADOC_API_IS_PACKAGE (_tmp2_) == FALSE)) {
1167 				break;
1168 			}
1169 			_tmp3_ = ast;
1170 			_tmp4_ = valadoc_api_item_get_parent (_tmp3_);
1171 			_tmp5_ = _tmp4_;
1172 			_tmp6_ = _g_object_ref0 (_tmp5_);
1173 			_g_object_unref0 (ast);
1174 			ast = _tmp6_;
1175 			_tmp7_ = ast;
1176 			if (_tmp7_ == NULL) {
1177 				result = NULL;
1178 				_g_object_unref0 (ast);
1179 				return result;
1180 			}
1181 		}
1182 		_tmp8_ = ast;
1183 		_tmp9_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, VALADOC_API_TYPE_PACKAGE, ValadocApiPackage));
1184 		_g_object_unref0 (self->priv->_package);
1185 		self->priv->_package = _tmp9_;
1186 		_g_object_unref0 (ast);
1187 	}
1188 	_tmp10_ = self->priv->_package;
1189 	result = _tmp10_;
1190 	return result;
1191 }
1192 
1193 ValadocContentComment*
valadoc_api_node_get_documentation(ValadocApiNode * self)1194 valadoc_api_node_get_documentation (ValadocApiNode* self)
1195 {
1196 	ValadocContentComment* result;
1197 	ValadocContentComment* _tmp0_;
1198 	g_return_val_if_fail (self != NULL, NULL);
1199 	_tmp0_ = self->priv->_documentation;
1200 	result = _tmp0_;
1201 	return result;
1202 }
1203 
1204 G_GNUC_INTERNAL void
valadoc_api_node_set_documentation(ValadocApiNode * self,ValadocContentComment * value)1205 valadoc_api_node_set_documentation (ValadocApiNode* self,
1206                                     ValadocContentComment* value)
1207 {
1208 	ValadocContentComment* old_value;
1209 	g_return_if_fail (self != NULL);
1210 	old_value = valadoc_api_node_get_documentation (self);
1211 	if (old_value != value) {
1212 		ValadocContentComment* _tmp0_;
1213 		_tmp0_ = _g_object_ref0 (value);
1214 		_g_object_unref0 (self->priv->_documentation);
1215 		self->priv->_documentation = _tmp0_;
1216 		g_object_notify_by_pspec ((GObject *) self, valadoc_api_node_properties[VALADOC_API_NODE_DOCUMENTATION_PROPERTY]);
1217 	}
1218 }
1219 
1220 /**
1221  * Returns canonicalized absolute name (GLib.FileStream for instance)
1222  */
1223 gchar*
valadoc_api_node_get_full_name(ValadocApiNode * self)1224 valadoc_api_node_get_full_name (ValadocApiNode* self)
1225 {
1226 	const gchar* _tmp0_;
1227 	const gchar* _tmp25_;
1228 	gchar* _tmp26_;
1229 	gchar* result = NULL;
1230 	g_return_val_if_fail (self != NULL, NULL);
1231 	_tmp0_ = self->priv->_full_name;
1232 	if (_tmp0_ == NULL) {
1233 		const gchar* _tmp1_;
1234 		GString* full_name = NULL;
1235 		const gchar* _tmp2_;
1236 		GString* _tmp3_;
1237 		ValadocApiItem* _tmp4_;
1238 		ValadocApiItem* _tmp5_;
1239 		GString* _tmp22_;
1240 		const gchar* _tmp23_;
1241 		gchar* _tmp24_;
1242 		_tmp1_ = self->priv->_name;
1243 		if (_tmp1_ == NULL) {
1244 			result = NULL;
1245 			return result;
1246 		}
1247 		_tmp2_ = self->priv->_name;
1248 		_tmp3_ = g_string_new (_tmp2_);
1249 		full_name = _tmp3_;
1250 		_tmp4_ = valadoc_api_item_get_parent ((ValadocApiItem*) self);
1251 		_tmp5_ = _tmp4_;
1252 		if (_tmp5_ != NULL) {
1253 			{
1254 				ValadocApiItem* pos = NULL;
1255 				ValadocApiItem* _tmp6_;
1256 				ValadocApiItem* _tmp7_;
1257 				ValadocApiItem* _tmp8_;
1258 				_tmp6_ = valadoc_api_item_get_parent ((ValadocApiItem*) self);
1259 				_tmp7_ = _tmp6_;
1260 				_tmp8_ = _g_object_ref0 (_tmp7_);
1261 				pos = _tmp8_;
1262 				{
1263 					gboolean _tmp9_ = FALSE;
1264 					_tmp9_ = TRUE;
1265 					while (TRUE) {
1266 						ValadocApiItem* _tmp14_;
1267 						gchar* name = NULL;
1268 						ValadocApiItem* _tmp15_;
1269 						const gchar* _tmp16_;
1270 						gchar* _tmp17_;
1271 						const gchar* _tmp18_;
1272 						if (!_tmp9_) {
1273 							ValadocApiItem* _tmp10_;
1274 							ValadocApiItem* _tmp11_;
1275 							ValadocApiItem* _tmp12_;
1276 							ValadocApiItem* _tmp13_;
1277 							_tmp10_ = pos;
1278 							_tmp11_ = valadoc_api_item_get_parent (_tmp10_);
1279 							_tmp12_ = _tmp11_;
1280 							_tmp13_ = _g_object_ref0 (_tmp12_);
1281 							_g_object_unref0 (pos);
1282 							pos = _tmp13_;
1283 						}
1284 						_tmp9_ = FALSE;
1285 						_tmp14_ = pos;
1286 						if (!(VALADOC_API_IS_PACKAGE (_tmp14_) == FALSE)) {
1287 							break;
1288 						}
1289 						_tmp15_ = pos;
1290 						_tmp16_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp15_, VALADOC_API_TYPE_NODE, ValadocApiNode)->priv->_name;
1291 						_tmp17_ = g_strdup (_tmp16_);
1292 						name = _tmp17_;
1293 						_tmp18_ = name;
1294 						if (_tmp18_ != NULL) {
1295 							GString* _tmp19_;
1296 							GString* _tmp20_;
1297 							const gchar* _tmp21_;
1298 							_tmp19_ = full_name;
1299 							g_string_prepend_unichar (_tmp19_, (gunichar) '.');
1300 							_tmp20_ = full_name;
1301 							_tmp21_ = name;
1302 							g_string_prepend (_tmp20_, _tmp21_);
1303 						}
1304 						_g_free0 (name);
1305 					}
1306 				}
1307 				_g_object_unref0 (pos);
1308 			}
1309 		}
1310 		_tmp22_ = full_name;
1311 		_tmp23_ = _tmp22_->str;
1312 		_tmp24_ = g_strdup (_tmp23_);
1313 		_g_free0 (self->priv->_full_name);
1314 		self->priv->_full_name = _tmp24_;
1315 		_g_string_free0 (full_name);
1316 	}
1317 	_tmp25_ = self->priv->_full_name;
1318 	_tmp26_ = g_strdup (_tmp25_);
1319 	result = _tmp26_;
1320 	return result;
1321 }
1322 
1323 /**
1324  * A comparison function used to sort nodes in alphabetical order
1325  */
1326 gint
valadoc_api_node_compare_to(ValadocApiNode * self,ValadocApiNode * node)1327 valadoc_api_node_compare_to (ValadocApiNode* self,
1328                              ValadocApiNode* node)
1329 {
1330 	GCompareFunc _tmp0_;
1331 	const gchar* _tmp1_;
1332 	const gchar* _tmp2_;
1333 	gint result = 0;
1334 	g_return_val_if_fail (self != NULL, 0);
1335 	g_return_val_if_fail (node != NULL, 0);
1336 	_tmp0_ = ((GCompareFunc) g_strcmp0);
1337 	_tmp1_ = self->priv->_name;
1338 	_tmp2_ = node->priv->_name;
1339 	result = _tmp0_ (_tmp1_, _tmp2_);
1340 	return result;
1341 }
1342 
1343 static void
valadoc_api_node_class_init(ValadocApiNodeClass * klass,gpointer klass_data)1344 valadoc_api_node_class_init (ValadocApiNodeClass * klass,
1345                              gpointer klass_data)
1346 {
1347 	valadoc_api_node_parent_class = g_type_class_peek_parent (klass);
1348 	g_type_class_adjust_private_offset (klass, &ValadocApiNode_private_offset);
1349 	((ValadocApiNodeClass *) klass)->accept = (void (*) (ValadocApiNode*, ValadocApiVisitor*)) valadoc_api_node_real_accept;
1350 	((ValadocApiNodeClass *) klass)->is_browsable = (gboolean (*) (ValadocApiNode*, ValadocSettings*)) valadoc_api_node_real_is_browsable;
1351 	((ValadocApiItemClass *) klass)->parse_comments = (void (*) (ValadocApiItem*, ValadocSettings*, ValadocDocumentationParser*)) valadoc_api_node_real_parse_comments;
1352 	((ValadocApiItemClass *) klass)->check_comments = (void (*) (ValadocApiItem*, ValadocSettings*, ValadocDocumentationParser*)) valadoc_api_node_real_check_comments;
1353 	G_OBJECT_CLASS (klass)->get_property = _vala_valadoc_api_node_get_property;
1354 	G_OBJECT_CLASS (klass)->set_property = _vala_valadoc_api_node_set_property;
1355 	G_OBJECT_CLASS (klass)->finalize = valadoc_api_node_finalize;
1356 	/**
1357 	 * The name of the node
1358 	 */
1359 	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_API_NODE_NAME_PROPERTY, valadoc_api_node_properties[VALADOC_API_NODE_NAME_PROPERTY] = g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
1360 	/**
1361 	 * Returns the type of this node
1362 	 */
1363 	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_API_NODE_NODE_TYPE_PROPERTY, valadoc_api_node_properties[VALADOC_API_NODE_NODE_TYPE_PROPERTY] = g_param_spec_enum ("node-type", "node-type", "node-type", VALADOC_API_TYPE_NODE_TYPE, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
1364 	/**
1365 	 * The corresponding namespace
1366 	 */
1367 	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_API_NODE_NSPACE_PROPERTY, valadoc_api_node_properties[VALADOC_API_NODE_NSPACE_PROPERTY] = g_param_spec_object ("nspace", "nspace", "nspace", VALADOC_API_TYPE_NAMESPACE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
1368 	/**
1369 	 * The corresponding package such as a vapi or gir file
1370 	 */
1371 	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_API_NODE_PACKAGE_PROPERTY, valadoc_api_node_properties[VALADOC_API_NODE_PACKAGE_PROPERTY] = g_param_spec_object ("package", "package", "package", VALADOC_API_TYPE_PACKAGE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
1372 	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_API_NODE_DOCUMENTATION_PROPERTY, valadoc_api_node_properties[VALADOC_API_NODE_DOCUMENTATION_PROPERTY] = g_param_spec_object ("documentation", "documentation", "documentation", VALADOC_CONTENT_TYPE_COMMENT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
1373 }
1374 
1375 static void
valadoc_api_node_valadoc_documentation_interface_init(ValadocDocumentationIface * iface,gpointer iface_data)1376 valadoc_api_node_valadoc_documentation_interface_init (ValadocDocumentationIface * iface,
1377                                                        gpointer iface_data)
1378 {
1379 	valadoc_api_node_valadoc_documentation_parent_iface = g_type_interface_peek_parent (iface);
1380 	iface->get_filename = (gchar* (*) (ValadocDocumentation*)) valadoc_api_node_real_get_filename;
1381 	iface->get_package = valadoc_api_node_real_get_package;
1382 }
1383 
1384 static void
valadoc_api_node_instance_init(ValadocApiNode * self,gpointer klass)1385 valadoc_api_node_instance_init (ValadocApiNode * self,
1386                                 gpointer klass)
1387 {
1388 	self->priv = valadoc_api_node_get_instance_private (self);
1389 	self->do_document = FALSE;
1390 	self->priv->_nspace = NULL;
1391 	self->priv->_package = NULL;
1392 	self->priv->_full_name = NULL;
1393 }
1394 
1395 static void
valadoc_api_node_finalize(GObject * obj)1396 valadoc_api_node_finalize (GObject * obj)
1397 {
1398 	ValadocApiNode * self;
1399 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_API_TYPE_NODE, ValadocApiNode);
1400 	_g_object_unref0 (self->priv->file);
1401 	_g_free0 (self->priv->_name);
1402 	_vala_map_unref0 (self->priv->per_name_children);
1403 	_vala_map_unref0 (self->priv->per_type_children);
1404 	_g_object_unref0 (self->priv->_nspace);
1405 	_g_object_unref0 (self->priv->_package);
1406 	_g_free0 (self->priv->_full_name);
1407 	_g_object_unref0 (self->priv->_documentation);
1408 	G_OBJECT_CLASS (valadoc_api_node_parent_class)->finalize (obj);
1409 }
1410 
1411 /**
1412  * Represents a node in the api tree.
1413  */
1414 static GType
valadoc_api_node_get_type_once(void)1415 valadoc_api_node_get_type_once (void)
1416 {
1417 	static const GTypeInfo g_define_type_info = { sizeof (ValadocApiNodeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_api_node_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocApiNode), 0, (GInstanceInitFunc) valadoc_api_node_instance_init, NULL };
1418 	static const GInterfaceInfo valadoc_documentation_info = { (GInterfaceInitFunc) valadoc_api_node_valadoc_documentation_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
1419 	GType valadoc_api_node_type_id;
1420 	valadoc_api_node_type_id = g_type_register_static (VALADOC_API_TYPE_ITEM, "ValadocApiNode", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
1421 	g_type_add_interface_static (valadoc_api_node_type_id, VALADOC_TYPE_DOCUMENTATION, &valadoc_documentation_info);
1422 	ValadocApiNode_private_offset = g_type_add_instance_private (valadoc_api_node_type_id, sizeof (ValadocApiNodePrivate));
1423 	return valadoc_api_node_type_id;
1424 }
1425 
1426 GType
valadoc_api_node_get_type(void)1427 valadoc_api_node_get_type (void)
1428 {
1429 	static volatile gsize valadoc_api_node_type_id__volatile = 0;
1430 	if (g_once_init_enter (&valadoc_api_node_type_id__volatile)) {
1431 		GType valadoc_api_node_type_id;
1432 		valadoc_api_node_type_id = valadoc_api_node_get_type_once ();
1433 		g_once_init_leave (&valadoc_api_node_type_id__volatile, valadoc_api_node_type_id);
1434 	}
1435 	return valadoc_api_node_type_id__volatile;
1436 }
1437 
1438 static void
_vala_valadoc_api_node_get_property(GObject * object,guint property_id,GValue * value,GParamSpec * pspec)1439 _vala_valadoc_api_node_get_property (GObject * object,
1440                                      guint property_id,
1441                                      GValue * value,
1442                                      GParamSpec * pspec)
1443 {
1444 	ValadocApiNode * self;
1445 	self = G_TYPE_CHECK_INSTANCE_CAST (object, VALADOC_API_TYPE_NODE, ValadocApiNode);
1446 	switch (property_id) {
1447 		case VALADOC_API_NODE_NAME_PROPERTY:
1448 		g_value_set_string (value, valadoc_api_node_get_name (self));
1449 		break;
1450 		case VALADOC_API_NODE_NSPACE_PROPERTY:
1451 		g_value_set_object (value, valadoc_api_node_get_nspace (self));
1452 		break;
1453 		case VALADOC_API_NODE_PACKAGE_PROPERTY:
1454 		g_value_set_object (value, valadoc_documentation_get_package ((ValadocDocumentation*) self));
1455 		break;
1456 		case VALADOC_API_NODE_DOCUMENTATION_PROPERTY:
1457 		g_value_set_object (value, valadoc_api_node_get_documentation (self));
1458 		break;
1459 		default:
1460 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1461 		break;
1462 	}
1463 }
1464 
1465 static void
_vala_valadoc_api_node_set_property(GObject * object,guint property_id,const GValue * value,GParamSpec * pspec)1466 _vala_valadoc_api_node_set_property (GObject * object,
1467                                      guint property_id,
1468                                      const GValue * value,
1469                                      GParamSpec * pspec)
1470 {
1471 	ValadocApiNode * self;
1472 	self = G_TYPE_CHECK_INSTANCE_CAST (object, VALADOC_API_TYPE_NODE, ValadocApiNode);
1473 	switch (property_id) {
1474 		case VALADOC_API_NODE_NAME_PROPERTY:
1475 		valadoc_api_node_set_name (self, g_value_get_string (value));
1476 		break;
1477 		case VALADOC_API_NODE_DOCUMENTATION_PROPERTY:
1478 		valadoc_api_node_set_documentation (self, g_value_get_object (value));
1479 		break;
1480 		default:
1481 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1482 		break;
1483 	}
1484 }
1485 
1486