1 /* wiki.c generated by valac, the Vala compiler
2  * generated from wiki.vala, do not modify */
3 
4 /* wiki.vala
5  *
6  * Copyright (C) 2008-2009 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 <stdlib.h>
28 #include <string.h>
29 #include <glib.h>
30 #include <glib-object.h>
31 #include <glib/gstdio.h>
32 #include <valagee.h>
33 
34 enum  {
35 	VALADOC_WIKI_PAGE_0_PROPERTY,
36 	VALADOC_WIKI_PAGE_DOCUMENTATION_PROPERTY,
37 	VALADOC_WIKI_PAGE_DOCUMENTATION_STR_PROPERTY,
38 	VALADOC_WIKI_PAGE_PATH_PROPERTY,
39 	VALADOC_WIKI_PAGE_NAME_PROPERTY,
40 	VALADOC_WIKI_PAGE_PACKAGE_PROPERTY,
41 	VALADOC_WIKI_PAGE_NUM_PROPERTIES
42 };
43 static GParamSpec* valadoc_wiki_page_properties[VALADOC_WIKI_PAGE_NUM_PROPERTIES];
44 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
45 #define _g_free0(var) (var = (g_free (var), NULL))
46 #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
47 enum  {
48 	VALADOC_WIKI_PAGE_TREE_0_PROPERTY,
49 	VALADOC_WIKI_PAGE_TREE_NUM_PROPERTIES
50 };
51 static GParamSpec* valadoc_wiki_page_tree_properties[VALADOC_WIKI_PAGE_TREE_NUM_PROPERTIES];
52 #define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
53 #define _g_dir_close0(var) ((var == NULL) ? NULL : (var = (g_dir_close (var), NULL)))
54 
55 struct _ValadocWikiPagePrivate {
56 	ValadocContentPage* _documentation;
57 	gchar* _documentation_str;
58 	gchar* _path;
59 	gchar* _name;
60 	ValadocApiPackage* _package;
61 };
62 
63 struct _ValadocWikiPageTreePrivate {
64 	ValaArrayList* wikipages;
65 };
66 
67 static gint ValadocWikiPage_private_offset;
68 static gpointer valadoc_wiki_page_parent_class = NULL;
69 static ValadocDocumentationIface * valadoc_wiki_page_valadoc_documentation_parent_iface = NULL;
70 static gint ValadocWikiPageTree_private_offset;
71 static gpointer valadoc_wiki_page_tree_parent_class = NULL;
72 
73 static void valadoc_wiki_page_set_documentation_str (ValadocWikiPage* self,
74                                               const gchar* value);
75 static void valadoc_wiki_page_set_path (ValadocWikiPage* self,
76                                  const gchar* value);
77 static void valadoc_wiki_page_set_name (ValadocWikiPage* self,
78                                  const gchar* value);
79 static gchar* valadoc_wiki_page_real_get_filename (ValadocDocumentation* base);
80 static void valadoc_wiki_page_finalize (GObject * obj);
81 static GType valadoc_wiki_page_get_type_once (void);
82 static void _vala_valadoc_wiki_page_get_property (GObject * object,
83                                            guint property_id,
84                                            GValue * value,
85                                            GParamSpec * pspec);
86 static void _vala_valadoc_wiki_page_set_property (GObject * object,
87                                            guint property_id,
88                                            const GValue * value,
89                                            GParamSpec * pspec);
90 static void valadoc_wiki_page_tree_create_tree_from_path (ValadocWikiPageTree* self,
91                                                    ValadocDocumentationParser* docparser,
92                                                    ValadocApiPackage* package,
93                                                    ValadocErrorReporter* reporter,
94                                                    const gchar* path,
95                                                    const gchar* nameoffset);
96 static void valadoc_wiki_page_tree_finalize (GObject * obj);
97 static GType valadoc_wiki_page_tree_get_type_once (void);
98 
99 static inline gpointer
valadoc_wiki_page_get_instance_private(ValadocWikiPage * self)100 valadoc_wiki_page_get_instance_private (ValadocWikiPage* self)
101 {
102 	return G_STRUCT_MEMBER_P (self, ValadocWikiPage_private_offset);
103 }
104 
105 ValadocContentPage*
valadoc_wiki_page_get_documentation(ValadocWikiPage * self)106 valadoc_wiki_page_get_documentation (ValadocWikiPage* self)
107 {
108 	ValadocContentPage* result;
109 	ValadocContentPage* _tmp0_;
110 	g_return_val_if_fail (self != NULL, NULL);
111 	_tmp0_ = self->priv->_documentation;
112 	result = _tmp0_;
113 	return result;
114 }
115 
116 static gpointer
_g_object_ref0(gpointer self)117 _g_object_ref0 (gpointer self)
118 {
119 	return self ? g_object_ref (self) : NULL;
120 }
121 
122 void
valadoc_wiki_page_set_documentation(ValadocWikiPage * self,ValadocContentPage * value)123 valadoc_wiki_page_set_documentation (ValadocWikiPage* self,
124                                      ValadocContentPage* value)
125 {
126 	ValadocContentPage* old_value;
127 	g_return_if_fail (self != NULL);
128 	old_value = valadoc_wiki_page_get_documentation (self);
129 	if (old_value != value) {
130 		ValadocContentPage* _tmp0_;
131 		_tmp0_ = _g_object_ref0 (value);
132 		_g_object_unref0 (self->priv->_documentation);
133 		self->priv->_documentation = _tmp0_;
134 		g_object_notify_by_pspec ((GObject *) self, valadoc_wiki_page_properties[VALADOC_WIKI_PAGE_DOCUMENTATION_PROPERTY]);
135 	}
136 }
137 
138 const gchar*
valadoc_wiki_page_get_documentation_str(ValadocWikiPage * self)139 valadoc_wiki_page_get_documentation_str (ValadocWikiPage* self)
140 {
141 	const gchar* result;
142 	const gchar* _tmp0_;
143 	g_return_val_if_fail (self != NULL, NULL);
144 	_tmp0_ = self->priv->_documentation_str;
145 	result = _tmp0_;
146 	return result;
147 }
148 
149 static void
valadoc_wiki_page_set_documentation_str(ValadocWikiPage * self,const gchar * value)150 valadoc_wiki_page_set_documentation_str (ValadocWikiPage* self,
151                                          const gchar* value)
152 {
153 	gchar* old_value;
154 	g_return_if_fail (self != NULL);
155 	old_value = valadoc_wiki_page_get_documentation_str (self);
156 	if (g_strcmp0 (value, old_value) != 0) {
157 		gchar* _tmp0_;
158 		_tmp0_ = g_strdup (value);
159 		_g_free0 (self->priv->_documentation_str);
160 		self->priv->_documentation_str = _tmp0_;
161 		g_object_notify_by_pspec ((GObject *) self, valadoc_wiki_page_properties[VALADOC_WIKI_PAGE_DOCUMENTATION_STR_PROPERTY]);
162 	}
163 }
164 
165 const gchar*
valadoc_wiki_page_get_path(ValadocWikiPage * self)166 valadoc_wiki_page_get_path (ValadocWikiPage* self)
167 {
168 	const gchar* result;
169 	const gchar* _tmp0_;
170 	g_return_val_if_fail (self != NULL, NULL);
171 	_tmp0_ = self->priv->_path;
172 	result = _tmp0_;
173 	return result;
174 }
175 
176 static void
valadoc_wiki_page_set_path(ValadocWikiPage * self,const gchar * value)177 valadoc_wiki_page_set_path (ValadocWikiPage* self,
178                             const gchar* value)
179 {
180 	gchar* old_value;
181 	g_return_if_fail (self != NULL);
182 	old_value = valadoc_wiki_page_get_path (self);
183 	if (g_strcmp0 (value, old_value) != 0) {
184 		gchar* _tmp0_;
185 		_tmp0_ = g_strdup (value);
186 		_g_free0 (self->priv->_path);
187 		self->priv->_path = _tmp0_;
188 		g_object_notify_by_pspec ((GObject *) self, valadoc_wiki_page_properties[VALADOC_WIKI_PAGE_PATH_PROPERTY]);
189 	}
190 }
191 
192 const gchar*
valadoc_wiki_page_get_name(ValadocWikiPage * self)193 valadoc_wiki_page_get_name (ValadocWikiPage* self)
194 {
195 	const gchar* result;
196 	const gchar* _tmp0_;
197 	g_return_val_if_fail (self != NULL, NULL);
198 	_tmp0_ = self->priv->_name;
199 	result = _tmp0_;
200 	return result;
201 }
202 
203 static void
valadoc_wiki_page_set_name(ValadocWikiPage * self,const gchar * value)204 valadoc_wiki_page_set_name (ValadocWikiPage* self,
205                             const gchar* value)
206 {
207 	gchar* old_value;
208 	g_return_if_fail (self != NULL);
209 	old_value = valadoc_wiki_page_get_name (self);
210 	if (g_strcmp0 (value, old_value) != 0) {
211 		gchar* _tmp0_;
212 		_tmp0_ = g_strdup (value);
213 		_g_free0 (self->priv->_name);
214 		self->priv->_name = _tmp0_;
215 		g_object_notify_by_pspec ((GObject *) self, valadoc_wiki_page_properties[VALADOC_WIKI_PAGE_NAME_PROPERTY]);
216 	}
217 }
218 
219 static ValadocApiPackage*
valadoc_wiki_page_real_get_package(ValadocDocumentation * base)220 valadoc_wiki_page_real_get_package (ValadocDocumentation* base)
221 {
222 	ValadocApiPackage* result;
223 	ValadocWikiPage* self;
224 	ValadocApiPackage* _tmp0_;
225 	self = (ValadocWikiPage*) base;
226 	_tmp0_ = self->priv->_package;
227 	result = _tmp0_;
228 	return result;
229 }
230 
231 /**
232  * The corresponding file name
233  */
234 static gchar*
valadoc_wiki_page_real_get_filename(ValadocDocumentation * base)235 valadoc_wiki_page_real_get_filename (ValadocDocumentation* base)
236 {
237 	ValadocWikiPage * self;
238 	const gchar* _tmp0_;
239 	gchar* _tmp1_;
240 	gchar* result = NULL;
241 	self = (ValadocWikiPage*) base;
242 	_tmp0_ = self->priv->_path;
243 	_tmp1_ = g_path_get_basename (_tmp0_);
244 	result = _tmp1_;
245 	return result;
246 }
247 
248 ValadocWikiPage*
valadoc_wiki_page_construct(GType object_type,const gchar * name,const gchar * path,ValadocApiPackage * package)249 valadoc_wiki_page_construct (GType object_type,
250                              const gchar* name,
251                              const gchar* path,
252                              ValadocApiPackage* package)
253 {
254 	ValadocWikiPage * self = NULL;
255 	ValadocApiPackage* _tmp0_;
256 	g_return_val_if_fail (name != NULL, NULL);
257 	g_return_val_if_fail (path != NULL, NULL);
258 	g_return_val_if_fail (package != NULL, NULL);
259 	self = (ValadocWikiPage*) g_object_new (object_type, NULL);
260 	_tmp0_ = _g_object_ref0 (package);
261 	_g_object_unref0 (self->priv->_package);
262 	self->priv->_package = _tmp0_;
263 	valadoc_wiki_page_set_name (self, name);
264 	valadoc_wiki_page_set_path (self, path);
265 	return self;
266 }
267 
268 ValadocWikiPage*
valadoc_wiki_page_new(const gchar * name,const gchar * path,ValadocApiPackage * package)269 valadoc_wiki_page_new (const gchar* name,
270                        const gchar* path,
271                        ValadocApiPackage* package)
272 {
273 	return valadoc_wiki_page_construct (VALADOC_TYPE_WIKI_PAGE, name, path, package);
274 }
275 
276 void
valadoc_wiki_page_read(ValadocWikiPage * self,ValadocErrorReporter * reporter)277 valadoc_wiki_page_read (ValadocWikiPage* self,
278                         ValadocErrorReporter* reporter)
279 {
280 	GError* _inner_error0_ = NULL;
281 	g_return_if_fail (self != NULL);
282 	g_return_if_fail (reporter != NULL);
283 	{
284 		gchar* content = NULL;
285 		const gchar* _tmp0_;
286 		gchar* _tmp1_ = NULL;
287 		_tmp0_ = self->priv->_path;
288 		g_file_get_contents (_tmp0_, &_tmp1_, NULL, &_inner_error0_);
289 		_g_free0 (content);
290 		content = _tmp1_;
291 		if (G_UNLIKELY (_inner_error0_ != NULL)) {
292 			_g_free0 (content);
293 			if (_inner_error0_->domain == G_FILE_ERROR) {
294 				goto __catch0_g_file_error;
295 			}
296 			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
297 			g_clear_error (&_inner_error0_);
298 			return;
299 		}
300 		valadoc_wiki_page_set_documentation_str (self, content);
301 		_g_free0 (content);
302 	}
303 	goto __finally0;
304 	__catch0_g_file_error:
305 	{
306 		GError* err = NULL;
307 		const gchar* _tmp2_;
308 		GError* _tmp3_;
309 		const gchar* _tmp4_;
310 		err = _inner_error0_;
311 		_inner_error0_ = NULL;
312 		_tmp2_ = self->priv->_path;
313 		_tmp3_ = err;
314 		_tmp4_ = _tmp3_->message;
315 		valadoc_error_reporter_simple_error (reporter, NULL, "Unable to read file '%s': %s", _tmp2_, _tmp4_);
316 		_g_error_free0 (err);
317 	}
318 	__finally0:
319 	if (G_UNLIKELY (_inner_error0_ != NULL)) {
320 		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
321 		g_clear_error (&_inner_error0_);
322 		return;
323 	}
324 }
325 
326 void
valadoc_wiki_page_parse(ValadocWikiPage * self,ValadocDocumentationParser * docparser,ValadocApiPackage * pkg)327 valadoc_wiki_page_parse (ValadocWikiPage* self,
328                          ValadocDocumentationParser* docparser,
329                          ValadocApiPackage* pkg)
330 {
331 	ValadocContentPage* _tmp0_;
332 	ValadocContentPage* _tmp1_;
333 	g_return_if_fail (self != NULL);
334 	g_return_if_fail (docparser != NULL);
335 	g_return_if_fail (pkg != NULL);
336 	_tmp0_ = valadoc_documentation_parser_parse_wikipage (docparser, pkg, self);
337 	_tmp1_ = _tmp0_;
338 	valadoc_wiki_page_set_documentation (self, _tmp1_);
339 	_g_object_unref0 (_tmp1_);
340 }
341 
342 static void
valadoc_wiki_page_class_init(ValadocWikiPageClass * klass,gpointer klass_data)343 valadoc_wiki_page_class_init (ValadocWikiPageClass * klass,
344                               gpointer klass_data)
345 {
346 	valadoc_wiki_page_parent_class = g_type_class_peek_parent (klass);
347 	g_type_class_adjust_private_offset (klass, &ValadocWikiPage_private_offset);
348 	G_OBJECT_CLASS (klass)->get_property = _vala_valadoc_wiki_page_get_property;
349 	G_OBJECT_CLASS (klass)->set_property = _vala_valadoc_wiki_page_set_property;
350 	G_OBJECT_CLASS (klass)->finalize = valadoc_wiki_page_finalize;
351 	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_WIKI_PAGE_DOCUMENTATION_PROPERTY, valadoc_wiki_page_properties[VALADOC_WIKI_PAGE_DOCUMENTATION_PROPERTY] = g_param_spec_object ("documentation", "documentation", "documentation", VALADOC_CONTENT_TYPE_PAGE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
352 	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_WIKI_PAGE_DOCUMENTATION_STR_PROPERTY, valadoc_wiki_page_properties[VALADOC_WIKI_PAGE_DOCUMENTATION_STR_PROPERTY] = g_param_spec_string ("documentation-str", "documentation-str", "documentation-str", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
353 	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_WIKI_PAGE_PATH_PROPERTY, valadoc_wiki_page_properties[VALADOC_WIKI_PAGE_PATH_PROPERTY] = g_param_spec_string ("path", "path", "path", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
354 	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_WIKI_PAGE_NAME_PROPERTY, valadoc_wiki_page_properties[VALADOC_WIKI_PAGE_NAME_PROPERTY] = g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
355 	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_WIKI_PAGE_PACKAGE_PROPERTY, valadoc_wiki_page_properties[VALADOC_WIKI_PAGE_PACKAGE_PROPERTY] = g_param_spec_object ("package", "package", "package", VALADOC_API_TYPE_PACKAGE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
356 }
357 
358 static void
valadoc_wiki_page_valadoc_documentation_interface_init(ValadocDocumentationIface * iface,gpointer iface_data)359 valadoc_wiki_page_valadoc_documentation_interface_init (ValadocDocumentationIface * iface,
360                                                         gpointer iface_data)
361 {
362 	valadoc_wiki_page_valadoc_documentation_parent_iface = g_type_interface_peek_parent (iface);
363 	iface->get_filename = (gchar* (*) (ValadocDocumentation*)) valadoc_wiki_page_real_get_filename;
364 	iface->get_package = valadoc_wiki_page_real_get_package;
365 }
366 
367 static void
valadoc_wiki_page_instance_init(ValadocWikiPage * self,gpointer klass)368 valadoc_wiki_page_instance_init (ValadocWikiPage * self,
369                                  gpointer klass)
370 {
371 	self->priv = valadoc_wiki_page_get_instance_private (self);
372 }
373 
374 static void
valadoc_wiki_page_finalize(GObject * obj)375 valadoc_wiki_page_finalize (GObject * obj)
376 {
377 	ValadocWikiPage * self;
378 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_TYPE_WIKI_PAGE, ValadocWikiPage);
379 	_g_object_unref0 (self->priv->_documentation);
380 	_g_free0 (self->priv->_documentation_str);
381 	_g_free0 (self->priv->_path);
382 	_g_free0 (self->priv->_name);
383 	_g_object_unref0 (self->priv->_package);
384 	G_OBJECT_CLASS (valadoc_wiki_page_parent_class)->finalize (obj);
385 }
386 
387 static GType
valadoc_wiki_page_get_type_once(void)388 valadoc_wiki_page_get_type_once (void)
389 {
390 	static const GTypeInfo g_define_type_info = { sizeof (ValadocWikiPageClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_wiki_page_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocWikiPage), 0, (GInstanceInitFunc) valadoc_wiki_page_instance_init, NULL };
391 	static const GInterfaceInfo valadoc_documentation_info = { (GInterfaceInitFunc) valadoc_wiki_page_valadoc_documentation_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
392 	GType valadoc_wiki_page_type_id;
393 	valadoc_wiki_page_type_id = g_type_register_static (G_TYPE_OBJECT, "ValadocWikiPage", &g_define_type_info, 0);
394 	g_type_add_interface_static (valadoc_wiki_page_type_id, VALADOC_TYPE_DOCUMENTATION, &valadoc_documentation_info);
395 	ValadocWikiPage_private_offset = g_type_add_instance_private (valadoc_wiki_page_type_id, sizeof (ValadocWikiPagePrivate));
396 	return valadoc_wiki_page_type_id;
397 }
398 
399 GType
valadoc_wiki_page_get_type(void)400 valadoc_wiki_page_get_type (void)
401 {
402 	static volatile gsize valadoc_wiki_page_type_id__volatile = 0;
403 	if (g_once_init_enter (&valadoc_wiki_page_type_id__volatile)) {
404 		GType valadoc_wiki_page_type_id;
405 		valadoc_wiki_page_type_id = valadoc_wiki_page_get_type_once ();
406 		g_once_init_leave (&valadoc_wiki_page_type_id__volatile, valadoc_wiki_page_type_id);
407 	}
408 	return valadoc_wiki_page_type_id__volatile;
409 }
410 
411 static void
_vala_valadoc_wiki_page_get_property(GObject * object,guint property_id,GValue * value,GParamSpec * pspec)412 _vala_valadoc_wiki_page_get_property (GObject * object,
413                                       guint property_id,
414                                       GValue * value,
415                                       GParamSpec * pspec)
416 {
417 	ValadocWikiPage * self;
418 	self = G_TYPE_CHECK_INSTANCE_CAST (object, VALADOC_TYPE_WIKI_PAGE, ValadocWikiPage);
419 	switch (property_id) {
420 		case VALADOC_WIKI_PAGE_DOCUMENTATION_PROPERTY:
421 		g_value_set_object (value, valadoc_wiki_page_get_documentation (self));
422 		break;
423 		case VALADOC_WIKI_PAGE_DOCUMENTATION_STR_PROPERTY:
424 		g_value_set_string (value, valadoc_wiki_page_get_documentation_str (self));
425 		break;
426 		case VALADOC_WIKI_PAGE_PATH_PROPERTY:
427 		g_value_set_string (value, valadoc_wiki_page_get_path (self));
428 		break;
429 		case VALADOC_WIKI_PAGE_NAME_PROPERTY:
430 		g_value_set_string (value, valadoc_wiki_page_get_name (self));
431 		break;
432 		case VALADOC_WIKI_PAGE_PACKAGE_PROPERTY:
433 		g_value_set_object (value, valadoc_documentation_get_package ((ValadocDocumentation*) self));
434 		break;
435 		default:
436 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
437 		break;
438 	}
439 }
440 
441 static void
_vala_valadoc_wiki_page_set_property(GObject * object,guint property_id,const GValue * value,GParamSpec * pspec)442 _vala_valadoc_wiki_page_set_property (GObject * object,
443                                       guint property_id,
444                                       const GValue * value,
445                                       GParamSpec * pspec)
446 {
447 	ValadocWikiPage * self;
448 	self = G_TYPE_CHECK_INSTANCE_CAST (object, VALADOC_TYPE_WIKI_PAGE, ValadocWikiPage);
449 	switch (property_id) {
450 		case VALADOC_WIKI_PAGE_DOCUMENTATION_PROPERTY:
451 		valadoc_wiki_page_set_documentation (self, g_value_get_object (value));
452 		break;
453 		case VALADOC_WIKI_PAGE_DOCUMENTATION_STR_PROPERTY:
454 		valadoc_wiki_page_set_documentation_str (self, g_value_get_string (value));
455 		break;
456 		case VALADOC_WIKI_PAGE_PATH_PROPERTY:
457 		valadoc_wiki_page_set_path (self, g_value_get_string (value));
458 		break;
459 		case VALADOC_WIKI_PAGE_NAME_PROPERTY:
460 		valadoc_wiki_page_set_name (self, g_value_get_string (value));
461 		break;
462 		default:
463 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
464 		break;
465 	}
466 }
467 
468 static inline gpointer
valadoc_wiki_page_tree_get_instance_private(ValadocWikiPageTree * self)469 valadoc_wiki_page_tree_get_instance_private (ValadocWikiPageTree* self)
470 {
471 	return G_STRUCT_MEMBER_P (self, ValadocWikiPageTree_private_offset);
472 }
473 
474 ValadocWikiPageTree*
valadoc_wiki_page_tree_construct(GType object_type)475 valadoc_wiki_page_tree_construct (GType object_type)
476 {
477 	ValadocWikiPageTree * self = NULL;
478 	self = (ValadocWikiPageTree*) g_object_new (object_type, NULL);
479 	return self;
480 }
481 
482 ValadocWikiPageTree*
valadoc_wiki_page_tree_new(void)483 valadoc_wiki_page_tree_new (void)
484 {
485 	return valadoc_wiki_page_tree_construct (VALADOC_TYPE_WIKI_PAGE_TREE);
486 }
487 
488 static gpointer
_vala_iterable_ref0(gpointer self)489 _vala_iterable_ref0 (gpointer self)
490 {
491 	return self ? vala_iterable_ref (self) : NULL;
492 }
493 
494 ValaCollection*
valadoc_wiki_page_tree_get_pages(ValadocWikiPageTree * self)495 valadoc_wiki_page_tree_get_pages (ValadocWikiPageTree* self)
496 {
497 	ValaArrayList* _tmp0_ = NULL;
498 	ValaArrayList* _tmp1_;
499 	ValaCollection* result = NULL;
500 	g_return_val_if_fail (self != NULL, NULL);
501 	_tmp1_ = self->priv->wikipages;
502 	if (_tmp1_ == NULL) {
503 		GEqualFunc _tmp2_;
504 		ValaArrayList* _tmp3_;
505 		_tmp2_ = g_direct_equal;
506 		_tmp3_ = vala_array_list_new (VALADOC_TYPE_WIKI_PAGE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp2_);
507 		_vala_iterable_unref0 (_tmp0_);
508 		_tmp0_ = _tmp3_;
509 	} else {
510 		ValaArrayList* _tmp4_;
511 		ValaArrayList* _tmp5_;
512 		_tmp4_ = self->priv->wikipages;
513 		_tmp5_ = _vala_iterable_ref0 (_tmp4_);
514 		_vala_iterable_unref0 (_tmp0_);
515 		_tmp0_ = _tmp5_;
516 	}
517 	result = (ValaCollection*) _tmp0_;
518 	return result;
519 }
520 
521 ValadocWikiPage*
valadoc_wiki_page_tree_search(ValadocWikiPageTree * self,const gchar * name)522 valadoc_wiki_page_tree_search (ValadocWikiPageTree* self,
523                                const gchar* name)
524 {
525 	ValaArrayList* _tmp0_;
526 	ValadocWikiPage* result = NULL;
527 	g_return_val_if_fail (self != NULL, NULL);
528 	g_return_val_if_fail (name != NULL, NULL);
529 	_tmp0_ = self->priv->wikipages;
530 	if (_tmp0_ == NULL) {
531 		result = NULL;
532 		return result;
533 	}
534 	{
535 		ValaArrayList* _page_list = NULL;
536 		ValaArrayList* _tmp1_;
537 		ValaArrayList* _tmp2_;
538 		gint _page_size = 0;
539 		ValaArrayList* _tmp3_;
540 		gint _tmp4_;
541 		gint _tmp5_;
542 		gint _page_index = 0;
543 		_tmp1_ = self->priv->wikipages;
544 		_tmp2_ = _vala_iterable_ref0 (_tmp1_);
545 		_page_list = _tmp2_;
546 		_tmp3_ = _page_list;
547 		_tmp4_ = vala_collection_get_size ((ValaCollection*) _tmp3_);
548 		_tmp5_ = _tmp4_;
549 		_page_size = _tmp5_;
550 		_page_index = -1;
551 		while (TRUE) {
552 			gint _tmp6_;
553 			gint _tmp7_;
554 			ValadocWikiPage* page = NULL;
555 			ValaArrayList* _tmp8_;
556 			gpointer _tmp9_;
557 			ValadocWikiPage* _tmp10_;
558 			const gchar* _tmp11_;
559 			const gchar* _tmp12_;
560 			_page_index = _page_index + 1;
561 			_tmp6_ = _page_index;
562 			_tmp7_ = _page_size;
563 			if (!(_tmp6_ < _tmp7_)) {
564 				break;
565 			}
566 			_tmp8_ = _page_list;
567 			_tmp9_ = vala_list_get ((ValaList*) _tmp8_, _page_index);
568 			page = (ValadocWikiPage*) _tmp9_;
569 			_tmp10_ = page;
570 			_tmp11_ = valadoc_wiki_page_get_name (_tmp10_);
571 			_tmp12_ = _tmp11_;
572 			if (g_strcmp0 (_tmp12_, name) == 0) {
573 				result = page;
574 				_vala_iterable_unref0 (_page_list);
575 				return result;
576 			}
577 			_g_object_unref0 (page);
578 		}
579 		_vala_iterable_unref0 (_page_list);
580 	}
581 	result = NULL;
582 	return result;
583 }
584 
585 static void
valadoc_wiki_page_tree_create_tree_from_path(ValadocWikiPageTree * self,ValadocDocumentationParser * docparser,ValadocApiPackage * package,ValadocErrorReporter * reporter,const gchar * path,const gchar * nameoffset)586 valadoc_wiki_page_tree_create_tree_from_path (ValadocWikiPageTree* self,
587                                               ValadocDocumentationParser* docparser,
588                                               ValadocApiPackage* package,
589                                               ValadocErrorReporter* reporter,
590                                               const gchar* path,
591                                               const gchar* nameoffset)
592 {
593 	GError* _inner_error0_ = NULL;
594 	g_return_if_fail (self != NULL);
595 	g_return_if_fail (docparser != NULL);
596 	g_return_if_fail (package != NULL);
597 	g_return_if_fail (reporter != NULL);
598 	g_return_if_fail (path != NULL);
599 	{
600 		GDir* dir = NULL;
601 		GDir* _tmp0_;
602 		_tmp0_ = g_dir_open (path, (guint) 0, &_inner_error0_);
603 		dir = _tmp0_;
604 		if (G_UNLIKELY (_inner_error0_ != NULL)) {
605 			if (_inner_error0_->domain == G_FILE_ERROR) {
606 				goto __catch0_g_file_error;
607 			}
608 			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
609 			g_clear_error (&_inner_error0_);
610 			return;
611 		}
612 		{
613 			gchar* curname = NULL;
614 			GDir* _tmp1_;
615 			const gchar* _tmp2_;
616 			gchar* _tmp3_;
617 			_tmp1_ = dir;
618 			_tmp2_ = g_dir_read_name (_tmp1_);
619 			_tmp3_ = g_strdup (_tmp2_);
620 			curname = _tmp3_;
621 			{
622 				gboolean _tmp4_ = FALSE;
623 				_tmp4_ = TRUE;
624 				while (TRUE) {
625 					const gchar* _tmp8_;
626 					gchar* filename = NULL;
627 					const gchar* _tmp9_;
628 					gchar* _tmp10_;
629 					gboolean _tmp11_ = FALSE;
630 					const gchar* _tmp12_;
631 					if (!_tmp4_) {
632 						GDir* _tmp5_;
633 						const gchar* _tmp6_;
634 						gchar* _tmp7_;
635 						_tmp5_ = dir;
636 						_tmp6_ = g_dir_read_name (_tmp5_);
637 						_tmp7_ = g_strdup (_tmp6_);
638 						_g_free0 (curname);
639 						curname = _tmp7_;
640 					}
641 					_tmp4_ = FALSE;
642 					_tmp8_ = curname;
643 					if (!(_tmp8_ != NULL)) {
644 						break;
645 					}
646 					_tmp9_ = curname;
647 					_tmp10_ = g_build_filename (path, _tmp9_, NULL);
648 					filename = _tmp10_;
649 					_tmp12_ = curname;
650 					if (g_str_has_suffix (_tmp12_, ".valadoc")) {
651 						const gchar* _tmp13_;
652 						_tmp13_ = filename;
653 						_tmp11_ = g_file_test (_tmp13_, G_FILE_TEST_IS_REGULAR);
654 					} else {
655 						_tmp11_ = FALSE;
656 					}
657 					if (_tmp11_) {
658 						gchar* _tmp14_ = NULL;
659 						ValadocWikiPage* wikipage = NULL;
660 						const gchar* _tmp19_;
661 						ValadocWikiPage* _tmp20_;
662 						ValaArrayList* _tmp21_;
663 						ValadocWikiPage* _tmp22_;
664 						ValadocWikiPage* _tmp23_;
665 						if (nameoffset != NULL) {
666 							const gchar* _tmp15_;
667 							gchar* _tmp16_;
668 							_tmp15_ = curname;
669 							_tmp16_ = g_build_filename (nameoffset, _tmp15_, NULL);
670 							_g_free0 (_tmp14_);
671 							_tmp14_ = _tmp16_;
672 						} else {
673 							const gchar* _tmp17_;
674 							gchar* _tmp18_;
675 							_tmp17_ = curname;
676 							_tmp18_ = g_strdup (_tmp17_);
677 							_g_free0 (_tmp14_);
678 							_tmp14_ = _tmp18_;
679 						}
680 						_tmp19_ = filename;
681 						_tmp20_ = valadoc_wiki_page_new (_tmp14_, _tmp19_, package);
682 						wikipage = _tmp20_;
683 						_tmp21_ = self->priv->wikipages;
684 						_tmp22_ = wikipage;
685 						vala_collection_add ((ValaCollection*) _tmp21_, _tmp22_);
686 						_tmp23_ = wikipage;
687 						valadoc_wiki_page_read (_tmp23_, reporter);
688 						_g_object_unref0 (wikipage);
689 						_g_free0 (_tmp14_);
690 					} else {
691 						const gchar* _tmp24_;
692 						_tmp24_ = filename;
693 						if (g_file_test (_tmp24_, G_FILE_TEST_IS_DIR)) {
694 							gchar* _tmp25_ = NULL;
695 							const gchar* _tmp30_;
696 							if (nameoffset != NULL) {
697 								const gchar* _tmp26_;
698 								gchar* _tmp27_;
699 								_tmp26_ = curname;
700 								_tmp27_ = g_build_filename (nameoffset, _tmp26_, NULL);
701 								_g_free0 (_tmp25_);
702 								_tmp25_ = _tmp27_;
703 							} else {
704 								const gchar* _tmp28_;
705 								gchar* _tmp29_;
706 								_tmp28_ = curname;
707 								_tmp29_ = g_strdup (_tmp28_);
708 								_g_free0 (_tmp25_);
709 								_tmp25_ = _tmp29_;
710 							}
711 							_tmp30_ = filename;
712 							valadoc_wiki_page_tree_create_tree_from_path (self, docparser, package, reporter, _tmp30_, _tmp25_);
713 							_g_free0 (_tmp25_);
714 						}
715 					}
716 					_g_free0 (filename);
717 				}
718 			}
719 			_g_free0 (curname);
720 		}
721 		_g_dir_close0 (dir);
722 	}
723 	goto __finally0;
724 	__catch0_g_file_error:
725 	{
726 		GError* err = NULL;
727 		GError* _tmp31_;
728 		const gchar* _tmp32_;
729 		err = _inner_error0_;
730 		_inner_error0_ = NULL;
731 		_tmp31_ = err;
732 		_tmp32_ = _tmp31_->message;
733 		valadoc_error_reporter_simple_error (reporter, NULL, "Unable to open directory '%s': %s", path, _tmp32_);
734 		_g_error_free0 (err);
735 	}
736 	__finally0:
737 	if (G_UNLIKELY (_inner_error0_ != NULL)) {
738 		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
739 		g_clear_error (&_inner_error0_);
740 		return;
741 	}
742 }
743 
744 void
valadoc_wiki_page_tree_parse(ValadocWikiPageTree * self,ValadocSettings * settings,ValadocDocumentationParser * docparser,ValadocApiPackage * package,ValadocErrorReporter * reporter)745 valadoc_wiki_page_tree_parse (ValadocWikiPageTree* self,
746                               ValadocSettings* settings,
747                               ValadocDocumentationParser* docparser,
748                               ValadocApiPackage* package,
749                               ValadocErrorReporter* reporter)
750 {
751 	const gchar* path = NULL;
752 	const gchar* _tmp0_;
753 	const gchar* _tmp1_;
754 	GEqualFunc _tmp2_;
755 	ValaArrayList* _tmp3_;
756 	const gchar* _tmp4_;
757 	g_return_if_fail (self != NULL);
758 	g_return_if_fail (settings != NULL);
759 	g_return_if_fail (docparser != NULL);
760 	g_return_if_fail (package != NULL);
761 	g_return_if_fail (reporter != NULL);
762 	_tmp0_ = settings->wiki_directory;
763 	path = _tmp0_;
764 	_tmp1_ = path;
765 	if (_tmp1_ == NULL) {
766 		return;
767 	}
768 	_tmp2_ = g_direct_equal;
769 	_tmp3_ = vala_array_list_new (VALADOC_TYPE_WIKI_PAGE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp2_);
770 	_vala_iterable_unref0 (self->priv->wikipages);
771 	self->priv->wikipages = _tmp3_;
772 	_tmp4_ = path;
773 	valadoc_wiki_page_tree_create_tree_from_path (self, docparser, package, reporter, _tmp4_, NULL);
774 	{
775 		ValaArrayList* _page_list = NULL;
776 		ValaArrayList* _tmp5_;
777 		ValaArrayList* _tmp6_;
778 		gint _page_size = 0;
779 		ValaArrayList* _tmp7_;
780 		gint _tmp8_;
781 		gint _tmp9_;
782 		gint _page_index = 0;
783 		_tmp5_ = self->priv->wikipages;
784 		_tmp6_ = _vala_iterable_ref0 (_tmp5_);
785 		_page_list = _tmp6_;
786 		_tmp7_ = _page_list;
787 		_tmp8_ = vala_collection_get_size ((ValaCollection*) _tmp7_);
788 		_tmp9_ = _tmp8_;
789 		_page_size = _tmp9_;
790 		_page_index = -1;
791 		while (TRUE) {
792 			gint _tmp10_;
793 			gint _tmp11_;
794 			ValadocWikiPage* page = NULL;
795 			ValaArrayList* _tmp12_;
796 			gpointer _tmp13_;
797 			ValadocWikiPage* _tmp14_;
798 			_page_index = _page_index + 1;
799 			_tmp10_ = _page_index;
800 			_tmp11_ = _page_size;
801 			if (!(_tmp10_ < _tmp11_)) {
802 				break;
803 			}
804 			_tmp12_ = _page_list;
805 			_tmp13_ = vala_list_get ((ValaList*) _tmp12_, _page_index);
806 			page = (ValadocWikiPage*) _tmp13_;
807 			_tmp14_ = page;
808 			valadoc_wiki_page_parse (_tmp14_, docparser, package);
809 			_g_object_unref0 (page);
810 		}
811 		_vala_iterable_unref0 (_page_list);
812 	}
813 }
814 
815 void
valadoc_wiki_page_tree_check(ValadocWikiPageTree * self,ValadocSettings * settings,ValadocDocumentationParser * docparser,ValadocApiPackage * pkg)816 valadoc_wiki_page_tree_check (ValadocWikiPageTree* self,
817                               ValadocSettings* settings,
818                               ValadocDocumentationParser* docparser,
819                               ValadocApiPackage* pkg)
820 {
821 	ValaArrayList* _tmp0_;
822 	g_return_if_fail (self != NULL);
823 	g_return_if_fail (settings != NULL);
824 	g_return_if_fail (docparser != NULL);
825 	g_return_if_fail (pkg != NULL);
826 	_tmp0_ = self->priv->wikipages;
827 	if (_tmp0_ == NULL) {
828 		return;
829 	}
830 	{
831 		ValaArrayList* _page_list = NULL;
832 		ValaArrayList* _tmp1_;
833 		ValaArrayList* _tmp2_;
834 		gint _page_size = 0;
835 		ValaArrayList* _tmp3_;
836 		gint _tmp4_;
837 		gint _tmp5_;
838 		gint _page_index = 0;
839 		_tmp1_ = self->priv->wikipages;
840 		_tmp2_ = _vala_iterable_ref0 (_tmp1_);
841 		_page_list = _tmp2_;
842 		_tmp3_ = _page_list;
843 		_tmp4_ = vala_collection_get_size ((ValaCollection*) _tmp3_);
844 		_tmp5_ = _tmp4_;
845 		_page_size = _tmp5_;
846 		_page_index = -1;
847 		while (TRUE) {
848 			gint _tmp6_;
849 			gint _tmp7_;
850 			ValadocWikiPage* page = NULL;
851 			ValaArrayList* _tmp8_;
852 			gpointer _tmp9_;
853 			ValadocWikiPage* _tmp10_;
854 			_page_index = _page_index + 1;
855 			_tmp6_ = _page_index;
856 			_tmp7_ = _page_size;
857 			if (!(_tmp6_ < _tmp7_)) {
858 				break;
859 			}
860 			_tmp8_ = _page_list;
861 			_tmp9_ = vala_list_get ((ValaList*) _tmp8_, _page_index);
862 			page = (ValadocWikiPage*) _tmp9_;
863 			_tmp10_ = page;
864 			valadoc_documentation_parser_check_wikipage (docparser, pkg, _tmp10_);
865 			_g_object_unref0 (page);
866 		}
867 		_vala_iterable_unref0 (_page_list);
868 	}
869 }
870 
871 static void
valadoc_wiki_page_tree_class_init(ValadocWikiPageTreeClass * klass,gpointer klass_data)872 valadoc_wiki_page_tree_class_init (ValadocWikiPageTreeClass * klass,
873                                    gpointer klass_data)
874 {
875 	valadoc_wiki_page_tree_parent_class = g_type_class_peek_parent (klass);
876 	g_type_class_adjust_private_offset (klass, &ValadocWikiPageTree_private_offset);
877 	G_OBJECT_CLASS (klass)->finalize = valadoc_wiki_page_tree_finalize;
878 }
879 
880 static void
valadoc_wiki_page_tree_instance_init(ValadocWikiPageTree * self,gpointer klass)881 valadoc_wiki_page_tree_instance_init (ValadocWikiPageTree * self,
882                                       gpointer klass)
883 {
884 	self->priv = valadoc_wiki_page_tree_get_instance_private (self);
885 }
886 
887 static void
valadoc_wiki_page_tree_finalize(GObject * obj)888 valadoc_wiki_page_tree_finalize (GObject * obj)
889 {
890 	ValadocWikiPageTree * self;
891 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_TYPE_WIKI_PAGE_TREE, ValadocWikiPageTree);
892 	_vala_iterable_unref0 (self->priv->wikipages);
893 	G_OBJECT_CLASS (valadoc_wiki_page_tree_parent_class)->finalize (obj);
894 }
895 
896 static GType
valadoc_wiki_page_tree_get_type_once(void)897 valadoc_wiki_page_tree_get_type_once (void)
898 {
899 	static const GTypeInfo g_define_type_info = { sizeof (ValadocWikiPageTreeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_wiki_page_tree_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocWikiPageTree), 0, (GInstanceInitFunc) valadoc_wiki_page_tree_instance_init, NULL };
900 	GType valadoc_wiki_page_tree_type_id;
901 	valadoc_wiki_page_tree_type_id = g_type_register_static (G_TYPE_OBJECT, "ValadocWikiPageTree", &g_define_type_info, 0);
902 	ValadocWikiPageTree_private_offset = g_type_add_instance_private (valadoc_wiki_page_tree_type_id, sizeof (ValadocWikiPageTreePrivate));
903 	return valadoc_wiki_page_tree_type_id;
904 }
905 
906 GType
valadoc_wiki_page_tree_get_type(void)907 valadoc_wiki_page_tree_get_type (void)
908 {
909 	static volatile gsize valadoc_wiki_page_tree_type_id__volatile = 0;
910 	if (g_once_init_enter (&valadoc_wiki_page_tree_type_id__volatile)) {
911 		GType valadoc_wiki_page_tree_type_id;
912 		valadoc_wiki_page_tree_type_id = valadoc_wiki_page_tree_get_type_once ();
913 		g_once_init_leave (&valadoc_wiki_page_tree_type_id__volatile, valadoc_wiki_page_tree_type_id);
914 	}
915 	return valadoc_wiki_page_tree_type_id__volatile;
916 }
917 
918