1 /* sourcecode.c generated by valac, the Vala compiler
2 * generated from sourcecode.vala, do not modify */
3
4 /* sourcecode.vala
5 *
6 * Copyright (C) 2008-2009 Didier Villevalois
7 * Copyright (C) 2008-2012 Florian Brosch
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 *
23 * Author:
24 * Didier 'Ptitjes Villevalois <ptitjes@free.fr>
25 */
26
27 #include "valadoc.h"
28 #include <stdlib.h>
29 #include <string.h>
30 #include <glib.h>
31 #include <glib/gstdio.h>
32 #include <valagee.h>
33 #include <glib-object.h>
34
35 enum {
36 VALADOC_CONTENT_SOURCE_CODE_0_PROPERTY,
37 VALADOC_CONTENT_SOURCE_CODE_CODE_PROPERTY,
38 VALADOC_CONTENT_SOURCE_CODE_HIGHLIGHTED_CODE_PROPERTY,
39 VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_PROPERTY,
40 VALADOC_CONTENT_SOURCE_CODE_NUM_PROPERTIES
41 };
42 static GParamSpec* valadoc_content_source_code_properties[VALADOC_CONTENT_SOURCE_CODE_NUM_PROPERTIES];
43 #define _g_free0(var) (var = (g_free (var), NULL))
44 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
45 #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
46
47 struct _ValadocContentSourceCodePrivate {
48 gchar* _code;
49 ValadocContentRun* _highlighted_code;
50 ValadocContentSourceCodeLanguage _language;
51 };
52
53 static gint ValadocContentSourceCode_private_offset;
54 static gpointer valadoc_content_source_code_parent_class = NULL;
55 static ValadocContentInlineIface * valadoc_content_source_code_valadoc_content_inline_parent_iface = NULL;
56
57 static void valadoc_content_source_code_set_highlighted_code (ValadocContentSourceCode* self,
58 ValadocContentRun* value);
59 G_GNUC_INTERNAL ValadocContentSourceCode* valadoc_content_source_code_new (void);
60 G_GNUC_INTERNAL ValadocContentSourceCode* valadoc_content_source_code_construct (GType object_type);
61 static gchar* valadoc_content_source_code_get_path (ValadocContentSourceCode* self,
62 const gchar* path,
63 ValadocApiNode* container,
64 const gchar* source_file_path,
65 ValadocErrorReporter* reporter);
66 static void valadoc_content_source_code_load_source_code (ValadocContentSourceCode* self,
67 const gchar* _path,
68 ValadocApiNode* container,
69 const gchar* source_file_path,
70 ValadocErrorReporter* reporter);
71 static inline gboolean valadoc_content_source_code_is_empty_string (ValadocContentSourceCode* self,
72 const gchar* line);
73 static gchar* valadoc_content_source_code_strip_code (ValadocContentSourceCode* self,
74 const gchar* code);
75 static void valadoc_content_source_code_real_check (ValadocContentContentElement* base,
76 ValadocApiTree* api_root,
77 ValadocApiNode* container,
78 const gchar* file_path,
79 ValadocErrorReporter* reporter,
80 ValadocSettings* settings);
81 G_GNUC_INTERNAL ValadocContentRun* valadoc_content_run_new (ValadocContentRunStyle style);
82 G_GNUC_INTERNAL ValadocContentRun* valadoc_content_run_construct (GType object_type,
83 ValadocContentRunStyle style);
84 G_GNUC_INTERNAL ValadocContentText* valadoc_content_text_new (const gchar* text);
85 G_GNUC_INTERNAL ValadocContentText* valadoc_content_text_construct (GType object_type,
86 const gchar* text);
87 static void valadoc_content_source_code_real_accept (ValadocContentContentElement* base,
88 ValadocContentContentVisitor* visitor);
89 static void valadoc_content_source_code_real_accept_children (ValadocContentContentElement* base,
90 ValadocContentContentVisitor* visitor);
91 static gboolean valadoc_content_source_code_real_is_empty (ValadocContentContentElement* base);
92 static ValadocContentContentElement* valadoc_content_source_code_real_copy (ValadocContentContentElement* base,
93 ValadocContentContentElement* new_parent);
94 G_GNUC_INTERNAL void valadoc_content_content_element_set_parent (ValadocContentContentElement* self,
95 ValadocContentContentElement* value);
96 static void valadoc_content_source_code_finalize (GObject * obj);
97 static GType valadoc_content_source_code_get_type_once (void);
98 static void _vala_valadoc_content_source_code_get_property (GObject * object,
99 guint property_id,
100 GValue * value,
101 GParamSpec * pspec);
102 static void _vala_valadoc_content_source_code_set_property (GObject * object,
103 guint property_id,
104 const GValue * value,
105 GParamSpec * pspec);
106 static void _vala_array_destroy (gpointer array,
107 gint array_length,
108 GDestroyNotify destroy_func);
109 static void _vala_array_free (gpointer array,
110 gint array_length,
111 GDestroyNotify destroy_func);
112 static gint _vala_array_length (gpointer array);
113
114 static inline gpointer
valadoc_content_source_code_get_instance_private(ValadocContentSourceCode * self)115 valadoc_content_source_code_get_instance_private (ValadocContentSourceCode* self)
116 {
117 return G_STRUCT_MEMBER_P (self, ValadocContentSourceCode_private_offset);
118 }
119
120 static gint
string_last_index_of(const gchar * self,const gchar * needle,gint start_index)121 string_last_index_of (const gchar* self,
122 const gchar* needle,
123 gint start_index)
124 {
125 gchar* _result_ = NULL;
126 gchar* _tmp0_;
127 gchar* _tmp1_;
128 gint result = 0;
129 g_return_val_if_fail (self != NULL, 0);
130 g_return_val_if_fail (needle != NULL, 0);
131 _tmp0_ = g_strrstr (((gchar*) self) + start_index, (gchar*) needle);
132 _result_ = _tmp0_;
133 _tmp1_ = _result_;
134 if (_tmp1_ != NULL) {
135 gchar* _tmp2_;
136 _tmp2_ = _result_;
137 result = (gint) (_tmp2_ - ((gchar*) self));
138 return result;
139 } else {
140 result = -1;
141 return result;
142 }
143 }
144
145 static glong
string_strnlen(gchar * str,glong maxlen)146 string_strnlen (gchar* str,
147 glong maxlen)
148 {
149 gchar* end = NULL;
150 gchar* _tmp0_;
151 gchar* _tmp1_;
152 glong result = 0L;
153 _tmp0_ = memchr (str, 0, (gsize) maxlen);
154 end = _tmp0_;
155 _tmp1_ = end;
156 if (_tmp1_ == NULL) {
157 result = maxlen;
158 return result;
159 } else {
160 gchar* _tmp2_;
161 _tmp2_ = end;
162 result = (glong) (_tmp2_ - str);
163 return result;
164 }
165 }
166
167 static gchar*
string_substring(const gchar * self,glong offset,glong len)168 string_substring (const gchar* self,
169 glong offset,
170 glong len)
171 {
172 glong string_length = 0L;
173 gboolean _tmp0_ = FALSE;
174 gchar* _tmp3_;
175 gchar* result = NULL;
176 g_return_val_if_fail (self != NULL, NULL);
177 if (offset >= ((glong) 0)) {
178 _tmp0_ = len >= ((glong) 0);
179 } else {
180 _tmp0_ = FALSE;
181 }
182 if (_tmp0_) {
183 string_length = string_strnlen ((gchar*) self, offset + len);
184 } else {
185 gint _tmp1_;
186 gint _tmp2_;
187 _tmp1_ = strlen (self);
188 _tmp2_ = _tmp1_;
189 string_length = (glong) _tmp2_;
190 }
191 if (offset < ((glong) 0)) {
192 offset = string_length + offset;
193 g_return_val_if_fail (offset >= ((glong) 0), NULL);
194 } else {
195 g_return_val_if_fail (offset <= string_length, NULL);
196 }
197 if (len < ((glong) 0)) {
198 len = string_length - offset;
199 }
200 g_return_val_if_fail ((offset + len) <= string_length, NULL);
201 _tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
202 result = _tmp3_;
203 return result;
204 }
205
206 ValadocContentSourceCodeLanguage
valadoc_content_source_code_language_from_path(const gchar * path)207 valadoc_content_source_code_language_from_path (const gchar* path)
208 {
209 gint pos = 0;
210 gchar* ext = NULL;
211 gchar* _tmp0_;
212 const gchar* _tmp1_;
213 ValadocContentSourceCodeLanguage result = 0;
214 g_return_val_if_fail (path != NULL, 0);
215 pos = string_last_index_of (path, ".", 0);
216 if (pos < 0) {
217 result = VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_UNKNOWN;
218 return result;
219 }
220 _tmp0_ = string_substring (path, (glong) (pos + 1), (glong) -1);
221 ext = _tmp0_;
222 _tmp1_ = ext;
223 result = valadoc_content_source_code_language_from_string (_tmp1_, TRUE);
224 _g_free0 (ext);
225 return result;
226 }
227
228 ValadocContentSourceCodeLanguage
valadoc_content_source_code_language_from_string(const gchar * str,gboolean is_extension)229 valadoc_content_source_code_language_from_string (const gchar* str,
230 gboolean is_extension)
231 {
232 const gchar* _tmp0_;
233 GQuark _tmp2_ = 0U;
234 static GQuark _tmp1_label0 = 0;
235 static GQuark _tmp1_label1 = 0;
236 static GQuark _tmp1_label2 = 0;
237 static GQuark _tmp1_label3 = 0;
238 static GQuark _tmp1_label4 = 0;
239 static GQuark _tmp1_label5 = 0;
240 ValadocContentSourceCodeLanguage result = 0;
241 g_return_val_if_fail (str != NULL, 0);
242 _tmp0_ = str;
243 _tmp2_ = (NULL == _tmp0_) ? 0 : g_quark_from_string (_tmp0_);
244 if (_tmp2_ == ((0 != _tmp1_label0) ? _tmp1_label0 : (_tmp1_label0 = g_quark_from_static_string ("genie")))) {
245 switch (0) {
246 default:
247 {
248 if (is_extension) {
249 result = VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_UNKNOWN;
250 return result;
251 }
252 result = VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_GENIE;
253 return result;
254 }
255 }
256 } else if (_tmp2_ == ((0 != _tmp1_label1) ? _tmp1_label1 : (_tmp1_label1 = g_quark_from_static_string ("gs")))) {
257 switch (0) {
258 default:
259 {
260 result = VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_GENIE;
261 return result;
262 }
263 }
264 } else if (_tmp2_ == ((0 != _tmp1_label2) ? _tmp1_label2 : (_tmp1_label2 = g_quark_from_static_string ("xml")))) {
265 switch (0) {
266 default:
267 {
268 result = VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_XML;
269 return result;
270 }
271 }
272 } else if (_tmp2_ == ((0 != _tmp1_label3) ? _tmp1_label3 : (_tmp1_label3 = g_quark_from_static_string ("vala")))) {
273 switch (0) {
274 default:
275 {
276 result = VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_VALA;
277 return result;
278 }
279 }
280 } else if ((_tmp2_ == ((0 != _tmp1_label4) ? _tmp1_label4 : (_tmp1_label4 = g_quark_from_static_string ("c")))) || (_tmp2_ == ((0 != _tmp1_label5) ? _tmp1_label5 : (_tmp1_label5 = g_quark_from_static_string ("h"))))) {
281 switch (0) {
282 default:
283 {
284 result = VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_C;
285 return result;
286 }
287 }
288 }
289 result = VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_UNKNOWN;
290 return result;
291 }
292
293 const gchar*
valadoc_content_source_code_language_to_string(ValadocContentSourceCodeLanguage self)294 valadoc_content_source_code_language_to_string (ValadocContentSourceCodeLanguage self)
295 {
296 const gchar* result = NULL;
297 switch (self) {
298 case VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_GENIE:
299 {
300 result = "genie";
301 return result;
302 }
303 case VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_VALA:
304 {
305 result = "vala";
306 return result;
307 }
308 case VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_XML:
309 {
310 result = "xml";
311 return result;
312 }
313 case VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_C:
314 {
315 result = "c";
316 return result;
317 }
318 default:
319 break;
320 }
321 g_assert_not_reached ();
322 }
323
324 static GType
valadoc_content_source_code_language_get_type_once(void)325 valadoc_content_source_code_language_get_type_once (void)
326 {
327 static const GEnumValue values[] = {{VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_UNKNOWN, "VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_UNKNOWN", "unknown"}, {VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_GENIE, "VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_GENIE", "genie"}, {VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_VALA, "VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_VALA", "vala"}, {VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_XML, "VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_XML", "xml"}, {VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_C, "VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_C", "c"}, {0, NULL, NULL}};
328 GType valadoc_content_source_code_language_type_id;
329 valadoc_content_source_code_language_type_id = g_enum_register_static ("ValadocContentSourceCodeLanguage", values);
330 return valadoc_content_source_code_language_type_id;
331 }
332
333 GType
valadoc_content_source_code_language_get_type(void)334 valadoc_content_source_code_language_get_type (void)
335 {
336 static volatile gsize valadoc_content_source_code_language_type_id__volatile = 0;
337 if (g_once_init_enter (&valadoc_content_source_code_language_type_id__volatile)) {
338 GType valadoc_content_source_code_language_type_id;
339 valadoc_content_source_code_language_type_id = valadoc_content_source_code_language_get_type_once ();
340 g_once_init_leave (&valadoc_content_source_code_language_type_id__volatile, valadoc_content_source_code_language_type_id);
341 }
342 return valadoc_content_source_code_language_type_id__volatile;
343 }
344
345 const gchar*
valadoc_content_source_code_get_code(ValadocContentSourceCode * self)346 valadoc_content_source_code_get_code (ValadocContentSourceCode* self)
347 {
348 const gchar* result;
349 const gchar* _tmp0_;
350 g_return_val_if_fail (self != NULL, NULL);
351 _tmp0_ = self->priv->_code;
352 result = _tmp0_;
353 return result;
354 }
355
356 void
valadoc_content_source_code_set_code(ValadocContentSourceCode * self,const gchar * value)357 valadoc_content_source_code_set_code (ValadocContentSourceCode* self,
358 const gchar* value)
359 {
360 gchar* old_value;
361 g_return_if_fail (self != NULL);
362 old_value = valadoc_content_source_code_get_code (self);
363 if (g_strcmp0 (value, old_value) != 0) {
364 gchar* _tmp0_;
365 _tmp0_ = g_strdup (value);
366 _g_free0 (self->priv->_code);
367 self->priv->_code = _tmp0_;
368 g_object_notify_by_pspec ((GObject *) self, valadoc_content_source_code_properties[VALADOC_CONTENT_SOURCE_CODE_CODE_PROPERTY]);
369 }
370 }
371
372 ValadocContentRun*
valadoc_content_source_code_get_highlighted_code(ValadocContentSourceCode * self)373 valadoc_content_source_code_get_highlighted_code (ValadocContentSourceCode* self)
374 {
375 ValadocContentRun* result;
376 ValadocContentRun* _tmp0_;
377 g_return_val_if_fail (self != NULL, NULL);
378 _tmp0_ = self->priv->_highlighted_code;
379 result = _tmp0_;
380 return result;
381 }
382
383 static gpointer
_g_object_ref0(gpointer self)384 _g_object_ref0 (gpointer self)
385 {
386 return self ? g_object_ref (self) : NULL;
387 }
388
389 static void
valadoc_content_source_code_set_highlighted_code(ValadocContentSourceCode * self,ValadocContentRun * value)390 valadoc_content_source_code_set_highlighted_code (ValadocContentSourceCode* self,
391 ValadocContentRun* value)
392 {
393 ValadocContentRun* old_value;
394 g_return_if_fail (self != NULL);
395 old_value = valadoc_content_source_code_get_highlighted_code (self);
396 if (old_value != value) {
397 ValadocContentRun* _tmp0_;
398 _tmp0_ = _g_object_ref0 (value);
399 _g_object_unref0 (self->priv->_highlighted_code);
400 self->priv->_highlighted_code = _tmp0_;
401 g_object_notify_by_pspec ((GObject *) self, valadoc_content_source_code_properties[VALADOC_CONTENT_SOURCE_CODE_HIGHLIGHTED_CODE_PROPERTY]);
402 }
403 }
404
405 ValadocContentSourceCodeLanguage
valadoc_content_source_code_get_language(ValadocContentSourceCode * self)406 valadoc_content_source_code_get_language (ValadocContentSourceCode* self)
407 {
408 ValadocContentSourceCodeLanguage result;
409 ValadocContentSourceCodeLanguage _tmp0_;
410 g_return_val_if_fail (self != NULL, 0);
411 _tmp0_ = self->priv->_language;
412 result = _tmp0_;
413 return result;
414 }
415
416 void
valadoc_content_source_code_set_language(ValadocContentSourceCode * self,ValadocContentSourceCodeLanguage value)417 valadoc_content_source_code_set_language (ValadocContentSourceCode* self,
418 ValadocContentSourceCodeLanguage value)
419 {
420 ValadocContentSourceCodeLanguage old_value;
421 g_return_if_fail (self != NULL);
422 old_value = valadoc_content_source_code_get_language (self);
423 if (old_value != value) {
424 self->priv->_language = value;
425 g_object_notify_by_pspec ((GObject *) self, valadoc_content_source_code_properties[VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_PROPERTY]);
426 }
427 }
428
429 G_GNUC_INTERNAL ValadocContentSourceCode*
valadoc_content_source_code_construct(GType object_type)430 valadoc_content_source_code_construct (GType object_type)
431 {
432 ValadocContentSourceCode * self = NULL;
433 self = (ValadocContentSourceCode*) valadoc_content_content_element_construct (object_type);
434 self->priv->_language = VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_VALA;
435 return self;
436 }
437
438 G_GNUC_INTERNAL ValadocContentSourceCode*
valadoc_content_source_code_new(void)439 valadoc_content_source_code_new (void)
440 {
441 return valadoc_content_source_code_construct (VALADOC_CONTENT_TYPE_SOURCE_CODE);
442 }
443
444 static gchar*
valadoc_content_source_code_get_path(ValadocContentSourceCode * self,const gchar * path,ValadocApiNode * container,const gchar * source_file_path,ValadocErrorReporter * reporter)445 valadoc_content_source_code_get_path (ValadocContentSourceCode* self,
446 const gchar* path,
447 ValadocApiNode* container,
448 const gchar* source_file_path,
449 ValadocErrorReporter* reporter)
450 {
451 gchar* _tmp18_;
452 gchar* result = NULL;
453 g_return_val_if_fail (self != NULL, NULL);
454 g_return_val_if_fail (path != NULL, NULL);
455 g_return_val_if_fail (container != NULL, NULL);
456 g_return_val_if_fail (source_file_path != NULL, NULL);
457 g_return_val_if_fail (reporter != NULL, NULL);
458 if (!g_path_is_absolute (path)) {
459 gchar* relative_to_file = NULL;
460 gchar* _tmp0_;
461 gchar* _tmp1_;
462 gchar* _tmp2_;
463 gchar* _tmp3_;
464 const gchar* _tmp4_;
465 _tmp0_ = g_path_get_dirname (source_file_path);
466 _tmp1_ = _tmp0_;
467 _tmp2_ = g_build_path (G_DIR_SEPARATOR_S, _tmp1_, path, NULL);
468 _tmp3_ = _tmp2_;
469 _g_free0 (_tmp1_);
470 relative_to_file = _tmp3_;
471 _tmp4_ = relative_to_file;
472 if (g_file_test (_tmp4_, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
473 gchar* _tmp5_;
474 _tmp5_ = relative_to_file;
475 relative_to_file = NULL;
476 result = _tmp5_;
477 _g_free0 (relative_to_file);
478 return result;
479 }
480 _g_free0 (relative_to_file);
481 }
482 if (!g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
483 gchar* _tmp6_ = NULL;
484 gchar* node_segment = NULL;
485 gchar* _tmp11_;
486 gchar* _tmp12_;
487 gchar* _tmp13_;
488 const gchar* _tmp14_;
489 gchar* _tmp15_;
490 gchar* _tmp16_;
491 const gchar* _tmp17_;
492 if (VALADOC_API_IS_PACKAGE (container)) {
493 gchar* _tmp7_;
494 _tmp7_ = g_strdup ("");
495 _g_free0 (_tmp6_);
496 _tmp6_ = _tmp7_;
497 } else {
498 gchar* _tmp8_;
499 gchar* _tmp9_;
500 gchar* _tmp10_;
501 _tmp8_ = valadoc_api_node_get_full_name (container);
502 _tmp9_ = _tmp8_;
503 _tmp10_ = g_strconcat (_tmp9_, ": ", NULL);
504 _g_free0 (_tmp6_);
505 _tmp6_ = _tmp10_;
506 _g_free0 (_tmp9_);
507 }
508 _tmp11_ = g_strdup (_tmp6_);
509 node_segment = _tmp11_;
510 _tmp12_ = g_strdup_printf ("File '%s' does not exist", path);
511 _tmp13_ = _tmp12_;
512 valadoc_content_source_code_set_code (self, _tmp13_);
513 _g_free0 (_tmp13_);
514 _tmp14_ = node_segment;
515 _tmp15_ = g_strdup_printf ("%s: %s{{{", source_file_path, _tmp14_);
516 _tmp16_ = _tmp15_;
517 _tmp17_ = self->priv->_code;
518 valadoc_error_reporter_simple_warning (reporter, _tmp16_, "%s", _tmp17_);
519 _g_free0 (_tmp16_);
520 result = NULL;
521 _g_free0 (node_segment);
522 _g_free0 (_tmp6_);
523 return result;
524 }
525 _tmp18_ = g_strdup (path);
526 result = _tmp18_;
527 return result;
528 }
529
530 static void
valadoc_content_source_code_load_source_code(ValadocContentSourceCode * self,const gchar * _path,ValadocApiNode * container,const gchar * source_file_path,ValadocErrorReporter * reporter)531 valadoc_content_source_code_load_source_code (ValadocContentSourceCode* self,
532 const gchar* _path,
533 ValadocApiNode* container,
534 const gchar* source_file_path,
535 ValadocErrorReporter* reporter)
536 {
537 gchar* path = NULL;
538 gchar* _tmp0_;
539 const gchar* _tmp1_;
540 GError* _inner_error0_ = NULL;
541 g_return_if_fail (self != NULL);
542 g_return_if_fail (_path != NULL);
543 g_return_if_fail (container != NULL);
544 g_return_if_fail (source_file_path != NULL);
545 g_return_if_fail (reporter != NULL);
546 _tmp0_ = valadoc_content_source_code_get_path (self, _path, container, source_file_path, reporter);
547 path = _tmp0_;
548 _tmp1_ = path;
549 if (_tmp1_ == NULL) {
550 _g_free0 (path);
551 return;
552 }
553 {
554 gchar* content = NULL;
555 const gchar* _tmp2_;
556 gchar* _tmp3_ = NULL;
557 const gchar* _tmp4_;
558 gchar* _tmp5_;
559 gchar* _tmp6_;
560 content = NULL;
561 _tmp2_ = path;
562 g_file_get_contents (_tmp2_, &_tmp3_, NULL, &_inner_error0_);
563 _g_free0 (content);
564 content = _tmp3_;
565 if (G_UNLIKELY (_inner_error0_ != NULL)) {
566 _g_free0 (content);
567 if (_inner_error0_->domain == G_FILE_ERROR) {
568 goto __catch0_g_file_error;
569 }
570 _g_free0 (path);
571 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);
572 g_clear_error (&_inner_error0_);
573 return;
574 }
575 _tmp4_ = path;
576 self->priv->_language = valadoc_content_source_code_language_from_path (_tmp4_);
577 _tmp5_ = content;
578 content = NULL;
579 _tmp6_ = _tmp5_;
580 valadoc_content_source_code_set_code (self, _tmp6_);
581 _g_free0 (_tmp6_);
582 _g_free0 (content);
583 }
584 goto __finally0;
585 __catch0_g_file_error:
586 {
587 GError* err = NULL;
588 gchar* _tmp7_ = NULL;
589 gchar* node_segment = NULL;
590 gchar* _tmp12_;
591 const gchar* _tmp13_;
592 gchar* _tmp14_;
593 gchar* _tmp15_;
594 const gchar* _tmp16_;
595 GError* _tmp17_;
596 const gchar* _tmp18_;
597 err = _inner_error0_;
598 _inner_error0_ = NULL;
599 if (VALADOC_API_IS_PACKAGE (container)) {
600 gchar* _tmp8_;
601 _tmp8_ = g_strdup ("");
602 _g_free0 (_tmp7_);
603 _tmp7_ = _tmp8_;
604 } else {
605 gchar* _tmp9_;
606 gchar* _tmp10_;
607 gchar* _tmp11_;
608 _tmp9_ = valadoc_api_node_get_full_name (container);
609 _tmp10_ = _tmp9_;
610 _tmp11_ = g_strconcat (_tmp10_, ": ", NULL);
611 _g_free0 (_tmp7_);
612 _tmp7_ = _tmp11_;
613 _g_free0 (_tmp10_);
614 }
615 _tmp12_ = g_strdup (_tmp7_);
616 node_segment = _tmp12_;
617 _tmp13_ = node_segment;
618 _tmp14_ = g_strdup_printf ("%s: %s{{{", source_file_path, _tmp13_);
619 _tmp15_ = _tmp14_;
620 _tmp16_ = path;
621 _tmp17_ = err;
622 _tmp18_ = _tmp17_->message;
623 valadoc_error_reporter_simple_error (reporter, _tmp15_, "Can't read file '%s': %s", _tmp16_, _tmp18_);
624 _g_free0 (_tmp15_);
625 _g_free0 (node_segment);
626 _g_free0 (_tmp7_);
627 _g_error_free0 (err);
628 }
629 __finally0:
630 if (G_UNLIKELY (_inner_error0_ != NULL)) {
631 _g_free0 (path);
632 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);
633 g_clear_error (&_inner_error0_);
634 return;
635 }
636 _g_free0 (path);
637 }
638
639 static gchar
string_get(const gchar * self,glong index)640 string_get (const gchar* self,
641 glong index)
642 {
643 gchar _tmp0_;
644 gchar result = '\0';
645 g_return_val_if_fail (self != NULL, '\0');
646 _tmp0_ = ((gchar*) self)[index];
647 result = _tmp0_;
648 return result;
649 }
650
651 static inline gboolean
valadoc_content_source_code_is_empty_string(ValadocContentSourceCode * self,const gchar * line)652 valadoc_content_source_code_is_empty_string (ValadocContentSourceCode* self,
653 const gchar* line)
654 {
655 gboolean result = FALSE;
656 g_return_val_if_fail (self != NULL, FALSE);
657 g_return_val_if_fail (line != NULL, FALSE);
658 {
659 gint i = 0;
660 i = 0;
661 {
662 gboolean _tmp0_ = FALSE;
663 _tmp0_ = TRUE;
664 while (TRUE) {
665 if (!_tmp0_) {
666 gint _tmp1_;
667 _tmp1_ = i;
668 i = _tmp1_ + 1;
669 }
670 _tmp0_ = FALSE;
671 if (!(string_get (line, (glong) i) != '\0')) {
672 break;
673 }
674 if (g_ascii_isspace (string_get (line, (glong) i)) == FALSE) {
675 result = FALSE;
676 return result;
677 }
678 }
679 }
680 }
681 result = TRUE;
682 return result;
683 }
684
685 static gchar*
_vala_g_strjoinv(const gchar * separator,gchar ** str_array,gint str_array_length1)686 _vala_g_strjoinv (const gchar* separator,
687 gchar** str_array,
688 gint str_array_length1)
689 {
690 gboolean _tmp0_ = FALSE;
691 gchar* result = NULL;
692 if (separator == NULL) {
693 separator = "";
694 }
695 if (str_array != NULL) {
696 gboolean _tmp1_ = FALSE;
697 if (str_array_length1 > 0) {
698 _tmp1_ = TRUE;
699 } else {
700 gboolean _tmp2_ = FALSE;
701 if (str_array_length1 == -1) {
702 const gchar* _tmp3_;
703 _tmp3_ = str_array[0];
704 _tmp2_ = _tmp3_ != NULL;
705 } else {
706 _tmp2_ = FALSE;
707 }
708 _tmp1_ = _tmp2_;
709 }
710 _tmp0_ = _tmp1_;
711 } else {
712 _tmp0_ = FALSE;
713 }
714 if (_tmp0_) {
715 gint i = 0;
716 gsize len = 0UL;
717 gint _tmp16_;
718 gint _tmp17_;
719 const gchar* res = NULL;
720 void* _tmp18_;
721 void* ptr = NULL;
722 const gchar* _tmp19_;
723 const gchar* _tmp20_;
724 void* _tmp21_;
725 const gchar* _tmp31_;
726 len = (gsize) 1;
727 {
728 gboolean _tmp4_ = FALSE;
729 i = 0;
730 _tmp4_ = TRUE;
731 while (TRUE) {
732 gboolean _tmp6_ = FALSE;
733 gboolean _tmp7_ = FALSE;
734 gint _tmp10_ = 0;
735 const gchar* _tmp11_;
736 if (!_tmp4_) {
737 gint _tmp5_;
738 _tmp5_ = i;
739 i = _tmp5_ + 1;
740 }
741 _tmp4_ = FALSE;
742 if (str_array_length1 != -1) {
743 _tmp7_ = i < str_array_length1;
744 } else {
745 _tmp7_ = FALSE;
746 }
747 if (_tmp7_) {
748 _tmp6_ = TRUE;
749 } else {
750 gboolean _tmp8_ = FALSE;
751 if (str_array_length1 == -1) {
752 const gchar* _tmp9_;
753 _tmp9_ = str_array[i];
754 _tmp8_ = _tmp9_ != NULL;
755 } else {
756 _tmp8_ = FALSE;
757 }
758 _tmp6_ = _tmp8_;
759 }
760 if (!_tmp6_) {
761 break;
762 }
763 _tmp11_ = str_array[i];
764 if (_tmp11_ != NULL) {
765 const gchar* _tmp12_;
766 gint _tmp13_;
767 gint _tmp14_;
768 _tmp12_ = str_array[i];
769 _tmp13_ = strlen ((const gchar*) _tmp12_);
770 _tmp14_ = _tmp13_;
771 _tmp10_ = _tmp14_;
772 } else {
773 _tmp10_ = 0;
774 }
775 len += (gsize) _tmp10_;
776 }
777 }
778 if (i == 0) {
779 gchar* _tmp15_;
780 _tmp15_ = g_strdup ("");
781 result = _tmp15_;
782 return result;
783 }
784 str_array_length1 = i;
785 _tmp16_ = strlen ((const gchar*) separator);
786 _tmp17_ = _tmp16_;
787 len += (gsize) (_tmp17_ * (i - 1));
788 _tmp18_ = g_malloc (len);
789 res = _tmp18_;
790 _tmp19_ = res;
791 _tmp20_ = str_array[0];
792 _tmp21_ = g_stpcpy ((void*) _tmp19_, (const gchar*) _tmp20_);
793 ptr = _tmp21_;
794 {
795 gboolean _tmp22_ = FALSE;
796 i = 1;
797 _tmp22_ = TRUE;
798 while (TRUE) {
799 void* _tmp24_;
800 void* _tmp25_;
801 const gchar* _tmp26_ = NULL;
802 const gchar* _tmp27_;
803 void* _tmp29_;
804 void* _tmp30_;
805 if (!_tmp22_) {
806 gint _tmp23_;
807 _tmp23_ = i;
808 i = _tmp23_ + 1;
809 }
810 _tmp22_ = FALSE;
811 if (!(i < str_array_length1)) {
812 break;
813 }
814 _tmp24_ = ptr;
815 _tmp25_ = g_stpcpy (_tmp24_, (const gchar*) separator);
816 ptr = _tmp25_;
817 _tmp27_ = str_array[i];
818 if (_tmp27_ != NULL) {
819 const gchar* _tmp28_;
820 _tmp28_ = str_array[i];
821 _tmp26_ = (const gchar*) _tmp28_;
822 } else {
823 _tmp26_ = "";
824 }
825 _tmp29_ = ptr;
826 _tmp30_ = g_stpcpy (_tmp29_, _tmp26_);
827 ptr = _tmp30_;
828 }
829 }
830 _tmp31_ = res;
831 res = NULL;
832 result = (gchar*) _tmp31_;
833 return result;
834 } else {
835 gchar* _tmp32_;
836 _tmp32_ = g_strdup ("");
837 result = _tmp32_;
838 return result;
839 }
840 }
841
842 static gchar*
valadoc_content_source_code_strip_code(ValadocContentSourceCode * self,const gchar * code)843 valadoc_content_source_code_strip_code (ValadocContentSourceCode* self,
844 const gchar* code)
845 {
846 gchar** lines = NULL;
847 gchar** _tmp0_;
848 gchar** _tmp1_;
849 gint lines_length1;
850 gint _lines_size_;
851 const gchar** _lines = NULL;
852 gchar** _tmp9_;
853 gint _tmp9__length1;
854 const gchar** _tmp18_;
855 gchar* _tmp19_;
856 gchar* result = NULL;
857 g_return_val_if_fail (self != NULL, NULL);
858 g_return_val_if_fail (code != NULL, NULL);
859 _tmp1_ = _tmp0_ = g_strsplit (code, "\n", 0);
860 lines = _tmp1_;
861 lines_length1 = _vala_array_length (_tmp0_);
862 _lines_size_ = lines_length1;
863 {
864 gint i = 0;
865 gchar** _tmp2_;
866 gint _tmp2__length1;
867 _tmp2_ = lines;
868 _tmp2__length1 = lines_length1;
869 i = _tmp2__length1 - 1;
870 {
871 gboolean _tmp3_ = FALSE;
872 _tmp3_ = TRUE;
873 while (TRUE) {
874 gboolean _tmp5_ = FALSE;
875 gchar** _tmp8_;
876 gint _tmp8__length1;
877 if (!_tmp3_) {
878 gint _tmp4_;
879 _tmp4_ = i;
880 i = _tmp4_ - 1;
881 }
882 _tmp3_ = FALSE;
883 if (i >= 0) {
884 gchar** _tmp6_;
885 gint _tmp6__length1;
886 const gchar* _tmp7_;
887 _tmp6_ = lines;
888 _tmp6__length1 = lines_length1;
889 _tmp7_ = _tmp6_[i];
890 _tmp5_ = valadoc_content_source_code_is_empty_string (self, _tmp7_);
891 } else {
892 _tmp5_ = FALSE;
893 }
894 if (!_tmp5_) {
895 break;
896 }
897 _tmp8_ = lines;
898 _tmp8__length1 = lines_length1;
899 _g_free0 (_tmp8_[i]);
900 _tmp8_[i] = NULL;
901 }
902 }
903 }
904 _tmp9_ = lines;
905 _tmp9__length1 = lines_length1;
906 _lines = _tmp9_;
907 {
908 gint i = 0;
909 i = 0;
910 {
911 gboolean _tmp10_ = FALSE;
912 _tmp10_ = TRUE;
913 while (TRUE) {
914 gboolean _tmp12_ = FALSE;
915 gchar** _tmp13_;
916 gint _tmp13__length1;
917 const gchar* _tmp14_;
918 gchar** _tmp17_;
919 gint _tmp17__length1;
920 if (!_tmp10_) {
921 gint _tmp11_;
922 _tmp11_ = i;
923 i = _tmp11_ + 1;
924 }
925 _tmp10_ = FALSE;
926 _tmp13_ = lines;
927 _tmp13__length1 = lines_length1;
928 _tmp14_ = _tmp13_[i];
929 if (_tmp14_ != NULL) {
930 gchar** _tmp15_;
931 gint _tmp15__length1;
932 const gchar* _tmp16_;
933 _tmp15_ = lines;
934 _tmp15__length1 = lines_length1;
935 _tmp16_ = _tmp15_[i];
936 _tmp12_ = valadoc_content_source_code_is_empty_string (self, _tmp16_);
937 } else {
938 _tmp12_ = FALSE;
939 }
940 if (!_tmp12_) {
941 break;
942 }
943 _tmp17_ = lines;
944 _tmp17__length1 = lines_length1;
945 _lines = &_tmp17_[i + 1];
946 }
947 }
948 }
949 _tmp18_ = _lines;
950 _tmp19_ = _vala_g_strjoinv ("\n", (gchar**) _tmp18_, (gint) -1);
951 result = _tmp19_;
952 lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
953 return result;
954 }
955
956 static gchar*
string_strip(const gchar * self)957 string_strip (const gchar* self)
958 {
959 gchar* _result_ = NULL;
960 gchar* _tmp0_;
961 gchar* result = NULL;
962 g_return_val_if_fail (self != NULL, NULL);
963 _tmp0_ = g_strdup (self);
964 _result_ = _tmp0_;
965 g_strstrip (_result_);
966 result = _result_;
967 return result;
968 }
969
970 static void
valadoc_content_source_code_real_check(ValadocContentContentElement * base,ValadocApiTree * api_root,ValadocApiNode * container,const gchar * file_path,ValadocErrorReporter * reporter,ValadocSettings * settings)971 valadoc_content_source_code_real_check (ValadocContentContentElement* base,
972 ValadocApiTree* api_root,
973 ValadocApiNode* container,
974 const gchar* file_path,
975 ValadocErrorReporter* reporter,
976 ValadocSettings* settings)
977 {
978 ValadocContentSourceCode * self;
979 gchar** splitted = NULL;
980 const gchar* _tmp0_;
981 gchar** _tmp1_;
982 gchar** _tmp2_;
983 gint splitted_length1;
984 gint _splitted_size_;
985 gchar** _tmp3_;
986 gint _tmp3__length1;
987 const gchar* _tmp4_;
988 gchar* _tmp5_;
989 gchar* _tmp6_;
990 gboolean _tmp7_;
991 const gchar* _tmp40_;
992 gchar* _tmp41_;
993 gchar* _tmp42_;
994 ValadocContentSourceCodeLanguage _tmp43_;
995 self = (ValadocContentSourceCode*) base;
996 g_return_if_fail (api_root != NULL);
997 g_return_if_fail (container != NULL);
998 g_return_if_fail (file_path != NULL);
999 g_return_if_fail (reporter != NULL);
1000 g_return_if_fail (settings != NULL);
1001 _tmp0_ = self->priv->_code;
1002 _tmp2_ = _tmp1_ = g_strsplit (_tmp0_, "\n", 2);
1003 splitted = _tmp2_;
1004 splitted_length1 = _vala_array_length (_tmp1_);
1005 _splitted_size_ = splitted_length1;
1006 _tmp3_ = splitted;
1007 _tmp3__length1 = splitted_length1;
1008 _tmp4_ = _tmp3_[0];
1009 _tmp5_ = string_strip (_tmp4_);
1010 _tmp6_ = _tmp5_;
1011 _tmp7_ = g_strcmp0 (_tmp6_, "") == 0;
1012 _g_free0 (_tmp6_);
1013 if (_tmp7_) {
1014 const gchar* _tmp8_ = NULL;
1015 gchar** _tmp9_;
1016 gint _tmp9__length1;
1017 const gchar* _tmp10_;
1018 _tmp9_ = splitted;
1019 _tmp9__length1 = splitted_length1;
1020 _tmp10_ = _tmp9_[1];
1021 _tmp8_ = _tmp10_;
1022 if (_tmp8_ == NULL) {
1023 _tmp8_ = "";
1024 }
1025 valadoc_content_source_code_set_code (self, _tmp8_);
1026 } else {
1027 gchar** _tmp11_;
1028 gint _tmp11__length1;
1029 const gchar* _tmp12_;
1030 _tmp11_ = splitted;
1031 _tmp11__length1 = splitted_length1;
1032 _tmp12_ = _tmp11_[0];
1033 if (g_str_has_prefix (_tmp12_, "#!")) {
1034 const gchar* start = NULL;
1035 gchar** _tmp13_;
1036 gint _tmp13__length1;
1037 const gchar* _tmp14_;
1038 const gchar* _tmp15_;
1039 _tmp13_ = splitted;
1040 _tmp13__length1 = splitted_length1;
1041 _tmp14_ = _tmp13_[0];
1042 start = (const gchar*) (((gchar*) _tmp14_) + 2);
1043 _tmp15_ = start;
1044 if (g_str_has_prefix (_tmp15_, "include:")) {
1045 const gchar* _tmp16_;
1046 gchar* path = NULL;
1047 const gchar* _tmp17_;
1048 gchar* _tmp18_;
1049 const gchar* _tmp19_;
1050 _tmp16_ = start;
1051 start = (const gchar*) (((gchar*) _tmp16_) + 8);
1052 _tmp17_ = start;
1053 _tmp18_ = string_strip (_tmp17_);
1054 path = _tmp18_;
1055 _tmp19_ = path;
1056 valadoc_content_source_code_load_source_code (self, _tmp19_, container, file_path, reporter);
1057 _g_free0 (path);
1058 } else {
1059 gchar* name = NULL;
1060 const gchar* _tmp20_;
1061 const gchar* _tmp21_;
1062 gchar* _tmp22_;
1063 const gchar* _tmp23_;
1064 const gchar* _tmp24_ = NULL;
1065 gchar** _tmp25_;
1066 gint _tmp25__length1;
1067 const gchar* _tmp26_;
1068 gboolean _tmp27_ = FALSE;
1069 ValadocContentSourceCodeLanguage _tmp28_;
1070 _tmp20_ = start;
1071 _tmp21_ = g_strstrip (_tmp20_);
1072 _tmp22_ = g_ascii_strdown (_tmp21_, (gssize) -1);
1073 name = _tmp22_;
1074 _tmp23_ = name;
1075 self->priv->_language = valadoc_content_source_code_language_from_string (_tmp23_, FALSE);
1076 _tmp25_ = splitted;
1077 _tmp25__length1 = splitted_length1;
1078 _tmp26_ = _tmp25_[1];
1079 _tmp24_ = _tmp26_;
1080 if (_tmp24_ == NULL) {
1081 _tmp24_ = "";
1082 }
1083 valadoc_content_source_code_set_code (self, _tmp24_);
1084 _tmp28_ = self->priv->_language;
1085 if (_tmp28_ == VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_UNKNOWN) {
1086 const gchar* _tmp29_;
1087 _tmp29_ = name;
1088 _tmp27_ = g_strcmp0 (_tmp29_, "none") != 0;
1089 } else {
1090 _tmp27_ = FALSE;
1091 }
1092 if (_tmp27_) {
1093 gchar* _tmp30_ = NULL;
1094 gchar* node_segment = NULL;
1095 gchar* _tmp35_;
1096 const gchar* _tmp36_;
1097 gchar* _tmp37_;
1098 gchar* _tmp38_;
1099 const gchar* _tmp39_;
1100 if (VALADOC_API_IS_PACKAGE (container)) {
1101 gchar* _tmp31_;
1102 _tmp31_ = g_strdup ("");
1103 _g_free0 (_tmp30_);
1104 _tmp30_ = _tmp31_;
1105 } else {
1106 gchar* _tmp32_;
1107 gchar* _tmp33_;
1108 gchar* _tmp34_;
1109 _tmp32_ = valadoc_api_node_get_full_name (container);
1110 _tmp33_ = _tmp32_;
1111 _tmp34_ = g_strconcat (_tmp33_, ": ", NULL);
1112 _g_free0 (_tmp30_);
1113 _tmp30_ = _tmp34_;
1114 _g_free0 (_tmp33_);
1115 }
1116 _tmp35_ = g_strdup (_tmp30_);
1117 node_segment = _tmp35_;
1118 _tmp36_ = node_segment;
1119 _tmp37_ = g_strdup_printf ("%s: %s{{{", file_path, _tmp36_);
1120 _tmp38_ = _tmp37_;
1121 _tmp39_ = name;
1122 valadoc_error_reporter_simple_warning (reporter, _tmp38_, "Unsupported programming language '%s'", _tmp39_);
1123 _g_free0 (_tmp38_);
1124 _g_free0 (node_segment);
1125 _g_free0 (_tmp30_);
1126 }
1127 _g_free0 (name);
1128 }
1129 }
1130 }
1131 _tmp40_ = self->priv->_code;
1132 _tmp41_ = valadoc_content_source_code_strip_code (self, _tmp40_);
1133 _tmp42_ = _tmp41_;
1134 valadoc_content_source_code_set_code (self, _tmp42_);
1135 _g_free0 (_tmp42_);
1136 _tmp43_ = self->priv->_language;
1137 if (_tmp43_ == VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_VALA) {
1138 ValadocHighlighterHighlighter* _tmp44_;
1139 ValadocHighlighterHighlighter* _tmp45_;
1140 const gchar* _tmp46_;
1141 ValadocContentRun* _tmp47_;
1142 ValadocContentRun* _tmp48_;
1143 _tmp44_ = valadoc_api_tree_get_highlighter (api_root);
1144 _tmp45_ = _tmp44_;
1145 _tmp46_ = self->priv->_code;
1146 _tmp47_ = valadoc_highlighter_highlighter_highlight_vala (_tmp45_, _tmp46_);
1147 _tmp48_ = _tmp47_;
1148 valadoc_content_source_code_set_highlighted_code (self, _tmp48_);
1149 _g_object_unref0 (_tmp48_);
1150 } else {
1151 ValadocContentSourceCodeLanguage _tmp49_;
1152 _tmp49_ = self->priv->_language;
1153 if (_tmp49_ == VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_XML) {
1154 ValadocHighlighterHighlighter* _tmp50_;
1155 ValadocHighlighterHighlighter* _tmp51_;
1156 const gchar* _tmp52_;
1157 ValadocContentRun* _tmp53_;
1158 ValadocContentRun* _tmp54_;
1159 _tmp50_ = valadoc_api_tree_get_highlighter (api_root);
1160 _tmp51_ = _tmp50_;
1161 _tmp52_ = self->priv->_code;
1162 _tmp53_ = valadoc_highlighter_highlighter_highlight_xml (_tmp51_, _tmp52_);
1163 _tmp54_ = _tmp53_;
1164 valadoc_content_source_code_set_highlighted_code (self, _tmp54_);
1165 _g_object_unref0 (_tmp54_);
1166 } else {
1167 ValadocContentSourceCodeLanguage _tmp55_;
1168 _tmp55_ = self->priv->_language;
1169 if (_tmp55_ == VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_C) {
1170 ValadocHighlighterHighlighter* _tmp56_;
1171 ValadocHighlighterHighlighter* _tmp57_;
1172 const gchar* _tmp58_;
1173 ValadocContentRun* _tmp59_;
1174 ValadocContentRun* _tmp60_;
1175 _tmp56_ = valadoc_api_tree_get_highlighter (api_root);
1176 _tmp57_ = _tmp56_;
1177 _tmp58_ = self->priv->_code;
1178 _tmp59_ = valadoc_highlighter_highlighter_highlight_c (_tmp57_, _tmp58_);
1179 _tmp60_ = _tmp59_;
1180 valadoc_content_source_code_set_highlighted_code (self, _tmp60_);
1181 _g_object_unref0 (_tmp60_);
1182 } else {
1183 ValadocContentRun* _tmp61_;
1184 ValadocContentRun* _tmp62_;
1185 ValadocContentRun* _tmp63_;
1186 ValaList* _tmp64_;
1187 ValaList* _tmp65_;
1188 const gchar* _tmp66_;
1189 ValadocContentText* _tmp67_;
1190 ValadocContentText* _tmp68_;
1191 _tmp61_ = valadoc_content_run_new (VALADOC_CONTENT_RUN_STYLE_MONOSPACED);
1192 _tmp62_ = _tmp61_;
1193 valadoc_content_source_code_set_highlighted_code (self, _tmp62_);
1194 _g_object_unref0 (_tmp62_);
1195 _tmp63_ = self->priv->_highlighted_code;
1196 _tmp64_ = valadoc_content_inline_content_get_content ((ValadocContentInlineContent*) _tmp63_);
1197 _tmp65_ = _tmp64_;
1198 _tmp66_ = self->priv->_code;
1199 _tmp67_ = valadoc_content_text_new (_tmp66_);
1200 _tmp68_ = _tmp67_;
1201 vala_collection_add ((ValaCollection*) _tmp65_, (ValadocContentInline*) _tmp68_);
1202 _g_object_unref0 (_tmp68_);
1203 }
1204 }
1205 }
1206 splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
1207 }
1208
1209 static void
valadoc_content_source_code_real_accept(ValadocContentContentElement * base,ValadocContentContentVisitor * visitor)1210 valadoc_content_source_code_real_accept (ValadocContentContentElement* base,
1211 ValadocContentContentVisitor* visitor)
1212 {
1213 ValadocContentSourceCode * self;
1214 self = (ValadocContentSourceCode*) base;
1215 g_return_if_fail (visitor != NULL);
1216 valadoc_content_content_visitor_visit_source_code (visitor, self);
1217 }
1218
1219 static void
valadoc_content_source_code_real_accept_children(ValadocContentContentElement * base,ValadocContentContentVisitor * visitor)1220 valadoc_content_source_code_real_accept_children (ValadocContentContentElement* base,
1221 ValadocContentContentVisitor* visitor)
1222 {
1223 ValadocContentSourceCode * self;
1224 ValadocContentRun* _tmp0_;
1225 self = (ValadocContentSourceCode*) base;
1226 g_return_if_fail (visitor != NULL);
1227 _tmp0_ = self->priv->_highlighted_code;
1228 if (_tmp0_ != NULL) {
1229 ValadocContentRun* _tmp1_;
1230 _tmp1_ = self->priv->_highlighted_code;
1231 valadoc_content_content_element_accept ((ValadocContentContentElement*) _tmp1_, visitor);
1232 }
1233 }
1234
1235 static gboolean
valadoc_content_source_code_real_is_empty(ValadocContentContentElement * base)1236 valadoc_content_source_code_real_is_empty (ValadocContentContentElement* base)
1237 {
1238 ValadocContentSourceCode * self;
1239 gboolean result = FALSE;
1240 self = (ValadocContentSourceCode*) base;
1241 result = FALSE;
1242 return result;
1243 }
1244
1245 static ValadocContentContentElement*
valadoc_content_source_code_real_copy(ValadocContentContentElement * base,ValadocContentContentElement * new_parent)1246 valadoc_content_source_code_real_copy (ValadocContentContentElement* base,
1247 ValadocContentContentElement* new_parent)
1248 {
1249 ValadocContentSourceCode * self;
1250 ValadocContentSourceCode* source_code = NULL;
1251 ValadocContentSourceCode* _tmp0_;
1252 ValadocContentSourceCodeLanguage _tmp1_;
1253 const gchar* _tmp2_;
1254 ValadocContentContentElement* result = NULL;
1255 self = (ValadocContentSourceCode*) base;
1256 _tmp0_ = valadoc_content_source_code_new ();
1257 source_code = _tmp0_;
1258 valadoc_content_content_element_set_parent ((ValadocContentContentElement*) source_code, new_parent);
1259 _tmp1_ = self->priv->_language;
1260 valadoc_content_source_code_set_language (source_code, _tmp1_);
1261 _tmp2_ = self->priv->_code;
1262 valadoc_content_source_code_set_code (source_code, _tmp2_);
1263 result = (ValadocContentContentElement*) source_code;
1264 return result;
1265 }
1266
1267 static void
valadoc_content_source_code_class_init(ValadocContentSourceCodeClass * klass,gpointer klass_data)1268 valadoc_content_source_code_class_init (ValadocContentSourceCodeClass * klass,
1269 gpointer klass_data)
1270 {
1271 valadoc_content_source_code_parent_class = g_type_class_peek_parent (klass);
1272 g_type_class_adjust_private_offset (klass, &ValadocContentSourceCode_private_offset);
1273 ((ValadocContentContentElementClass *) klass)->check = (void (*) (ValadocContentContentElement*, ValadocApiTree*, ValadocApiNode*, const gchar*, ValadocErrorReporter*, ValadocSettings*)) valadoc_content_source_code_real_check;
1274 ((ValadocContentContentElementClass *) klass)->accept = (void (*) (ValadocContentContentElement*, ValadocContentContentVisitor*)) valadoc_content_source_code_real_accept;
1275 ((ValadocContentContentElementClass *) klass)->accept_children = (void (*) (ValadocContentContentElement*, ValadocContentContentVisitor*)) valadoc_content_source_code_real_accept_children;
1276 ((ValadocContentContentElementClass *) klass)->is_empty = (gboolean (*) (ValadocContentContentElement*)) valadoc_content_source_code_real_is_empty;
1277 ((ValadocContentContentElementClass *) klass)->copy = (ValadocContentContentElement* (*) (ValadocContentContentElement*, ValadocContentContentElement*)) valadoc_content_source_code_real_copy;
1278 G_OBJECT_CLASS (klass)->get_property = _vala_valadoc_content_source_code_get_property;
1279 G_OBJECT_CLASS (klass)->set_property = _vala_valadoc_content_source_code_set_property;
1280 G_OBJECT_CLASS (klass)->finalize = valadoc_content_source_code_finalize;
1281 g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_CONTENT_SOURCE_CODE_CODE_PROPERTY, valadoc_content_source_code_properties[VALADOC_CONTENT_SOURCE_CODE_CODE_PROPERTY] = g_param_spec_string ("code", "code", "code", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
1282 g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_CONTENT_SOURCE_CODE_HIGHLIGHTED_CODE_PROPERTY, valadoc_content_source_code_properties[VALADOC_CONTENT_SOURCE_CODE_HIGHLIGHTED_CODE_PROPERTY] = g_param_spec_object ("highlighted-code", "highlighted-code", "highlighted-code", VALADOC_CONTENT_TYPE_RUN, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
1283 g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_PROPERTY, valadoc_content_source_code_properties[VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_PROPERTY] = g_param_spec_enum ("language", "language", "language", VALADOC_CONTENT_SOURCE_CODE_TYPE_LANGUAGE, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
1284 }
1285
1286 static void
valadoc_content_source_code_valadoc_content_inline_interface_init(ValadocContentInlineIface * iface,gpointer iface_data)1287 valadoc_content_source_code_valadoc_content_inline_interface_init (ValadocContentInlineIface * iface,
1288 gpointer iface_data)
1289 {
1290 valadoc_content_source_code_valadoc_content_inline_parent_iface = g_type_interface_peek_parent (iface);
1291 }
1292
1293 static void
valadoc_content_source_code_instance_init(ValadocContentSourceCode * self,gpointer klass)1294 valadoc_content_source_code_instance_init (ValadocContentSourceCode * self,
1295 gpointer klass)
1296 {
1297 self->priv = valadoc_content_source_code_get_instance_private (self);
1298 }
1299
1300 static void
valadoc_content_source_code_finalize(GObject * obj)1301 valadoc_content_source_code_finalize (GObject * obj)
1302 {
1303 ValadocContentSourceCode * self;
1304 self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_CONTENT_TYPE_SOURCE_CODE, ValadocContentSourceCode);
1305 _g_free0 (self->priv->_code);
1306 _g_object_unref0 (self->priv->_highlighted_code);
1307 G_OBJECT_CLASS (valadoc_content_source_code_parent_class)->finalize (obj);
1308 }
1309
1310 static GType
valadoc_content_source_code_get_type_once(void)1311 valadoc_content_source_code_get_type_once (void)
1312 {
1313 static const GTypeInfo g_define_type_info = { sizeof (ValadocContentSourceCodeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_content_source_code_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocContentSourceCode), 0, (GInstanceInitFunc) valadoc_content_source_code_instance_init, NULL };
1314 static const GInterfaceInfo valadoc_content_inline_info = { (GInterfaceInitFunc) valadoc_content_source_code_valadoc_content_inline_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
1315 GType valadoc_content_source_code_type_id;
1316 valadoc_content_source_code_type_id = g_type_register_static (VALADOC_CONTENT_TYPE_CONTENT_ELEMENT, "ValadocContentSourceCode", &g_define_type_info, 0);
1317 g_type_add_interface_static (valadoc_content_source_code_type_id, VALADOC_CONTENT_TYPE_INLINE, &valadoc_content_inline_info);
1318 ValadocContentSourceCode_private_offset = g_type_add_instance_private (valadoc_content_source_code_type_id, sizeof (ValadocContentSourceCodePrivate));
1319 return valadoc_content_source_code_type_id;
1320 }
1321
1322 GType
valadoc_content_source_code_get_type(void)1323 valadoc_content_source_code_get_type (void)
1324 {
1325 static volatile gsize valadoc_content_source_code_type_id__volatile = 0;
1326 if (g_once_init_enter (&valadoc_content_source_code_type_id__volatile)) {
1327 GType valadoc_content_source_code_type_id;
1328 valadoc_content_source_code_type_id = valadoc_content_source_code_get_type_once ();
1329 g_once_init_leave (&valadoc_content_source_code_type_id__volatile, valadoc_content_source_code_type_id);
1330 }
1331 return valadoc_content_source_code_type_id__volatile;
1332 }
1333
1334 static void
_vala_valadoc_content_source_code_get_property(GObject * object,guint property_id,GValue * value,GParamSpec * pspec)1335 _vala_valadoc_content_source_code_get_property (GObject * object,
1336 guint property_id,
1337 GValue * value,
1338 GParamSpec * pspec)
1339 {
1340 ValadocContentSourceCode * self;
1341 self = G_TYPE_CHECK_INSTANCE_CAST (object, VALADOC_CONTENT_TYPE_SOURCE_CODE, ValadocContentSourceCode);
1342 switch (property_id) {
1343 case VALADOC_CONTENT_SOURCE_CODE_CODE_PROPERTY:
1344 g_value_set_string (value, valadoc_content_source_code_get_code (self));
1345 break;
1346 case VALADOC_CONTENT_SOURCE_CODE_HIGHLIGHTED_CODE_PROPERTY:
1347 g_value_set_object (value, valadoc_content_source_code_get_highlighted_code (self));
1348 break;
1349 case VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_PROPERTY:
1350 g_value_set_enum (value, valadoc_content_source_code_get_language (self));
1351 break;
1352 default:
1353 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1354 break;
1355 }
1356 }
1357
1358 static void
_vala_valadoc_content_source_code_set_property(GObject * object,guint property_id,const GValue * value,GParamSpec * pspec)1359 _vala_valadoc_content_source_code_set_property (GObject * object,
1360 guint property_id,
1361 const GValue * value,
1362 GParamSpec * pspec)
1363 {
1364 ValadocContentSourceCode * self;
1365 self = G_TYPE_CHECK_INSTANCE_CAST (object, VALADOC_CONTENT_TYPE_SOURCE_CODE, ValadocContentSourceCode);
1366 switch (property_id) {
1367 case VALADOC_CONTENT_SOURCE_CODE_CODE_PROPERTY:
1368 valadoc_content_source_code_set_code (self, g_value_get_string (value));
1369 break;
1370 case VALADOC_CONTENT_SOURCE_CODE_HIGHLIGHTED_CODE_PROPERTY:
1371 valadoc_content_source_code_set_highlighted_code (self, g_value_get_object (value));
1372 break;
1373 case VALADOC_CONTENT_SOURCE_CODE_LANGUAGE_PROPERTY:
1374 valadoc_content_source_code_set_language (self, g_value_get_enum (value));
1375 break;
1376 default:
1377 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1378 break;
1379 }
1380 }
1381
1382 static void
_vala_array_destroy(gpointer array,gint array_length,GDestroyNotify destroy_func)1383 _vala_array_destroy (gpointer array,
1384 gint array_length,
1385 GDestroyNotify destroy_func)
1386 {
1387 if ((array != NULL) && (destroy_func != NULL)) {
1388 gint i;
1389 for (i = 0; i < array_length; i = i + 1) {
1390 if (((gpointer*) array)[i] != NULL) {
1391 destroy_func (((gpointer*) array)[i]);
1392 }
1393 }
1394 }
1395 }
1396
1397 static void
_vala_array_free(gpointer array,gint array_length,GDestroyNotify destroy_func)1398 _vala_array_free (gpointer array,
1399 gint array_length,
1400 GDestroyNotify destroy_func)
1401 {
1402 _vala_array_destroy (array, array_length, destroy_func);
1403 g_free (array);
1404 }
1405
1406 static gint
_vala_array_length(gpointer array)1407 _vala_array_length (gpointer array)
1408 {
1409 gint length;
1410 length = 0;
1411 if (array) {
1412 while (((gpointer*) array)[length]) {
1413 length++;
1414 }
1415 }
1416 return length;
1417 }
1418
1419