1 /* tree.c generated by valac, the Vala compiler
2  * generated from tree.vala, do not modify */
3 
4 /* tree.vala
5  *
6  * Copyright (C) 2008-2011  Florian Brosch
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
21  *
22  * Author:
23  * 	Florian Brosch <flo.brosch@gmail.com>
24  */
25 
26 #include "valadoc.h"
27 #include <valagee.h>
28 #include <glib-object.h>
29 #include <stdlib.h>
30 #include <string.h>
31 #include <glib.h>
32 #include <vala.h>
33 #include <glib/gstdio.h>
34 #include <gobject/gvaluecollector.h>
35 
36 #define VALADOC_API_TREE_TYPE_INHERIT_DOC_CONTAINER (valadoc_api_tree_inherit_doc_container_get_type ())
37 #define VALADOC_API_TREE_INHERIT_DOC_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALADOC_API_TREE_TYPE_INHERIT_DOC_CONTAINER, ValadocApiTreeInheritDocContainer))
38 #define VALADOC_API_TREE_INHERIT_DOC_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VALADOC_API_TREE_TYPE_INHERIT_DOC_CONTAINER, ValadocApiTreeInheritDocContainerClass))
39 #define VALADOC_API_TREE_IS_INHERIT_DOC_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VALADOC_API_TREE_TYPE_INHERIT_DOC_CONTAINER))
40 #define VALADOC_API_TREE_IS_INHERIT_DOC_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VALADOC_API_TREE_TYPE_INHERIT_DOC_CONTAINER))
41 #define VALADOC_API_TREE_INHERIT_DOC_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VALADOC_API_TREE_TYPE_INHERIT_DOC_CONTAINER, ValadocApiTreeInheritDocContainerClass))
42 
43 typedef struct _ValadocApiTreeInheritDocContainer ValadocApiTreeInheritDocContainer;
44 typedef struct _ValadocApiTreeInheritDocContainerClass ValadocApiTreeInheritDocContainerClass;
45 #define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
46 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
47 #define _vala_code_context_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_context_unref (var), NULL)))
48 #define _g_free0(var) (var = (g_free (var), NULL))
49 #define _valadoc_api_tree_inherit_doc_container_unref0(var) ((var == NULL) ? NULL : (var = (valadoc_api_tree_inherit_doc_container_unref (var), NULL)))
50 typedef struct _ValadocApiTreeInheritDocContainerPrivate ValadocApiTreeInheritDocContainerPrivate;
51 typedef struct _ValadocApiTreeParamSpecInheritDocContainer ValadocApiTreeParamSpecInheritDocContainer;
52 typedef struct _ValadocApiParamSpecTree ValadocApiParamSpecTree;
53 
54 struct _ValadocApiTreePrivate {
55 	ValaList* inheritdocs;
56 	ValaArrayList* external_c_files;
57 	ValaArrayList* packages;
58 	ValadocApiPackage* source_package;
59 	ValadocSettings* settings;
60 	ValadocErrorReporter* reporter;
61 	ValadocHighlighterHighlighter* _highlighter;
62 	ValadocCTypeResolver* _cresolver;
63 	ValadocApiPackage* _source_package;
64 	ValaCodeContext* _context;
65 	ValadocWikiPageTree* _wikitree;
66 };
67 
68 struct _ValadocApiTreeInheritDocContainer {
69 	GTypeInstance parent_instance;
70 	volatile int ref_count;
71 	ValadocTagletsInheritDoc* taglet;
72 	ValadocApiNode* taglet_container;
73 	ValadocApiTreeInheritDocContainerPrivate * priv;
74 };
75 
76 struct _ValadocApiTreeInheritDocContainerClass {
77 	GTypeClass parent_class;
78 	void (*finalize) (ValadocApiTreeInheritDocContainer *self);
79 };
80 
81 struct _ValadocApiTreeParamSpecInheritDocContainer {
82 	GParamSpec parent_instance;
83 };
84 
85 struct _ValadocApiParamSpecTree {
86 	GParamSpec parent_instance;
87 };
88 
89 static gint ValadocApiTree_private_offset;
90 static gpointer valadoc_api_tree_parent_class = NULL;
91 static gpointer valadoc_api_tree_inherit_doc_container_parent_class = NULL;
92 
93 static gpointer valadoc_api_tree_inherit_doc_container_ref (gpointer instance);
94 static void valadoc_api_tree_inherit_doc_container_unref (gpointer instance);
95 static GParamSpec* valadoc_api_tree_param_spec_inherit_doc_container (const gchar* name,
96                                                                const gchar* nick,
97                                                                const gchar* blurb,
98                                                                GType object_type,
99                                                                GParamFlags flags) G_GNUC_UNUSED;
100 static void valadoc_api_tree_value_set_inherit_doc_container (GValue* value,
101                                                        gpointer v_object) G_GNUC_UNUSED;
102 static void valadoc_api_tree_value_take_inherit_doc_container (GValue* value,
103                                                         gpointer v_object) G_GNUC_UNUSED;
104 static gpointer valadoc_api_tree_value_get_inherit_doc_container (const GValue* value) G_GNUC_UNUSED;
105 static GType valadoc_api_tree_inherit_doc_container_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
106 static void valadoc_api_tree_set_wikitree (ValadocApiTree* self,
107                                     ValadocWikiPageTree* value);
108 static void valadoc_api_tree_add_dependencies_to_source_package (ValadocApiTree* self);
109 G_GNUC_INTERNAL void valadoc_api_package_set_dependency_list (ValadocApiPackage* self,
110                                               ValaArrayList* list);
111 static ValadocApiNode* valadoc_api_tree_search_relative_to (ValadocApiTree* self,
112                                                      ValadocApiNode* element,
113                                                      gchar** path,
114                                                      gint path_length1);
115 static gchar** valadoc_api_tree_split_name (ValadocApiTree* self,
116                                      const gchar* full_name,
117                                      gint* result_length1);
118 static gchar* valadoc_api_tree_get_file_path (ValadocApiTree* self,
119                                        const gchar* basename,
120                                        gchar** directories,
121                                        gint directories_length1);
122 static ValadocApiPackage* valadoc_api_tree_get_source_package (ValadocApiTree* self);
123 static void valadoc_api_tree_parse_wiki (ValadocApiTree* self,
124                                   ValadocDocumentationParser* docparser);
125 static void valadoc_api_tree_check_wiki (ValadocApiTree* self,
126                                   ValadocDocumentationParser* docparser);
127 G_GNUC_INTERNAL void valadoc_api_item_parse_comments (ValadocApiItem* self,
128                                       ValadocSettings* settings,
129                                       ValadocDocumentationParser* parser);
130 G_GNUC_INTERNAL void valadoc_api_item_check_comments (ValadocApiItem* self,
131                                       ValadocSettings* settings,
132                                       ValadocDocumentationParser* parser);
133 static void valadoc_api_tree_postprocess_inheritdoc (ValadocApiTree* self,
134                                               ValadocDocumentationParser* docparser);
135 G_GNUC_INTERNAL void valadoc_api_tree_register_inheritdoc (ValadocApiTree* self,
136                                            ValadocApiNode* container,
137                                            ValadocTagletsInheritDoc* taglet);
138 static ValadocApiTreeInheritDocContainer* valadoc_api_tree_inherit_doc_container_new (ValadocApiNode* taglet_container,
139                                                                                ValadocTagletsInheritDoc* taglet);
140 static ValadocApiTreeInheritDocContainer* valadoc_api_tree_inherit_doc_container_construct (GType object_type,
141                                                                                      ValadocApiNode* taglet_container,
142                                                                                      ValadocTagletsInheritDoc* taglet);
143 static void valadoc_api_tree_inherit_doc_container_finalize (ValadocApiTreeInheritDocContainer * obj);
144 static GType valadoc_api_tree_inherit_doc_container_get_type_once (void);
145 static void valadoc_api_tree_finalize (ValadocApiTree * obj);
146 static GType valadoc_api_tree_get_type_once (void);
147 static void _vala_array_destroy (gpointer array,
148                           gint array_length,
149                           GDestroyNotify destroy_func);
150 static void _vala_array_free (gpointer array,
151                        gint array_length,
152                        GDestroyNotify destroy_func);
153 static gint _vala_array_length (gpointer array);
154 
155 static inline gpointer
valadoc_api_tree_get_instance_private(ValadocApiTree * self)156 valadoc_api_tree_get_instance_private (ValadocApiTree* self)
157 {
158 	return G_STRUCT_MEMBER_P (self, ValadocApiTree_private_offset);
159 }
160 
161 void
valadoc_api_tree_add_package(ValadocApiTree * self,ValadocApiPackage * package)162 valadoc_api_tree_add_package (ValadocApiTree* self,
163                               ValadocApiPackage* package)
164 {
165 	ValaArrayList* _tmp0_;
166 	g_return_if_fail (self != NULL);
167 	g_return_if_fail (package != NULL);
168 	_tmp0_ = self->priv->packages;
169 	vala_collection_add ((ValaCollection*) _tmp0_, package);
170 }
171 
172 ValaCodeContext*
valadoc_api_tree_get_context(ValadocApiTree * self)173 valadoc_api_tree_get_context (ValadocApiTree* self)
174 {
175 	ValaCodeContext* result;
176 	ValaCodeContext* _tmp0_;
177 	g_return_val_if_fail (self != NULL, NULL);
178 	_tmp0_ = self->priv->_context;
179 	result = _tmp0_;
180 	return result;
181 }
182 
183 static gpointer
_vala_code_context_ref0(gpointer self)184 _vala_code_context_ref0 (gpointer self)
185 {
186 	return self ? vala_code_context_ref (self) : NULL;
187 }
188 
189 void
valadoc_api_tree_set_context(ValadocApiTree * self,ValaCodeContext * value)190 valadoc_api_tree_set_context (ValadocApiTree* self,
191                               ValaCodeContext* value)
192 {
193 	ValaCodeContext* _tmp0_;
194 	g_return_if_fail (self != NULL);
195 	_tmp0_ = _vala_code_context_ref0 (value);
196 	_vala_code_context_unref0 (self->priv->_context);
197 	self->priv->_context = _tmp0_;
198 }
199 
200 ValadocHighlighterHighlighter*
valadoc_api_tree_get_highlighter(ValadocApiTree * self)201 valadoc_api_tree_get_highlighter (ValadocApiTree* self)
202 {
203 	ValadocHighlighterHighlighter* result;
204 	ValadocHighlighterHighlighter* _tmp0_;
205 	ValadocHighlighterHighlighter* _tmp2_;
206 	g_return_val_if_fail (self != NULL, NULL);
207 	_tmp0_ = self->priv->_highlighter;
208 	if (_tmp0_ == NULL) {
209 		ValadocHighlighterHighlighter* _tmp1_;
210 		_tmp1_ = valadoc_highlighter_highlighter_new ();
211 		_g_object_unref0 (self->priv->_highlighter);
212 		self->priv->_highlighter = _tmp1_;
213 	}
214 	_tmp2_ = self->priv->_highlighter;
215 	result = _tmp2_;
216 	return result;
217 }
218 
219 ValadocWikiPageTree*
valadoc_api_tree_get_wikitree(ValadocApiTree * self)220 valadoc_api_tree_get_wikitree (ValadocApiTree* self)
221 {
222 	ValadocWikiPageTree* result;
223 	ValadocWikiPageTree* _tmp0_;
224 	g_return_val_if_fail (self != NULL, NULL);
225 	_tmp0_ = self->priv->_wikitree;
226 	result = _tmp0_;
227 	return result;
228 }
229 
230 static gpointer
_g_object_ref0(gpointer self)231 _g_object_ref0 (gpointer self)
232 {
233 	return self ? g_object_ref (self) : NULL;
234 }
235 
236 static void
valadoc_api_tree_set_wikitree(ValadocApiTree * self,ValadocWikiPageTree * value)237 valadoc_api_tree_set_wikitree (ValadocApiTree* self,
238                                ValadocWikiPageTree* value)
239 {
240 	ValadocWikiPageTree* _tmp0_;
241 	g_return_if_fail (self != NULL);
242 	_tmp0_ = _g_object_ref0 (value);
243 	_g_object_unref0 (self->priv->_wikitree);
244 	self->priv->_wikitree = _tmp0_;
245 }
246 
247 /**
248  * Returns a list of C source files.
249  *
250  * @return list of C source files
251  */
252 static gpointer
_vala_iterable_ref0(gpointer self)253 _vala_iterable_ref0 (gpointer self)
254 {
255 	return self ? vala_iterable_ref (self) : NULL;
256 }
257 
258 ValaCollection*
valadoc_api_tree_get_external_c_files(ValadocApiTree * self)259 valadoc_api_tree_get_external_c_files (ValadocApiTree* self)
260 {
261 	ValaArrayList* _tmp0_;
262 	ValaCollection* _tmp1_;
263 	ValaCollection* result = NULL;
264 	g_return_val_if_fail (self != NULL, NULL);
265 	_tmp0_ = self->priv->external_c_files;
266 	_tmp1_ = _vala_iterable_ref0 ((ValaCollection*) _tmp0_);
267 	result = _tmp1_;
268 	return result;
269 }
270 
271 void
valadoc_api_tree_add_external_c_files(ValadocApiTree * self,const gchar * name)272 valadoc_api_tree_add_external_c_files (ValadocApiTree* self,
273                                        const gchar* name)
274 {
275 	ValaArrayList* _tmp0_;
276 	g_return_if_fail (self != NULL);
277 	g_return_if_fail (name != NULL);
278 	_tmp0_ = self->priv->external_c_files;
279 	vala_collection_add ((ValaCollection*) _tmp0_, name);
280 }
281 
282 /**
283  * Returns a list of all packages in the tree
284  *
285  * @return list of all packages
286  */
287 ValaCollection*
valadoc_api_tree_get_package_list(ValadocApiTree * self)288 valadoc_api_tree_get_package_list (ValadocApiTree* self)
289 {
290 	ValaArrayList* _tmp0_;
291 	ValaCollection* _tmp1_;
292 	ValaCollection* result = NULL;
293 	g_return_val_if_fail (self != NULL, NULL);
294 	_tmp0_ = self->priv->packages;
295 	_tmp1_ = _vala_iterable_ref0 ((ValaCollection*) _tmp0_);
296 	result = _tmp1_;
297 	return result;
298 }
299 
300 static void
valadoc_api_tree_add_dependencies_to_source_package(ValadocApiTree * self)301 valadoc_api_tree_add_dependencies_to_source_package (ValadocApiTree* self)
302 {
303 	ValadocApiPackage* _tmp0_;
304 	g_return_if_fail (self != NULL);
305 	_tmp0_ = self->priv->source_package;
306 	if (_tmp0_ != NULL) {
307 		ValaArrayList* deplst = NULL;
308 		GEqualFunc _tmp1_;
309 		ValaArrayList* _tmp2_;
310 		ValadocApiPackage* _tmp16_;
311 		ValaArrayList* _tmp17_;
312 		_tmp1_ = g_direct_equal;
313 		_tmp2_ = vala_array_list_new (VALADOC_API_TYPE_PACKAGE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp1_);
314 		deplst = _tmp2_;
315 		{
316 			ValaArrayList* _pkg_list = NULL;
317 			ValaArrayList* _tmp3_;
318 			ValaArrayList* _tmp4_;
319 			gint _pkg_size = 0;
320 			ValaArrayList* _tmp5_;
321 			gint _tmp6_;
322 			gint _tmp7_;
323 			gint _pkg_index = 0;
324 			_tmp3_ = self->priv->packages;
325 			_tmp4_ = _vala_iterable_ref0 (_tmp3_);
326 			_pkg_list = _tmp4_;
327 			_tmp5_ = _pkg_list;
328 			_tmp6_ = vala_collection_get_size ((ValaCollection*) _tmp5_);
329 			_tmp7_ = _tmp6_;
330 			_pkg_size = _tmp7_;
331 			_pkg_index = -1;
332 			while (TRUE) {
333 				gint _tmp8_;
334 				gint _tmp9_;
335 				ValadocApiPackage* pkg = NULL;
336 				ValaArrayList* _tmp10_;
337 				gpointer _tmp11_;
338 				ValadocApiPackage* _tmp12_;
339 				ValadocApiPackage* _tmp13_;
340 				_pkg_index = _pkg_index + 1;
341 				_tmp8_ = _pkg_index;
342 				_tmp9_ = _pkg_size;
343 				if (!(_tmp8_ < _tmp9_)) {
344 					break;
345 				}
346 				_tmp10_ = _pkg_list;
347 				_tmp11_ = vala_list_get ((ValaList*) _tmp10_, _pkg_index);
348 				pkg = (ValadocApiPackage*) _tmp11_;
349 				_tmp12_ = pkg;
350 				_tmp13_ = self->priv->source_package;
351 				if (_tmp12_ != _tmp13_) {
352 					ValaArrayList* _tmp14_;
353 					ValadocApiPackage* _tmp15_;
354 					_tmp14_ = deplst;
355 					_tmp15_ = pkg;
356 					vala_collection_add ((ValaCollection*) _tmp14_, _tmp15_);
357 				}
358 				_g_object_unref0 (pkg);
359 			}
360 			_vala_iterable_unref0 (_pkg_list);
361 		}
362 		_tmp16_ = self->priv->source_package;
363 		_tmp17_ = deplst;
364 		valadoc_api_package_set_dependency_list (_tmp16_, _tmp17_);
365 		_vala_iterable_unref0 (deplst);
366 	}
367 }
368 
369 /**
370  * Visits this node with the specified Visitor.
371  *
372  * @param visitor the visitor to be called while traversing
373  */
374 void
valadoc_api_tree_accept(ValadocApiTree * self,ValadocApiVisitor * visitor)375 valadoc_api_tree_accept (ValadocApiTree* self,
376                          ValadocApiVisitor* visitor)
377 {
378 	g_return_if_fail (self != NULL);
379 	g_return_if_fail (visitor != NULL);
380 	valadoc_api_visitor_visit_tree (visitor, self);
381 }
382 
383 /**
384  * Visits all children of this node with the given types with the specified Visitor.
385  *
386  * @param visitor the visitor to be called while traversing
387  */
388 void
valadoc_api_tree_accept_children(ValadocApiTree * self,ValadocApiVisitor * visitor)389 valadoc_api_tree_accept_children (ValadocApiTree* self,
390                                   ValadocApiVisitor* visitor)
391 {
392 	g_return_if_fail (self != NULL);
393 	g_return_if_fail (visitor != NULL);
394 	{
395 		ValaArrayList* _node_list = NULL;
396 		ValaArrayList* _tmp0_;
397 		ValaArrayList* _tmp1_;
398 		gint _node_size = 0;
399 		ValaArrayList* _tmp2_;
400 		gint _tmp3_;
401 		gint _tmp4_;
402 		gint _node_index = 0;
403 		_tmp0_ = self->priv->packages;
404 		_tmp1_ = _vala_iterable_ref0 (_tmp0_);
405 		_node_list = _tmp1_;
406 		_tmp2_ = _node_list;
407 		_tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
408 		_tmp4_ = _tmp3_;
409 		_node_size = _tmp4_;
410 		_node_index = -1;
411 		while (TRUE) {
412 			gint _tmp5_;
413 			gint _tmp6_;
414 			ValadocApiNode* node = NULL;
415 			ValaArrayList* _tmp7_;
416 			gpointer _tmp8_;
417 			ValadocApiNode* _tmp9_;
418 			_node_index = _node_index + 1;
419 			_tmp5_ = _node_index;
420 			_tmp6_ = _node_size;
421 			if (!(_tmp5_ < _tmp6_)) {
422 				break;
423 			}
424 			_tmp7_ = _node_list;
425 			_tmp8_ = vala_list_get ((ValaList*) _tmp7_, _node_index);
426 			node = (ValadocApiNode*) ((ValadocApiPackage*) _tmp8_);
427 			_tmp9_ = node;
428 			valadoc_api_node_accept (_tmp9_, visitor);
429 			_g_object_unref0 (node);
430 		}
431 		_vala_iterable_unref0 (_node_list);
432 	}
433 }
434 
435 static ValadocApiNode*
valadoc_api_tree_search_relative_to(ValadocApiTree * self,ValadocApiNode * element,gchar ** path,gint path_length1)436 valadoc_api_tree_search_relative_to (ValadocApiTree* self,
437                                      ValadocApiNode* element,
438                                      gchar** path,
439                                      gint path_length1)
440 {
441 	ValadocApiNode* node = NULL;
442 	ValadocApiNode* _tmp0_;
443 	gboolean _tmp6_ = FALSE;
444 	ValadocApiNode* _tmp7_;
445 	ValadocApiNode* result = NULL;
446 	g_return_val_if_fail (self != NULL, NULL);
447 	g_return_val_if_fail (element != NULL, NULL);
448 	_tmp0_ = _g_object_ref0 (element);
449 	node = _tmp0_;
450 	{
451 		gchar** name_collection = NULL;
452 		gint name_collection_length1 = 0;
453 		gint _name_collection_size_ = 0;
454 		gint name_it = 0;
455 		name_collection = path;
456 		name_collection_length1 = path_length1;
457 		for (name_it = 0; name_it < name_collection_length1; name_it = name_it + 1) {
458 			gchar* _tmp1_;
459 			gchar* name = NULL;
460 			_tmp1_ = g_strdup (name_collection[name_it]);
461 			name = _tmp1_;
462 			{
463 				ValadocApiNode* _tmp2_;
464 				const gchar* _tmp3_;
465 				ValadocApiNode* _tmp4_;
466 				ValadocApiNode* _tmp5_;
467 				_tmp2_ = node;
468 				_tmp3_ = name;
469 				_tmp4_ = valadoc_api_node_find_by_name (_tmp2_, _tmp3_);
470 				_g_object_unref0 (node);
471 				node = _tmp4_;
472 				_tmp5_ = node;
473 				if (_tmp5_ == NULL) {
474 					_g_free0 (name);
475 					break;
476 				}
477 				_g_free0 (name);
478 			}
479 		}
480 	}
481 	_tmp7_ = node;
482 	if (_tmp7_ == NULL) {
483 		ValadocApiItem* _tmp8_;
484 		ValadocApiItem* _tmp9_;
485 		_tmp8_ = valadoc_api_item_get_parent ((ValadocApiItem*) element);
486 		_tmp9_ = _tmp8_;
487 		_tmp6_ = _tmp9_ != NULL;
488 	} else {
489 		_tmp6_ = FALSE;
490 	}
491 	if (_tmp6_) {
492 		ValadocApiItem* _tmp10_;
493 		ValadocApiItem* _tmp11_;
494 		ValadocApiNode* _tmp12_;
495 		_tmp10_ = valadoc_api_item_get_parent ((ValadocApiItem*) element);
496 		_tmp11_ = _tmp10_;
497 		_tmp12_ = valadoc_api_tree_search_relative_to (self, G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, VALADOC_API_TYPE_NODE, ValadocApiNode), path, (gint) path_length1);
498 		_g_object_unref0 (node);
499 		node = _tmp12_;
500 	}
501 	result = node;
502 	return result;
503 }
504 
505 ValadocApiNode*
valadoc_api_tree_search_symbol_path(ValadocApiTree * self,ValadocApiNode * element,gchar ** path,gint path_length1)506 valadoc_api_tree_search_symbol_path (ValadocApiTree* self,
507                                      ValadocApiNode* element,
508                                      gchar** path,
509                                      gint path_length1)
510 {
511 	ValadocApiNode* node = NULL;
512 	ValadocApiNode* result = NULL;
513 	g_return_val_if_fail (self != NULL, NULL);
514 	node = NULL;
515 	if (element != NULL) {
516 		ValadocApiNode* _tmp0_;
517 		ValadocApiNode* _tmp1_;
518 		_tmp0_ = valadoc_api_tree_search_relative_to (self, element, path, (gint) path_length1);
519 		_g_object_unref0 (node);
520 		node = _tmp0_;
521 		_tmp1_ = node;
522 		if (_tmp1_ != NULL) {
523 			result = node;
524 			return result;
525 		}
526 	}
527 	{
528 		ValaArrayList* _package_list = NULL;
529 		ValaArrayList* _tmp2_;
530 		ValaArrayList* _tmp3_;
531 		gint _package_size = 0;
532 		ValaArrayList* _tmp4_;
533 		gint _tmp5_;
534 		gint _tmp6_;
535 		gint _package_index = 0;
536 		_tmp2_ = self->priv->packages;
537 		_tmp3_ = _vala_iterable_ref0 (_tmp2_);
538 		_package_list = _tmp3_;
539 		_tmp4_ = _package_list;
540 		_tmp5_ = vala_collection_get_size ((ValaCollection*) _tmp4_);
541 		_tmp6_ = _tmp5_;
542 		_package_size = _tmp6_;
543 		_package_index = -1;
544 		while (TRUE) {
545 			gint _tmp7_;
546 			gint _tmp8_;
547 			ValadocApiPackage* package = NULL;
548 			ValaArrayList* _tmp9_;
549 			gpointer _tmp10_;
550 			ValadocApiNode* global = NULL;
551 			ValadocApiPackage* _tmp11_;
552 			ValadocApiNode* _tmp12_;
553 			ValadocApiNode* _tmp13_;
554 			_package_index = _package_index + 1;
555 			_tmp7_ = _package_index;
556 			_tmp8_ = _package_size;
557 			if (!(_tmp7_ < _tmp8_)) {
558 				break;
559 			}
560 			_tmp9_ = _package_list;
561 			_tmp10_ = vala_list_get ((ValaList*) _tmp9_, _package_index);
562 			package = (ValadocApiPackage*) _tmp10_;
563 			_tmp11_ = package;
564 			_tmp12_ = valadoc_api_node_find_by_name ((ValadocApiNode*) _tmp11_, "");
565 			global = _tmp12_;
566 			_tmp13_ = global;
567 			if (_tmp13_ != NULL) {
568 				ValadocApiNode* _tmp14_;
569 				ValadocApiNode* _tmp15_;
570 				ValadocApiNode* _tmp16_;
571 				_tmp14_ = global;
572 				_tmp15_ = valadoc_api_tree_search_relative_to (self, _tmp14_, path, (gint) path_length1);
573 				_g_object_unref0 (node);
574 				node = _tmp15_;
575 				_tmp16_ = node;
576 				if (_tmp16_ != NULL) {
577 					result = node;
578 					_g_object_unref0 (global);
579 					_g_object_unref0 (package);
580 					_vala_iterable_unref0 (_package_list);
581 					return result;
582 				}
583 			}
584 			_g_object_unref0 (global);
585 			_g_object_unref0 (package);
586 		}
587 		_vala_iterable_unref0 (_package_list);
588 	}
589 	result = NULL;
590 	_g_object_unref0 (node);
591 	return result;
592 }
593 
594 ValadocApiTypeSymbol*
valadoc_api_tree_search_symbol_type_cstr(ValadocApiTree * self,const gchar * cname)595 valadoc_api_tree_search_symbol_type_cstr (ValadocApiTree* self,
596                                           const gchar* cname)
597 {
598 	ValadocCTypeResolver* _tmp0_;
599 	ValadocCTypeResolver* _tmp2_;
600 	ValadocApiTypeSymbol* _tmp3_;
601 	ValadocApiTypeSymbol* result = NULL;
602 	g_return_val_if_fail (self != NULL, NULL);
603 	g_return_val_if_fail (cname != NULL, NULL);
604 	_tmp0_ = self->priv->_cresolver;
605 	if (_tmp0_ == NULL) {
606 		ValadocCTypeResolver* _tmp1_;
607 		_tmp1_ = valadoc_ctype_resolver_new (self);
608 		_g_object_unref0 (self->priv->_cresolver);
609 		self->priv->_cresolver = _tmp1_;
610 	}
611 	_tmp2_ = self->priv->_cresolver;
612 	_tmp3_ = valadoc_ctype_resolver_resolve_symbol_type (_tmp2_, cname);
613 	result = _tmp3_;
614 	return result;
615 }
616 
617 ValadocApiNode*
valadoc_api_tree_search_symbol_cstr(ValadocApiTree * self,ValadocApiNode * element,const gchar * cname)618 valadoc_api_tree_search_symbol_cstr (ValadocApiTree* self,
619                                      ValadocApiNode* element,
620                                      const gchar* cname)
621 {
622 	ValadocCTypeResolver* _tmp0_;
623 	ValadocCTypeResolver* _tmp2_;
624 	ValadocApiNode* _tmp3_;
625 	ValadocApiNode* result = NULL;
626 	g_return_val_if_fail (self != NULL, NULL);
627 	g_return_val_if_fail (cname != NULL, NULL);
628 	_tmp0_ = self->priv->_cresolver;
629 	if (_tmp0_ == NULL) {
630 		ValadocCTypeResolver* _tmp1_;
631 		_tmp1_ = valadoc_ctype_resolver_new (self);
632 		_g_object_unref0 (self->priv->_cresolver);
633 		self->priv->_cresolver = _tmp1_;
634 	}
635 	_tmp2_ = self->priv->_cresolver;
636 	_tmp3_ = valadoc_ctype_resolver_resolve_symbol (_tmp2_, element, cname);
637 	result = _tmp3_;
638 	return result;
639 }
640 
641 ValadocApiNode*
valadoc_api_tree_search_symbol_str(ValadocApiTree * self,ValadocApiNode * element,const gchar * symname)642 valadoc_api_tree_search_symbol_str (ValadocApiTree* self,
643                                     ValadocApiNode* element,
644                                     const gchar* symname)
645 {
646 	gchar** path = NULL;
647 	gint _tmp0_ = 0;
648 	gchar** _tmp1_;
649 	gint path_length1;
650 	gint _path_size_;
651 	ValadocApiNode* node = NULL;
652 	gchar** _tmp2_;
653 	gint _tmp2__length1;
654 	ValadocApiNode* _tmp3_;
655 	ValadocApiNode* _tmp4_;
656 	gboolean _tmp5_ = FALSE;
657 	gchar** _tmp6_;
658 	gint _tmp6__length1;
659 	ValadocApiNode* result = NULL;
660 	g_return_val_if_fail (self != NULL, NULL);
661 	g_return_val_if_fail (symname != NULL, NULL);
662 	_tmp1_ = valadoc_api_tree_split_name (self, symname, &_tmp0_);
663 	path = _tmp1_;
664 	path_length1 = _tmp0_;
665 	_path_size_ = path_length1;
666 	_tmp2_ = path;
667 	_tmp2__length1 = path_length1;
668 	_tmp3_ = valadoc_api_tree_search_symbol_path (self, element, _tmp2_, (gint) _tmp2__length1);
669 	node = _tmp3_;
670 	_tmp4_ = node;
671 	if (_tmp4_ != NULL) {
672 		result = node;
673 		path = (_vala_array_free (path, path_length1, (GDestroyNotify) g_free), NULL);
674 		return result;
675 	}
676 	_tmp6_ = path;
677 	_tmp6__length1 = path_length1;
678 	if (_tmp6__length1 >= 2) {
679 		gchar** _tmp7_;
680 		gint _tmp7__length1;
681 		gchar** _tmp8_;
682 		gint _tmp8__length1;
683 		const gchar* _tmp9_;
684 		gchar** _tmp10_;
685 		gint _tmp10__length1;
686 		gchar** _tmp11_;
687 		gint _tmp11__length1;
688 		const gchar* _tmp12_;
689 		_tmp7_ = path;
690 		_tmp7__length1 = path_length1;
691 		_tmp8_ = path;
692 		_tmp8__length1 = path_length1;
693 		_tmp9_ = _tmp7_[_tmp8__length1 - 2];
694 		_tmp10_ = path;
695 		_tmp10__length1 = path_length1;
696 		_tmp11_ = path;
697 		_tmp11__length1 = path_length1;
698 		_tmp12_ = _tmp10_[_tmp11__length1 - 2];
699 		_tmp5_ = g_strcmp0 (_tmp9_, _tmp12_) == 0;
700 	} else {
701 		_tmp5_ = FALSE;
702 	}
703 	if (_tmp5_) {
704 		gchar** _tmp13_;
705 		gint _tmp13__length1;
706 		gchar** _tmp14_;
707 		gint _tmp14__length1;
708 		gchar** _tmp15_;
709 		gint _tmp15__length1;
710 		gchar** _tmp16_;
711 		gint _tmp16__length1;
712 		const gchar* _tmp17_;
713 		gchar* _tmp18_;
714 		gchar* _tmp19_;
715 		gchar** _tmp20_;
716 		gint _tmp20__length1;
717 		gchar** _tmp21_;
718 		gint _tmp21__length1;
719 		const gchar* _tmp22_;
720 		gchar* _tmp23_;
721 		gchar** _tmp24_;
722 		gint _tmp24__length1;
723 		gint _tmp25_;
724 		gchar** _tmp26_;
725 		gint _tmp26__length1;
726 		ValadocApiNode* _tmp27_;
727 		_tmp13_ = path;
728 		_tmp13__length1 = path_length1;
729 		_tmp14_ = path;
730 		_tmp14__length1 = path_length1;
731 		_tmp15_ = path;
732 		_tmp15__length1 = path_length1;
733 		_tmp16_ = path;
734 		_tmp16__length1 = path_length1;
735 		_tmp17_ = _tmp15_[_tmp16__length1 - 2];
736 		_tmp18_ = g_strconcat (_tmp17_, ".", NULL);
737 		_tmp19_ = _tmp18_;
738 		_tmp20_ = path;
739 		_tmp20__length1 = path_length1;
740 		_tmp21_ = path;
741 		_tmp21__length1 = path_length1;
742 		_tmp22_ = _tmp20_[_tmp21__length1 - 1];
743 		_tmp23_ = g_strconcat (_tmp19_, _tmp22_, NULL);
744 		_g_free0 (_tmp13_[_tmp14__length1 - 2]);
745 		_tmp13_[_tmp14__length1 - 2] = _tmp23_;
746 		_g_free0 (_tmp19_);
747 		_tmp24_ = path;
748 		_tmp24__length1 = path_length1;
749 		_tmp25_ = _tmp24__length1 - 1;
750 		path = g_renew (gchar*, path, _tmp24__length1 - 1);
751 		(_tmp25_ > path_length1) ? memset (path + path_length1, 0, sizeof (gchar*) * (_tmp25_ - path_length1)) : NULL;
752 		path_length1 = _tmp25_;
753 		_path_size_ = _tmp25_;
754 		_tmp26_ = path;
755 		_tmp26__length1 = path_length1;
756 		_tmp27_ = valadoc_api_tree_search_symbol_path (self, element, _tmp26_, (gint) _tmp26__length1);
757 		result = _tmp27_;
758 		_g_object_unref0 (node);
759 		path = (_vala_array_free (path, path_length1, (GDestroyNotify) g_free), NULL);
760 		return result;
761 	}
762 	result = NULL;
763 	_g_object_unref0 (node);
764 	path = (_vala_array_free (path, path_length1, (GDestroyNotify) g_free), NULL);
765 	return result;
766 }
767 
768 static gchar**
valadoc_api_tree_split_name(ValadocApiTree * self,const gchar * full_name,gint * result_length1)769 valadoc_api_tree_split_name (ValadocApiTree* self,
770                              const gchar* full_name,
771                              gint* result_length1)
772 {
773 	gchar** params = NULL;
774 	gchar** _tmp0_;
775 	gchar** _tmp1_;
776 	gint params_length1;
777 	gint _params_size_;
778 	gint i = 0;
779 	gchar** _tmp5_;
780 	gint _tmp5__length1;
781 	gchar** result = NULL;
782 	g_return_val_if_fail (self != NULL, NULL);
783 	g_return_val_if_fail (full_name != NULL, NULL);
784 	_tmp1_ = _tmp0_ = g_strsplit (full_name, ".", -1);
785 	params = _tmp1_;
786 	params_length1 = _vala_array_length (_tmp0_);
787 	_params_size_ = params_length1;
788 	i = 0;
789 	while (TRUE) {
790 		gchar** _tmp2_;
791 		gint _tmp2__length1;
792 		const gchar* _tmp3_;
793 		gint _tmp4_;
794 		_tmp2_ = params;
795 		_tmp2__length1 = params_length1;
796 		_tmp3_ = _tmp2_[i];
797 		if (!(_tmp3_ != NULL)) {
798 			break;
799 		}
800 		_tmp4_ = i;
801 		i = _tmp4_ + 1;
802 	}
803 	params_length1 = i;
804 	_tmp5_ = params;
805 	_tmp5__length1 = params_length1;
806 	if (result_length1) {
807 		*result_length1 = _tmp5__length1;
808 	}
809 	result = _tmp5_;
810 	return result;
811 }
812 
813 ValadocApiTree*
valadoc_api_tree_construct(GType object_type,ValadocErrorReporter * reporter,ValadocSettings * settings,ValaCodeContext * context)814 valadoc_api_tree_construct (GType object_type,
815                             ValadocErrorReporter* reporter,
816                             ValadocSettings* settings,
817                             ValaCodeContext* context)
818 {
819 	ValadocApiTree* self = NULL;
820 	ValadocSettings* _tmp0_;
821 	ValadocErrorReporter* _tmp1_;
822 	g_return_val_if_fail (reporter != NULL, NULL);
823 	g_return_val_if_fail (settings != NULL, NULL);
824 	g_return_val_if_fail (context != NULL, NULL);
825 	self = (ValadocApiTree*) g_type_create_instance (object_type);
826 	_tmp0_ = _g_object_ref0 (settings);
827 	_g_object_unref0 (self->priv->settings);
828 	self->priv->settings = _tmp0_;
829 	_tmp1_ = _g_object_ref0 (reporter);
830 	_g_object_unref0 (self->priv->reporter);
831 	self->priv->reporter = _tmp1_;
832 	valadoc_api_tree_set_context (self, context);
833 	return self;
834 }
835 
836 ValadocApiTree*
valadoc_api_tree_new(ValadocErrorReporter * reporter,ValadocSettings * settings,ValaCodeContext * context)837 valadoc_api_tree_new (ValadocErrorReporter* reporter,
838                       ValadocSettings* settings,
839                       ValaCodeContext* context)
840 {
841 	return valadoc_api_tree_construct (VALADOC_API_TYPE_TREE, reporter, settings, context);
842 }
843 
844 static gchar*
valadoc_api_tree_get_file_path(ValadocApiTree * self,const gchar * basename,gchar ** directories,gint directories_length1)845 valadoc_api_tree_get_file_path (ValadocApiTree* self,
846                                 const gchar* basename,
847                                 gchar** directories,
848                                 gint directories_length1)
849 {
850 	gchar* filename = NULL;
851 	gchar** _tmp4_;
852 	gchar** _tmp5_;
853 	gchar* result = NULL;
854 	g_return_val_if_fail (self != NULL, NULL);
855 	g_return_val_if_fail (basename != NULL, NULL);
856 	filename = NULL;
857 	if (directories != NULL) {
858 		{
859 			gchar** dir_collection = NULL;
860 			gint dir_collection_length1 = 0;
861 			gint _dir_collection_size_ = 0;
862 			gint dir_it = 0;
863 			dir_collection = directories;
864 			dir_collection_length1 = directories_length1;
865 			for (dir_it = 0; dir_it < dir_collection_length1; dir_it = dir_it + 1) {
866 				gchar* _tmp0_;
867 				gchar* dir = NULL;
868 				_tmp0_ = g_strdup (dir_collection[dir_it]);
869 				dir = _tmp0_;
870 				{
871 					const gchar* _tmp1_;
872 					gchar* _tmp2_;
873 					const gchar* _tmp3_;
874 					_tmp1_ = dir;
875 					_tmp2_ = g_build_filename (_tmp1_, basename, NULL);
876 					_g_free0 (filename);
877 					filename = _tmp2_;
878 					_tmp3_ = filename;
879 					if (g_file_test (_tmp3_, G_FILE_TEST_EXISTS)) {
880 						result = filename;
881 						_g_free0 (dir);
882 						return result;
883 					}
884 					_g_free0 (dir);
885 				}
886 			}
887 		}
888 	}
889 	_tmp5_ = _tmp4_ = g_get_system_data_dirs ();
890 	{
891 		gchar** dir_collection = NULL;
892 		gint dir_collection_length1 = 0;
893 		gint _dir_collection_size_ = 0;
894 		gint dir_it = 0;
895 		dir_collection = _tmp5_;
896 		dir_collection_length1 = _vala_array_length (_tmp4_);
897 		for (dir_it = 0; dir_it < dir_collection_length1; dir_it = dir_it + 1) {
898 			gchar* _tmp6_;
899 			gchar* dir = NULL;
900 			_tmp6_ = g_strdup (dir_collection[dir_it]);
901 			dir = _tmp6_;
902 			{
903 				const gchar* _tmp7_;
904 				gchar* _tmp8_;
905 				const gchar* _tmp9_;
906 				_tmp7_ = dir;
907 				_tmp8_ = g_build_filename (_tmp7_, basename, NULL);
908 				_g_free0 (filename);
909 				filename = _tmp8_;
910 				_tmp9_ = filename;
911 				if (g_file_test (_tmp9_, G_FILE_TEST_EXISTS)) {
912 					result = filename;
913 					_g_free0 (dir);
914 					return result;
915 				}
916 				_g_free0 (dir);
917 			}
918 		}
919 	}
920 	result = NULL;
921 	_g_free0 (filename);
922 	return result;
923 }
924 
925 gboolean
valadoc_api_tree_create_tree(ValadocApiTree * self)926 valadoc_api_tree_create_tree (ValadocApiTree* self)
927 {
928 	gboolean result = FALSE;
929 	g_return_val_if_fail (self != NULL, FALSE);
930 	valadoc_api_tree_add_dependencies_to_source_package (self);
931 	result = TRUE;
932 	return result;
933 }
934 
935 static ValadocApiPackage*
valadoc_api_tree_get_source_package(ValadocApiTree * self)936 valadoc_api_tree_get_source_package (ValadocApiTree* self)
937 {
938 	ValadocApiPackage* _tmp0_;
939 	ValadocApiPackage* _tmp15_;
940 	ValadocApiPackage* _tmp16_;
941 	ValadocApiPackage* result = NULL;
942 	g_return_val_if_fail (self != NULL, NULL);
943 	_tmp0_ = self->priv->_source_package;
944 	if (_tmp0_ == NULL) {
945 		{
946 			ValaArrayList* _pkg_list = NULL;
947 			ValaArrayList* _tmp1_;
948 			ValaArrayList* _tmp2_;
949 			gint _pkg_size = 0;
950 			ValaArrayList* _tmp3_;
951 			gint _tmp4_;
952 			gint _tmp5_;
953 			gint _pkg_index = 0;
954 			_tmp1_ = self->priv->packages;
955 			_tmp2_ = _vala_iterable_ref0 (_tmp1_);
956 			_pkg_list = _tmp2_;
957 			_tmp3_ = _pkg_list;
958 			_tmp4_ = vala_collection_get_size ((ValaCollection*) _tmp3_);
959 			_tmp5_ = _tmp4_;
960 			_pkg_size = _tmp5_;
961 			_pkg_index = -1;
962 			while (TRUE) {
963 				gint _tmp6_;
964 				gint _tmp7_;
965 				ValadocApiPackage* pkg = NULL;
966 				ValaArrayList* _tmp8_;
967 				gpointer _tmp9_;
968 				ValadocApiPackage* _tmp10_;
969 				gboolean _tmp11_;
970 				gboolean _tmp12_;
971 				_pkg_index = _pkg_index + 1;
972 				_tmp6_ = _pkg_index;
973 				_tmp7_ = _pkg_size;
974 				if (!(_tmp6_ < _tmp7_)) {
975 					break;
976 				}
977 				_tmp8_ = _pkg_list;
978 				_tmp9_ = vala_list_get ((ValaList*) _tmp8_, _pkg_index);
979 				pkg = (ValadocApiPackage*) _tmp9_;
980 				_tmp10_ = pkg;
981 				_tmp11_ = valadoc_api_package_get_is_package (_tmp10_);
982 				_tmp12_ = _tmp11_;
983 				if (!_tmp12_) {
984 					ValadocApiPackage* _tmp13_;
985 					ValadocApiPackage* _tmp14_;
986 					_tmp13_ = pkg;
987 					_tmp14_ = _g_object_ref0 (_tmp13_);
988 					_g_object_unref0 (self->priv->_source_package);
989 					self->priv->_source_package = _tmp14_;
990 					_g_object_unref0 (pkg);
991 					break;
992 				}
993 				_g_object_unref0 (pkg);
994 			}
995 			_vala_iterable_unref0 (_pkg_list);
996 		}
997 	}
998 	_tmp15_ = self->priv->_source_package;
999 	_tmp16_ = _g_object_ref0 (_tmp15_);
1000 	result = _tmp16_;
1001 	return result;
1002 }
1003 
1004 static void
valadoc_api_tree_parse_wiki(ValadocApiTree * self,ValadocDocumentationParser * docparser)1005 valadoc_api_tree_parse_wiki (ValadocApiTree* self,
1006                              ValadocDocumentationParser* docparser)
1007 {
1008 	ValadocWikiPageTree* _tmp0_;
1009 	ValadocWikiPageTree* _tmp1_;
1010 	ValadocApiPackage* pkg = NULL;
1011 	ValadocApiPackage* _tmp2_;
1012 	ValadocApiPackage* _tmp3_;
1013 	g_return_if_fail (self != NULL);
1014 	g_return_if_fail (docparser != NULL);
1015 	_tmp0_ = valadoc_wiki_page_tree_new ();
1016 	_tmp1_ = _tmp0_;
1017 	valadoc_api_tree_set_wikitree (self, _tmp1_);
1018 	_g_object_unref0 (_tmp1_);
1019 	_tmp2_ = valadoc_api_tree_get_source_package (self);
1020 	pkg = _tmp2_;
1021 	_tmp3_ = pkg;
1022 	if (_tmp3_ != NULL) {
1023 		ValadocWikiPageTree* _tmp4_;
1024 		ValadocSettings* _tmp5_;
1025 		ValadocApiPackage* _tmp6_;
1026 		ValadocErrorReporter* _tmp7_;
1027 		_tmp4_ = self->priv->_wikitree;
1028 		_tmp5_ = self->priv->settings;
1029 		_tmp6_ = pkg;
1030 		_tmp7_ = self->priv->reporter;
1031 		valadoc_wiki_page_tree_parse (_tmp4_, _tmp5_, docparser, _tmp6_, _tmp7_);
1032 	}
1033 	_g_object_unref0 (pkg);
1034 }
1035 
1036 static void
valadoc_api_tree_check_wiki(ValadocApiTree * self,ValadocDocumentationParser * docparser)1037 valadoc_api_tree_check_wiki (ValadocApiTree* self,
1038                              ValadocDocumentationParser* docparser)
1039 {
1040 	ValadocApiPackage* pkg = NULL;
1041 	ValadocApiPackage* _tmp0_;
1042 	ValadocApiPackage* _tmp1_;
1043 	g_return_if_fail (self != NULL);
1044 	g_return_if_fail (docparser != NULL);
1045 	_tmp0_ = valadoc_api_tree_get_source_package (self);
1046 	pkg = _tmp0_;
1047 	_tmp1_ = pkg;
1048 	if (_tmp1_ != NULL) {
1049 		ValadocWikiPageTree* _tmp2_;
1050 		ValadocSettings* _tmp3_;
1051 		ValadocApiPackage* _tmp4_;
1052 		_tmp2_ = self->priv->_wikitree;
1053 		_tmp3_ = self->priv->settings;
1054 		_tmp4_ = pkg;
1055 		valadoc_wiki_page_tree_check (_tmp2_, _tmp3_, docparser, _tmp4_);
1056 	}
1057 	_g_object_unref0 (pkg);
1058 }
1059 
1060 void
valadoc_api_tree_parse_comments(ValadocApiTree * self,ValadocDocumentationParser * docparser)1061 valadoc_api_tree_parse_comments (ValadocApiTree* self,
1062                                  ValadocDocumentationParser* docparser)
1063 {
1064 	g_return_if_fail (self != NULL);
1065 	g_return_if_fail (docparser != NULL);
1066 	valadoc_api_tree_parse_wiki (self, docparser);
1067 	{
1068 		ValaArrayList* _pkg_list = NULL;
1069 		ValaArrayList* _tmp0_;
1070 		ValaArrayList* _tmp1_;
1071 		gint _pkg_size = 0;
1072 		ValaArrayList* _tmp2_;
1073 		gint _tmp3_;
1074 		gint _tmp4_;
1075 		gint _pkg_index = 0;
1076 		_tmp0_ = self->priv->packages;
1077 		_tmp1_ = _vala_iterable_ref0 (_tmp0_);
1078 		_pkg_list = _tmp1_;
1079 		_tmp2_ = _pkg_list;
1080 		_tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
1081 		_tmp4_ = _tmp3_;
1082 		_pkg_size = _tmp4_;
1083 		_pkg_index = -1;
1084 		while (TRUE) {
1085 			gint _tmp5_;
1086 			gint _tmp6_;
1087 			ValadocApiPackage* pkg = NULL;
1088 			ValaArrayList* _tmp7_;
1089 			gpointer _tmp8_;
1090 			ValadocApiPackage* _tmp9_;
1091 			ValadocSettings* _tmp10_;
1092 			_pkg_index = _pkg_index + 1;
1093 			_tmp5_ = _pkg_index;
1094 			_tmp6_ = _pkg_size;
1095 			if (!(_tmp5_ < _tmp6_)) {
1096 				break;
1097 			}
1098 			_tmp7_ = _pkg_list;
1099 			_tmp8_ = vala_list_get ((ValaList*) _tmp7_, _pkg_index);
1100 			pkg = (ValadocApiPackage*) _tmp8_;
1101 			_tmp9_ = pkg;
1102 			_tmp10_ = self->priv->settings;
1103 			if (valadoc_api_node_is_browsable ((ValadocApiNode*) _tmp9_, _tmp10_)) {
1104 				ValadocApiPackage* _tmp11_;
1105 				ValadocSettings* _tmp12_;
1106 				_tmp11_ = pkg;
1107 				_tmp12_ = self->priv->settings;
1108 				valadoc_api_item_parse_comments ((ValadocApiItem*) _tmp11_, _tmp12_, docparser);
1109 			}
1110 			_g_object_unref0 (pkg);
1111 		}
1112 		_vala_iterable_unref0 (_pkg_list);
1113 	}
1114 }
1115 
1116 void
valadoc_api_tree_check_comments(ValadocApiTree * self,ValadocDocumentationParser * docparser)1117 valadoc_api_tree_check_comments (ValadocApiTree* self,
1118                                  ValadocDocumentationParser* docparser)
1119 {
1120 	g_return_if_fail (self != NULL);
1121 	g_return_if_fail (docparser != NULL);
1122 	valadoc_api_tree_check_wiki (self, docparser);
1123 	{
1124 		ValaArrayList* _pkg_list = NULL;
1125 		ValaArrayList* _tmp0_;
1126 		ValaArrayList* _tmp1_;
1127 		gint _pkg_size = 0;
1128 		ValaArrayList* _tmp2_;
1129 		gint _tmp3_;
1130 		gint _tmp4_;
1131 		gint _pkg_index = 0;
1132 		_tmp0_ = self->priv->packages;
1133 		_tmp1_ = _vala_iterable_ref0 (_tmp0_);
1134 		_pkg_list = _tmp1_;
1135 		_tmp2_ = _pkg_list;
1136 		_tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
1137 		_tmp4_ = _tmp3_;
1138 		_pkg_size = _tmp4_;
1139 		_pkg_index = -1;
1140 		while (TRUE) {
1141 			gint _tmp5_;
1142 			gint _tmp6_;
1143 			ValadocApiPackage* pkg = NULL;
1144 			ValaArrayList* _tmp7_;
1145 			gpointer _tmp8_;
1146 			ValadocApiPackage* _tmp9_;
1147 			ValadocSettings* _tmp10_;
1148 			_pkg_index = _pkg_index + 1;
1149 			_tmp5_ = _pkg_index;
1150 			_tmp6_ = _pkg_size;
1151 			if (!(_tmp5_ < _tmp6_)) {
1152 				break;
1153 			}
1154 			_tmp7_ = _pkg_list;
1155 			_tmp8_ = vala_list_get ((ValaList*) _tmp7_, _pkg_index);
1156 			pkg = (ValadocApiPackage*) _tmp8_;
1157 			_tmp9_ = pkg;
1158 			_tmp10_ = self->priv->settings;
1159 			if (valadoc_api_node_is_browsable ((ValadocApiNode*) _tmp9_, _tmp10_)) {
1160 				ValadocApiPackage* _tmp11_;
1161 				ValadocSettings* _tmp12_;
1162 				_tmp11_ = pkg;
1163 				_tmp12_ = self->priv->settings;
1164 				valadoc_api_item_check_comments ((ValadocApiItem*) _tmp11_, _tmp12_, docparser);
1165 				valadoc_api_tree_postprocess_inheritdoc (self, docparser);
1166 			}
1167 			_g_object_unref0 (pkg);
1168 		}
1169 		_vala_iterable_unref0 (_pkg_list);
1170 	}
1171 }
1172 
1173 G_GNUC_INTERNAL void
valadoc_api_tree_register_inheritdoc(ValadocApiTree * self,ValadocApiNode * container,ValadocTagletsInheritDoc * taglet)1174 valadoc_api_tree_register_inheritdoc (ValadocApiTree* self,
1175                                       ValadocApiNode* container,
1176                                       ValadocTagletsInheritDoc* taglet)
1177 {
1178 	ValaList* _tmp0_;
1179 	ValadocApiTreeInheritDocContainer* _tmp1_;
1180 	ValadocApiTreeInheritDocContainer* _tmp2_;
1181 	g_return_if_fail (self != NULL);
1182 	g_return_if_fail (container != NULL);
1183 	g_return_if_fail (taglet != NULL);
1184 	_tmp0_ = self->priv->inheritdocs;
1185 	_tmp1_ = valadoc_api_tree_inherit_doc_container_new (container, taglet);
1186 	_tmp2_ = _tmp1_;
1187 	vala_collection_add ((ValaCollection*) _tmp0_, _tmp2_);
1188 	_valadoc_api_tree_inherit_doc_container_unref0 (_tmp2_);
1189 }
1190 
1191 static void
valadoc_api_tree_postprocess_inheritdoc(ValadocApiTree * self,ValadocDocumentationParser * docparser)1192 valadoc_api_tree_postprocess_inheritdoc (ValadocApiTree* self,
1193                                          ValadocDocumentationParser* docparser)
1194 {
1195 	g_return_if_fail (self != NULL);
1196 	g_return_if_fail (docparser != NULL);
1197 	while (TRUE) {
1198 		ValaList* _tmp0_;
1199 		gboolean _tmp1_;
1200 		gboolean _tmp2_;
1201 		ValadocApiTreeInheritDocContainer* container = NULL;
1202 		ValaList* _tmp3_;
1203 		gpointer _tmp4_;
1204 		ValadocApiTreeInheritDocContainer* _tmp5_;
1205 		ValadocApiNode* _tmp6_;
1206 		ValadocApiTreeInheritDocContainer* _tmp7_;
1207 		ValadocTagletsInheritDoc* _tmp8_;
1208 		_tmp0_ = self->priv->inheritdocs;
1209 		_tmp1_ = vala_collection_get_is_empty ((ValaCollection*) _tmp0_);
1210 		_tmp2_ = _tmp1_;
1211 		if (!(!_tmp2_)) {
1212 			break;
1213 		}
1214 		_tmp3_ = self->priv->inheritdocs;
1215 		_tmp4_ = vala_list_remove_at (_tmp3_, 0);
1216 		container = (ValadocApiTreeInheritDocContainer*) _tmp4_;
1217 		_tmp5_ = container;
1218 		_tmp6_ = _tmp5_->taglet_container;
1219 		_tmp7_ = container;
1220 		_tmp8_ = _tmp7_->taglet;
1221 		valadoc_documentation_parser_transform_inheritdoc (docparser, _tmp6_, _tmp8_);
1222 		_valadoc_api_tree_inherit_doc_container_unref0 (container);
1223 	}
1224 }
1225 
1226 /**
1227  * Import documentation from various sources
1228  *
1229  * @param importers a list of importers
1230  * @param packages sources
1231  * @param import_directories List of directories where to find the files
1232  */
1233 void
valadoc_api_tree_import_comments(ValadocApiTree * self,ValadocImporterDocumentationImporter ** importers,gint importers_length1,gchar ** packages,gint packages_length1,gchar ** import_directories,gint import_directories_length1)1234 valadoc_api_tree_import_comments (ValadocApiTree* self,
1235                                   ValadocImporterDocumentationImporter** importers,
1236                                   gint importers_length1,
1237                                   gchar** packages,
1238                                   gint packages_length1,
1239                                   gchar** import_directories,
1240                                   gint import_directories_length1)
1241 {
1242 	ValaHashSet* processed = NULL;
1243 	GHashFunc _tmp0_;
1244 	GEqualFunc _tmp1_;
1245 	ValaHashSet* _tmp2_;
1246 	g_return_if_fail (self != NULL);
1247 	_tmp0_ = g_direct_hash;
1248 	_tmp1_ = g_direct_equal;
1249 	_tmp2_ = vala_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp0_, _tmp1_);
1250 	processed = _tmp2_;
1251 	{
1252 		gchar** pkg_name_collection = NULL;
1253 		gint pkg_name_collection_length1 = 0;
1254 		gint _pkg_name_collection_size_ = 0;
1255 		gint pkg_name_it = 0;
1256 		pkg_name_collection = packages;
1257 		pkg_name_collection_length1 = packages_length1;
1258 		for (pkg_name_it = 0; pkg_name_it < pkg_name_collection_length1; pkg_name_it = pkg_name_it + 1) {
1259 			gchar* _tmp3_;
1260 			gchar* pkg_name = NULL;
1261 			_tmp3_ = g_strdup (pkg_name_collection[pkg_name_it]);
1262 			pkg_name = _tmp3_;
1263 			{
1264 				gboolean imported = FALSE;
1265 				imported = FALSE;
1266 				{
1267 					ValadocImporterDocumentationImporter** importer_collection = NULL;
1268 					gint importer_collection_length1 = 0;
1269 					gint _importer_collection_size_ = 0;
1270 					gint importer_it = 0;
1271 					importer_collection = importers;
1272 					importer_collection_length1 = importers_length1;
1273 					for (importer_it = 0; importer_it < importer_collection_length1; importer_it = importer_it + 1) {
1274 						ValadocImporterDocumentationImporter* _tmp4_;
1275 						ValadocImporterDocumentationImporter* importer = NULL;
1276 						_tmp4_ = _g_object_ref0 (importer_collection[importer_it]);
1277 						importer = _tmp4_;
1278 						{
1279 							gchar* path = NULL;
1280 							const gchar* _tmp5_;
1281 							ValadocImporterDocumentationImporter* _tmp6_;
1282 							const gchar* _tmp7_;
1283 							const gchar* _tmp8_;
1284 							gchar* _tmp9_;
1285 							gchar* _tmp10_;
1286 							gchar* _tmp11_;
1287 							gchar* _tmp12_;
1288 							const gchar* _tmp13_;
1289 							const gchar* _tmp14_;
1290 							gchar* _tmp15_;
1291 							ValaHashSet* _tmp16_;
1292 							const gchar* _tmp17_;
1293 							_tmp5_ = pkg_name;
1294 							_tmp6_ = importer;
1295 							_tmp7_ = valadoc_importer_documentation_importer_get_file_extension (_tmp6_);
1296 							_tmp8_ = _tmp7_;
1297 							_tmp9_ = g_strdup_printf ("%s.%s", _tmp5_, _tmp8_);
1298 							_tmp10_ = _tmp9_;
1299 							_tmp11_ = valadoc_api_tree_get_file_path (self, _tmp10_, import_directories, (gint) import_directories_length1);
1300 							_tmp12_ = _tmp11_;
1301 							_g_free0 (_tmp10_);
1302 							path = _tmp12_;
1303 							_tmp13_ = path;
1304 							if (_tmp13_ == NULL) {
1305 								_g_free0 (path);
1306 								_g_object_unref0 (importer);
1307 								continue;
1308 							}
1309 							_tmp14_ = path;
1310 							_tmp15_ = vala_code_context_realpath (_tmp14_);
1311 							_g_free0 (path);
1312 							path = _tmp15_;
1313 							imported = TRUE;
1314 							_tmp16_ = processed;
1315 							_tmp17_ = path;
1316 							if (!vala_collection_contains ((ValaCollection*) _tmp16_, _tmp17_)) {
1317 								ValadocImporterDocumentationImporter* _tmp18_;
1318 								const gchar* _tmp19_;
1319 								ValaHashSet* _tmp20_;
1320 								const gchar* _tmp21_;
1321 								_tmp18_ = importer;
1322 								_tmp19_ = path;
1323 								valadoc_importer_documentation_importer_process (_tmp18_, _tmp19_);
1324 								_tmp20_ = processed;
1325 								_tmp21_ = path;
1326 								vala_collection_add ((ValaCollection*) _tmp20_, _tmp21_);
1327 							}
1328 							_g_free0 (path);
1329 							_g_object_unref0 (importer);
1330 						}
1331 					}
1332 				}
1333 				if (imported == FALSE) {
1334 					ValadocErrorReporter* _tmp22_;
1335 					const gchar* _tmp23_;
1336 					_tmp22_ = self->priv->reporter;
1337 					_tmp23_ = pkg_name;
1338 					valadoc_error_reporter_simple_error (_tmp22_, NULL, "'%s' not found in specified import directories", _tmp23_);
1339 				}
1340 				_g_free0 (pkg_name);
1341 			}
1342 		}
1343 	}
1344 	_vala_iterable_unref0 (processed);
1345 }
1346 
1347 static ValadocApiTreeInheritDocContainer*
valadoc_api_tree_inherit_doc_container_construct(GType object_type,ValadocApiNode * taglet_container,ValadocTagletsInheritDoc * taglet)1348 valadoc_api_tree_inherit_doc_container_construct (GType object_type,
1349                                                   ValadocApiNode* taglet_container,
1350                                                   ValadocTagletsInheritDoc* taglet)
1351 {
1352 	ValadocApiTreeInheritDocContainer* self = NULL;
1353 	g_return_val_if_fail (taglet_container != NULL, NULL);
1354 	g_return_val_if_fail (taglet != NULL, NULL);
1355 	self = (ValadocApiTreeInheritDocContainer*) g_type_create_instance (object_type);
1356 	self->taglet_container = taglet_container;
1357 	self->taglet = taglet;
1358 	return self;
1359 }
1360 
1361 static ValadocApiTreeInheritDocContainer*
valadoc_api_tree_inherit_doc_container_new(ValadocApiNode * taglet_container,ValadocTagletsInheritDoc * taglet)1362 valadoc_api_tree_inherit_doc_container_new (ValadocApiNode* taglet_container,
1363                                             ValadocTagletsInheritDoc* taglet)
1364 {
1365 	return valadoc_api_tree_inherit_doc_container_construct (VALADOC_API_TREE_TYPE_INHERIT_DOC_CONTAINER, taglet_container, taglet);
1366 }
1367 
1368 static void
valadoc_api_tree_value_inherit_doc_container_init(GValue * value)1369 valadoc_api_tree_value_inherit_doc_container_init (GValue* value)
1370 {
1371 	value->data[0].v_pointer = NULL;
1372 }
1373 
1374 static void
valadoc_api_tree_value_inherit_doc_container_free_value(GValue * value)1375 valadoc_api_tree_value_inherit_doc_container_free_value (GValue* value)
1376 {
1377 	if (value->data[0].v_pointer) {
1378 		valadoc_api_tree_inherit_doc_container_unref (value->data[0].v_pointer);
1379 	}
1380 }
1381 
1382 static void
valadoc_api_tree_value_inherit_doc_container_copy_value(const GValue * src_value,GValue * dest_value)1383 valadoc_api_tree_value_inherit_doc_container_copy_value (const GValue* src_value,
1384                                                          GValue* dest_value)
1385 {
1386 	if (src_value->data[0].v_pointer) {
1387 		dest_value->data[0].v_pointer = valadoc_api_tree_inherit_doc_container_ref (src_value->data[0].v_pointer);
1388 	} else {
1389 		dest_value->data[0].v_pointer = NULL;
1390 	}
1391 }
1392 
1393 static gpointer
valadoc_api_tree_value_inherit_doc_container_peek_pointer(const GValue * value)1394 valadoc_api_tree_value_inherit_doc_container_peek_pointer (const GValue* value)
1395 {
1396 	return value->data[0].v_pointer;
1397 }
1398 
1399 static gchar*
valadoc_api_tree_value_inherit_doc_container_collect_value(GValue * value,guint n_collect_values,GTypeCValue * collect_values,guint collect_flags)1400 valadoc_api_tree_value_inherit_doc_container_collect_value (GValue* value,
1401                                                             guint n_collect_values,
1402                                                             GTypeCValue* collect_values,
1403                                                             guint collect_flags)
1404 {
1405 	if (collect_values[0].v_pointer) {
1406 		ValadocApiTreeInheritDocContainer * object;
1407 		object = collect_values[0].v_pointer;
1408 		if (object->parent_instance.g_class == NULL) {
1409 			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
1410 		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
1411 			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
1412 		}
1413 		value->data[0].v_pointer = valadoc_api_tree_inherit_doc_container_ref (object);
1414 	} else {
1415 		value->data[0].v_pointer = NULL;
1416 	}
1417 	return NULL;
1418 }
1419 
1420 static gchar*
valadoc_api_tree_value_inherit_doc_container_lcopy_value(const GValue * value,guint n_collect_values,GTypeCValue * collect_values,guint collect_flags)1421 valadoc_api_tree_value_inherit_doc_container_lcopy_value (const GValue* value,
1422                                                           guint n_collect_values,
1423                                                           GTypeCValue* collect_values,
1424                                                           guint collect_flags)
1425 {
1426 	ValadocApiTreeInheritDocContainer ** object_p;
1427 	object_p = collect_values[0].v_pointer;
1428 	if (!object_p) {
1429 		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
1430 	}
1431 	if (!value->data[0].v_pointer) {
1432 		*object_p = NULL;
1433 	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
1434 		*object_p = value->data[0].v_pointer;
1435 	} else {
1436 		*object_p = valadoc_api_tree_inherit_doc_container_ref (value->data[0].v_pointer);
1437 	}
1438 	return NULL;
1439 }
1440 
1441 static GParamSpec*
valadoc_api_tree_param_spec_inherit_doc_container(const gchar * name,const gchar * nick,const gchar * blurb,GType object_type,GParamFlags flags)1442 valadoc_api_tree_param_spec_inherit_doc_container (const gchar* name,
1443                                                    const gchar* nick,
1444                                                    const gchar* blurb,
1445                                                    GType object_type,
1446                                                    GParamFlags flags)
1447 {
1448 	ValadocApiTreeParamSpecInheritDocContainer* spec;
1449 	g_return_val_if_fail (g_type_is_a (object_type, VALADOC_API_TREE_TYPE_INHERIT_DOC_CONTAINER), NULL);
1450 	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
1451 	G_PARAM_SPEC (spec)->value_type = object_type;
1452 	return G_PARAM_SPEC (spec);
1453 }
1454 
1455 static gpointer
valadoc_api_tree_value_get_inherit_doc_container(const GValue * value)1456 valadoc_api_tree_value_get_inherit_doc_container (const GValue* value)
1457 {
1458 	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALADOC_API_TREE_TYPE_INHERIT_DOC_CONTAINER), NULL);
1459 	return value->data[0].v_pointer;
1460 }
1461 
1462 static void
valadoc_api_tree_value_set_inherit_doc_container(GValue * value,gpointer v_object)1463 valadoc_api_tree_value_set_inherit_doc_container (GValue* value,
1464                                                   gpointer v_object)
1465 {
1466 	ValadocApiTreeInheritDocContainer * old;
1467 	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALADOC_API_TREE_TYPE_INHERIT_DOC_CONTAINER));
1468 	old = value->data[0].v_pointer;
1469 	if (v_object) {
1470 		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VALADOC_API_TREE_TYPE_INHERIT_DOC_CONTAINER));
1471 		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
1472 		value->data[0].v_pointer = v_object;
1473 		valadoc_api_tree_inherit_doc_container_ref (value->data[0].v_pointer);
1474 	} else {
1475 		value->data[0].v_pointer = NULL;
1476 	}
1477 	if (old) {
1478 		valadoc_api_tree_inherit_doc_container_unref (old);
1479 	}
1480 }
1481 
1482 static void
valadoc_api_tree_value_take_inherit_doc_container(GValue * value,gpointer v_object)1483 valadoc_api_tree_value_take_inherit_doc_container (GValue* value,
1484                                                    gpointer v_object)
1485 {
1486 	ValadocApiTreeInheritDocContainer * old;
1487 	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALADOC_API_TREE_TYPE_INHERIT_DOC_CONTAINER));
1488 	old = value->data[0].v_pointer;
1489 	if (v_object) {
1490 		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VALADOC_API_TREE_TYPE_INHERIT_DOC_CONTAINER));
1491 		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
1492 		value->data[0].v_pointer = v_object;
1493 	} else {
1494 		value->data[0].v_pointer = NULL;
1495 	}
1496 	if (old) {
1497 		valadoc_api_tree_inherit_doc_container_unref (old);
1498 	}
1499 }
1500 
1501 static void
valadoc_api_tree_inherit_doc_container_class_init(ValadocApiTreeInheritDocContainerClass * klass,gpointer klass_data)1502 valadoc_api_tree_inherit_doc_container_class_init (ValadocApiTreeInheritDocContainerClass * klass,
1503                                                    gpointer klass_data)
1504 {
1505 	valadoc_api_tree_inherit_doc_container_parent_class = g_type_class_peek_parent (klass);
1506 	((ValadocApiTreeInheritDocContainerClass *) klass)->finalize = valadoc_api_tree_inherit_doc_container_finalize;
1507 }
1508 
1509 static void
valadoc_api_tree_inherit_doc_container_instance_init(ValadocApiTreeInheritDocContainer * self,gpointer klass)1510 valadoc_api_tree_inherit_doc_container_instance_init (ValadocApiTreeInheritDocContainer * self,
1511                                                       gpointer klass)
1512 {
1513 	self->ref_count = 1;
1514 }
1515 
1516 static void
valadoc_api_tree_inherit_doc_container_finalize(ValadocApiTreeInheritDocContainer * obj)1517 valadoc_api_tree_inherit_doc_container_finalize (ValadocApiTreeInheritDocContainer * obj)
1518 {
1519 	ValadocApiTreeInheritDocContainer * self;
1520 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_API_TREE_TYPE_INHERIT_DOC_CONTAINER, ValadocApiTreeInheritDocContainer);
1521 	g_signal_handlers_destroy (self);
1522 }
1523 
1524 static GType
valadoc_api_tree_inherit_doc_container_get_type_once(void)1525 valadoc_api_tree_inherit_doc_container_get_type_once (void)
1526 {
1527 	static const GTypeValueTable g_define_type_value_table = { valadoc_api_tree_value_inherit_doc_container_init, valadoc_api_tree_value_inherit_doc_container_free_value, valadoc_api_tree_value_inherit_doc_container_copy_value, valadoc_api_tree_value_inherit_doc_container_peek_pointer, "p", valadoc_api_tree_value_inherit_doc_container_collect_value, "p", valadoc_api_tree_value_inherit_doc_container_lcopy_value };
1528 	static const GTypeInfo g_define_type_info = { sizeof (ValadocApiTreeInheritDocContainerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_api_tree_inherit_doc_container_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocApiTreeInheritDocContainer), 0, (GInstanceInitFunc) valadoc_api_tree_inherit_doc_container_instance_init, &g_define_type_value_table };
1529 	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) };
1530 	GType valadoc_api_tree_inherit_doc_container_type_id;
1531 	valadoc_api_tree_inherit_doc_container_type_id = g_type_register_fundamental (g_type_fundamental_next (), "ValadocApiTreeInheritDocContainer", &g_define_type_info, &g_define_type_fundamental_info, 0);
1532 	return valadoc_api_tree_inherit_doc_container_type_id;
1533 }
1534 
1535 static GType
valadoc_api_tree_inherit_doc_container_get_type(void)1536 valadoc_api_tree_inherit_doc_container_get_type (void)
1537 {
1538 	static volatile gsize valadoc_api_tree_inherit_doc_container_type_id__volatile = 0;
1539 	if (g_once_init_enter (&valadoc_api_tree_inherit_doc_container_type_id__volatile)) {
1540 		GType valadoc_api_tree_inherit_doc_container_type_id;
1541 		valadoc_api_tree_inherit_doc_container_type_id = valadoc_api_tree_inherit_doc_container_get_type_once ();
1542 		g_once_init_leave (&valadoc_api_tree_inherit_doc_container_type_id__volatile, valadoc_api_tree_inherit_doc_container_type_id);
1543 	}
1544 	return valadoc_api_tree_inherit_doc_container_type_id__volatile;
1545 }
1546 
1547 static gpointer
valadoc_api_tree_inherit_doc_container_ref(gpointer instance)1548 valadoc_api_tree_inherit_doc_container_ref (gpointer instance)
1549 {
1550 	ValadocApiTreeInheritDocContainer * self;
1551 	self = instance;
1552 	g_atomic_int_inc (&self->ref_count);
1553 	return instance;
1554 }
1555 
1556 static void
valadoc_api_tree_inherit_doc_container_unref(gpointer instance)1557 valadoc_api_tree_inherit_doc_container_unref (gpointer instance)
1558 {
1559 	ValadocApiTreeInheritDocContainer * self;
1560 	self = instance;
1561 	if (g_atomic_int_dec_and_test (&self->ref_count)) {
1562 		VALADOC_API_TREE_INHERIT_DOC_CONTAINER_GET_CLASS (self)->finalize (self);
1563 		g_type_free_instance ((GTypeInstance *) self);
1564 	}
1565 }
1566 
1567 static void
valadoc_api_value_tree_init(GValue * value)1568 valadoc_api_value_tree_init (GValue* value)
1569 {
1570 	value->data[0].v_pointer = NULL;
1571 }
1572 
1573 static void
valadoc_api_value_tree_free_value(GValue * value)1574 valadoc_api_value_tree_free_value (GValue* value)
1575 {
1576 	if (value->data[0].v_pointer) {
1577 		valadoc_api_tree_unref (value->data[0].v_pointer);
1578 	}
1579 }
1580 
1581 static void
valadoc_api_value_tree_copy_value(const GValue * src_value,GValue * dest_value)1582 valadoc_api_value_tree_copy_value (const GValue* src_value,
1583                                    GValue* dest_value)
1584 {
1585 	if (src_value->data[0].v_pointer) {
1586 		dest_value->data[0].v_pointer = valadoc_api_tree_ref (src_value->data[0].v_pointer);
1587 	} else {
1588 		dest_value->data[0].v_pointer = NULL;
1589 	}
1590 }
1591 
1592 static gpointer
valadoc_api_value_tree_peek_pointer(const GValue * value)1593 valadoc_api_value_tree_peek_pointer (const GValue* value)
1594 {
1595 	return value->data[0].v_pointer;
1596 }
1597 
1598 static gchar*
valadoc_api_value_tree_collect_value(GValue * value,guint n_collect_values,GTypeCValue * collect_values,guint collect_flags)1599 valadoc_api_value_tree_collect_value (GValue* value,
1600                                       guint n_collect_values,
1601                                       GTypeCValue* collect_values,
1602                                       guint collect_flags)
1603 {
1604 	if (collect_values[0].v_pointer) {
1605 		ValadocApiTree * object;
1606 		object = collect_values[0].v_pointer;
1607 		if (object->parent_instance.g_class == NULL) {
1608 			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
1609 		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
1610 			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
1611 		}
1612 		value->data[0].v_pointer = valadoc_api_tree_ref (object);
1613 	} else {
1614 		value->data[0].v_pointer = NULL;
1615 	}
1616 	return NULL;
1617 }
1618 
1619 static gchar*
valadoc_api_value_tree_lcopy_value(const GValue * value,guint n_collect_values,GTypeCValue * collect_values,guint collect_flags)1620 valadoc_api_value_tree_lcopy_value (const GValue* value,
1621                                     guint n_collect_values,
1622                                     GTypeCValue* collect_values,
1623                                     guint collect_flags)
1624 {
1625 	ValadocApiTree ** object_p;
1626 	object_p = collect_values[0].v_pointer;
1627 	if (!object_p) {
1628 		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
1629 	}
1630 	if (!value->data[0].v_pointer) {
1631 		*object_p = NULL;
1632 	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
1633 		*object_p = value->data[0].v_pointer;
1634 	} else {
1635 		*object_p = valadoc_api_tree_ref (value->data[0].v_pointer);
1636 	}
1637 	return NULL;
1638 }
1639 
1640 GParamSpec*
valadoc_api_param_spec_tree(const gchar * name,const gchar * nick,const gchar * blurb,GType object_type,GParamFlags flags)1641 valadoc_api_param_spec_tree (const gchar* name,
1642                              const gchar* nick,
1643                              const gchar* blurb,
1644                              GType object_type,
1645                              GParamFlags flags)
1646 {
1647 	ValadocApiParamSpecTree* spec;
1648 	g_return_val_if_fail (g_type_is_a (object_type, VALADOC_API_TYPE_TREE), NULL);
1649 	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
1650 	G_PARAM_SPEC (spec)->value_type = object_type;
1651 	return G_PARAM_SPEC (spec);
1652 }
1653 
1654 gpointer
valadoc_api_value_get_tree(const GValue * value)1655 valadoc_api_value_get_tree (const GValue* value)
1656 {
1657 	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALADOC_API_TYPE_TREE), NULL);
1658 	return value->data[0].v_pointer;
1659 }
1660 
1661 void
valadoc_api_value_set_tree(GValue * value,gpointer v_object)1662 valadoc_api_value_set_tree (GValue* value,
1663                             gpointer v_object)
1664 {
1665 	ValadocApiTree * old;
1666 	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALADOC_API_TYPE_TREE));
1667 	old = value->data[0].v_pointer;
1668 	if (v_object) {
1669 		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VALADOC_API_TYPE_TREE));
1670 		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
1671 		value->data[0].v_pointer = v_object;
1672 		valadoc_api_tree_ref (value->data[0].v_pointer);
1673 	} else {
1674 		value->data[0].v_pointer = NULL;
1675 	}
1676 	if (old) {
1677 		valadoc_api_tree_unref (old);
1678 	}
1679 }
1680 
1681 void
valadoc_api_value_take_tree(GValue * value,gpointer v_object)1682 valadoc_api_value_take_tree (GValue* value,
1683                              gpointer v_object)
1684 {
1685 	ValadocApiTree * old;
1686 	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALADOC_API_TYPE_TREE));
1687 	old = value->data[0].v_pointer;
1688 	if (v_object) {
1689 		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VALADOC_API_TYPE_TREE));
1690 		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
1691 		value->data[0].v_pointer = v_object;
1692 	} else {
1693 		value->data[0].v_pointer = NULL;
1694 	}
1695 	if (old) {
1696 		valadoc_api_tree_unref (old);
1697 	}
1698 }
1699 
1700 static void
valadoc_api_tree_class_init(ValadocApiTreeClass * klass,gpointer klass_data)1701 valadoc_api_tree_class_init (ValadocApiTreeClass * klass,
1702                              gpointer klass_data)
1703 {
1704 	valadoc_api_tree_parent_class = g_type_class_peek_parent (klass);
1705 	((ValadocApiTreeClass *) klass)->finalize = valadoc_api_tree_finalize;
1706 	g_type_class_adjust_private_offset (klass, &ValadocApiTree_private_offset);
1707 }
1708 
1709 static void
valadoc_api_tree_instance_init(ValadocApiTree * self,gpointer klass)1710 valadoc_api_tree_instance_init (ValadocApiTree * self,
1711                                 gpointer klass)
1712 {
1713 	GEqualFunc _tmp0_;
1714 	ValaArrayList* _tmp1_;
1715 	GEqualFunc _tmp2_;
1716 	ValaArrayList* _tmp3_;
1717 	GEqualFunc _tmp4_;
1718 	ValaArrayList* _tmp5_;
1719 	self->priv = valadoc_api_tree_get_instance_private (self);
1720 	_tmp0_ = g_direct_equal;
1721 	_tmp1_ = vala_array_list_new (VALADOC_API_TREE_TYPE_INHERIT_DOC_CONTAINER, (GBoxedCopyFunc) valadoc_api_tree_inherit_doc_container_ref, (GDestroyNotify) valadoc_api_tree_inherit_doc_container_unref, _tmp0_);
1722 	self->priv->inheritdocs = (ValaList*) _tmp1_;
1723 	_tmp2_ = g_str_equal;
1724 	_tmp3_ = vala_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp2_);
1725 	self->priv->external_c_files = _tmp3_;
1726 	_tmp4_ = g_direct_equal;
1727 	_tmp5_ = vala_array_list_new (VALADOC_API_TYPE_PACKAGE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp4_);
1728 	self->priv->packages = _tmp5_;
1729 	self->priv->source_package = NULL;
1730 	self->priv->_cresolver = NULL;
1731 	self->ref_count = 1;
1732 }
1733 
1734 static void
valadoc_api_tree_finalize(ValadocApiTree * obj)1735 valadoc_api_tree_finalize (ValadocApiTree * obj)
1736 {
1737 	ValadocApiTree * self;
1738 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_API_TYPE_TREE, ValadocApiTree);
1739 	g_signal_handlers_destroy (self);
1740 	_vala_iterable_unref0 (self->priv->inheritdocs);
1741 	_vala_iterable_unref0 (self->priv->external_c_files);
1742 	_vala_iterable_unref0 (self->priv->packages);
1743 	_g_object_unref0 (self->priv->source_package);
1744 	_g_object_unref0 (self->priv->settings);
1745 	_g_object_unref0 (self->priv->reporter);
1746 	_g_object_unref0 (self->priv->_highlighter);
1747 	_g_object_unref0 (self->priv->_cresolver);
1748 	_g_object_unref0 (self->priv->_source_package);
1749 	_vala_code_context_unref0 (self->priv->_context);
1750 	_g_object_unref0 (self->priv->_wikitree);
1751 }
1752 
1753 /**
1754  * The root of the code tree.
1755  */
1756 static GType
valadoc_api_tree_get_type_once(void)1757 valadoc_api_tree_get_type_once (void)
1758 {
1759 	static const GTypeValueTable g_define_type_value_table = { valadoc_api_value_tree_init, valadoc_api_value_tree_free_value, valadoc_api_value_tree_copy_value, valadoc_api_value_tree_peek_pointer, "p", valadoc_api_value_tree_collect_value, "p", valadoc_api_value_tree_lcopy_value };
1760 	static const GTypeInfo g_define_type_info = { sizeof (ValadocApiTreeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_api_tree_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocApiTree), 0, (GInstanceInitFunc) valadoc_api_tree_instance_init, &g_define_type_value_table };
1761 	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) };
1762 	GType valadoc_api_tree_type_id;
1763 	valadoc_api_tree_type_id = g_type_register_fundamental (g_type_fundamental_next (), "ValadocApiTree", &g_define_type_info, &g_define_type_fundamental_info, 0);
1764 	ValadocApiTree_private_offset = g_type_add_instance_private (valadoc_api_tree_type_id, sizeof (ValadocApiTreePrivate));
1765 	return valadoc_api_tree_type_id;
1766 }
1767 
1768 GType
valadoc_api_tree_get_type(void)1769 valadoc_api_tree_get_type (void)
1770 {
1771 	static volatile gsize valadoc_api_tree_type_id__volatile = 0;
1772 	if (g_once_init_enter (&valadoc_api_tree_type_id__volatile)) {
1773 		GType valadoc_api_tree_type_id;
1774 		valadoc_api_tree_type_id = valadoc_api_tree_get_type_once ();
1775 		g_once_init_leave (&valadoc_api_tree_type_id__volatile, valadoc_api_tree_type_id);
1776 	}
1777 	return valadoc_api_tree_type_id__volatile;
1778 }
1779 
1780 gpointer
valadoc_api_tree_ref(gpointer instance)1781 valadoc_api_tree_ref (gpointer instance)
1782 {
1783 	ValadocApiTree * self;
1784 	self = instance;
1785 	g_atomic_int_inc (&self->ref_count);
1786 	return instance;
1787 }
1788 
1789 void
valadoc_api_tree_unref(gpointer instance)1790 valadoc_api_tree_unref (gpointer instance)
1791 {
1792 	ValadocApiTree * self;
1793 	self = instance;
1794 	if (g_atomic_int_dec_and_test (&self->ref_count)) {
1795 		VALADOC_API_TREE_GET_CLASS (self)->finalize (self);
1796 		g_type_free_instance ((GTypeInstance *) self);
1797 	}
1798 }
1799 
1800 static void
_vala_array_destroy(gpointer array,gint array_length,GDestroyNotify destroy_func)1801 _vala_array_destroy (gpointer array,
1802                      gint array_length,
1803                      GDestroyNotify destroy_func)
1804 {
1805 	if ((array != NULL) && (destroy_func != NULL)) {
1806 		gint i;
1807 		for (i = 0; i < array_length; i = i + 1) {
1808 			if (((gpointer*) array)[i] != NULL) {
1809 				destroy_func (((gpointer*) array)[i]);
1810 			}
1811 		}
1812 	}
1813 }
1814 
1815 static void
_vala_array_free(gpointer array,gint array_length,GDestroyNotify destroy_func)1816 _vala_array_free (gpointer array,
1817                   gint array_length,
1818                   GDestroyNotify destroy_func)
1819 {
1820 	_vala_array_destroy (array, array_length, destroy_func);
1821 	g_free (array);
1822 }
1823 
1824 static gint
_vala_array_length(gpointer array)1825 _vala_array_length (gpointer array)
1826 {
1827 	gint length;
1828 	length = 0;
1829 	if (array) {
1830 		while (((gpointer*) array)[length]) {
1831 			length++;
1832 		}
1833 	}
1834 	return length;
1835 }
1836 
1837