1 /* valadocdocumentationimporter.c generated by valac, the Vala compiler
2  * generated from valadocdocumentationimporter.vala, do not modify */
3 
4 /* resourcelocator.vala
5  *
6  * Copyright (C) 2010 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 <glib.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <vala.h>
31 #include <glib-object.h>
32 #include <valagee.h>
33 
34 enum  {
35 	VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_0_PROPERTY,
36 	VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_FILE_EXTENSION_PROPERTY,
37 	VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_NUM_PROPERTIES
38 };
39 static GParamSpec* valadoc_importer_valadoc_documentation_importer_properties[VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_NUM_PROPERTIES];
40 typedef enum  {
41 	VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_INSERTION_MODE_APPEND,
42 	VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_INSERTION_MODE_PREPEND,
43 	VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_INSERTION_MODE_REPLACE
44 } ValadocImporterValadocDocumentationImporterInsertionMode;
45 
46 #define VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_TYPE_INSERTION_MODE (valadoc_importer_valadoc_documentation_importer_insertion_mode_get_type ())
47 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
48 #define _valadoc_parser_unref0(var) ((var == NULL) ? NULL : (var = (valadoc_parser_unref (var), NULL)))
49 #define _g_mapped_file_unref0(var) ((var == NULL) ? NULL : (var = (g_mapped_file_unref (var), NULL)))
50 #define _g_free0(var) (var = (g_free (var), NULL))
51 #define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
52 #define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
53 #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
54 
55 struct _ValadocImporterValadocDocumentationImporterPrivate {
56 	ValadocImporterValadocDocumentationScanner* _scanner;
57 	ValadocDocumentationParser* _doc_parser;
58 	ValadocParser* _parser;
59 	GMappedFile* _mapped_file;
60 	gchar* _filename;
61 	gchar* _cname;
62 	GString* _comment;
63 	ValaSourceLocation _comment_location;
64 	ValadocErrorReporter* reporter;
65 };
66 
67 static gint ValadocImporterValadocDocumentationImporter_private_offset;
68 static gpointer valadoc_importer_valadoc_documentation_importer_parent_class = NULL;
69 static ValadocResourceLocatorIface * valadoc_importer_valadoc_documentation_importer_valadoc_resource_locator_parent_iface = NULL;
70 
71 static GType valadoc_importer_valadoc_documentation_importer_insertion_mode_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
72 static void __lambda133_ (ValadocImporterValadocDocumentationImporter* self,
73                    ValadocToken* token,
74                    GError** error);
75 static void ___lambda133__valadoc_token_type_action (ValadocToken* token,
76                                               gpointer self,
77                                               GError** error);
78 static void valadoc_importer_valadoc_documentation_importer_add_comment (ValadocImporterValadocDocumentationImporter* self,
79                                                                   ValadocToken* token,
80                                                                   GError** error);
81 static void _valadoc_importer_valadoc_documentation_importer_add_comment_valadoc_token_type_action (ValadocToken* token,
82                                                                                              gpointer self,
83                                                                                              GError** error);
84 static void __lambda134_ (ValadocImporterValadocDocumentationImporter* self,
85                    ValadocToken* token,
86                    GError** error);
87 static void ___lambda134__valadoc_token_type_action (ValadocToken* token,
88                                               gpointer self,
89                                               GError** error);
90 static void __lambda135_ (ValadocImporterValadocDocumentationImporter* self,
91                    GError** error);
92 static void valadoc_importer_valadoc_documentation_importer_add_documentation (ValadocImporterValadocDocumentationImporter* self,
93                                                                         const gchar* _symbol_name,
94                                                                         GString* comment,
95                                                                         const gchar* filename,
96                                                                         ValaSourceLocation* src_ref);
97 static void ___lambda135__valadoc_rule_action (gpointer self,
98                                         GError** error);
99 static void __lambda136_ (ValadocImporterValadocDocumentationImporter* self,
100                    ValadocToken* token,
101                    GError** error);
102 static void ___lambda136__valadoc_token_type_action (ValadocToken* token,
103                                               gpointer self,
104                                               GError** error);
105 G_GNUC_INTERNAL void valadoc_api_node_set_documentation (ValadocApiNode* self,
106                                          ValadocContentComment* value);
107 static void valadoc_importer_valadoc_documentation_importer_merge_taglets (ValadocImporterValadocDocumentationImporter* self,
108                                                                     ValadocContentComment* comment,
109                                                                     ValadocContentComment* imported);
110 static void valadoc_importer_valadoc_documentation_importer_real_process (ValadocImporterDocumentationImporter* base,
111                                                                    const gchar* filename);
112 static void valadoc_importer_valadoc_documentation_importer_finalize (GObject * obj);
113 static GType valadoc_importer_valadoc_documentation_importer_get_type_once (void);
114 static void _vala_valadoc_importer_valadoc_documentation_importer_get_property (GObject * object,
115                                                                          guint property_id,
116                                                                          GValue * value,
117                                                                          GParamSpec * pspec);
118 static void _vala_array_destroy (gpointer array,
119                           gint array_length,
120                           GDestroyNotify destroy_func);
121 static void _vala_array_free (gpointer array,
122                        gint array_length,
123                        GDestroyNotify destroy_func);
124 
125 static inline gpointer
valadoc_importer_valadoc_documentation_importer_get_instance_private(ValadocImporterValadocDocumentationImporter * self)126 valadoc_importer_valadoc_documentation_importer_get_instance_private (ValadocImporterValadocDocumentationImporter* self)
127 {
128 	return G_STRUCT_MEMBER_P (self, ValadocImporterValadocDocumentationImporter_private_offset);
129 }
130 
131 static GType
valadoc_importer_valadoc_documentation_importer_insertion_mode_get_type_once(void)132 valadoc_importer_valadoc_documentation_importer_insertion_mode_get_type_once (void)
133 {
134 	static const GEnumValue values[] = {{VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_INSERTION_MODE_APPEND, "VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_INSERTION_MODE_APPEND", "append"}, {VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_INSERTION_MODE_PREPEND, "VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_INSERTION_MODE_PREPEND", "prepend"}, {VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_INSERTION_MODE_REPLACE, "VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_INSERTION_MODE_REPLACE", "replace"}, {0, NULL, NULL}};
135 	GType valadoc_importer_valadoc_documentation_importer_insertion_mode_type_id;
136 	valadoc_importer_valadoc_documentation_importer_insertion_mode_type_id = g_enum_register_static ("ValadocImporterValadocDocumentationImporterInsertionMode", values);
137 	return valadoc_importer_valadoc_documentation_importer_insertion_mode_type_id;
138 }
139 
140 static GType
valadoc_importer_valadoc_documentation_importer_insertion_mode_get_type(void)141 valadoc_importer_valadoc_documentation_importer_insertion_mode_get_type (void)
142 {
143 	static volatile gsize valadoc_importer_valadoc_documentation_importer_insertion_mode_type_id__volatile = 0;
144 	if (g_once_init_enter (&valadoc_importer_valadoc_documentation_importer_insertion_mode_type_id__volatile)) {
145 		GType valadoc_importer_valadoc_documentation_importer_insertion_mode_type_id;
146 		valadoc_importer_valadoc_documentation_importer_insertion_mode_type_id = valadoc_importer_valadoc_documentation_importer_insertion_mode_get_type_once ();
147 		g_once_init_leave (&valadoc_importer_valadoc_documentation_importer_insertion_mode_type_id__volatile, valadoc_importer_valadoc_documentation_importer_insertion_mode_type_id);
148 	}
149 	return valadoc_importer_valadoc_documentation_importer_insertion_mode_type_id__volatile;
150 }
151 
152 static const gchar*
valadoc_importer_valadoc_documentation_importer_real_get_file_extension(ValadocImporterDocumentationImporter * base)153 valadoc_importer_valadoc_documentation_importer_real_get_file_extension (ValadocImporterDocumentationImporter* base)
154 {
155 	const gchar* result;
156 	ValadocImporterValadocDocumentationImporter* self;
157 	self = (ValadocImporterValadocDocumentationImporter*) base;
158 	result = "valadoc";
159 	return result;
160 }
161 
162 static gpointer
_g_object_ref0(gpointer self)163 _g_object_ref0 (gpointer self)
164 {
165 	return self ? g_object_ref (self) : NULL;
166 }
167 
168 static void
__lambda133_(ValadocImporterValadocDocumentationImporter * self,ValadocToken * token,GError ** error)169 __lambda133_ (ValadocImporterValadocDocumentationImporter* self,
170               ValadocToken* token,
171               GError** error)
172 {
173 	ValaSourceLocation _tmp0_ = {0};
174 	ValaSourceLocation _tmp1_;
175 	g_return_if_fail (token != NULL);
176 	valadoc_token_get_end (token, &_tmp0_);
177 	_tmp1_ = _tmp0_;
178 	self->priv->_comment_location = _tmp1_;
179 }
180 
181 static void
___lambda133__valadoc_token_type_action(ValadocToken * token,gpointer self,GError ** error)182 ___lambda133__valadoc_token_type_action (ValadocToken* token,
183                                          gpointer self,
184                                          GError** error)
185 {
186 	__lambda133_ ((ValadocImporterValadocDocumentationImporter*) self, token, error);
187 }
188 
189 static void
_valadoc_importer_valadoc_documentation_importer_add_comment_valadoc_token_type_action(ValadocToken * token,gpointer self,GError ** error)190 _valadoc_importer_valadoc_documentation_importer_add_comment_valadoc_token_type_action (ValadocToken* token,
191                                                                                         gpointer self,
192                                                                                         GError** error)
193 {
194 	valadoc_importer_valadoc_documentation_importer_add_comment ((ValadocImporterValadocDocumentationImporter*) self, token, error);
195 }
196 
197 static void
__lambda134_(ValadocImporterValadocDocumentationImporter * self,ValadocToken * token,GError ** error)198 __lambda134_ (ValadocImporterValadocDocumentationImporter* self,
199               ValadocToken* token,
200               GError** error)
201 {
202 	const gchar* _tmp0_;
203 	gchar* _tmp1_;
204 	g_return_if_fail (token != NULL);
205 	_tmp0_ = valadoc_token_to_string (token);
206 	_tmp1_ = g_strdup (_tmp0_);
207 	_g_free0 (self->priv->_cname);
208 	self->priv->_cname = _tmp1_;
209 }
210 
211 static void
___lambda134__valadoc_token_type_action(ValadocToken * token,gpointer self,GError ** error)212 ___lambda134__valadoc_token_type_action (ValadocToken* token,
213                                          gpointer self,
214                                          GError** error)
215 {
216 	__lambda134_ ((ValadocImporterValadocDocumentationImporter*) self, token, error);
217 }
218 
219 static void
__lambda135_(ValadocImporterValadocDocumentationImporter * self,GError ** error)220 __lambda135_ (ValadocImporterValadocDocumentationImporter* self,
221               GError** error)
222 {
223 	const gchar* _tmp0_;
224 	GString* _tmp1_;
225 	const gchar* _tmp2_;
226 	ValaSourceLocation _tmp3_;
227 	GString* _tmp4_;
228 	_tmp0_ = self->priv->_cname;
229 	_tmp1_ = self->priv->_comment;
230 	_tmp2_ = self->priv->_filename;
231 	_tmp3_ = self->priv->_comment_location;
232 	valadoc_importer_valadoc_documentation_importer_add_documentation (self, _tmp0_, _tmp1_, _tmp2_, &_tmp3_);
233 	_tmp4_ = self->priv->_comment;
234 	g_string_erase (_tmp4_, (gssize) 0, (gssize) -1);
235 	_g_free0 (self->priv->_cname);
236 	self->priv->_cname = NULL;
237 }
238 
239 static void
___lambda135__valadoc_rule_action(gpointer self,GError ** error)240 ___lambda135__valadoc_rule_action (gpointer self,
241                                    GError** error)
242 {
243 	__lambda135_ ((ValadocImporterValadocDocumentationImporter*) self, error);
244 }
245 
246 static void
__lambda136_(ValadocImporterValadocDocumentationImporter * self,ValadocToken * token,GError ** error)247 __lambda136_ (ValadocImporterValadocDocumentationImporter* self,
248               ValadocToken* token,
249               GError** error)
250 {
251 	const gchar* _tmp0_;
252 	const gchar* _tmp1_;
253 	ValaSourceLocation _tmp2_;
254 	g_return_if_fail (token != NULL);
255 	_tmp0_ = valadoc_token_to_string (token);
256 	_tmp1_ = self->priv->_filename;
257 	_tmp2_ = self->priv->_comment_location;
258 	valadoc_importer_valadoc_documentation_importer_add_documentation (self, _tmp0_, NULL, _tmp1_, &_tmp2_);
259 }
260 
261 static void
___lambda136__valadoc_token_type_action(ValadocToken * token,gpointer self,GError ** error)262 ___lambda136__valadoc_token_type_action (ValadocToken* token,
263                                          gpointer self,
264                                          GError** error)
265 {
266 	__lambda136_ ((ValadocImporterValadocDocumentationImporter*) self, token, error);
267 }
268 
269 ValadocImporterValadocDocumentationImporter*
valadoc_importer_valadoc_documentation_importer_construct(GType object_type,ValadocApiTree * tree,ValadocDocumentationParser * parser,ValadocModuleLoader * modules,ValadocSettings * settings,ValadocErrorReporter * reporter)270 valadoc_importer_valadoc_documentation_importer_construct (GType object_type,
271                                                            ValadocApiTree* tree,
272                                                            ValadocDocumentationParser* parser,
273                                                            ValadocModuleLoader* modules,
274                                                            ValadocSettings* settings,
275                                                            ValadocErrorReporter* reporter)
276 {
277 	ValadocImporterValadocDocumentationImporter * self = NULL;
278 	ValadocContentContentFactory* _tmp0_;
279 	ValadocErrorReporter* _tmp1_;
280 	ValadocImporterValadocDocumentationScanner* _tmp2_;
281 	ValadocDocumentationParser* _tmp3_;
282 	ValadocImporterValadocDocumentationScanner* _tmp4_;
283 	ValadocImporterValadocDocumentationScanner* _tmp5_;
284 	ValadocParser* _tmp6_;
285 	ValadocImporterValadocDocumentationScanner* _tmp7_;
286 	ValadocParser* _tmp8_;
287 	GString* _tmp9_;
288 	ValadocRule* unprinted_spaces = NULL;
289 	ValadocTokenType* _tmp10_;
290 	GObject* _tmp11_;
291 	ValadocTokenType* _tmp12_;
292 	GObject* _tmp13_;
293 	GObject** _tmp14_;
294 	GObject** _tmp15_;
295 	gint _tmp15__length1;
296 	ValadocRule* _tmp16_;
297 	GObject** _tmp17_;
298 	GObject** _tmp18_;
299 	gint _tmp18__length1;
300 	ValadocRule* _tmp19_;
301 	ValadocRule* _tmp20_;
302 	ValadocRule* empty_lines = NULL;
303 	GObject* _tmp21_;
304 	ValadocTokenType* _tmp22_;
305 	GObject* _tmp23_;
306 	GObject** _tmp24_;
307 	GObject** _tmp25_;
308 	gint _tmp25__length1;
309 	ValadocRule* _tmp26_;
310 	GObject** _tmp27_;
311 	GObject** _tmp28_;
312 	gint _tmp28__length1;
313 	ValadocRule* _tmp29_;
314 	ValadocRule* _tmp30_;
315 	ValadocRule* _tmp31_;
316 	ValadocRule* _tmp32_;
317 	ValadocRule* optional_empty_lines = NULL;
318 	GObject* _tmp33_;
319 	GObject** _tmp34_;
320 	GObject** _tmp35_;
321 	gint _tmp35__length1;
322 	ValadocRule* _tmp36_;
323 	ValadocRule* _tmp37_;
324 	ValadocRule* documentation = NULL;
325 	ValadocTokenType* _tmp38_;
326 	ValadocTokenType* _tmp39_;
327 	ValadocTokenType* _tmp40_;
328 	ValadocTokenType* _tmp41_;
329 	ValadocTokenType* _tmp42_;
330 	ValadocTokenType* _tmp43_;
331 	ValadocTokenType* _tmp44_;
332 	ValadocTokenType* _tmp45_;
333 	ValadocTokenType* _tmp46_;
334 	ValadocTokenType* _tmp47_;
335 	ValadocTokenType* _tmp48_;
336 	ValadocTokenType* _tmp49_;
337 	GObject** _tmp50_;
338 	GObject** _tmp51_;
339 	gint _tmp51__length1;
340 	ValadocRule* _tmp52_;
341 	GObject** _tmp53_;
342 	GObject** _tmp54_;
343 	gint _tmp54__length1;
344 	ValadocRule* _tmp55_;
345 	ValadocTokenType* _tmp56_;
346 	GObject* _tmp57_;
347 	GObject* _tmp58_;
348 	ValadocTokenType* _tmp59_;
349 	ValadocTokenType* _tmp60_;
350 	GObject** _tmp61_;
351 	GObject** _tmp62_;
352 	gint _tmp62__length1;
353 	ValadocRule* _tmp63_;
354 	ValadocRule* _tmp64_;
355 	ValadocRule* _tmp65_;
356 	ValadocTokenType* _tmp66_;
357 	ValadocTokenType* _tmp67_;
358 	GObject** _tmp68_;
359 	GObject** _tmp69_;
360 	gint _tmp69__length1;
361 	ValadocRule* _tmp70_;
362 	ValadocRule* _tmp71_;
363 	ValadocRule* _tmp72_;
364 	ValadocRule* _tmp73_;
365 	ValadocRule* file = NULL;
366 	GObject* _tmp74_;
367 	GObject* _tmp75_;
368 	GObject** _tmp76_;
369 	GObject** _tmp77_;
370 	gint _tmp77__length1;
371 	ValadocRule* _tmp78_;
372 	GObject** _tmp79_;
373 	GObject** _tmp80_;
374 	gint _tmp80__length1;
375 	ValadocRule* _tmp81_;
376 	ValadocRule* _tmp82_;
377 	ValadocRule* _tmp83_;
378 	ValadocRule* _tmp84_;
379 	ValadocParser* _tmp85_;
380 	g_return_val_if_fail (tree != NULL, NULL);
381 	g_return_val_if_fail (parser != NULL, NULL);
382 	g_return_val_if_fail (modules != NULL, NULL);
383 	g_return_val_if_fail (settings != NULL, NULL);
384 	g_return_val_if_fail (reporter != NULL, NULL);
385 	self = (ValadocImporterValadocDocumentationImporter*) valadoc_importer_documentation_importer_construct (object_type, tree, modules, settings);
386 	_tmp0_ = valadoc_content_content_factory_new (settings, (ValadocResourceLocator*) self, modules);
387 	_g_object_unref0 (self->factory);
388 	self->factory = _tmp0_;
389 	_tmp1_ = _g_object_ref0 (reporter);
390 	_g_object_unref0 (self->priv->reporter);
391 	self->priv->reporter = _tmp1_;
392 	_tmp2_ = valadoc_importer_valadoc_documentation_scanner_new (settings);
393 	_g_object_unref0 (self->priv->_scanner);
394 	self->priv->_scanner = _tmp2_;
395 	_tmp3_ = _g_object_ref0 (parser);
396 	_g_object_unref0 (self->priv->_doc_parser);
397 	self->priv->_doc_parser = _tmp3_;
398 	_tmp4_ = valadoc_importer_valadoc_documentation_scanner_new (settings);
399 	_g_object_unref0 (self->priv->_scanner);
400 	self->priv->_scanner = _tmp4_;
401 	_tmp5_ = self->priv->_scanner;
402 	_tmp6_ = valadoc_parser_new (settings, (ValadocScanner*) _tmp5_, reporter);
403 	_valadoc_parser_unref0 (self->priv->_parser);
404 	self->priv->_parser = _tmp6_;
405 	_tmp7_ = self->priv->_scanner;
406 	_tmp8_ = self->priv->_parser;
407 	valadoc_scanner_set_parser ((ValadocScanner*) _tmp7_, _tmp8_);
408 	_tmp9_ = g_string_new ("");
409 	_g_string_free0 (self->priv->_comment);
410 	self->priv->_comment = _tmp9_;
411 	_tmp10_ = valadoc_token_type_VALADOC_SPACE;
412 	_tmp11_ = _g_object_ref0 ((GObject*) _tmp10_);
413 	_tmp12_ = valadoc_token_type_VALADOC_TAB;
414 	_tmp13_ = _g_object_ref0 ((GObject*) _tmp12_);
415 	_tmp14_ = g_new0 (GObject*, 2 + 1);
416 	_tmp14_[0] = _tmp11_;
417 	_tmp14_[1] = _tmp13_;
418 	_tmp15_ = _tmp14_;
419 	_tmp15__length1 = 2;
420 	_tmp16_ = valadoc_rule_one_of (_tmp15_, (gint) 2);
421 	_tmp17_ = g_new0 (GObject*, 1 + 1);
422 	_tmp17_[0] = (GObject*) _tmp16_;
423 	_tmp18_ = _tmp17_;
424 	_tmp18__length1 = 1;
425 	_tmp19_ = valadoc_rule_many (_tmp18_, (gint) 1);
426 	_tmp20_ = _tmp19_;
427 	_tmp18_ = (_vala_array_free (_tmp18_, _tmp18__length1, (GDestroyNotify) g_object_unref), NULL);
428 	_tmp15_ = (_vala_array_free (_tmp15_, _tmp15__length1, (GDestroyNotify) g_object_unref), NULL);
429 	unprinted_spaces = _tmp20_;
430 	_tmp21_ = _g_object_ref0 ((GObject*) unprinted_spaces);
431 	_tmp22_ = valadoc_token_type_VALADOC_EOL;
432 	_tmp23_ = _g_object_ref0 ((GObject*) _tmp22_);
433 	_tmp24_ = g_new0 (GObject*, 2 + 1);
434 	_tmp24_[0] = _tmp21_;
435 	_tmp24_[1] = _tmp23_;
436 	_tmp25_ = _tmp24_;
437 	_tmp25__length1 = 2;
438 	_tmp26_ = valadoc_rule_one_of (_tmp25_, (gint) 2);
439 	_tmp27_ = g_new0 (GObject*, 1 + 1);
440 	_tmp27_[0] = (GObject*) _tmp26_;
441 	_tmp28_ = _tmp27_;
442 	_tmp28__length1 = 1;
443 	_tmp29_ = valadoc_rule_many (_tmp28_, (gint) 1);
444 	_tmp30_ = _tmp29_;
445 	_tmp31_ = valadoc_rule_set_name (_tmp30_, "EmptyLines");
446 	_tmp32_ = _tmp31_;
447 	_g_object_unref0 (_tmp30_);
448 	_tmp28_ = (_vala_array_free (_tmp28_, _tmp28__length1, (GDestroyNotify) g_object_unref), NULL);
449 	_tmp25_ = (_vala_array_free (_tmp25_, _tmp25__length1, (GDestroyNotify) g_object_unref), NULL);
450 	empty_lines = _tmp32_;
451 	_tmp33_ = _g_object_ref0 ((GObject*) empty_lines);
452 	_tmp34_ = g_new0 (GObject*, 1 + 1);
453 	_tmp34_[0] = _tmp33_;
454 	_tmp35_ = _tmp34_;
455 	_tmp35__length1 = 1;
456 	_tmp36_ = valadoc_rule_option (_tmp35_, (gint) 1);
457 	_tmp37_ = _tmp36_;
458 	_tmp35_ = (_vala_array_free (_tmp35_, _tmp35__length1, (GDestroyNotify) g_object_unref), NULL);
459 	optional_empty_lines = _tmp37_;
460 	_tmp38_ = valadoc_token_type_VALADOC_COMMENT_START;
461 	_tmp39_ = valadoc_token_type_action (_tmp38_, ___lambda133__valadoc_token_type_action, self);
462 	_tmp40_ = valadoc_token_type_ANY_WORD;
463 	_tmp41_ = valadoc_token_type_action (_tmp40_, _valadoc_importer_valadoc_documentation_importer_add_comment_valadoc_token_type_action, self);
464 	_tmp42_ = valadoc_token_type_VALADOC_COMMENT_START;
465 	_tmp43_ = valadoc_token_type_action (_tmp42_, _valadoc_importer_valadoc_documentation_importer_add_comment_valadoc_token_type_action, self);
466 	_tmp44_ = valadoc_token_type_VALADOC_SPACE;
467 	_tmp45_ = valadoc_token_type_action (_tmp44_, _valadoc_importer_valadoc_documentation_importer_add_comment_valadoc_token_type_action, self);
468 	_tmp46_ = valadoc_token_type_VALADOC_TAB;
469 	_tmp47_ = valadoc_token_type_action (_tmp46_, _valadoc_importer_valadoc_documentation_importer_add_comment_valadoc_token_type_action, self);
470 	_tmp48_ = valadoc_token_type_VALADOC_EOL;
471 	_tmp49_ = valadoc_token_type_action (_tmp48_, _valadoc_importer_valadoc_documentation_importer_add_comment_valadoc_token_type_action, self);
472 	_tmp50_ = g_new0 (GObject*, 5 + 1);
473 	_tmp50_[0] = (GObject*) _tmp41_;
474 	_tmp50_[1] = (GObject*) _tmp43_;
475 	_tmp50_[2] = (GObject*) _tmp45_;
476 	_tmp50_[3] = (GObject*) _tmp47_;
477 	_tmp50_[4] = (GObject*) _tmp49_;
478 	_tmp51_ = _tmp50_;
479 	_tmp51__length1 = 5;
480 	_tmp52_ = valadoc_rule_one_of (_tmp51_, (gint) 5);
481 	_tmp53_ = g_new0 (GObject*, 1 + 1);
482 	_tmp53_[0] = (GObject*) _tmp52_;
483 	_tmp54_ = _tmp53_;
484 	_tmp54__length1 = 1;
485 	_tmp55_ = valadoc_rule_many (_tmp54_, (gint) 1);
486 	_tmp56_ = valadoc_token_type_VALADOC_COMMENT_END;
487 	_tmp57_ = _g_object_ref0 ((GObject*) _tmp56_);
488 	_tmp58_ = _g_object_ref0 ((GObject*) optional_empty_lines);
489 	_tmp59_ = valadoc_token_type_ANY_WORD;
490 	_tmp60_ = valadoc_token_type_action (_tmp59_, ___lambda134__valadoc_token_type_action, self);
491 	_tmp61_ = g_new0 (GObject*, 5 + 1);
492 	_tmp61_[0] = (GObject*) _tmp39_;
493 	_tmp61_[1] = (GObject*) _tmp55_;
494 	_tmp61_[2] = _tmp57_;
495 	_tmp61_[3] = _tmp58_;
496 	_tmp61_[4] = (GObject*) _tmp60_;
497 	_tmp62_ = _tmp61_;
498 	_tmp62__length1 = 5;
499 	_tmp63_ = valadoc_rule_seq (_tmp62_, (gint) 5);
500 	_tmp64_ = _tmp63_;
501 	_tmp65_ = valadoc_rule_set_reduce (_tmp64_, ___lambda135__valadoc_rule_action, self);
502 	_tmp66_ = valadoc_token_type_ANY_WORD;
503 	_tmp67_ = valadoc_token_type_action (_tmp66_, ___lambda136__valadoc_token_type_action, self);
504 	_tmp68_ = g_new0 (GObject*, 2 + 1);
505 	_tmp68_[0] = (GObject*) _tmp65_;
506 	_tmp68_[1] = (GObject*) _tmp67_;
507 	_tmp69_ = _tmp68_;
508 	_tmp69__length1 = 2;
509 	_tmp70_ = valadoc_rule_one_of (_tmp69_, (gint) 2);
510 	_tmp71_ = _tmp70_;
511 	_tmp72_ = valadoc_rule_set_name (_tmp71_, "Documentation");
512 	_tmp73_ = _tmp72_;
513 	_g_object_unref0 (_tmp71_);
514 	_tmp69_ = (_vala_array_free (_tmp69_, _tmp69__length1, (GDestroyNotify) g_object_unref), NULL);
515 	_g_object_unref0 (_tmp64_);
516 	_tmp62_ = (_vala_array_free (_tmp62_, _tmp62__length1, (GDestroyNotify) g_object_unref), NULL);
517 	_tmp54_ = (_vala_array_free (_tmp54_, _tmp54__length1, (GDestroyNotify) g_object_unref), NULL);
518 	_tmp51_ = (_vala_array_free (_tmp51_, _tmp51__length1, (GDestroyNotify) g_object_unref), NULL);
519 	documentation = _tmp73_;
520 	_tmp74_ = _g_object_ref0 ((GObject*) documentation);
521 	_tmp75_ = _g_object_ref0 ((GObject*) optional_empty_lines);
522 	_tmp76_ = g_new0 (GObject*, 2 + 1);
523 	_tmp76_[0] = _tmp74_;
524 	_tmp76_[1] = _tmp75_;
525 	_tmp77_ = _tmp76_;
526 	_tmp77__length1 = 2;
527 	_tmp78_ = valadoc_rule_one_of (_tmp77_, (gint) 2);
528 	_tmp79_ = g_new0 (GObject*, 1 + 1);
529 	_tmp79_[0] = (GObject*) _tmp78_;
530 	_tmp80_ = _tmp79_;
531 	_tmp80__length1 = 1;
532 	_tmp81_ = valadoc_rule_many (_tmp80_, (gint) 1);
533 	_tmp82_ = _tmp81_;
534 	_tmp83_ = valadoc_rule_set_name (_tmp82_, "ValadocFile");
535 	_tmp84_ = _tmp83_;
536 	_g_object_unref0 (_tmp82_);
537 	_tmp80_ = (_vala_array_free (_tmp80_, _tmp80__length1, (GDestroyNotify) g_object_unref), NULL);
538 	_tmp77_ = (_vala_array_free (_tmp77_, _tmp77__length1, (GDestroyNotify) g_object_unref), NULL);
539 	file = _tmp84_;
540 	_tmp85_ = self->priv->_parser;
541 	valadoc_parser_set_root_rule (_tmp85_, file);
542 	_g_object_unref0 (file);
543 	_g_object_unref0 (documentation);
544 	_g_object_unref0 (optional_empty_lines);
545 	_g_object_unref0 (empty_lines);
546 	_g_object_unref0 (unprinted_spaces);
547 	return self;
548 }
549 
550 ValadocImporterValadocDocumentationImporter*
valadoc_importer_valadoc_documentation_importer_new(ValadocApiTree * tree,ValadocDocumentationParser * parser,ValadocModuleLoader * modules,ValadocSettings * settings,ValadocErrorReporter * reporter)551 valadoc_importer_valadoc_documentation_importer_new (ValadocApiTree* tree,
552                                                      ValadocDocumentationParser* parser,
553                                                      ValadocModuleLoader* modules,
554                                                      ValadocSettings* settings,
555                                                      ValadocErrorReporter* reporter)
556 {
557 	return valadoc_importer_valadoc_documentation_importer_construct (VALADOC_IMPORTER_TYPE_VALADOC_DOCUMENTATION_IMPORTER, tree, parser, modules, settings, reporter);
558 }
559 
560 static void
valadoc_importer_valadoc_documentation_importer_add_comment(ValadocImporterValadocDocumentationImporter * self,ValadocToken * token,GError ** error)561 valadoc_importer_valadoc_documentation_importer_add_comment (ValadocImporterValadocDocumentationImporter* self,
562                                                              ValadocToken* token,
563                                                              GError** error)
564 {
565 	GString* _tmp0_;
566 	const gchar* _tmp1_;
567 	g_return_if_fail (self != NULL);
568 	g_return_if_fail (token != NULL);
569 	_tmp0_ = self->priv->_comment;
570 	_tmp1_ = valadoc_token_to_string (token);
571 	g_string_append (_tmp0_, _tmp1_);
572 }
573 
574 static glong
string_strnlen(gchar * str,glong maxlen)575 string_strnlen (gchar* str,
576                 glong maxlen)
577 {
578 	gchar* end = NULL;
579 	gchar* _tmp0_;
580 	gchar* _tmp1_;
581 	glong result = 0L;
582 	_tmp0_ = memchr (str, 0, (gsize) maxlen);
583 	end = _tmp0_;
584 	_tmp1_ = end;
585 	if (_tmp1_ == NULL) {
586 		result = maxlen;
587 		return result;
588 	} else {
589 		gchar* _tmp2_;
590 		_tmp2_ = end;
591 		result = (glong) (_tmp2_ - str);
592 		return result;
593 	}
594 }
595 
596 static gchar*
string_substring(const gchar * self,glong offset,glong len)597 string_substring (const gchar* self,
598                   glong offset,
599                   glong len)
600 {
601 	glong string_length = 0L;
602 	gboolean _tmp0_ = FALSE;
603 	gchar* _tmp3_;
604 	gchar* result = NULL;
605 	g_return_val_if_fail (self != NULL, NULL);
606 	if (offset >= ((glong) 0)) {
607 		_tmp0_ = len >= ((glong) 0);
608 	} else {
609 		_tmp0_ = FALSE;
610 	}
611 	if (_tmp0_) {
612 		string_length = string_strnlen ((gchar*) self, offset + len);
613 	} else {
614 		gint _tmp1_;
615 		gint _tmp2_;
616 		_tmp1_ = strlen (self);
617 		_tmp2_ = _tmp1_;
618 		string_length = (glong) _tmp2_;
619 	}
620 	if (offset < ((glong) 0)) {
621 		offset = string_length + offset;
622 		g_return_val_if_fail (offset >= ((glong) 0), NULL);
623 	} else {
624 		g_return_val_if_fail (offset <= string_length, NULL);
625 	}
626 	if (len < ((glong) 0)) {
627 		len = string_length - offset;
628 	}
629 	g_return_val_if_fail ((offset + len) <= string_length, NULL);
630 	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
631 	result = _tmp3_;
632 	return result;
633 }
634 
635 static void
valadoc_importer_valadoc_documentation_importer_add_documentation(ValadocImporterValadocDocumentationImporter * self,const gchar * _symbol_name,GString * comment,const gchar * filename,ValaSourceLocation * src_ref)636 valadoc_importer_valadoc_documentation_importer_add_documentation (ValadocImporterValadocDocumentationImporter* self,
637                                                                    const gchar* _symbol_name,
638                                                                    GString* comment,
639                                                                    const gchar* filename,
640                                                                    ValaSourceLocation* src_ref)
641 {
642 	ValadocApiNode* symbol = NULL;
643 	ValadocImporterValadocDocumentationImporterInsertionMode insertion_mode = 0;
644 	gchar* symbol_name = NULL;
645 	const gchar* _tmp7_;
646 	ValadocApiNode* _tmp16_;
647 	g_return_if_fail (self != NULL);
648 	g_return_if_fail (_symbol_name != NULL);
649 	g_return_if_fail (filename != NULL);
650 	g_return_if_fail (src_ref != NULL);
651 	symbol = NULL;
652 	if (g_str_has_suffix (_symbol_name, "::append")) {
653 		gint _tmp0_;
654 		gint _tmp1_;
655 		gchar* _tmp2_;
656 		_tmp0_ = strlen (_symbol_name);
657 		_tmp1_ = _tmp0_;
658 		_tmp2_ = string_substring (_symbol_name, (glong) 0, (glong) (_tmp1_ - 8));
659 		_g_free0 (symbol_name);
660 		symbol_name = _tmp2_;
661 		insertion_mode = VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_INSERTION_MODE_APPEND;
662 	} else {
663 		if (g_str_has_suffix (_symbol_name, "::prepend")) {
664 			gint _tmp3_;
665 			gint _tmp4_;
666 			gchar* _tmp5_;
667 			_tmp3_ = strlen (_symbol_name);
668 			_tmp4_ = _tmp3_;
669 			_tmp5_ = string_substring (_symbol_name, (glong) 0, (glong) (_tmp4_ - 9));
670 			_g_free0 (symbol_name);
671 			symbol_name = _tmp5_;
672 			insertion_mode = VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_INSERTION_MODE_PREPEND;
673 		} else {
674 			gchar* _tmp6_;
675 			_tmp6_ = g_strdup (_symbol_name);
676 			_g_free0 (symbol_name);
677 			symbol_name = _tmp6_;
678 			insertion_mode = VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_INSERTION_MODE_REPLACE;
679 		}
680 	}
681 	_tmp7_ = symbol_name;
682 	if (g_str_has_prefix (_tmp7_, "c::")) {
683 		ValadocApiTree* _tmp8_;
684 		const gchar* _tmp9_;
685 		gchar* _tmp10_;
686 		gchar* _tmp11_;
687 		ValadocApiNode* _tmp12_;
688 		_tmp8_ = ((ValadocImporterDocumentationImporter*) self)->tree;
689 		_tmp9_ = symbol_name;
690 		_tmp10_ = string_substring (_tmp9_, (glong) 3, (glong) -1);
691 		_tmp11_ = _tmp10_;
692 		_tmp12_ = valadoc_api_tree_search_symbol_cstr (_tmp8_, NULL, _tmp11_);
693 		_g_object_unref0 (symbol);
694 		symbol = _tmp12_;
695 		_g_free0 (_tmp11_);
696 	} else {
697 		ValadocApiTree* _tmp13_;
698 		const gchar* _tmp14_;
699 		ValadocApiNode* _tmp15_;
700 		_tmp13_ = ((ValadocImporterDocumentationImporter*) self)->tree;
701 		_tmp14_ = symbol_name;
702 		_tmp15_ = valadoc_api_tree_search_symbol_str (_tmp13_, NULL, _tmp14_);
703 		_g_object_unref0 (symbol);
704 		symbol = _tmp15_;
705 	}
706 	_tmp16_ = symbol;
707 	if (_tmp16_ == NULL) {
708 		ValadocSettings* _tmp17_;
709 		_tmp17_ = ((ValadocImporterDocumentationImporter*) self)->settings;
710 		if (_tmp17_->verbose) {
711 			ValadocErrorReporter* _tmp18_;
712 			const gchar* _tmp19_;
713 			_tmp18_ = self->priv->reporter;
714 			_tmp19_ = symbol_name;
715 			valadoc_error_reporter_simple_warning (_tmp18_, filename, "Node `%s' does not exist", _tmp19_);
716 		}
717 		_g_free0 (symbol_name);
718 		_g_object_unref0 (symbol);
719 		return;
720 	}
721 	if (comment != NULL) {
722 		ValadocContentComment* docu = NULL;
723 		ValadocDocumentationParser* _tmp20_;
724 		ValadocApiNode* _tmp21_;
725 		const gchar* _tmp22_;
726 		ValaSourceLocation _tmp23_;
727 		ValaSourceLocation _tmp24_;
728 		ValadocContentComment* _tmp25_;
729 		ValadocContentComment* _tmp26_;
730 		_tmp20_ = self->priv->_doc_parser;
731 		_tmp21_ = symbol;
732 		_tmp22_ = comment->str;
733 		_tmp23_ = *src_ref;
734 		_tmp24_ = *src_ref;
735 		_tmp25_ = valadoc_documentation_parser_parse_comment_str (_tmp20_, _tmp21_, _tmp22_, filename, _tmp23_.line, _tmp24_.column);
736 		docu = _tmp25_;
737 		_tmp26_ = docu;
738 		if (_tmp26_ != NULL) {
739 			ValadocContentComment* _tmp27_;
740 			ValadocApiTree* _tmp28_;
741 			ValadocApiNode* _tmp29_;
742 			ValadocErrorReporter* _tmp30_;
743 			ValadocSettings* _tmp31_;
744 			gboolean _tmp32_ = FALSE;
745 			ValadocApiNode* _tmp33_;
746 			ValadocContentComment* _tmp34_;
747 			ValadocContentComment* _tmp35_;
748 			_tmp27_ = docu;
749 			_tmp28_ = ((ValadocImporterDocumentationImporter*) self)->tree;
750 			_tmp29_ = symbol;
751 			_tmp30_ = self->priv->reporter;
752 			_tmp31_ = ((ValadocImporterDocumentationImporter*) self)->settings;
753 			valadoc_content_content_element_check ((ValadocContentContentElement*) _tmp27_, _tmp28_, _tmp29_, filename, _tmp30_, _tmp31_);
754 			_tmp33_ = symbol;
755 			_tmp34_ = valadoc_api_node_get_documentation (_tmp33_);
756 			_tmp35_ = _tmp34_;
757 			if (_tmp35_ == NULL) {
758 				_tmp32_ = TRUE;
759 			} else {
760 				ValadocImporterValadocDocumentationImporterInsertionMode _tmp36_;
761 				_tmp36_ = insertion_mode;
762 				_tmp32_ = _tmp36_ == VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_INSERTION_MODE_REPLACE;
763 			}
764 			if (_tmp32_) {
765 				ValadocImporterValadocDocumentationImporterInsertionMode _tmp37_;
766 				ValadocApiNode* _tmp44_;
767 				ValadocContentComment* _tmp45_;
768 				_tmp37_ = insertion_mode;
769 				if (_tmp37_ == VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_INSERTION_MODE_APPEND) {
770 					ValadocContentComment* _tmp38_;
771 					ValaList* _tmp39_;
772 					ValaList* _tmp40_;
773 					ValadocContentContentFactory* _tmp41_;
774 					ValadocContentParagraph* _tmp42_;
775 					ValadocContentParagraph* _tmp43_;
776 					_tmp38_ = docu;
777 					_tmp39_ = valadoc_content_block_content_get_content ((ValadocContentBlockContent*) _tmp38_);
778 					_tmp40_ = _tmp39_;
779 					_tmp41_ = self->factory;
780 					_tmp42_ = valadoc_content_content_factory_create_paragraph (_tmp41_);
781 					_tmp43_ = _tmp42_;
782 					vala_list_insert (_tmp40_, 0, (ValadocContentBlock*) _tmp43_);
783 					_g_object_unref0 (_tmp43_);
784 				}
785 				_tmp44_ = symbol;
786 				_tmp45_ = docu;
787 				valadoc_api_node_set_documentation (_tmp44_, _tmp45_);
788 			} else {
789 				ValadocImporterValadocDocumentationImporterInsertionMode _tmp46_;
790 				_tmp46_ = insertion_mode;
791 				if (_tmp46_ == VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_INSERTION_MODE_APPEND) {
792 					ValadocApiNode* _tmp47_;
793 					ValadocContentComment* _tmp48_;
794 					ValadocContentComment* _tmp49_;
795 					ValaList* _tmp50_;
796 					ValaList* _tmp51_;
797 					ValadocContentComment* _tmp52_;
798 					ValaList* _tmp53_;
799 					ValaList* _tmp54_;
800 					ValadocApiNode* _tmp55_;
801 					ValadocContentComment* _tmp56_;
802 					ValadocContentComment* _tmp57_;
803 					ValadocContentComment* _tmp58_;
804 					_tmp47_ = symbol;
805 					_tmp48_ = valadoc_api_node_get_documentation (_tmp47_);
806 					_tmp49_ = _tmp48_;
807 					_tmp50_ = valadoc_content_block_content_get_content ((ValadocContentBlockContent*) _tmp49_);
808 					_tmp51_ = _tmp50_;
809 					_tmp52_ = docu;
810 					_tmp53_ = valadoc_content_block_content_get_content ((ValadocContentBlockContent*) _tmp52_);
811 					_tmp54_ = _tmp53_;
812 					vala_collection_add_all ((ValaCollection*) _tmp51_, (ValaCollection*) _tmp54_);
813 					_tmp55_ = symbol;
814 					_tmp56_ = valadoc_api_node_get_documentation (_tmp55_);
815 					_tmp57_ = _tmp56_;
816 					_tmp58_ = docu;
817 					valadoc_importer_valadoc_documentation_importer_merge_taglets (self, _tmp57_, _tmp58_);
818 				} else {
819 					ValadocImporterValadocDocumentationImporterInsertionMode _tmp59_;
820 					_tmp59_ = insertion_mode;
821 					if (_tmp59_ == VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_INSERTION_MODE_PREPEND) {
822 						ValadocApiNode* _tmp60_;
823 						ValadocContentComment* _tmp61_;
824 						ValadocContentComment* _tmp62_;
825 						ValaList* _tmp63_;
826 						ValaList* _tmp64_;
827 						ValadocContentComment* _tmp65_;
828 						ValaList* _tmp66_;
829 						ValaList* _tmp67_;
830 						ValadocApiNode* _tmp68_;
831 						ValadocContentComment* _tmp69_;
832 						ValadocContentComment* _tmp70_;
833 						ValadocContentComment* _tmp71_;
834 						_tmp60_ = symbol;
835 						_tmp61_ = valadoc_api_node_get_documentation (_tmp60_);
836 						_tmp62_ = _tmp61_;
837 						_tmp63_ = valadoc_content_block_content_get_content ((ValadocContentBlockContent*) _tmp62_);
838 						_tmp64_ = _tmp63_;
839 						_tmp65_ = docu;
840 						_tmp66_ = valadoc_content_block_content_get_content ((ValadocContentBlockContent*) _tmp65_);
841 						_tmp67_ = _tmp66_;
842 						vala_list_insert_all (_tmp64_, 0, (ValaCollection*) _tmp67_);
843 						_tmp68_ = symbol;
844 						_tmp69_ = valadoc_api_node_get_documentation (_tmp68_);
845 						_tmp70_ = _tmp69_;
846 						_tmp71_ = docu;
847 						valadoc_importer_valadoc_documentation_importer_merge_taglets (self, _tmp70_, _tmp71_);
848 					}
849 				}
850 			}
851 		}
852 		_g_object_unref0 (docu);
853 	}
854 	_g_free0 (symbol_name);
855 	_g_object_unref0 (symbol);
856 }
857 
858 static gpointer
_vala_iterable_ref0(gpointer self)859 _vala_iterable_ref0 (gpointer self)
860 {
861 	return self ? vala_iterable_ref (self) : NULL;
862 }
863 
864 static void
valadoc_importer_valadoc_documentation_importer_merge_taglets(ValadocImporterValadocDocumentationImporter * self,ValadocContentComment * comment,ValadocContentComment * imported)865 valadoc_importer_valadoc_documentation_importer_merge_taglets (ValadocImporterValadocDocumentationImporter* self,
866                                                                ValadocContentComment* comment,
867                                                                ValadocContentComment* imported)
868 {
869 	g_return_if_fail (self != NULL);
870 	g_return_if_fail (comment != NULL);
871 	g_return_if_fail (imported != NULL);
872 	{
873 		ValaList* _taglet_list = NULL;
874 		ValaList* _tmp0_;
875 		ValaList* _tmp1_;
876 		ValaList* _tmp2_;
877 		gint _taglet_size = 0;
878 		ValaList* _tmp3_;
879 		gint _tmp4_;
880 		gint _tmp5_;
881 		gint _taglet_index = 0;
882 		_tmp0_ = valadoc_content_comment_get_taglets (imported);
883 		_tmp1_ = _tmp0_;
884 		_tmp2_ = _vala_iterable_ref0 (_tmp1_);
885 		_taglet_list = _tmp2_;
886 		_tmp3_ = _taglet_list;
887 		_tmp4_ = vala_collection_get_size ((ValaCollection*) _tmp3_);
888 		_tmp5_ = _tmp4_;
889 		_taglet_size = _tmp5_;
890 		_taglet_index = -1;
891 		while (TRUE) {
892 			gint _tmp6_;
893 			gint _tmp7_;
894 			ValadocContentTaglet* taglet = NULL;
895 			ValaList* _tmp8_;
896 			gpointer _tmp9_;
897 			ValaList* _tmp10_;
898 			ValaList* _tmp11_;
899 			ValadocContentTaglet* _tmp12_;
900 			_taglet_index = _taglet_index + 1;
901 			_tmp6_ = _taglet_index;
902 			_tmp7_ = _taglet_size;
903 			if (!(_tmp6_ < _tmp7_)) {
904 				break;
905 			}
906 			_tmp8_ = _taglet_list;
907 			_tmp9_ = vala_list_get (_tmp8_, _taglet_index);
908 			taglet = (ValadocContentTaglet*) _tmp9_;
909 			_tmp10_ = valadoc_content_comment_get_taglets (imported);
910 			_tmp11_ = _tmp10_;
911 			_tmp12_ = taglet;
912 			vala_collection_add ((ValaCollection*) _tmp11_, _tmp12_);
913 			_g_object_unref0 (taglet);
914 		}
915 		_vala_iterable_unref0 (_taglet_list);
916 	}
917 }
918 
919 static void
valadoc_importer_valadoc_documentation_importer_real_process(ValadocImporterDocumentationImporter * base,const gchar * filename)920 valadoc_importer_valadoc_documentation_importer_real_process (ValadocImporterDocumentationImporter* base,
921                                                               const gchar* filename)
922 {
923 	ValadocImporterValadocDocumentationImporter * self;
924 	GError* _inner_error0_ = NULL;
925 	self = (ValadocImporterValadocDocumentationImporter*) base;
926 	g_return_if_fail (filename != NULL);
927 	{
928 		gchar* _tmp0_;
929 		GMappedFile* _tmp1_ = NULL;
930 		GMappedFile* _tmp2_;
931 		GMappedFile* _tmp3_;
932 		gchar* content = NULL;
933 		GMappedFile* _tmp4_;
934 		gchar* _tmp5_;
935 		gchar* _tmp6_;
936 		_tmp0_ = g_strdup (filename);
937 		_g_free0 (self->priv->_filename);
938 		self->priv->_filename = _tmp0_;
939 		_tmp2_ = g_mapped_file_new (filename, FALSE, &_inner_error0_);
940 		_tmp1_ = _tmp2_;
941 		if (G_UNLIKELY (_inner_error0_ != NULL)) {
942 			if (_inner_error0_->domain == G_FILE_ERROR) {
943 				goto __catch0_g_file_error;
944 			}
945 			if (_inner_error0_->domain == VALADOC_PARSER_ERROR) {
946 				goto __catch0_valadoc_parser_error;
947 			}
948 			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);
949 			g_clear_error (&_inner_error0_);
950 			return;
951 		}
952 		_tmp3_ = _tmp1_;
953 		_tmp1_ = NULL;
954 		_g_mapped_file_unref0 (self->priv->_mapped_file);
955 		self->priv->_mapped_file = _tmp3_;
956 		_tmp4_ = self->priv->_mapped_file;
957 		_tmp5_ = g_mapped_file_get_contents (_tmp4_);
958 		content = _tmp5_;
959 		_tmp6_ = content;
960 		if (_tmp6_ != NULL) {
961 			ValadocParser* _tmp7_;
962 			gchar* _tmp8_;
963 			_tmp7_ = self->priv->_parser;
964 			_tmp8_ = content;
965 			valadoc_parser_parse (_tmp7_, (const gchar*) _tmp8_, filename, 0, 0, &_inner_error0_);
966 			if (G_UNLIKELY (_inner_error0_ != NULL)) {
967 				_g_mapped_file_unref0 (_tmp1_);
968 				if (_inner_error0_->domain == G_FILE_ERROR) {
969 					goto __catch0_g_file_error;
970 				}
971 				if (_inner_error0_->domain == VALADOC_PARSER_ERROR) {
972 					goto __catch0_valadoc_parser_error;
973 				}
974 				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);
975 				g_clear_error (&_inner_error0_);
976 				return;
977 			}
978 		}
979 		_g_mapped_file_unref0 (_tmp1_);
980 	}
981 	goto __finally0;
982 	__catch0_g_file_error:
983 	{
984 		GError* err = NULL;
985 		ValadocErrorReporter* _tmp9_;
986 		GError* _tmp10_;
987 		const gchar* _tmp11_;
988 		err = _inner_error0_;
989 		_inner_error0_ = NULL;
990 		_tmp9_ = self->priv->reporter;
991 		_tmp10_ = err;
992 		_tmp11_ = _tmp10_->message;
993 		valadoc_error_reporter_simple_error (_tmp9_, NULL, "Unable to map file `%s': %s", filename, _tmp11_);
994 		_g_error_free0 (err);
995 	}
996 	goto __finally0;
997 	__catch0_valadoc_parser_error:
998 	{
999 		g_clear_error (&_inner_error0_);
1000 	}
1001 	__finally0:
1002 	if (G_UNLIKELY (_inner_error0_ != NULL)) {
1003 		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);
1004 		g_clear_error (&_inner_error0_);
1005 		return;
1006 	}
1007 }
1008 
1009 static void
valadoc_importer_valadoc_documentation_importer_class_init(ValadocImporterValadocDocumentationImporterClass * klass,gpointer klass_data)1010 valadoc_importer_valadoc_documentation_importer_class_init (ValadocImporterValadocDocumentationImporterClass * klass,
1011                                                             gpointer klass_data)
1012 {
1013 	valadoc_importer_valadoc_documentation_importer_parent_class = g_type_class_peek_parent (klass);
1014 	g_type_class_adjust_private_offset (klass, &ValadocImporterValadocDocumentationImporter_private_offset);
1015 	((ValadocImporterDocumentationImporterClass *) klass)->process = (void (*) (ValadocImporterDocumentationImporter*, const gchar*)) valadoc_importer_valadoc_documentation_importer_real_process;
1016 	VALADOC_IMPORTER_DOCUMENTATION_IMPORTER_CLASS (klass)->get_file_extension = valadoc_importer_valadoc_documentation_importer_real_get_file_extension;
1017 	G_OBJECT_CLASS (klass)->get_property = _vala_valadoc_importer_valadoc_documentation_importer_get_property;
1018 	G_OBJECT_CLASS (klass)->finalize = valadoc_importer_valadoc_documentation_importer_finalize;
1019 	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_FILE_EXTENSION_PROPERTY, valadoc_importer_valadoc_documentation_importer_properties[VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_FILE_EXTENSION_PROPERTY] = g_param_spec_string ("file-extension", "file-extension", "file-extension", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
1020 }
1021 
1022 static void
valadoc_importer_valadoc_documentation_importer_valadoc_resource_locator_interface_init(ValadocResourceLocatorIface * iface,gpointer iface_data)1023 valadoc_importer_valadoc_documentation_importer_valadoc_resource_locator_interface_init (ValadocResourceLocatorIface * iface,
1024                                                                                          gpointer iface_data)
1025 {
1026 	valadoc_importer_valadoc_documentation_importer_valadoc_resource_locator_parent_iface = g_type_interface_peek_parent (iface);
1027 }
1028 
1029 static void
valadoc_importer_valadoc_documentation_importer_instance_init(ValadocImporterValadocDocumentationImporter * self,gpointer klass)1030 valadoc_importer_valadoc_documentation_importer_instance_init (ValadocImporterValadocDocumentationImporter * self,
1031                                                                gpointer klass)
1032 {
1033 	self->priv = valadoc_importer_valadoc_documentation_importer_get_instance_private (self);
1034 }
1035 
1036 static void
valadoc_importer_valadoc_documentation_importer_finalize(GObject * obj)1037 valadoc_importer_valadoc_documentation_importer_finalize (GObject * obj)
1038 {
1039 	ValadocImporterValadocDocumentationImporter * self;
1040 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_IMPORTER_TYPE_VALADOC_DOCUMENTATION_IMPORTER, ValadocImporterValadocDocumentationImporter);
1041 	_g_object_unref0 (self->priv->_scanner);
1042 	_g_object_unref0 (self->priv->_doc_parser);
1043 	_valadoc_parser_unref0 (self->priv->_parser);
1044 	_g_mapped_file_unref0 (self->priv->_mapped_file);
1045 	_g_free0 (self->priv->_filename);
1046 	_g_free0 (self->priv->_cname);
1047 	_g_string_free0 (self->priv->_comment);
1048 	_g_object_unref0 (self->factory);
1049 	_g_object_unref0 (self->priv->reporter);
1050 	G_OBJECT_CLASS (valadoc_importer_valadoc_documentation_importer_parent_class)->finalize (obj);
1051 }
1052 
1053 static GType
valadoc_importer_valadoc_documentation_importer_get_type_once(void)1054 valadoc_importer_valadoc_documentation_importer_get_type_once (void)
1055 {
1056 	static const GTypeInfo g_define_type_info = { sizeof (ValadocImporterValadocDocumentationImporterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_importer_valadoc_documentation_importer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocImporterValadocDocumentationImporter), 0, (GInstanceInitFunc) valadoc_importer_valadoc_documentation_importer_instance_init, NULL };
1057 	static const GInterfaceInfo valadoc_resource_locator_info = { (GInterfaceInitFunc) valadoc_importer_valadoc_documentation_importer_valadoc_resource_locator_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
1058 	GType valadoc_importer_valadoc_documentation_importer_type_id;
1059 	valadoc_importer_valadoc_documentation_importer_type_id = g_type_register_static (VALADOC_IMPORTER_TYPE_DOCUMENTATION_IMPORTER, "ValadocImporterValadocDocumentationImporter", &g_define_type_info, 0);
1060 	g_type_add_interface_static (valadoc_importer_valadoc_documentation_importer_type_id, VALADOC_TYPE_RESOURCE_LOCATOR, &valadoc_resource_locator_info);
1061 	ValadocImporterValadocDocumentationImporter_private_offset = g_type_add_instance_private (valadoc_importer_valadoc_documentation_importer_type_id, sizeof (ValadocImporterValadocDocumentationImporterPrivate));
1062 	return valadoc_importer_valadoc_documentation_importer_type_id;
1063 }
1064 
1065 GType
valadoc_importer_valadoc_documentation_importer_get_type(void)1066 valadoc_importer_valadoc_documentation_importer_get_type (void)
1067 {
1068 	static volatile gsize valadoc_importer_valadoc_documentation_importer_type_id__volatile = 0;
1069 	if (g_once_init_enter (&valadoc_importer_valadoc_documentation_importer_type_id__volatile)) {
1070 		GType valadoc_importer_valadoc_documentation_importer_type_id;
1071 		valadoc_importer_valadoc_documentation_importer_type_id = valadoc_importer_valadoc_documentation_importer_get_type_once ();
1072 		g_once_init_leave (&valadoc_importer_valadoc_documentation_importer_type_id__volatile, valadoc_importer_valadoc_documentation_importer_type_id);
1073 	}
1074 	return valadoc_importer_valadoc_documentation_importer_type_id__volatile;
1075 }
1076 
1077 static void
_vala_valadoc_importer_valadoc_documentation_importer_get_property(GObject * object,guint property_id,GValue * value,GParamSpec * pspec)1078 _vala_valadoc_importer_valadoc_documentation_importer_get_property (GObject * object,
1079                                                                     guint property_id,
1080                                                                     GValue * value,
1081                                                                     GParamSpec * pspec)
1082 {
1083 	ValadocImporterValadocDocumentationImporter * self;
1084 	self = G_TYPE_CHECK_INSTANCE_CAST (object, VALADOC_IMPORTER_TYPE_VALADOC_DOCUMENTATION_IMPORTER, ValadocImporterValadocDocumentationImporter);
1085 	switch (property_id) {
1086 		case VALADOC_IMPORTER_VALADOC_DOCUMENTATION_IMPORTER_FILE_EXTENSION_PROPERTY:
1087 		g_value_set_string (value, valadoc_importer_documentation_importer_get_file_extension ((ValadocImporterDocumentationImporter*) self));
1088 		break;
1089 		default:
1090 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1091 		break;
1092 	}
1093 }
1094 
1095 static void
_vala_array_destroy(gpointer array,gint array_length,GDestroyNotify destroy_func)1096 _vala_array_destroy (gpointer array,
1097                      gint array_length,
1098                      GDestroyNotify destroy_func)
1099 {
1100 	if ((array != NULL) && (destroy_func != NULL)) {
1101 		gint i;
1102 		for (i = 0; i < array_length; i = i + 1) {
1103 			if (((gpointer*) array)[i] != NULL) {
1104 				destroy_func (((gpointer*) array)[i]);
1105 			}
1106 		}
1107 	}
1108 }
1109 
1110 static void
_vala_array_free(gpointer array,gint array_length,GDestroyNotify destroy_func)1111 _vala_array_free (gpointer array,
1112                   gint array_length,
1113                   GDestroyNotify destroy_func)
1114 {
1115 	_vala_array_destroy (array, array_length, destroy_func);
1116 	g_free (array);
1117 }
1118 
1119