]> git.pld-linux.org Git - packages/valadoc.git/blob - vala-0.32.patch
- add support for vala 0.32 from upstream
[packages/valadoc.git] / vala-0.32.patch
1 From 5863c16c6585be9e29621b1c061817fc8b4ef6d3 Mon Sep 17 00:00:00 2001
2 From: Rico Tzschichholz <ricotz@ubuntu.com>
3 Date: Fri, 27 Nov 2015 17:03:21 +0100
4 Subject: driver: Add support for vala-0.32
5
6 ---
7  configure.ac                              |    4 +
8  src/driver/0.32.x/Makefile.am             |   72 ++
9  src/driver/0.32.x/driver.vala             |   70 ++
10  src/driver/0.32.x/girwriter.vala          |  204 ++++
11  src/driver/0.32.x/initializerbuilder.vala |  669 +++++++++++++
12  src/driver/0.32.x/symbolresolver.vala     |  323 ++++++
13  src/driver/0.32.x/treebuilder.vala        | 1524 +++++++++++++++++++++++++++++
14  src/driver/Makefile.am                    |    5 +
15  src/libvaladoc/moduleloader.vala          |    3 +-
16  tests/Makefile.am                         |    1 +
17  tests/drivers/driver-0-32.vala            |    6 +
18  11 files changed, 2880 insertions(+), 1 deletion(-)
19  create mode 100644 src/driver/0.32.x/Makefile.am
20  create mode 100644 src/driver/0.32.x/driver.vala
21  create mode 100644 src/driver/0.32.x/girwriter.vala
22  create mode 100644 src/driver/0.32.x/initializerbuilder.vala
23  create mode 100644 src/driver/0.32.x/symbolresolver.vala
24  create mode 100644 src/driver/0.32.x/treebuilder.vala
25  create mode 100644 tests/drivers/driver-0-32.vala
26
27 diff --git a/configure.ac b/configure.ac
28 index ff0b2c9..cd7b619 100644
29 --- a/configure.ac
30 +++ b/configure.ac
31 @@ -80,6 +80,9 @@ AM_CONDITIONAL(HAVE_CGRAPH, test "$have_cgraph" = "yes")
32  ## Drivers:
33  ##
34  
35 +PKG_CHECK_MODULES(LIBVALA_0_32_X, libvala-0.32 > 0.26.0, have_libvala_0_32_x="yes", have_libvala_0_32_x="no")
36 +AM_CONDITIONAL(HAVE_LIBVALA_0_32_X, test "$have_libvala_0_32_x" = "yes")
37 +
38  PKG_CHECK_MODULES(LIBVALA_0_30_X, libvala-0.30 > 0.26.0, have_libvala_0_30_x="yes", have_libvala_0_30_x="no")
39  AM_CONDITIONAL(HAVE_LIBVALA_0_30_X, test "$have_libvala_0_30_x" = "yes")
40  
41 @@ -114,6 +117,7 @@ src/driver/0.24.x/Makefile
42  src/driver/0.26.x/Makefile
43  src/driver/0.28.x/Makefile
44  src/driver/0.30.x/Makefile
45 +src/driver/0.32.x/Makefile
46  src/doclets/Makefile
47  src/doclets/html/Makefile
48  src/doclets/devhelp/Makefile
49 diff --git a/src/driver/0.32.x/Makefile.am b/src/driver/0.32.x/Makefile.am
50 new file mode 100644
51 index 0000000..3803a69
52 --- /dev/null
53 +++ b/src/driver/0.32.x/Makefile.am
54 @@ -0,0 +1,72 @@
55 +NULL =
56 +
57 +VERSIONED_VAPI_DIR = $(shell pkg-config libvala-0.32 --variable vapidir)
58 +
59 +AM_CFLAGS = \
60 +       -DPACKAGE_ICONDIR=\"$(datadir)/valadoc/icons/\" \
61 +       -I $(top_builddir)/src/libvaladoc/ \
62 +       $(GLIB_CFLAGS) \
63 +       $(LIBGEE_CFLAGS) \
64 +       $(LIBGVC_CFLAGS) \
65 +       $(LIBVALA_0_32_X_CFLAGS) \
66 +       -g \
67 +       -w \
68 +       $(NULL)
69 +
70 +AM_VALAFLAGS = \
71 +       $(VALAFLAGS) \
72 +       --vapidir $(VERSIONED_VAPI_DIR) \
73 +       --vapidir $(top_srcdir)/src/vapi \
74 +       --vapidir $(top_srcdir)/src/libvaladoc \
75 +       --basedir $(srcdir) \
76 +       --directory $(builddir) \
77 +       -C \
78 +       -g \
79 +       $(NULL)
80 +
81 +BUILT_SOURCES = libdriver.vala.stamp
82 +
83 +driver_LTLIBRARIES = libdriver.la
84 +
85 +driverdir = $(libdir)/valadoc/drivers/0.32.x
86 +
87 +libdriver_la_LDFLAGS = -module -avoid-version -no-undefined
88 +
89 +libdriver_la_VALASOURCES = \
90 +       initializerbuilder.vala \
91 +       symbolresolver.vala \
92 +       treebuilder.vala \
93 +       girwriter.vala \
94 +       driver.vala \
95 +       $(NULL)
96 +
97 +nodist_libdriver_la_SOURCES = \
98 +       $(libdriver_la_VALASOURCES:.vala=.c) \
99 +       $(NULL)
100 +
101 +libdriver.vala.stamp: $(libdriver_la_VALASOURCES) Makefile
102 +       $(VALAC) \
103 +               $(AM_VALAFLAGS) \
104 +               --pkg libvala-0.32 \
105 +               --pkg gee-0.8 \
106 +               --pkg valadoc-1.0 \
107 +               $(filter %.vala %.c,$^)
108 +       touch $@
109 +
110 +libdriver_la_LIBADD = \
111 +       $(top_builddir)/src/libvaladoc/libvaladoc.la \
112 +       $(GLIB_LIBS) \
113 +       $(LIBVALA_0_32_X_LIBS) \
114 +       $(LIBGEE_LIBS) \
115 +       $(LIBGVC_LIBS) \
116 +       $(NULL)
117 +
118 +EXTRA_DIST = \
119 +       $(libdriver_la_VALASOURCES) \
120 +       $(NULL)
121 +
122 +CLEANFILES = \
123 +       $(BUILT_SOURCES) \
124 +       $(nodist_libdriver_la_SOURCES) \
125 +       $(NULL)
126 +
127 diff --git a/src/driver/0.32.x/driver.vala b/src/driver/0.32.x/driver.vala
128 new file mode 100644
129 index 0000000..902d28d
130 --- /dev/null
131 +++ b/src/driver/0.32.x/driver.vala
132 @@ -0,0 +1,70 @@
133 +/* driver.vala
134 + *
135 + * Copyright (C) 2011  Florian Brosch
136 + *
137 + * This library is free software; you can redistribute it and/or
138 + * modify it under the terms of the GNU Lesser General Public
139 + * License as published by the Free Software Foundation; either
140 + * version 2.1 of the License, or (at your option) any later version.
141 + *
142 + * This library is distributed in the hope that it will be useful,
143 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
144 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
145 + * Lesser General Public License for more details.
146 + *
147 + * You should have received a copy of the GNU Lesser General Public
148 + * License along with this library; if not, write to the Free Software
149 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
150 + *
151 + * Author:
152 + *     Florian Brosch <flo.brosch@gmail.com>
153 + */
154 +
155 +using Valadoc.Api;
156 +using Gee;
157 +
158 +
159 +
160 +/**
161 + * Creates an simpler, minimized, more abstract AST for valacs AST.
162 + */
163 +public class Valadoc.Drivers.Driver : Object, Valadoc.Driver {
164 +       private SymbolResolver resolver;
165 +       private Api.Tree? tree;
166 +
167 +       public void write_gir (Settings settings, ErrorReporter reporter) {
168 +               var gir_writer = new Drivers.GirWriter (resolver);
169 +
170 +               // put .gir file in current directory unless -d has been explicitly specified
171 +               string gir_directory = ".";
172 +               if (settings.gir_directory != null) {
173 +                       gir_directory = settings.gir_directory;
174 +               }
175 +
176 +               gir_writer.write_file ((Vala.CodeContext) tree.data,
177 +                                                          gir_directory,
178 +                                                          "%s-%s.gir".printf (settings.gir_namespace, settings.gir_version),
179 +                                                          settings.gir_namespace,
180 +                                                          settings.gir_version,
181 +                                                          settings.pkg_name);
182 +       }
183 +
184 +       public Api.Tree? build (Settings settings, ErrorReporter reporter) {
185 +               TreeBuilder builder = new TreeBuilder ();
186 +               tree = builder.build (settings, reporter);
187 +               if (reporter.errors > 0) {
188 +                       return null;
189 +               }
190 +
191 +               resolver = new SymbolResolver (builder);
192 +               tree.accept (resolver);
193 +
194 +               return tree;
195 +       }
196 +}
197 +
198 +
199 +public Type register_plugin (Valadoc.ModuleLoader module_loader) {
200 +       return typeof (Valadoc.Drivers.Driver);
201 +}
202 +
203 diff --git a/src/driver/0.32.x/girwriter.vala b/src/driver/0.32.x/girwriter.vala
204 new file mode 100644
205 index 0000000..c250854
206 --- /dev/null
207 +++ b/src/driver/0.32.x/girwriter.vala
208 @@ -0,0 +1,204 @@
209 +/* girwriter.vala
210 + *
211 + * Copyright (C) 2011  Florian Brosch
212 + *
213 + * This library is free software; you can redistribute it and/or
214 + * modify it under the terms of the GNU Lesser General Public
215 + * License as published by the Free Software Foundation; either
216 + * version 2.1 of the License, or (at your option) any later version.
217 + *
218 + * This library is distributed in the hope that it will be useful,
219 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
220 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
221 + * Lesser General Public License for more details.
222 + *
223 + * You should have received a copy of the GNU Lesser General Public
224 + * License along with this library; if not, write to the Free Software
225 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
226 + *
227 + * Author:
228 + *     Florian Brosch <flo.brosch@gmail.com>
229 + */
230 +
231 +
232 +using Valadoc.Api;
233 +
234 +
235 +/**
236 + * Code visitor generating .gir file for the public interface.
237 + */
238 +public class Valadoc.Drivers.GirWriter : Vala.GIRWriter {
239 +       private GtkdocRenderer renderer;
240 +       private SymbolResolver resolver;
241 +
242 +       public GirWriter (SymbolResolver resolver) {
243 +               this.renderer = new GtkdocRenderer ();
244 +               this.resolver = resolver;
245 +       }
246 +
247 +       private string? translate (Content.Comment? documentation) {
248 +               if (documentation == null) {
249 +                       return null;
250 +               }
251 +
252 +               renderer.render_symbol (documentation);
253 +
254 +               return MarkupWriter.escape (renderer.content);
255 +       }
256 +
257 +       private string? translate_taglet (Content.Taglet? taglet) {
258 +               if (taglet == null) {
259 +                       return null;
260 +               }
261 +
262 +               renderer.render_children (taglet);
263 +
264 +               return MarkupWriter.escape (renderer.content);
265 +       }
266 +
267 +       protected override string? get_interface_comment (Vala.Interface viface) {
268 +               Interface iface = resolver.resolve (viface) as Interface;
269 +               return translate (iface.documentation);
270 +       }
271 +
272 +       protected override string? get_struct_comment (Vala.Struct vst) {
273 +               Struct st = resolver.resolve (vst) as Struct;
274 +               return translate (st.documentation);
275 +       }
276 +
277 +       protected override string? get_enum_comment (Vala.Enum ven) {
278 +               Enum en = resolver.resolve (ven) as Enum;
279 +               return translate (en.documentation);
280 +       }
281 +
282 +       protected override string? get_class_comment (Vala.Class vc) {
283 +               Class c = resolver.resolve (vc) as Class;
284 +               return translate (c.documentation);
285 +       }
286 +
287 +       protected override string? get_error_code_comment (Vala.ErrorCode vecode) {
288 +               ErrorCode ecode = resolver.resolve (vecode) as ErrorCode;
289 +               return translate (ecode.documentation);
290 +       }
291 +
292 +       protected override string? get_enum_value_comment (Vala.EnumValue vev) {
293 +               Api.EnumValue ev = resolver.resolve (vev) as Api.EnumValue;
294 +               return translate (ev.documentation);
295 +       }
296 +
297 +       protected override string? get_constant_comment (Vala.Constant vc) {
298 +               Constant c = resolver.resolve (vc) as Constant;
299 +               return translate (c.documentation);
300 +       }
301 +
302 +       protected override string? get_error_domain_comment (Vala.ErrorDomain vedomain) {
303 +               ErrorDomain edomain = resolver.resolve (vedomain) as ErrorDomain;
304 +               return translate (edomain.documentation);
305 +       }
306 +
307 +       protected override string? get_field_comment (Vala.Field vf) {
308 +               Field f = resolver.resolve (vf) as Field;
309 +               return translate (f.documentation);
310 +       }
311 +
312 +       protected override string? get_delegate_comment (Vala.Delegate vcb) {
313 +               Delegate cb = resolver.resolve (vcb) as Delegate;
314 +               return translate (cb.documentation);
315 +       }
316 +
317 +       protected override string? get_method_comment (Vala.Method vm) {
318 +               Method m = resolver.resolve (vm) as Method;
319 +               return translate (m.documentation);
320 +       }
321 +
322 +       protected override string? get_property_comment (Vala.Property vprop) {
323 +               Property prop = resolver.resolve (vprop) as Property;
324 +               return translate (prop.documentation);
325 +       }
326 +
327 +       protected override string? get_delegate_return_comment (Vala.Delegate vcb) {
328 +               Delegate cb = resolver.resolve (vcb) as Delegate;
329 +               if (cb.documentation == null) {
330 +                       return null;
331 +               }
332 +
333 +               Content.Comment? documentation = cb.documentation;
334 +               if (documentation == null) {
335 +                       return null;
336 +               }
337 +
338 +               Gee.List<Content.Taglet> taglets = documentation.find_taglets (cb, typeof(Taglets.Return));
339 +               foreach (Content.Taglet taglet in taglets) {
340 +                       return translate_taglet (taglet);
341 +               }
342 +
343 +               return null;
344 +       }
345 +
346 +       protected override string? get_signal_return_comment (Vala.Signal vsig) {
347 +               Api.Signal sig = resolver.resolve (vsig) as Api.Signal;
348 +               if (sig.documentation == null) {
349 +                       return null;
350 +               }
351 +
352 +               Content.Comment? documentation = sig.documentation;
353 +               if (documentation == null) {
354 +                       return null;
355 +               }
356 +
357 +               Gee.List<Content.Taglet> taglets = documentation.find_taglets (sig, typeof(Taglets.Return));
358 +               foreach (Content.Taglet taglet in taglets) {
359 +                       return translate_taglet (taglet);
360 +               }
361 +
362 +               return null;
363 +       }
364 +
365 +       protected override string? get_method_return_comment (Vala.Method vm) {
366 +               Method m = resolver.resolve (vm) as Method;
367 +               if (m.documentation == null) {
368 +                       return null;
369 +               }
370 +
371 +               Content.Comment? documentation = m.documentation;
372 +               if (documentation == null) {
373 +                       return null;
374 +               }
375 +
376 +               Gee.List<Content.Taglet> taglets = documentation.find_taglets (m, typeof(Taglets.Return));
377 +               foreach (Content.Taglet taglet in taglets) {
378 +                       return translate_taglet (taglet);
379 +               }
380 +
381 +               return null;
382 +       }
383 +
384 +       protected override string? get_signal_comment (Vala.Signal vsig) {
385 +               Api.Signal sig = resolver.resolve (vsig) as Api.Signal;
386 +               return translate (sig.documentation);
387 +       }
388 +
389 +       protected override string? get_parameter_comment (Vala.Parameter param) {
390 +               Api.Symbol symbol = resolver.resolve (((Vala.Symbol) param.parent_symbol));
391 +               if (symbol == null) {
392 +                       return null;
393 +               }
394 +
395 +               Content.Comment? documentation = symbol.documentation;
396 +               if (documentation == null) {
397 +                       return null;
398 +               }
399 +
400 +               Gee.List<Content.Taglet> taglets = documentation.find_taglets (symbol, typeof(Taglets.Param));
401 +               foreach (Content.Taglet _taglet in taglets) {
402 +                       Taglets.Param taglet = (Taglets.Param) _taglet;
403 +                       if (taglet.parameter_name == param.name) {
404 +                               return translate_taglet (taglet);
405 +                       }
406 +               }
407 +
408 +               return null;
409 +       }
410 +}
411 +
412 +
413 diff --git a/src/driver/0.32.x/initializerbuilder.vala b/src/driver/0.32.x/initializerbuilder.vala
414 new file mode 100644
415 index 0000000..7b26ab5
416 --- /dev/null
417 +++ b/src/driver/0.32.x/initializerbuilder.vala
418 @@ -0,0 +1,669 @@
419 +/* initializerbuilder.vala
420 + *
421 + * Copyright (C) 2011  Florian Brosch
422 + *
423 + * This library is free software; you can redistribute it and/or
424 + * modify it under the terms of the GNU Lesser General Public
425 + * License as published by the Free Software Foundation; either
426 + * version 2.1 of the License, or (at your option) any later version.
427 + *
428 + * This library is distributed in the hope that it will be useful,
429 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
430 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
431 + * Lesser General Public License for more details.
432 + *
433 + * You should have received a copy of the GNU Lesser General Public
434 + * License along with this library; if not, write to the Free Software
435 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
436 + *
437 + * Author:
438 + *     Florian Brosch <flo.brosch@gmail.com>
439 + */
440 +
441 +
442 +using Valadoc.Content;
443 +using Gee;
444 +
445 +
446 +private class Valadoc.Api.InitializerBuilder : Vala.CodeVisitor {
447 +       private HashMap<Vala.Symbol, Symbol> symbol_map;
448 +       private SignatureBuilder signature;
449 +
450 +       private Symbol? resolve (Vala.Symbol symbol) {
451 +               return symbol_map.get (symbol);
452 +       }
453 +
454 +       private void write_node (Vala.Symbol vsymbol) {
455 +               signature.append_symbol (resolve (vsymbol));
456 +       }
457 +
458 +       private void write_type (Vala.DataType vsymbol) {
459 +               if (vsymbol.data_type != null) {
460 +                       write_node (vsymbol.data_type);
461 +               } else {
462 +                       signature.append_literal ("null");
463 +               }
464 +
465 +               var type_args = vsymbol.get_type_arguments ();
466 +               if (type_args.size > 0) {
467 +                       signature.append ("<");
468 +                       bool first = true;
469 +                       foreach (Vala.DataType type_arg in type_args) {
470 +                               if (!first) {
471 +                                       signature.append (",");
472 +                               } else {
473 +                                       first = false;
474 +                               }
475 +                               if (!type_arg.value_owned) {
476 +                                       signature.append_keyword ("weak");
477 +                               }
478 +                               signature.append (type_arg.to_qualified_string (null));
479 +                       }
480 +                       signature.append (">");
481 +               }
482 +
483 +               if (vsymbol.nullable) {
484 +                       signature.append ("?");
485 +               }
486 +       }
487 +
488 +       /**
489 +        * {@inheritDoc}
490 +        */
491 +       public override void visit_array_creation_expression (Vala.ArrayCreationExpression expr) {
492 +               signature.append_keyword ("new");
493 +               write_type (expr.element_type);
494 +               signature.append ("[", false);
495 +
496 +               bool first = true;
497 +               foreach (Vala.Expression size in expr.get_sizes ()) {
498 +                       if (!first) {
499 +                               signature.append (", ", false);
500 +                       }
501 +                       size.accept (this);
502 +                       first = false;
503 +               }
504 +
505 +               signature.append ("]", false);
506 +
507 +               if (expr.initializer_list != null) {
508 +                       signature.append (" ", false);
509 +                       expr.initializer_list.accept (this);
510 +               }
511 +       }
512 +
513 +       public InitializerBuilder (SignatureBuilder signature, HashMap<Vala.Symbol, Symbol> symbol_map) {
514 +               this.symbol_map = symbol_map;
515 +               this.signature = signature;
516 +       }
517 +
518 +       /**
519 +        * {@inheritDoc}
520 +        */
521 +       public override void visit_binary_expression (Vala.BinaryExpression expr) {
522 +               expr.left.accept (this);
523 +
524 +               switch (expr.operator) {
525 +               case Vala.BinaryOperator.PLUS:
526 +                       signature.append ("+ ");
527 +                       break;
528 +
529 +               case Vala.BinaryOperator.MINUS:
530 +                       signature.append ("- ");
531 +                       break;
532 +
533 +               case Vala.BinaryOperator.MUL:
534 +                       signature.append ("* ");
535 +                       break;
536 +
537 +               case Vala.BinaryOperator.DIV:
538 +                       signature.append ("/ ");
539 +                       break;
540 +
541 +               case Vala.BinaryOperator.MOD:
542 +                       signature.append ("% ");
543 +                       break;
544 +
545 +               case Vala.BinaryOperator.SHIFT_LEFT:
546 +                       signature.append ("<< ");
547 +                       break;
548 +
549 +               case Vala.BinaryOperator.SHIFT_RIGHT:
550 +                       signature.append (">> ");
551 +                       break;
552 +
553 +               case Vala.BinaryOperator.LESS_THAN:
554 +                       signature.append ("< ");
555 +                       break;
556 +
557 +               case Vala.BinaryOperator.GREATER_THAN:
558 +                       signature.append ("> ");
559 +                       break;
560 +
561 +               case Vala.BinaryOperator.LESS_THAN_OR_EQUAL:
562 +                       signature.append ("<= ");
563 +                       break;
564 +
565 +               case Vala.BinaryOperator.GREATER_THAN_OR_EQUAL:
566 +                       signature.append (">= ");
567 +                       break;
568 +
569 +               case Vala.BinaryOperator.EQUALITY:
570 +                       signature.append ("== ");
571 +                       break;
572 +
573 +               case Vala.BinaryOperator.INEQUALITY:
574 +                       signature.append ("!= ");
575 +                       break;
576 +
577 +               case Vala.BinaryOperator.BITWISE_AND:
578 +                       signature.append ("& ");
579 +                       break;
580 +
581 +               case Vala.BinaryOperator.BITWISE_OR:
582 +                       signature.append ("| ");
583 +                       break;
584 +
585 +               case Vala.BinaryOperator.BITWISE_XOR:
586 +                       signature.append ("^ ");
587 +                       break;
588 +
589 +               case Vala.BinaryOperator.AND:
590 +                       signature.append ("&& ");
591 +                       break;
592 +
593 +               case Vala.BinaryOperator.OR:
594 +                       signature.append ("|| ");
595 +                       break;
596 +
597 +               case Vala.BinaryOperator.IN:
598 +                       signature.append_keyword ("in");
599 +                       signature.append (" ");
600 +                       break;
601 +
602 +               case Vala.BinaryOperator.COALESCE:
603 +                       signature.append ("?? ");
604 +                       break;
605 +
606 +               default:
607 +                       assert_not_reached ();
608 +               }
609 +
610 +               expr.right.accept (this);
611 +       }
612 +
613 +       /**
614 +        * {@inheritDoc}
615 +        */
616 +       public override void visit_unary_expression (Vala.UnaryExpression expr) {
617 +               switch (expr.operator) {
618 +               case Vala.UnaryOperator.PLUS:
619 +                       signature.append ("+");
620 +                       break;
621 +
622 +               case Vala.UnaryOperator.MINUS:
623 +                       signature.append ("-");
624 +                       break;
625 +
626 +               case Vala.UnaryOperator.LOGICAL_NEGATION:
627 +                       signature.append ("!");
628 +                       break;
629 +
630 +               case Vala.UnaryOperator.BITWISE_COMPLEMENT:
631 +                       signature.append ("~");
632 +                       break;
633 +
634 +               case Vala.UnaryOperator.INCREMENT:
635 +                       signature.append ("++");
636 +                       break;
637 +
638 +               case Vala.UnaryOperator.DECREMENT:
639 +                       signature.append ("--");
640 +                       break;
641 +
642 +               case Vala.UnaryOperator.REF:
643 +                       signature.append_keyword ("ref");
644 +                       break;
645 +
646 +               case Vala.UnaryOperator.OUT:
647 +                       signature.append_keyword ("out");
648 +                       break;
649 +
650 +               default:
651 +                       assert_not_reached ();
652 +               }
653 +               expr.inner.accept (this);
654 +       }
655 +
656 +       /**
657 +        * {@inheritDoc}
658 +        */
659 +       public override void visit_assignment (Vala.Assignment a) {
660 +               a.left.accept (this);
661 +
662 +               switch (a.operator) {
663 +               case Vala.AssignmentOperator.SIMPLE:
664 +                       signature.append ("=");
665 +                       break;
666 +
667 +               case Vala.AssignmentOperator.BITWISE_OR:
668 +                       signature.append ("|");
669 +                       break;
670 +
671 +               case Vala.AssignmentOperator.BITWISE_AND:
672 +                       signature.append ("&");
673 +                       break;
674 +
675 +               case Vala.AssignmentOperator.BITWISE_XOR:
676 +                       signature.append ("^");
677 +                       break;
678 +
679 +               case Vala.AssignmentOperator.ADD:
680 +                       signature.append ("+");
681 +                       break;
682 +
683 +               case Vala.AssignmentOperator.SUB:
684 +                       signature.append ("-");
685 +                       break;
686 +
687 +               case Vala.AssignmentOperator.MUL:
688 +                       signature.append ("*");
689 +                       break;
690 +
691 +               case Vala.AssignmentOperator.DIV:
692 +                       signature.append ("/");
693 +                       break;
694 +
695 +               case Vala.AssignmentOperator.PERCENT:
696 +                       signature.append ("%");
697 +                       break;
698 +
699 +               case Vala.AssignmentOperator.SHIFT_LEFT:
700 +                       signature.append ("<<");
701 +                       break;
702 +
703 +               case Vala.AssignmentOperator.SHIFT_RIGHT:
704 +                       signature.append (">>");
705 +                       break;
706 +
707 +               default:
708 +                       assert_not_reached ();
709 +               }
710 +
711 +               a.right.accept (this);
712 +       }
713 +
714 +       /**
715 +        * {@inheritDoc}
716 +        */
717 +       public override void visit_cast_expression (Vala.CastExpression expr) {
718 +               if (expr.is_non_null_cast) {
719 +                       signature.append ("(!)");
720 +                       expr.inner.accept (this);
721 +                       return;
722 +               }
723 +
724 +               if (!expr.is_silent_cast) {
725 +                       signature.append ("(", false);
726 +                       write_type (expr.type_reference);
727 +                       signature.append (")", false);
728 +               }
729 +
730 +               expr.inner.accept (this);
731 +
732 +               if (expr.is_silent_cast) {
733 +                       signature.append_keyword ("as");
734 +                       write_type (expr.type_reference);
735 +               }
736 +       }
737 +
738 +       /**
739 +        * {@inheritDoc}
740 +        */
741 +       public override void visit_initializer_list (Vala.InitializerList list) {
742 +               signature.append ("{", false);
743 +
744 +               bool first = true;
745 +               foreach (Vala.Expression initializer in list.get_initializers ()) {
746 +                       if (!first) {
747 +                               signature.append (", ", false);
748 +                       }
749 +                       first = false;
750 +                       initializer.accept (this);
751 +               }
752 +
753 +               signature.append ("}", false);
754 +       }
755 +
756 +       /**
757 +        * {@inheritDoc}
758 +        */
759 +       public override void visit_member_access (Vala.MemberAccess expr) {
760 +               if (expr.symbol_reference != null) {
761 +                       expr.symbol_reference.accept (this);
762 +               } else {
763 +                       signature.append (expr.member_name);
764 +               }
765 +       }
766 +
767 +       /**
768 +        * {@inheritDoc}
769 +        */
770 +       public override void visit_element_access (Vala.ElementAccess expr) {
771 +               expr.container.accept (this);
772 +               signature.append ("[", false);
773 +
774 +               bool first = true;
775 +               foreach (Vala.Expression index in expr.get_indices ()) {
776 +                       if (!first) {
777 +                               signature.append (", ", false);
778 +                       }
779 +                       first = false;
780 +
781 +                       index.accept (this);
782 +               }
783 +
784 +               signature.append ("]", false);
785 +       }
786 +
787 +       /**
788 +        * {@inheritDoc}
789 +        */
790 +       public override void visit_pointer_indirection (Vala.PointerIndirection expr) {
791 +               signature.append ("*", false);
792 +               expr.inner.accept (this);
793 +       }
794 +
795 +       /**
796 +        * {@inheritDoc}
797 +        */
798 +       public override void visit_addressof_expression (Vala.AddressofExpression expr) {
799 +               signature.append ("&", false);
800 +               expr.inner.accept (this);
801 +       }
802 +
803 +       /**
804 +        * {@inheritDoc}
805 +        */
806 +       public override void visit_reference_transfer_expression (Vala.ReferenceTransferExpression expr) {
807 +               signature.append ("(", false).append_keyword ("owned", false).append (")", false);
808 +               expr.inner.accept (this);
809 +       }
810 +
811 +       /**
812 +        * {@inheritDoc}
813 +        */
814 +       public override void visit_type_check (Vala.TypeCheck expr) {
815 +               expr.expression.accept (this);
816 +               signature.append_keyword ("is");
817 +               write_type (expr.type_reference);
818 +       }
819 +
820 +       /**
821 +        * {@inheritDoc}
822 +        */
823 +       public override void visit_method_call (Vala.MethodCall expr) {
824 +               // symbol-name:
825 +               expr.call.symbol_reference.accept (this);
826 +
827 +               // parameters:
828 +               signature.append (" (", false);
829 +               bool first = true;
830 +               foreach (Vala.Expression literal in expr.get_argument_list ()) {
831 +                       if (!first) {
832 +                               signature.append (", ", false);
833 +                       }
834 +
835 +                       literal.accept (this);
836 +                       first = false;
837 +               }
838 +               signature.append (")", false);
839 +       }
840 +
841 +       /**
842 +        * {@inheritDoc}
843 +        */
844 +       public override void visit_slice_expression (Vala.SliceExpression expr) {
845 +               expr.container.accept (this);
846 +               signature.append ("[", false);
847 +               expr.start.accept (this);
848 +               signature.append (":", false);
849 +               expr.stop.accept (this);
850 +               signature.append ("]", false);
851 +       }
852 +
853 +       /**
854 +        * {@inheritDoc}
855 +        */
856 +       public override void visit_base_access (Vala.BaseAccess expr) {
857 +               signature.append_keyword ("base", false);
858 +       }
859 +
860 +       /**
861 +        * {@inheritDoc}
862 +        */
863 +       public override void visit_postfix_expression (Vala.PostfixExpression expr) {
864 +               expr.inner.accept (this);
865 +               if (expr.increment) {
866 +                       signature.append ("++", false);
867 +               } else {
868 +                       signature.append ("--", false);
869 +               }
870 +       }
871 +
872 +       /**
873 +        * {@inheritDoc}
874 +        */
875 +       public override void visit_object_creation_expression (Vala.ObjectCreationExpression expr) {
876 +               if (!expr.struct_creation) {
877 +                       signature.append_keyword ("new");
878 +               }
879 +
880 +               signature.append_symbol (resolve (expr.symbol_reference));
881 +
882 +               signature.append (" (", false);
883 +
884 +               //TODO: rm conditional space
885 +               bool first = true;
886 +               foreach (Vala.Expression arg in expr.get_argument_list ()) {
887 +                       if (!first) {
888 +                               signature.append (", ", false);
889 +                       }
890 +                       arg.accept (this);
891 +                       first = false;
892 +               }
893 +
894 +               signature.append (")", false);
895 +       }
896 +
897 +       /**
898 +        * {@inheritDoc}
899 +        */
900 +       public override void visit_sizeof_expression (Vala.SizeofExpression expr) {
901 +               signature.append_keyword ("sizeof", false).append (" (", false);
902 +               write_type (expr.type_reference);
903 +               signature.append (")", false);
904 +       }
905 +
906 +       /**
907 +        * {@inheritDoc}
908 +        */
909 +       public override void visit_typeof_expression (Vala.TypeofExpression expr) {
910 +               signature.append_keyword ("typeof", false).append (" (", false);
911 +               write_type (expr.type_reference);
912 +               signature.append (")", false);
913 +       }
914 +
915 +       /**
916 +        * {@inheritDoc}
917 +        */
918 +       public override void visit_lambda_expression (Vala.LambdaExpression expr) {
919 +               signature.append ("(", false);
920 +
921 +               bool first = true;
922 +               foreach (Vala.Parameter param in expr.get_parameters ()) {
923 +                       if (!first) {
924 +                               signature.append (", ", false);
925 +                       }
926 +                       signature.append (param.name, false);
927 +                       first = false;
928 +               }
929 +
930 +
931 +               signature.append (") => {", false);
932 +               signature.append_highlighted (" [...] ", false);
933 +               signature.append ("}", false);
934 +       }
935 +
936 +
937 +
938 +       /**
939 +        * {@inheritDoc}
940 +        */
941 +       public override void visit_boolean_literal (Vala.BooleanLiteral lit) {
942 +               signature.append_literal (lit.to_string (), false);
943 +       }
944 +
945 +       /**
946 +        * {@inheritDoc}
947 +        */
948 +       public override void visit_character_literal (Vala.CharacterLiteral lit) {
949 +               signature.append_literal (lit.to_string (), false);
950 +       }
951 +
952 +       /**
953 +        * {@inheritDoc}
954 +        */
955 +       public override void visit_integer_literal (Vala.IntegerLiteral lit) {
956 +               signature.append_literal (lit.to_string (), false);
957 +       }
958 +
959 +       /**
960 +        * {@inheritDoc}
961 +        */
962 +       public override void visit_real_literal (Vala.RealLiteral lit) {
963 +               signature.append_literal (lit.to_string (), false);
964 +       }
965 +
966 +       /**
967 +        * {@inheritDoc}
968 +        */
969 +       public override void visit_regex_literal (Vala.RegexLiteral lit) {
970 +               signature.append_literal (lit.to_string (), false);
971 +       }
972 +
973 +       /**
974 +        * {@inheritDoc}
975 +        */
976 +       public override void visit_string_literal (Vala.StringLiteral lit) {
977 +               signature.append_literal (lit.to_string (), false);
978 +       }
979 +
980 +       /**
981 +        * {@inheritDoc}
982 +        */
983 +       public override void visit_null_literal (Vala.NullLiteral lit) {
984 +               signature.append_literal (lit.to_string (), false);
985 +       }
986 +
987 +
988 +
989 +       /**
990 +        * {@inheritDoc}
991 +        */
992 +       public override void visit_field (Vala.Field field) {
993 +               write_node (field);
994 +       }
995 +
996 +       /**
997 +        * {@inheritDoc}
998 +        */
999 +       public override void visit_constant (Vala.Constant constant) {
1000 +               write_node (constant);
1001 +       }
1002 +
1003 +       /**
1004 +        * {@inheritDoc}
1005 +        */
1006 +       public override void visit_enum_value (Vala.EnumValue ev) {
1007 +               write_node (ev);
1008 +       }
1009 +
1010 +       /**
1011 +        * {@inheritDoc}
1012 +        */
1013 +       public override void visit_error_code (Vala.ErrorCode ec) {
1014 +               write_node (ec);
1015 +       }
1016 +
1017 +       /**
1018 +        * {@inheritDoc}
1019 +        */
1020 +       public override void visit_delegate (Vala.Delegate d) {
1021 +               write_node (d);
1022 +       }
1023 +
1024 +       /**
1025 +        * {@inheritDoc}
1026 +        */
1027 +       public override void visit_method (Vala.Method m) {
1028 +               write_node (m);
1029 +       }
1030 +
1031 +       /**
1032 +        * {@inheritDoc}
1033 +        */
1034 +       public override void visit_creation_method (Vala.CreationMethod m) {
1035 +               write_node (m);
1036 +       }
1037 +
1038 +       /**
1039 +        * {@inheritDoc}
1040 +        */
1041 +       public override void visit_signal (Vala.Signal sig) {
1042 +               write_node (sig);
1043 +       }
1044 +
1045 +       /**
1046 +        * {@inheritDoc}
1047 +        */
1048 +       public override void visit_class (Vala.Class c) {
1049 +               write_node (c);
1050 +       }
1051 +
1052 +       /**
1053 +        * {@inheritDoc}
1054 +        */
1055 +       public override void visit_struct (Vala.Struct s) {
1056 +               write_node (s);
1057 +       }
1058 +
1059 +       /**
1060 +        * {@inheritDoc}
1061 +        */
1062 +       public override void visit_interface (Vala.Interface i) {
1063 +               write_node (i);
1064 +       }
1065 +
1066 +       /**
1067 +        * {@inheritDoc}
1068 +        */
1069 +       public override void visit_enum (Vala.Enum en) {
1070 +               write_node (en);
1071 +       }
1072 +
1073 +       /**
1074 +        * {@inheritDoc}
1075 +        */
1076 +       public override void visit_error_domain (Vala.ErrorDomain ed) {
1077 +               write_node (ed);
1078 +       }
1079 +
1080 +       /**
1081 +        * {@inheritDoc}
1082 +        */
1083 +       public override void visit_property (Vala.Property prop) {
1084 +               write_node (prop);
1085 +       }
1086 +}
1087 +
1088 diff --git a/src/driver/0.32.x/symbolresolver.vala b/src/driver/0.32.x/symbolresolver.vala
1089 new file mode 100644
1090 index 0000000..4adc06b
1091 --- /dev/null
1092 +++ b/src/driver/0.32.x/symbolresolver.vala
1093 @@ -0,0 +1,323 @@
1094 +/* symbolresolver.vala
1095 + *
1096 + * Copyright (C) 2011  Florian Brosch
1097 + *
1098 + * This library is free software; you can redistribute it and/or
1099 + * modify it under the terms of the GNU Lesser General Public
1100 + * License as published by the Free Software Foundation; either
1101 + * version 2.1 of the License, or (at your option) any later version.
1102 + *
1103 + * This library is distributed in the hope that it will be useful,
1104 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1105 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1106 + * Lesser General Public License for more details.
1107 + *
1108 + * You should have received a copy of the GNU Lesser General Public
1109 + * License along with this library; if not, write to the Free Software
1110 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
1111 + *
1112 + * Author:
1113 + *     Florian Brosch <flo.brosch@gmail.com>
1114 + */
1115 +
1116 +using Valadoc.Api;
1117 +using Gee;
1118 +
1119 +
1120 +public class Valadoc.Drivers.SymbolResolver : Visitor {
1121 +       private HashMap<Vala.Symbol, Symbol> symbol_map;
1122 +       private Valadoc.Api.Class glib_error;
1123 +       private Api.Tree root;
1124 +
1125 +       public SymbolResolver (TreeBuilder builder) {
1126 +               this.symbol_map = builder.get_symbol_map ();
1127 +               this.glib_error = builder.get_glib_error ();
1128 +       }
1129 +
1130 +       public Symbol? resolve (Vala.Symbol symbol) {
1131 +               return symbol_map.get (symbol);
1132 +       }
1133 +
1134 +       private void resolve_thrown_list (Symbol symbol, Vala.List<Vala.DataType> types) {
1135 +               foreach (Vala.DataType type in types) {
1136 +                       Vala.ErrorDomain vala_edom = (Vala.ErrorDomain) type.data_type;
1137 +                       Symbol? edom = symbol_map.get (vala_edom);
1138 +                       symbol.add_child (edom ?? glib_error);
1139 +               }
1140 +       }
1141 +
1142 +       private void resolve_array_type_references (Api.Array ptr) {
1143 +               Api.Item data_type = ptr.data_type;
1144 +               if (data_type == null) {
1145 +                       // void
1146 +               } else if (data_type is Api.Array) {
1147 +                       resolve_array_type_references ((Api.Array) data_type);
1148 +               } else if (data_type is Pointer) {
1149 +                       resolve_pointer_type_references ((Api.Pointer) data_type);
1150 +               } else {
1151 +                       resolve_type_reference ((TypeReference) data_type);
1152 +               }
1153 +       }
1154 +
1155 +       private void resolve_pointer_type_references (Pointer ptr) {
1156 +               Api.Item type = ptr.data_type;
1157 +               if (type == null) {
1158 +                       // void
1159 +               } else if (type is Api.Array) {
1160 +                       resolve_array_type_references ((Api.Array) type);
1161 +               } else if (type is Pointer) {
1162 +                       resolve_pointer_type_references ((Pointer) type);
1163 +               } else {
1164 +                       resolve_type_reference ((TypeReference) type);
1165 +               }
1166 +       }
1167 +
1168 +       private void resolve_type_reference (TypeReference reference) {
1169 +               Vala.DataType vtyperef = (Vala.DataType) reference.data;
1170 +               if (vtyperef is Vala.ErrorType) {
1171 +                       Vala.ErrorDomain verrdom = ((Vala.ErrorType) vtyperef).error_domain;
1172 +                       if (verrdom != null) {
1173 +                               reference.data_type = resolve (verrdom);
1174 +                       } else {
1175 +                               reference.data_type = glib_error;
1176 +                       }
1177 +               } else if (vtyperef is Vala.DelegateType) {
1178 +                       reference.data_type = resolve (((Vala.DelegateType) vtyperef).delegate_symbol);
1179 +               } else if (vtyperef is Vala.GenericType) {
1180 +                       reference.data_type = resolve (((Vala.GenericType) vtyperef).type_parameter);
1181 +               } else if (vtyperef.data_type != null) {
1182 +                       reference.data_type = resolve (vtyperef.data_type);
1183 +               }
1184 +
1185 +               // Type parameters:
1186 +               foreach (TypeReference type_param_ref in reference.get_type_arguments ()) {
1187 +                       resolve_type_reference (type_param_ref);
1188 +               }
1189 +
1190 +               if (reference.data_type is Pointer) {
1191 +                       resolve_pointer_type_references ((Pointer)reference.data_type);
1192 +               } else if (reference.data_type is Api.Array) {
1193 +                       resolve_array_type_references ((Api.Array)reference.data_type);
1194 +               }
1195 +       }
1196 +
1197 +       /**
1198 +        * {@inheritDoc}
1199 +        */
1200 +       public override void visit_tree (Api.Tree item) {
1201 +               this.root = item;
1202 +               item.accept_children (this);
1203 +               this.root = null;
1204 +       }
1205 +
1206 +       /**
1207 +        * {@inheritDoc}
1208 +        */
1209 +       public override void visit_package (Package item) {
1210 +               item.accept_all_children (this, false);
1211 +       }
1212 +
1213 +       /**
1214 +        * {@inheritDoc}
1215 +        */
1216 +       public override void visit_namespace (Namespace item) {
1217 +               item.accept_all_children (this, false);
1218 +       }
1219 +
1220 +       /**
1221 +        * {@inheritDoc}
1222 +        */
1223 +       public override void visit_interface (Interface item) {
1224 +               Collection<TypeReference> interfaces = item.get_implemented_interface_list ();
1225 +               foreach (var type_ref in interfaces) {
1226 +                       resolve_type_reference (type_ref);
1227 +               }
1228 +
1229 +               if (item.base_type != null) {
1230 +                       resolve_type_reference (item.base_type);
1231 +               }
1232 +
1233 +               item.accept_all_children (this, false);
1234 +       }
1235 +
1236 +       /**
1237 +        * {@inheritDoc}
1238 +        */
1239 +       public override void visit_class (Class item) {
1240 +               Collection<TypeReference> interfaces = item.get_implemented_interface_list ();
1241 +               foreach (TypeReference type_ref in interfaces) {
1242 +                       resolve_type_reference (type_ref);
1243 +               }
1244 +
1245 +               if (item.base_type != null)     {
1246 +                       resolve_type_reference (item.base_type);
1247 +               }
1248 +
1249 +               item.accept_all_children (this, false);
1250 +       }
1251 +
1252 +       /**
1253 +        * {@inheritDoc}
1254 +        */
1255 +       public override void visit_struct (Struct item) {
1256 +               if (item.base_type != null) {
1257 +                       resolve_type_reference (item.base_type);
1258 +               }
1259 +
1260 +               item.accept_all_children (this, false);
1261 +       }
1262 +
1263 +       /**
1264 +        * {@inheritDoc}
1265 +        */
1266 +       public override void visit_property (Property item) {
1267 +               Vala.Property vala_property = item.data as Vala.Property;
1268 +               Vala.Property? base_vala_property = null;
1269 +
1270 +               if (vala_property.base_property != null) {
1271 +                       base_vala_property = vala_property.base_property;
1272 +               } else if (vala_property.base_interface_property != null) {
1273 +                       base_vala_property = vala_property.base_interface_property;
1274 +               }
1275 +               if (base_vala_property == vala_property && vala_property.base_interface_property != null) {
1276 +                       base_vala_property = vala_property.base_interface_property;
1277 +               }
1278 +               if (base_vala_property != null) {
1279 +                       item.base_property = (Property?) resolve (base_vala_property);
1280 +               }
1281 +
1282 +               resolve_type_reference (item.property_type);
1283 +               
1284 +               item.accept_all_children (this, false);
1285 +       }
1286 +
1287 +       /**
1288 +        * {@inheritDoc}
1289 +        */
1290 +       public override void visit_field (Field item) {
1291 +               resolve_type_reference (item.field_type);
1292 +
1293 +               item.accept_all_children (this, false);
1294 +       }
1295 +
1296 +       /**
1297 +        * {@inheritDoc}
1298 +        */
1299 +       public override void visit_constant (Constant item) {
1300 +               resolve_type_reference (item.constant_type);
1301 +
1302 +               item.accept_all_children (this, false);
1303 +       }
1304 +
1305 +       /**
1306 +        * {@inheritDoc}
1307 +        */
1308 +       public override void visit_delegate (Delegate item) {
1309 +               Vala.Delegate vala_delegate = item.data as Vala.Delegate;
1310 +
1311 +               resolve_type_reference (item.return_type);
1312 +
1313 +               resolve_thrown_list (item, vala_delegate.get_error_types ());
1314 +
1315 +               item.accept_all_children (this, false);
1316 +       }
1317 +
1318 +       /**
1319 +        * {@inheritDoc}
1320 +        */
1321 +       public override void visit_signal (Api.Signal item) {
1322 +               resolve_type_reference (item.return_type);
1323 +
1324 +               item.accept_all_children (this, false);
1325 +       }
1326 +
1327 +       /**
1328 +        * {@inheritDoc}
1329 +        */
1330 +       public override void visit_method (Method item) {
1331 +               Vala.Method vala_method = item.data as Vala.Method;
1332 +               Vala.Method? base_vala_method = null;
1333 +               if (vala_method.base_method != null) {
1334 +                       base_vala_method = vala_method.base_method;
1335 +               } else if (vala_method.base_interface_method != null) {
1336 +                       base_vala_method = vala_method.base_interface_method;
1337 +               }
1338 +               if (base_vala_method == vala_method && vala_method.base_interface_method != null) {
1339 +                       base_vala_method = vala_method.base_interface_method;
1340 +               }
1341 +               if (base_vala_method != null) {
1342 +                       item.base_method = (Method?) resolve (base_vala_method);
1343 +               }
1344 +
1345 +               resolve_thrown_list (item, vala_method.get_error_types ());
1346 +
1347 +               resolve_type_reference (item.return_type);
1348 +
1349 +               item.accept_all_children (this, false);
1350 +       }
1351 +
1352 +       /**
1353 +        * {@inheritDoc}
1354 +        */
1355 +       public override void visit_type_parameter (TypeParameter item) {
1356 +               item.accept_all_children (this, false);
1357 +       }
1358 +
1359 +       /**
1360 +        * {@inheritDoc}
1361 +        */
1362 +       public override void visit_formal_parameter (FormalParameter item) {
1363 +               if (item.ellipsis) {
1364 +                       return;
1365 +               }
1366 +
1367 +               if (((Vala.Parameter) item.data).initializer != null) {
1368 +                       SignatureBuilder signature = new SignatureBuilder ();
1369 +                       InitializerBuilder ibuilder = new InitializerBuilder (signature, symbol_map);
1370 +                       ((Vala.Parameter) item.data).initializer.accept (ibuilder);
1371 +                       item.default_value = signature.get ();
1372 +               }
1373 +
1374 +               resolve_type_reference (item.parameter_type);
1375 +               item.accept_all_children (this, false);
1376 +       }
1377 +
1378 +       /**
1379 +        * {@inheritDoc}
1380 +        */
1381 +       public override void visit_error_domain (ErrorDomain item) {
1382 +               item.accept_all_children (this, false);
1383 +       }
1384 +
1385 +       /**
1386 +        * {@inheritDoc}
1387 +        */
1388 +       public override void visit_error_code (ErrorCode item) {
1389 +               item.accept_all_children (this, false);
1390 +       }
1391 +
1392 +       /**
1393 +        * {@inheritDoc}
1394 +        */
1395 +       public override void visit_enum (Enum item) {
1396 +               item.accept_all_children (this, false);
1397 +       }
1398 +
1399 +       /**
1400 +        * {@inheritDoc}
1401 +        */
1402 +       public override void visit_enum_value (Api.EnumValue item) {
1403 +
1404 +               if (((Vala.EnumValue) item.data).value != null) {
1405 +                       SignatureBuilder signature = new SignatureBuilder ();
1406 +                       InitializerBuilder ibuilder = new InitializerBuilder (signature, symbol_map);
1407 +                       ((Vala.EnumValue) item.data).value.accept (ibuilder);
1408 +                       item.default_value = signature.get ();
1409 +               }
1410 +
1411 +               item.accept_all_children (this, false);
1412 +       }
1413 +}
1414 +
1415 +
1416 +
1417 diff --git a/src/driver/0.32.x/treebuilder.vala b/src/driver/0.32.x/treebuilder.vala
1418 new file mode 100644
1419 index 0000000..59e019a
1420 --- /dev/null
1421 +++ b/src/driver/0.32.x/treebuilder.vala
1422 @@ -0,0 +1,1524 @@
1423 +/* treebuilder.vala
1424 + *
1425 + * Copyright (C) 2011  Florian Brosch
1426 + *
1427 + * This library is free software; you can redistribute it and/or
1428 + * modify it under the terms of the GNU Lesser General Public
1429 + * License as published by the Free Software Foundation; either
1430 + * version 2.1 of the License, or (at your option) any later version.
1431 + *
1432 + * This library is distributed in the hope that it will be useful,
1433 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1434 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1435 + * Lesser General Public License for more details.
1436 + *
1437 + * You should have received a copy of the GNU Lesser General Public
1438 + * License along with this library; if not, write to the Free Software
1439 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
1440 + *
1441 + * Author:
1442 + *     Florian Brosch <flo.brosch@gmail.com>
1443 + */
1444 +
1445 +
1446 +using Valadoc.Api;
1447 +using Gee;
1448 +
1449 +
1450 +/**
1451 + * Creates an simpler, minimized, more abstract AST for valacs AST.
1452 + */
1453 +public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
1454 +       private ArrayList<PackageMetaData> packages = new ArrayList<PackageMetaData> ();
1455 +       private PackageMetaData source_package;
1456 +
1457 +       private HashMap<Vala.SourceFile, SourceFile> files = new HashMap<Vala.SourceFile, SourceFile> ();
1458 +       private HashMap<Vala.Symbol, Symbol> symbol_map = new HashMap<Vala.Symbol, Symbol> ();
1459 +
1460 +       private ErrorReporter reporter;
1461 +       private Settings settings;
1462 +
1463 +       private Api.Node current_node;
1464 +       private Api.Tree tree;
1465 +
1466 +       private Valadoc.Api.Class glib_error = null;
1467 +
1468 +
1469 +       //
1470 +       // Accessors
1471 +       //
1472 +
1473 +       public Api.Class get_glib_error () {
1474 +               return glib_error;
1475 +       }
1476 +
1477 +       public HashMap<Vala.Symbol, Symbol> get_symbol_map () {
1478 +               return symbol_map;
1479 +       }
1480 +
1481 +
1482 +       //
1483 +       //
1484 +       //
1485 +
1486 +       private class PackageMetaData {
1487 +               public Package package;
1488 +               public HashMap<Vala.Namespace, Namespace> namespaces = new HashMap<Vala.Namespace, Namespace> ();
1489 +               public ArrayList<Vala.SourceFile> files = new ArrayList<Vala.SourceFile> ();
1490 +
1491 +               public PackageMetaData (Package package) {
1492 +                       this.package = package;
1493 +               }
1494 +
1495 +               public Namespace get_namespace (Vala.Namespace vns, SourceFile file) {
1496 +                       Namespace? ns = namespaces.get (vns);
1497 +                       if (ns != null) {
1498 +                               return ns;
1499 +                       }
1500 +
1501 +                       // find documentation comment if existing:
1502 +                       SourceComment? comment = null;
1503 +                       if (vns.source_reference != null) {
1504 +                               foreach (Vala.Comment c in vns.get_comments()) {
1505 +                                       if (c.source_reference.file == file.data ||
1506 +                                               (c.source_reference.file.file_type == Vala.SourceFileType.SOURCE
1507 +                                                && ((Vala.SourceFile) file.data).file_type == Vala.SourceFileType.SOURCE)
1508 +                                       ) {
1509 +                                               Vala.SourceReference pos = c.source_reference;
1510 +                                               if (c is Vala.GirComment) {
1511 +                                                       comment = new GirSourceComment (c.content,
1512 +                                                                                                                       file,
1513 +                                                                                                                       pos.begin.line,
1514 +                                                                                                                       pos.begin.column,
1515 +                                                                                                                       pos.end.line,
1516 +                                                                                                                       pos.end.column);
1517 +                                               } else {
1518 +                                                       comment = new SourceComment (c.content,
1519 +                                                                                                                file,
1520 +                                                                                                                pos.begin.line,
1521 +                                                                                                                pos.begin.column,
1522 +                                                                                                                pos.end.line,
1523 +                                                                                                                pos.end.column);
1524 +                                               }
1525 +                                               break;
1526 +                                       }
1527 +                               }
1528 +                       }
1529 +
1530 +                       // find parent if existing
1531 +                       var parent_vns = vns.parent_symbol;
1532 +
1533 +                       if (parent_vns == null) {
1534 +                               ns = new Namespace (package, file, vns.name, comment, vns);
1535 +                               package.add_child (ns);
1536 +                       } else {
1537 +                               Namespace parent_ns = get_namespace ((Vala.Namespace) parent_vns, file);
1538 +                               ns = new Namespace (parent_ns, file, vns.name, comment, vns);
1539 +                               parent_ns.add_child (ns);
1540 +                       }
1541 +
1542 +                       namespaces.set (vns, ns);
1543 +                       return ns;
1544 +               }
1545 +
1546 +               public void register_source_file (Vala.SourceFile file) {
1547 +                       files.add (file);
1548 +               }
1549 +
1550 +               public bool is_package_for_file (Vala.SourceFile source_file) {
1551 +                       if (source_file.file_type == Vala.SourceFileType.SOURCE && !package.is_package) {
1552 +                               return true;
1553 +                       }
1554 +
1555 +                       return files.contains (source_file);
1556 +               }
1557 +       }
1558 +
1559 +
1560 +       //
1561 +       // Type constructor translation helpers:
1562 +       //
1563 +
1564 +       private Pointer create_pointer (Vala.PointerType vtyperef, Item parent, Api.Node caller) {
1565 +               Pointer ptr = new Pointer (parent, vtyperef);
1566 +
1567 +               Vala.DataType vntype = vtyperef.base_type;
1568 +               if (vntype is Vala.PointerType) {
1569 +                       ptr.data_type = create_pointer ((Vala.PointerType) vntype, ptr, caller);
1570 +               } else if (vntype is Vala.ArrayType) {
1571 +                       ptr.data_type = create_array ((Vala.ArrayType) vntype, ptr, caller);
1572 +               } else {
1573 +                       ptr.data_type = create_type_reference (vntype, ptr, caller);
1574 +               }
1575 +
1576 +               return ptr;
1577 +       }
1578 +
1579 +       private Api.Array create_array (Vala.ArrayType vtyperef, Item parent, Api.Node caller) {
1580 +               Api.Array arr = new Api.Array (parent, vtyperef);
1581 +
1582 +               Vala.DataType vntype = vtyperef.element_type;
1583 +               if (vntype is Vala.ArrayType) {
1584 +                       arr.data_type = create_type_reference (vntype, arr, caller);
1585 +               } else {
1586 +                       arr.data_type = create_type_reference (vntype, arr, caller);
1587 +               }
1588 +
1589 +               return arr;
1590 +       }
1591 +
1592 +       private TypeReference create_type_reference (Vala.DataType? vtyperef, Item parent, Api.Node caller) {
1593 +               bool is_nullable = vtyperef != null
1594 +                       && vtyperef.nullable
1595 +                       && !(vtyperef is Vala.GenericType)
1596 +                       && !(vtyperef is Vala.PointerType);
1597 +               string? signature = (vtyperef != null
1598 +                       && vtyperef.data_type != null)? Vala.GVariantModule.get_dbus_signature (vtyperef.data_type) : null;
1599 +               bool pass_ownership = type_reference_pass_ownership (vtyperef);
1600 +               Ownership ownership = get_type_reference_ownership (vtyperef);
1601 +               bool is_dynamic = vtyperef != null && vtyperef.is_dynamic;
1602 +
1603 +               TypeReference type_ref = new TypeReference (parent,
1604 +                                                                                                       ownership,
1605 +                                                                                                       pass_ownership,
1606 +                                                                                                       is_dynamic,
1607 +                                                                                                       is_nullable,
1608 +                                                                                                       signature,
1609 +                                                                                                       vtyperef);
1610 +
1611 +               if (vtyperef is Vala.PointerType) {
1612 +                       type_ref.data_type = create_pointer ((Vala.PointerType) vtyperef,  type_ref, caller);
1613 +               } else if (vtyperef is Vala.ArrayType) {
1614 +                       type_ref.data_type = create_array ((Vala.ArrayType) vtyperef,  type_ref, caller);
1615 +               //} else if (vtyperef is Vala.GenericType) {
1616 +               //      type_ref.data_type = new TypeParameter (caller,
1617 +               //                                                                                      caller.get_source_file (),
1618 +               //                                                                                      ((Vala.GenericType) vtyperef).type_parameter.name,
1619 +               //                                                                                      vtyperef);
1620 +               }
1621 +
1622 +               // type parameters:
1623 +               if (vtyperef != null) {
1624 +                       foreach (Vala.DataType vdtype in vtyperef.get_type_arguments ()) {
1625 +                               var type_param = create_type_reference (vdtype, type_ref, caller);
1626 +                               type_ref.add_type_argument (type_param);
1627 +                       }
1628 +               }
1629 +
1630 +               return type_ref;
1631 +       }
1632 +
1633 +
1634 +
1635 +       //
1636 +       // Translation helpers:
1637 +       //
1638 +
1639 +       private void process_attributes (Api.Symbol parent, GLib.List<Vala.Attribute> lst) {
1640 +               // attributes without arguments:
1641 +               string[] attributes = {
1642 +                               "ReturnsModifiedPointer",
1643 +                               "DestroysInstance",
1644 +                               "GenericAccessors",
1645 +                               "NoAccessorMethod",
1646 +                               "NoArrayLength",
1647 +                               "Experimental",
1648 +                               "Diagnostics",
1649 +                               "PrintfFormat",
1650 +                               "PointerType",
1651 +                               "ScanfFormat",
1652 +                               "ThreadLocal",
1653 +                               "SimpleType",
1654 +                               "HasEmitter",
1655 +                               "ModuleInit",
1656 +                               "NoWrapper",
1657 +                               "Immutable",
1658 +                               "ErrorBase",
1659 +                               "NoReturn",
1660 +                               "NoThrow",
1661 +                               "Compact",
1662 +                               "Assert",
1663 +                               "Flags"
1664 +                       };
1665 +
1666 +               string? tmp = "";
1667 +
1668 +               foreach (Vala.Attribute att in lst) {
1669 +                       if (att.name == "CCode" && (tmp = att.args.get ("has_target")) != null && tmp == "false") {
1670 +                               Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att);
1671 +                               new_attribute.add_boolean ("has_target", false, att);
1672 +                               parent.add_attribute (new_attribute);
1673 +                       } else if (att.name == "Deprecated") {
1674 +                               Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att);
1675 +                               parent.add_attribute (new_attribute);
1676 +                               if ((tmp = att.args.get ("since")) != null) {
1677 +                                       new_attribute.add_string ("since", tmp, att);
1678 +                               }
1679 +
1680 +                               if ((tmp = att.args.get ("replacement")) != null) {
1681 +                                       new_attribute.add_string ("replacement", tmp, att);
1682 +                               }
1683 +                       } else if (att.name in attributes) {
1684 +                               Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att);
1685 +                               parent.add_attribute (new_attribute);
1686 +                       }
1687 +               }
1688 +       }
1689 +
1690 +       private string? get_ccode_type_id (Vala.CodeNode node) {
1691 +               return Vala.CCodeBaseModule.get_ccode_type_id (node);
1692 +       }
1693 +
1694 +       private bool is_reference_counting (Vala.TypeSymbol sym) {
1695 +               return Vala.CCodeBaseModule.is_reference_counting (sym);
1696 +       }
1697 +
1698 +       private string? get_ref_function (Vala.Class sym) {
1699 +               return Vala.CCodeBaseModule.get_ccode_ref_function (sym);
1700 +       }
1701 +
1702 +       private string? get_unref_function (Vala.Class sym) {
1703 +               return Vala.CCodeBaseModule.get_ccode_unref_function (sym);
1704 +       }
1705 +
1706 +       private string? get_finalize_function_name (Vala.Class element) {
1707 +               if (!element.is_fundamental ()) {
1708 +                       return null;
1709 +               }
1710 +
1711 +               return "%s_finalize".printf (Vala.CCodeBaseModule.get_ccode_lower_case_name (element, null));
1712 +       }
1713 +
1714 +       private string? get_free_function_name (Vala.Class element) {
1715 +               if (!element.is_compact) {
1716 +                       return null;
1717 +               }
1718 +
1719 +               return Vala.CCodeBaseModule.get_ccode_free_function (element);
1720 +       }
1721 +
1722 +       private string? get_finish_name (Vala.Method m) {
1723 +               return Vala.CCodeBaseModule.get_ccode_finish_name (m);
1724 +       }
1725 +
1726 +       private string? get_take_value_function (Vala.Class sym) {
1727 +               return Vala.CCodeBaseModule.get_ccode_take_value_function (sym);
1728 +       }
1729 +
1730 +       private string? get_get_value_function (Vala.Class sym) {
1731 +               return Vala.CCodeBaseModule.get_ccode_get_value_function (sym);
1732 +       }
1733 +
1734 +       private string? get_set_value_function (Vala.Class sym) {
1735 +               return Vala.CCodeBaseModule.get_ccode_set_value_function (sym);
1736 +       }
1737 +
1738 +
1739 +       private string? get_param_spec_function (Vala.CodeNode sym) {
1740 +               return Vala.CCodeBaseModule.get_ccode_param_spec_function (sym);
1741 +       }
1742 +
1743 +       private string? get_dup_function (Vala.TypeSymbol sym) {
1744 +               return Vala.CCodeBaseModule.get_ccode_dup_function (sym);
1745 +       }
1746 +
1747 +       private string? get_copy_function (Vala.TypeSymbol sym) {
1748 +               return Vala.CCodeBaseModule.get_ccode_copy_function (sym);
1749 +       }
1750 +
1751 +       private string? get_destroy_function (Vala.TypeSymbol sym) {
1752 +               return Vala.CCodeBaseModule.get_ccode_destroy_function (sym);
1753 +       }
1754 +
1755 +       private string? get_free_function (Vala.TypeSymbol sym) {
1756 +               return Vala.CCodeBaseModule.get_ccode_free_function (sym);
1757 +       }
1758 +
1759 +       private string? get_nick (Vala.Property prop) {
1760 +               return Vala.CCodeBaseModule.get_ccode_nick (prop);
1761 +       }
1762 +
1763 +       private string? get_cname (Vala.Symbol symbol) {
1764 +               return Vala.CCodeBaseModule.get_ccode_name (symbol);
1765 +       }
1766 +
1767 +       private SourceComment? create_comment (Vala.Comment? comment) {
1768 +               if (comment != null) {
1769 +                       Vala.SourceReference pos = comment.source_reference;
1770 +                       SourceFile file = files.get (pos.file);
1771 +                       if (comment is Vala.GirComment) {
1772 +                               var tmp = new GirSourceComment (comment.content,
1773 +                                                                                               file,
1774 +                                                                                               pos.begin.line,
1775 +                                                                                               pos.begin.column,
1776 +                                                                                               pos.end.line,
1777 +                                                                                               pos.end.column);
1778 +                               if (((Vala.GirComment) comment).return_content != null) {
1779 +                                       Vala.SourceReference return_pos = ((Vala.GirComment) comment).return_content.source_reference;
1780 +                                       tmp.return_comment = new SourceComment (((Vala.GirComment) comment).return_content.content,
1781 +                                                                                                                       file,
1782 +                                                                                                                       return_pos.begin.line,
1783 +                                                                                                                       return_pos.begin.column,
1784 +                                                                                                                       return_pos.end.line,
1785 +                                                                                                                       return_pos.end.column);
1786 +                               }
1787 +
1788 +                               Vala.MapIterator<string, Vala.Comment> it = ((Vala.GirComment) comment).parameter_iterator ();
1789 +                               while (it.next ()) {
1790 +                                       Vala.Comment vala_param = it.get_value ();
1791 +                                       Vala.SourceReference param_pos = vala_param.source_reference;
1792 +                                       var param_comment = new SourceComment (vala_param.content,
1793 +                                                                                                                  file,
1794 +                                                                                                                  param_pos.begin.line,
1795 +                                                                                                                  param_pos.begin.column,
1796 +                                                                                                                  param_pos.end.line,
1797 +                                                                                                                  param_pos.end.column);
1798 +                                       tmp.add_parameter_content (it.get_key (), param_comment);
1799 +                               }
1800 +                               return tmp;
1801 +                       } else {
1802 +                               return new SourceComment (comment.content,
1803 +                                                                                 file,
1804 +                                                                                 pos.begin.line,
1805 +                                                                                 pos.begin.column,
1806 +                                                                                 pos.end.line,
1807 +                                                                                 pos.end.column);
1808 +                       }
1809 +               }
1810 +
1811 +               return null;
1812 +       }
1813 +
1814 +       private string get_method_name (Vala.Method element) {
1815 +               if (element is Vala.CreationMethod) {
1816 +                       if (element.name == ".new") {
1817 +                               return element.parent_symbol.name;
1818 +                       } else {
1819 +                               return element.parent_symbol.name + "." + element.name;
1820 +                       }
1821 +               }
1822 +
1823 +               return element.name;
1824 +       }
1825 +
1826 +       private string? get_quark_macro_name (Vala.ErrorDomain element) {
1827 +               return Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null);
1828 +       }
1829 +
1830 +       private string? get_private_cname (Vala.Class element) {
1831 +               if (element.is_compact) {
1832 +                       return null;
1833 +               }
1834 +
1835 +               string? cname = get_cname (element);
1836 +               return (cname != null)? cname + "Private" : null;
1837 +       }
1838 +
1839 +       private string? get_class_macro_name (Vala.Class element) {
1840 +               if (element.is_compact) {
1841 +                       return null;
1842 +               }
1843 +
1844 +               return "%s_GET_CLASS".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null));
1845 +       }
1846 +
1847 +       private string? get_class_type_macro_name (Vala.Class element) {
1848 +               if (element.is_compact) {
1849 +                       return null;
1850 +               }
1851 +
1852 +               return "%s_CLASS".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null));
1853 +       }
1854 +
1855 +       private string? get_is_type_macro_name (Vala.TypeSymbol element) {
1856 +               string? name = Vala.CCodeBaseModule.get_ccode_type_check_function (element);
1857 +               return (name != null && name != "")? name : null;
1858 +       }
1859 +
1860 +       private string? get_is_class_type_macro_name (Vala.TypeSymbol element) {
1861 +               string? name = get_is_type_macro_name (element);
1862 +               return (name != null)? name + "_CLASS" : null;
1863 +       }
1864 +
1865 +       private string? get_type_function_name (Vala.TypeSymbol element) {
1866 +               if ((element is Vala.Class
1867 +                       && ((Vala.Class) element).is_compact)
1868 +                       || element is Vala.ErrorDomain
1869 +                       || element is Vala.Delegate)
1870 +               {
1871 +                       return null;
1872 +               }
1873 +
1874 +               return "%s_get_type".printf (Vala.CCodeBaseModule.get_ccode_lower_case_name (element, null));
1875 +       }
1876 +
1877 +       private string? get_type_macro_name (Vala.TypeSymbol element) {
1878 +               if ((element is Vala.Class
1879 +                       && ((Vala.Class) element).is_compact)
1880 +                       || element is Vala.ErrorDomain
1881 +                       || element is Vala.Delegate)
1882 +               {
1883 +                       return null;
1884 +               }
1885 +
1886 +               return Vala.CCodeBaseModule.get_ccode_type_id (element);
1887 +       }
1888 +
1889 +       private string? get_type_cast_macro_name (Vala.TypeSymbol element) {
1890 +               if ((element is Vala.Class
1891 +                       && !((Vala.Class) element).is_compact)
1892 +                       || element is Vala.Interface)
1893 +               {
1894 +                       return Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null);
1895 +               } else {
1896 +                       return null;
1897 +               }
1898 +       }
1899 +
1900 +       private string? get_interface_macro_name (Vala.Interface element) {
1901 +               return "%s_GET_INTERFACE".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null));
1902 +       }
1903 +
1904 +       private string get_quark_function_name (Vala.ErrorDomain element) {
1905 +               return Vala.CCodeBaseModule.get_ccode_lower_case_prefix (element) + "quark";
1906 +       }
1907 +
1908 +       private PackageMetaData? get_package_meta_data (Package pkg) {
1909 +               foreach (PackageMetaData data in packages) {
1910 +                       if (data.package == pkg) {
1911 +                               return data;
1912 +                       }
1913 +               }
1914 +
1915 +               return null;
1916 +       }
1917 +
1918 +       private PackageMetaData register_package (Package package) {
1919 +               PackageMetaData meta_data = new PackageMetaData (package);
1920 +               tree.add_package (package);
1921 +               packages.add (meta_data);
1922 +               return meta_data;
1923 +       }
1924 +
1925 +       private SourceFile register_source_file (PackageMetaData meta_data, Vala.SourceFile source_file) {
1926 +               SourceFile file = new SourceFile (meta_data.package,
1927 +                                                                                 source_file.get_relative_filename (),
1928 +                                                                                 source_file.get_csource_filename (),
1929 +                                                                                 source_file);
1930 +               files.set (source_file, file);
1931 +
1932 +               meta_data.register_source_file (source_file);
1933 +               return file;
1934 +       }
1935 +
1936 +       private SourceFile? get_source_file (Vala.Symbol symbol) {
1937 +               Vala.SourceReference source_ref = symbol.source_reference;
1938 +               if (source_ref == null) {
1939 +                       return null;
1940 +               }
1941 +
1942 +               SourceFile? file = files.get (source_ref.file);
1943 +               assert (file != null);
1944 +               return file;
1945 +       }
1946 +
1947 +       private Package? find_package_for_file (Vala.SourceFile source_file) {
1948 +               foreach (PackageMetaData pkg in this.packages) {
1949 +                       if (pkg.is_package_for_file (source_file)) {
1950 +                               return pkg.package;
1951 +                       }
1952 +               }
1953 +
1954 +               return null;
1955 +       }
1956 +
1957 +
1958 +       private Namespace get_namespace (Package pkg, Vala.Symbol symbol, SourceFile? file) {
1959 +               // Find the closest namespace in our vala-tree
1960 +               Vala.Symbol namespace_symbol = symbol;
1961 +               while (!(namespace_symbol is Vala.Namespace)) {
1962 +                       namespace_symbol = namespace_symbol.parent_symbol;
1963 +               }
1964 +
1965 +               PackageMetaData? meta_data = get_package_meta_data (pkg);
1966 +               assert (meta_data != null);
1967 +
1968 +               return meta_data.get_namespace ((Vala.Namespace) namespace_symbol, file);
1969 +       }
1970 +
1971 +       private MethodBindingType get_method_binding_type (Vala.Method element) {
1972 +               if (element.is_inline) {
1973 +                       return MethodBindingType.INLINE;
1974 +               } else if (element.is_abstract) {
1975 +                       return MethodBindingType.ABSTRACT;
1976 +               } else if (element.is_virtual) {
1977 +                       return MethodBindingType.VIRTUAL;
1978 +               } else if (element.overrides) {
1979 +                       return MethodBindingType.OVERRIDE;
1980 +               } else if (element.is_inline) {
1981 +                       return MethodBindingType.INLINE;
1982 +               } else if (element.binding != Vala.MemberBinding.INSTANCE) {
1983 +                       return MethodBindingType.STATIC;
1984 +               }
1985 +               return MethodBindingType.UNMODIFIED;
1986 +       }
1987 +
1988 +
1989 +       private SymbolAccessibility get_access_modifier(Vala.Symbol symbol) {
1990 +               switch (symbol.access) {
1991 +               case Vala.SymbolAccessibility.PROTECTED:
1992 +                       return SymbolAccessibility.PROTECTED;
1993 +
1994 +               case Vala.SymbolAccessibility.INTERNAL:
1995 +                       return SymbolAccessibility.INTERNAL;
1996 +
1997 +               case Vala.SymbolAccessibility.PRIVATE:
1998 +                       return SymbolAccessibility.PRIVATE;
1999 +
2000 +               case Vala.SymbolAccessibility.PUBLIC:
2001 +                       return SymbolAccessibility.PUBLIC;
2002 +
2003 +               default:
2004 +                       error ("Unknown symbol accessibility modifier found");
2005 +               }
2006 +       }
2007 +
2008 +       private PropertyAccessorType get_property_accessor_type (Vala.PropertyAccessor element) {
2009 +               if (element.construction) {
2010 +                       if (element.writable) {
2011 +                               return (PropertyAccessorType.CONSTRUCT | PropertyAccessorType.SET);
2012 +                       }
2013 +                       return PropertyAccessorType.CONSTRUCT;
2014 +               } else if (element.writable) {
2015 +                       return PropertyAccessorType.SET;
2016 +               } else if (element.readable) {
2017 +                       return PropertyAccessorType.GET;
2018 +               }
2019 +
2020 +               error ("Unknown symbol accessibility type");
2021 +       }
2022 +
2023 +       private bool type_reference_pass_ownership (Vala.DataType? element) {
2024 +               if (element == null) {
2025 +                       return false;
2026 +               }
2027 +
2028 +               weak Vala.CodeNode? node = element.parent_node;
2029 +               if (node == null) {
2030 +                       return false;
2031 +               }
2032 +               if (node is Vala.Parameter) {
2033 +                       return (((Vala.Parameter)node).direction == Vala.ParameterDirection.IN &&
2034 +                               ((Vala.Parameter)node).variable_type.value_owned);
2035 +               }
2036 +               if (node is Vala.Property) {
2037 +                       return ((Vala.Property)node).property_type.value_owned;
2038 +               }
2039 +
2040 +               return false;
2041 +       }
2042 +
2043 +       private bool is_type_reference_unowned (Vala.DataType? element) {
2044 +                       if (element == null) {
2045 +                               return false;
2046 +                       }
2047 +
2048 +                       // non ref counted types are weak, not unowned
2049 +                       if (element.data_type is Vala.TypeSymbol
2050 +                               && is_reference_counting ((Vala.TypeSymbol) element.data_type) == true)
2051 +                       {
2052 +                               return false;
2053 +                       }
2054 +
2055 +                       // FormalParameters are weak by default
2056 +                       return (element.parent_node is Vala.Parameter == false)
2057 +                               ? element.is_weak ()
2058 +                               : false;
2059 +       }
2060 +
2061 +       private bool is_type_reference_owned (Vala.DataType? element) {
2062 +               if (element == null) {
2063 +                       return false;
2064 +               }
2065 +
2066 +               weak Vala.CodeNode parent = element.parent_node;
2067 +
2068 +               // parameter:
2069 +               if (parent is Vala.Parameter) {
2070 +                       if (((Vala.Parameter)parent).direction != Vala.ParameterDirection.IN) {
2071 +                               return false;
2072 +                       }
2073 +                       return ((Vala.Parameter)parent).variable_type.value_owned;
2074 +               }
2075 +
2076 +               return false;
2077 +       }
2078 +
2079 +       private bool is_type_reference_weak (Vala.DataType? element) {
2080 +               if (element == null) {
2081 +                       return false;
2082 +               }
2083 +
2084 +               // non ref counted types are unowned, not weak
2085 +               if (element.data_type is Vala.TypeSymbol
2086 +                       && is_reference_counting ((Vala.TypeSymbol) element.data_type) == false)
2087 +               {
2088 +                       return false;
2089 +               }
2090 +
2091 +               // arrays are unowned, not weak
2092 +               if (element is Vala.ArrayType) {
2093 +                       return false;
2094 +               }
2095 +
2096 +               // FormalParameters are weak by default
2097 +               return (element.parent_node is Vala.Parameter == false)? element.is_weak () : false;
2098 +       }
2099 +
2100 +       private Ownership get_type_reference_ownership (Vala.DataType? element) {
2101 +               if (is_type_reference_owned (element)) {
2102 +                       return Ownership.OWNED;
2103 +               } else if (is_type_reference_weak (element)) {
2104 +                       return Ownership.WEAK;
2105 +               } else if (is_type_reference_unowned (element)) {
2106 +                       return Ownership.UNOWNED;
2107 +               }
2108 +
2109 +               return Ownership.DEFAULT;
2110 +       }
2111 +
2112 +       private Ownership get_property_ownership (Vala.PropertyAccessor element) {
2113 +               if (element.value_type.value_owned) {
2114 +                       return Ownership.OWNED;
2115 +               }
2116 +
2117 +               // the exact type (weak, unowned) does not matter
2118 +               return Ownership.UNOWNED;
2119 +       }
2120 +
2121 +       private PropertyBindingType get_property_binding_type (Vala.Property element) {
2122 +               if (element.is_abstract) {
2123 +                       return PropertyBindingType.ABSTRACT;
2124 +               } else if (element.is_virtual) {
2125 +                       return PropertyBindingType.VIRTUAL;
2126 +               } else if (element.overrides) {
2127 +                       return PropertyBindingType.OVERRIDE;
2128 +               }
2129 +
2130 +               return PropertyBindingType.UNMODIFIED;
2131 +       }
2132 +
2133 +       private FormalParameterType get_formal_parameter_type (Vala.Parameter element) {
2134 +               if (element.direction == Vala.ParameterDirection.OUT) {
2135 +                       return FormalParameterType.OUT;
2136 +               } else if (element.direction == Vala.ParameterDirection.REF) {
2137 +                       return FormalParameterType.REF;
2138 +               } else if (element.direction == Vala.ParameterDirection.IN) {
2139 +                       return FormalParameterType.IN;
2140 +               }
2141 +
2142 +               error ("Unknown formal parameter type");
2143 +       }
2144 +
2145 +
2146 +       //
2147 +       // Vala tree creation:
2148 +       //
2149 +
2150 +       private string get_package_name (string path) {
2151 +               string file_name = Path.get_basename (path);
2152 +               return file_name.substring (0, file_name.last_index_of_char ('.'));
2153 +       }
2154 +
2155 +       private bool add_package (Vala.CodeContext context, string pkg) {
2156 +               // ignore multiple occurences of the same package
2157 +               if (context.has_package (pkg)) {
2158 +                       return true;
2159 +               }
2160 +
2161 +               string vapi_name = pkg + ".vapi";
2162 +               string gir_name = pkg + ".gir";
2163 +               foreach (string source_file in settings.source_files) {
2164 +                       string basename = Path.get_basename (source_file);
2165 +                       if (basename == vapi_name || basename == gir_name) {
2166 +                               return true;
2167 +                       }
2168 +               }
2169 +
2170 +
2171 +               var package_path = context.get_vapi_path (pkg) ?? context.get_gir_path (pkg);
2172 +               if (package_path == null) {
2173 +                       Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (pkg));
2174 +                       return false;
2175 +               }
2176 +
2177 +               context.add_package (pkg);
2178 +
2179 +               var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, package_path);
2180 +               context.add_source_file (vfile);
2181 +               Package vdpkg = new Package (pkg, true, null);
2182 +               register_source_file (register_package (vdpkg), vfile);
2183 +
2184 +               add_deps (context, Path.build_filename (Path.get_dirname (package_path), "%s.deps".printf (pkg)), pkg);
2185 +               return true;
2186 +       }
2187 +
2188 +       private void add_deps (Vala.CodeContext context, string file_path, string pkg_name) {
2189 +               if (FileUtils.test (file_path, FileTest.EXISTS)) {
2190 +                       try {
2191 +                               string deps_content;
2192 +                               ulong deps_len;
2193 +                               FileUtils.get_contents (file_path, out deps_content, out deps_len);
2194 +                               foreach (string dep in deps_content.split ("\n")) {
2195 +                                       dep = dep.strip ();
2196 +                                       if (dep != "") {
2197 +                                               if (!add_package (context, dep)) {
2198 +                                                       Vala.Report.error (null, "%s, dependency of %s, not found in specified Vala API directories".printf (dep, pkg_name));
2199 +                                               }
2200 +                                       }
2201 +                               }
2202 +                       } catch (FileError e) {
2203 +                               Vala.Report.error (null, "Unable to read dependency file: %s".printf (e.message));
2204 +                       }
2205 +               }
2206 +       }
2207 +
2208 +       /**
2209 +        * Adds the specified packages to the list of used packages.
2210 +        *
2211 +        * @param context The code context
2212 +        * @param packages a list of package names
2213 +        */
2214 +       private void add_depencies (Vala.CodeContext context, string[] packages) {
2215 +               foreach (string package in packages) {
2216 +                       if (!add_package (context, package)) {
2217 +                               Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (package));
2218 +                       }
2219 +               }
2220 +       }
2221 +
2222 +       /**
2223 +        * Add the specified source file to the context. Only .vala, .vapi, .gs,
2224 +        * and .c files are supported.
2225 +        */
2226 +       private void add_documented_files (Vala.CodeContext context, string[] sources) {
2227 +               if (sources == null) {
2228 +                       return;
2229 +               }
2230 +
2231 +               foreach (string source in sources) {
2232 +                       if (FileUtils.test (source, FileTest.EXISTS)) {
2233 +                               var rpath = realpath (source);
2234 +                               if (source.has_suffix (".vala") || source.has_suffix (".gs")) {
2235 +                                       var source_file = new Vala.SourceFile (context, Vala.SourceFileType.SOURCE, rpath);
2236 +
2237 +                                       if (source_package == null) {
2238 +                                               source_package = register_package (new Package (settings.pkg_name, false, null));
2239 +                                       }
2240 +
2241 +                                       register_source_file (source_package, source_file);
2242 +
2243 +                                       if (context.profile == Vala.Profile.GOBJECT) {
2244 +                                               // import the GLib namespace by default (namespace of backend-specific standard library)
2245 +                                               var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null));
2246 +                                               source_file.add_using_directive (ns_ref);
2247 +                                               context.root.add_using_directive (ns_ref);
2248 +                                       }
2249 +
2250 +                                       context.add_source_file (source_file);
2251 +                               } else if (source.has_suffix (".vapi") || source.has_suffix (".gir")) {
2252 +                                       string file_name = get_package_name (source);
2253 +
2254 +                                       var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, rpath);
2255 +                                       context.add_source_file (vfile);
2256 +
2257 +                                       if (source_package == null) {
2258 +                                               source_package = register_package (new Package (settings.pkg_name, false, null));
2259 +                                       }
2260 +
2261 +                                       register_source_file (source_package, vfile);
2262 +
2263 +                                       add_deps (context, Path.build_filename (Path.get_dirname (source), "%s.deps".printf (file_name)), file_name);
2264 +                               } else if (source.has_suffix (".c")) {
2265 +                                       context.add_c_source_file (rpath);
2266 +                                       tree.add_external_c_files (rpath);
2267 +                               } else {
2268 +                                       Vala.Report.error (null, "%s is not a supported source file type. Only .vala, .vapi, .gs, and .c files are supported.".printf (source));
2269 +                               }
2270 +                       } else {
2271 +                               Vala.Report.error (null, "%s not found".printf (source));
2272 +                       }
2273 +               }
2274 +       }
2275 +
2276 +       private Vala.CodeContext create_valac_tree (Settings settings) {
2277 +               // init context:
2278 +               var context = new Vala.CodeContext ();
2279 +               Vala.CodeContext.push (context);
2280 +
2281 +
2282 +               // settings:
2283 +               context.experimental = settings.experimental;
2284 +               context.experimental_non_null = settings.experimental || settings.experimental_non_null;
2285 +               context.vapi_directories = settings.vapi_directories;
2286 +               context.report.enable_warnings = settings.verbose;
2287 +               context.metadata_directories = settings.metadata_directories;
2288 +               context.gir_directories = settings.gir_directories;
2289 +
2290 +               if (settings.basedir == null) {
2291 +                       context.basedir = realpath (".");
2292 +               } else {
2293 +                       context.basedir = realpath (settings.basedir);
2294 +               }
2295 +
2296 +               if (settings.directory != null) {
2297 +                       context.directory = realpath (settings.directory);
2298 +               } else {
2299 +                       context.directory = context.basedir;
2300 +               }
2301 +
2302 +
2303 +               // add default packages:
2304 +               if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) {
2305 +                       context.profile = Vala.Profile.GOBJECT;
2306 +                       context.add_define ("GOBJECT");
2307 +               }
2308 +
2309 +
2310 +               if (settings.defines != null) {
2311 +                       foreach (string define in settings.defines) {
2312 +                               context.add_define (define);
2313 +                       }
2314 +               }
2315 +
2316 +               for (int i = 2; i <= 32; i += 2) {
2317 +                       context.add_define ("VALA_0_%d".printf (i));
2318 +               }
2319 +
2320 +               if (context.profile == Vala.Profile.GOBJECT) {
2321 +                       int glib_major = 2;
2322 +                       int glib_minor = 24;
2323 +
2324 +                       context.target_glib_major = glib_major;
2325 +                       context.target_glib_minor = glib_minor;
2326 +                       if (context.target_glib_major != 2) {
2327 +                               Vala.Report.error (null, "This version of valac only supports GLib 2");
2328 +                       }
2329 +
2330 +                       if (settings.target_glib != null && settings.target_glib.scanf ("%d.%d", out glib_major, out glib_minor) != 2) {
2331 +                               Vala.Report.error (null, "Invalid format for --target-glib");
2332 +                       }
2333 +
2334 +                       context.target_glib_major = glib_major;
2335 +                       context.target_glib_minor = glib_minor;
2336 +                       if (context.target_glib_major != 2) {
2337 +                               Vala.Report.error (null, "This version of valac only supports GLib 2");
2338 +                       }
2339 +
2340 +                       for (int i = 16; i <= glib_minor; i += 2) {
2341 +                               context.add_define ("GLIB_2_%d".printf (i));
2342 +                       }
2343 +
2344 +                       // default packages
2345 +                       if (!this.add_package (context, "glib-2.0")) { //
2346 +                               Vala.Report.error (null, "glib-2.0 not found in specified Vala API directories");
2347 +                       }
2348 +
2349 +                       if (!this.add_package (context, "gobject-2.0")) { //
2350 +                               Vala.Report.error (null, "gobject-2.0 not found in specified Vala API directories");
2351 +                       }
2352 +               }
2353 +
2354 +               // add user defined files:
2355 +               add_depencies (context, settings.packages);
2356 +               if (reporter.errors > 0) {
2357 +                       return context;
2358 +               }
2359 +
2360 +               add_documented_files (context, settings.source_files);
2361 +               if (reporter.errors > 0) {
2362 +                       return context;
2363 +               }
2364 +
2365 +
2366 +               // parse vala-code:
2367 +               Vala.Parser parser = new Vala.Parser ();
2368 +
2369 +               parser.parse (context);
2370 +               if (context.report.get_errors () > 0) {
2371 +                       return context;
2372 +               }
2373 +
2374 +               // parse gir:
2375 +               Vala.GirParser gir_parser = new Vala.GirParser ();
2376 +
2377 +               gir_parser.parse (context);
2378 +               if (context.report.get_errors () > 0) {
2379 +                       return context;
2380 +               }
2381 +
2382 +
2383 +
2384 +               // check context:
2385 +               context.check ();
2386 +               if (context.report.get_errors () > 0) {
2387 +                       return context;
2388 +               }
2389 +
2390 +               return context;
2391 +       }
2392 +
2393 +
2394 +
2395 +       //
2396 +       // Valadoc tree creation:
2397 +       //
2398 +
2399 +       private void process_children (Api.Node node, Vala.CodeNode element) {
2400 +               Api.Node old_node = current_node;
2401 +               current_node = node;
2402 +               element.accept_children (this);
2403 +               current_node = old_node;
2404 +       }
2405 +
2406 +       private Api.Node get_parent_node_for (Vala.Symbol element) {
2407 +               if (current_node != null) {
2408 +                       return current_node;
2409 +               }
2410 +
2411 +               Vala.SourceFile vala_source_file = element.source_reference.file;
2412 +               Package package = find_package_for_file (vala_source_file);
2413 +               SourceFile? source_file = get_source_file (element);
2414 +
2415 +               return get_namespace (package, element, source_file);
2416 +       }
2417 +
2418 +       /**
2419 +        * {@inheritDoc}
2420 +        */
2421 +       public override void visit_namespace (Vala.Namespace element) {
2422 +               element.accept_children (this);
2423 +       }
2424 +
2425 +       /**
2426 +        * {@inheritDoc}
2427 +        */
2428 +       public override void visit_class (Vala.Class element) {
2429 +               Api.Node parent = get_parent_node_for (element);
2430 +               SourceFile? file = get_source_file (element);
2431 +               SourceComment? comment = create_comment (element.comment);
2432 +
2433 +               bool is_basic_type = element.base_class == null && element.name == "string";
2434 +
2435 +               Class node = new Class (parent,
2436 +                                                               file,
2437 +                                                               element.name,
2438 +                                                               get_access_modifier (element),
2439 +                                                               comment,
2440 +                                                               get_cname (element),
2441 +                                                               get_private_cname (element),
2442 +                                                               get_class_macro_name (element),
2443 +                                                               get_type_macro_name (element),
2444 +                                                               get_is_type_macro_name (element),
2445 +                                                               get_type_cast_macro_name (element),
2446 +                                                               get_type_function_name (element),
2447 +                                                               get_class_type_macro_name (element),
2448 +                                                               get_is_class_type_macro_name (element),
2449 +                                                               Vala.GDBusModule.get_dbus_name (element),
2450 +                                                               get_ccode_type_id (element),
2451 +                                                               get_param_spec_function (element),
2452 +                                                               get_ref_function (element),
2453 +                                                               get_unref_function (element),
2454 +                                                               get_free_function_name (element),
2455 +                                                               get_finalize_function_name (element),
2456 +                                                               get_take_value_function (element),
2457 +                                                               get_get_value_function (element),
2458 +                                                               get_set_value_function (element),
2459 +                                                               element.is_fundamental (),
2460 +                                                               element.is_abstract,
2461 +                                                               is_basic_type,
2462 +                                                               element);
2463 +               symbol_map.set (element, node);
2464 +               parent.add_child (node);
2465 +
2466 +               // relations
2467 +               foreach (Vala.DataType vala_type_ref in element.get_base_types ()) {
2468 +                       var type_ref = create_type_reference (vala_type_ref, node, node);
2469 +
2470 +                       if (vala_type_ref.data_type is Vala.Interface) {
2471 +                               node.add_interface (type_ref);
2472 +                       } else if (vala_type_ref.data_type is Vala.Class) {
2473 +                               node.base_type = type_ref;
2474 +                       }
2475 +               }
2476 +
2477 +               process_attributes (node, element.attributes);
2478 +               process_children (node, element);
2479 +
2480 +               // save GLib.Error
2481 +               if (glib_error == null && node.get_full_name () == "GLib.Error") {
2482 +                       glib_error = node;
2483 +               }
2484 +       }
2485 +
2486 +       /**
2487 +        * {@inheritDoc}
2488 +        */
2489 +       public override void visit_interface (Vala.Interface element) {
2490 +               Api.Node parent = get_parent_node_for (element);
2491 +               SourceFile? file = get_source_file (element);
2492 +               SourceComment? comment = create_comment (element.comment);
2493 +
2494 +               Interface node = new Interface (parent,
2495 +                                                                               file,
2496 +                                                                               element.name,
2497 +                                                                               get_access_modifier (element),
2498 +                                                                               comment,
2499 +                                                                               get_cname (element),
2500 +                                                                               get_type_macro_name (element),
2501 +                                                                               get_is_type_macro_name (element),
2502 +                                                                               get_type_cast_macro_name (element),
2503 +                                                                               get_type_function_name (element),
2504 +                                                                               get_interface_macro_name (element),
2505 +                                                                               Vala.GDBusModule.get_dbus_name (element),
2506 +                                                                               element);
2507 +               symbol_map.set (element, node);
2508 +               parent.add_child (node);
2509 +
2510 +               // prerequisites:
2511 +               foreach (Vala.DataType vala_type_ref in element.get_prerequisites ()) {
2512 +                       TypeReference type_ref = create_type_reference (vala_type_ref, node, node);
2513 +                       if (vala_type_ref.data_type is Vala.Interface) {
2514 +                               node.add_interface (type_ref);
2515 +                       } else {
2516 +                               node.base_type = type_ref;
2517 +                       }
2518 +               }
2519 +
2520 +               process_attributes (node, element.attributes);
2521 +               process_children (node, element);
2522 +       }
2523 +
2524 +       /**
2525 +        * {@inheritDoc}
2526 +        */
2527 +       public override void visit_struct (Vala.Struct element) {
2528 +               Api.Node parent = get_parent_node_for (element);
2529 +               SourceFile? file = get_source_file (element);
2530 +               SourceComment? comment = create_comment (element.comment);
2531 +
2532 +               bool is_basic_type = element.base_type == null
2533 +                       && (element.is_boolean_type ()
2534 +                       || element.is_floating_type ()
2535 +                       || element.is_integer_type ());
2536 +
2537 +               Struct node = new Struct (parent,
2538 +                                                                 file,
2539 +                                                                 element.name,
2540 +                                                                 get_access_modifier (element),
2541 +                                                                 comment,
2542 +                                                                 get_cname (element),
2543 +                                                                 get_type_macro_name (element),
2544 +                                                                 get_type_function_name (element),
2545 +                                                                 get_ccode_type_id (element),
2546 +                                                                 get_dup_function (element),
2547 +                                                                 get_copy_function (element),
2548 +                                                                 get_destroy_function (element),
2549 +                                                                 get_free_function (element),
2550 +                                                                 is_basic_type,
2551 +                                                                 element);
2552 +               symbol_map.set (element, node);
2553 +               parent.add_child (node);
2554 +
2555 +               // parent type:
2556 +               Vala.ValueType? basetype = element.base_type as Vala.ValueType;
2557 +               if (basetype != null) {
2558 +                       node.base_type = create_type_reference (basetype, node, node);
2559 +               }
2560 +
2561 +               process_attributes (node, element.attributes);
2562 +               process_children (node, element);
2563 +       }
2564 +
2565 +       /**
2566 +        * {@inheritDoc}
2567 +        */
2568 +       public override void visit_field (Vala.Field element) {
2569 +               Api.Node parent = get_parent_node_for (element);
2570 +               SourceFile? file = get_source_file (element);
2571 +               SourceComment? comment = create_comment (element.comment);
2572 +
2573 +               Field node = new Field (parent,
2574 +                                                               file,
2575 +                                                               element.name,
2576 +                                                               get_access_modifier (element),
2577 +                                                               comment,
2578 +                                                               get_cname (element),
2579 +                                                               element.binding == Vala.MemberBinding.STATIC,
2580 +                                                               element.is_volatile,
2581 +                                                               element);
2582 +               node.field_type = create_type_reference (element.variable_type, node, node);
2583 +               symbol_map.set (element, node);
2584 +               parent.add_child (node);
2585 +
2586 +               process_attributes (node, element.attributes);
2587 +               process_children (node, element);
2588 +       }
2589 +
2590 +       /**
2591 +        * {@inheritDoc}
2592 +        */
2593 +       public override void visit_property (Vala.Property element) {
2594 +               Api.Node parent = get_parent_node_for (element);
2595 +               SourceFile? file = get_source_file (element);
2596 +               SourceComment? comment = create_comment (element.comment);
2597 +
2598 +               Property node = new Property (parent,
2599 +                                                                         file,
2600 +                                                                         element.name,
2601 +                                                                         get_access_modifier (element),
2602 +                                                                         comment,
2603 +                                                                         get_nick (element),
2604 +                                                                         Vala.GDBusModule.get_dbus_name_for_member (element),
2605 +                                                                         Vala.GDBusModule.is_dbus_visible (element),
2606 +                                                                         get_property_binding_type (element),
2607 +                                                                         element);
2608 +               node.property_type = create_type_reference (element.property_type, node, node);
2609 +               symbol_map.set (element, node);
2610 +               parent.add_child (node);
2611 +
2612 +               // Process property type
2613 +               if (element.get_accessor != null) {
2614 +                       var accessor = element.get_accessor;
2615 +                       node.getter = new PropertyAccessor (node,
2616 +                                                                                               file,
2617 +                                                                                               element.name,
2618 +                                                                                               get_access_modifier (accessor),
2619 +                                                                                               get_cname (accessor),
2620 +                                                                                               get_property_accessor_type (accessor),
2621 +                                                                                               get_property_ownership (accessor),
2622 +                                                                                               accessor);
2623 +               }
2624 +
2625 +               if (element.set_accessor != null) {
2626 +                       var accessor = element.set_accessor;
2627 +                       node.setter = new PropertyAccessor (node,
2628 +                                                                                               file,
2629 +                                                                                               element.name,
2630 +                                                                                               get_access_modifier (accessor),
2631 +                                                                                               get_cname (accessor),
2632 +                                                                                               get_property_accessor_type (accessor),
2633 +                                                                                               get_property_ownership (accessor),
2634 +                                                                                               accessor);
2635 +               }
2636 +
2637 +               process_attributes (node, element.attributes);
2638 +               process_children (node, element);
2639 +       }
2640 +
2641 +       /**
2642 +        * {@inheritDoc}
2643 +        */
2644 +       public override void visit_creation_method (Vala.CreationMethod element) {
2645 +               Api.Node parent = get_parent_node_for (element);
2646 +               SourceFile? file = get_source_file (element);
2647 +               SourceComment? comment = create_comment (element.comment);
2648 +
2649 +               Method node = new Method (parent,
2650 +                                                                 file,
2651 +                                                                 get_method_name (element),
2652 +                                                                 get_access_modifier (element),
2653 +                                                                 comment,
2654 +                                                                 get_cname (element),
2655 +                                                                 Vala.GDBusModule.get_dbus_name_for_member (element),
2656 +                                                                 Vala.GDBusModule.dbus_result_name (element),
2657 +                                                                 (element.coroutine)? get_finish_name (element) : null,
2658 +                                                                 get_method_binding_type (element),
2659 +                                                                 element.coroutine,
2660 +                                                                 Vala.GDBusModule.is_dbus_visible (element),
2661 +                                                                 element is Vala.CreationMethod,
2662 +                                                                 element);
2663 +               node.return_type = create_type_reference (element.return_type, node, node);
2664 +               symbol_map.set (element, node);
2665 +               parent.add_child (node);
2666 +
2667 +               process_attributes (node, element.attributes);
2668 +               process_children (node, element);
2669 +       }
2670 +
2671 +       /**
2672 +        * {@inheritDoc}
2673 +        */
2674 +       public override void visit_method (Vala.Method element) {
2675 +               Api.Node parent = get_parent_node_for (element);
2676 +               SourceFile? file = get_source_file (element);
2677 +               SourceComment? comment = create_comment (element.comment);
2678 +
2679 +               Method node = new Method (parent,
2680 +                                                                 file,
2681 +                                                                 get_method_name (element),
2682 +                                                                 get_access_modifier (element),
2683 +                                                                 comment,
2684 +                                                                 get_cname (element),
2685 +                                                                 Vala.GDBusModule.get_dbus_name_for_member (element),
2686 +                                                                 Vala.GDBusModule.dbus_result_name (element),
2687 +                                                                 (element.coroutine)? get_finish_name (element) : null,
2688 +                                                                 get_method_binding_type (element),
2689 +                                                                 element.coroutine,
2690 +                                                                 Vala.GDBusModule.is_dbus_visible (element),
2691 +                                                                 element is Vala.CreationMethod,
2692 +                                                                 element);
2693 +               node.return_type = create_type_reference (element.return_type, node, node);
2694 +               symbol_map.set (element, node);
2695 +               parent.add_child (node);
2696 +
2697 +               process_attributes (node, element.attributes);
2698 +               process_children (node, element);
2699 +       }
2700 +
2701 +       /**
2702 +        * {@inheritDoc}
2703 +        */
2704 +       public override void visit_signal (Vala.Signal element) {
2705 +               Api.Node parent = get_parent_node_for (element);
2706 +               SourceFile? file = get_source_file (element);
2707 +               SourceComment? comment = create_comment (element.comment);
2708 +
2709 +               Api.Signal node = new Api.Signal (parent,
2710 +                                                                                 file,
2711 +                                                                                 element.name,
2712 +                                                                                 get_access_modifier (element),
2713 +                                                                                 comment,
2714 +                                                                                 get_cname (element),
2715 +                                                                                 (element.default_handler != null)? get_cname (element.default_handler) : null,
2716 +                                                                                 Vala.GDBusModule.get_dbus_name_for_member (element),
2717 +                                                                                 Vala.GDBusModule.is_dbus_visible (element),
2718 +                                                                                 element.is_virtual,
2719 +                                                                                 element);
2720 +               node.return_type = create_type_reference (element.return_type, node, node);
2721 +               symbol_map.set (element, node);
2722 +               parent.add_child (node);
2723 +
2724 +               process_attributes (node, element.attributes);
2725 +               process_children (node, element);
2726 +       }
2727 +
2728 +       /**
2729 +        * {@inheritDoc}
2730 +        */
2731 +       public override void visit_delegate (Vala.Delegate element) {
2732 +               Api.Node parent = get_parent_node_for (element);
2733 +               SourceFile? file = get_source_file (element);
2734 +               SourceComment? comment = create_comment (element.comment);
2735 +
2736 +               Delegate node = new Delegate (parent,
2737 +                                                                         file,
2738 +                                                                         element.name,
2739 +                                                                         get_access_modifier (element),
2740 +                                                                         comment,
2741 +                                                                         get_cname (element),
2742 +                                                                         !element.has_target,
2743 +                                                                         element);
2744 +               node.return_type = create_type_reference (element.return_type, node, node);
2745 +               symbol_map.set (element, node);
2746 +               parent.add_child (node);
2747 +
2748 +               process_attributes (node, element.attributes);
2749 +               process_children (node, element);
2750 +       }
2751 +
2752 +       /**
2753 +        * {@inheritDoc}
2754 +        */
2755 +       public override void visit_enum (Vala.Enum element) {
2756 +               Api.Node parent = get_parent_node_for (element);
2757 +               SourceFile? file = get_source_file (element);
2758 +               SourceComment? comment = create_comment (element.comment);
2759 +
2760 +               Symbol node = new Enum (parent,
2761 +                                                               file,
2762 +                                                               element.name,
2763 +                                                               get_access_modifier (element),
2764 +                                                               comment,
2765 +                                                               get_cname (element),
2766 +                                                               get_type_macro_name (element),
2767 +                                                               get_type_function_name (element),
2768 +                                                               element);
2769 +               symbol_map.set (element, node);
2770 +               parent.add_child (node);
2771 +
2772 +               process_attributes (node, element.attributes);
2773 +               process_children (node, element);
2774 +       }
2775 +
2776 +       /**
2777 +        * {@inheritDoc}
2778 +        */
2779 +       public override void visit_enum_value (Vala.EnumValue element) {
2780 +               Api.Enum parent = (Enum) get_parent_node_for (element);
2781 +               SourceFile? file = get_source_file (element);
2782 +               SourceComment? comment = create_comment (element.comment);
2783 +
2784 +               Symbol node = new Api.EnumValue (parent,
2785 +                                                                                file,
2786 +                                                                                element.name,
2787 +                                                                                comment,
2788 +                                                                                get_cname (element),
2789 +                                                                                element);
2790 +               symbol_map.set (element, node);
2791 +               parent.add_child (node);
2792 +
2793 +               process_attributes (node, element.attributes);
2794 +               process_children (node, element);
2795 +       }
2796 +
2797 +       /**
2798 +        * {@inheritDoc}
2799 +        */
2800 +       public override void visit_constant (Vala.Constant element) {
2801 +               Api.Node parent = get_parent_node_for (element);
2802 +               SourceFile? file = get_source_file (element);
2803 +               SourceComment? comment = create_comment (element.comment);
2804 +
2805 +               Constant node = new Constant (parent,
2806 +                                                                         file,
2807 +                                                                         element.name,
2808 +                                                                         get_access_modifier (element),
2809 +                                                                         comment,
2810 +                                                                         get_cname (element),
2811 +                                                                         element);
2812 +               node.constant_type = create_type_reference (element.type_reference, node, node);
2813 +               symbol_map.set (element, node);
2814 +               parent.add_child (node);
2815 +
2816 +               process_attributes (node, element.attributes);
2817 +               process_children (node, element);
2818 +       }
2819 +
2820 +       /**
2821 +        * {@inheritDoc}
2822 +        */
2823 +       public override void visit_error_domain (Vala.ErrorDomain element) {
2824 +               Api.Node parent = get_parent_node_for (element);
2825 +               SourceFile? file = get_source_file (element);
2826 +               SourceComment? comment = create_comment (element.comment);
2827 +
2828 +               Symbol node = new ErrorDomain (parent,
2829 +                                                                          file,
2830 +                                                                          element.name,
2831 +                                                                          get_access_modifier (element),
2832 +                                                                          comment,
2833 +                                                                          get_cname (element),
2834 +                                                                          get_quark_macro_name (element),
2835 +                                                                          get_quark_function_name (element),
2836 +                                                                          Vala.GDBusModule.get_dbus_name (element),
2837 +                                                                         element);
2838 +               symbol_map.set (element, node);
2839 +               parent.add_child (node);
2840 +
2841 +               process_attributes (node, element.attributes);
2842 +               process_children (node, element);
2843 +       }
2844 +
2845 +       /**
2846 +        * {@inheritDoc}
2847 +        */
2848 +       public override void visit_error_code (Vala.ErrorCode element) {
2849 +               Api.ErrorDomain parent = (ErrorDomain) get_parent_node_for (element);
2850 +               SourceFile? file = get_source_file (element);
2851 +               if (file == null) {
2852 +                       file = parent.get_source_file ();
2853 +               }
2854 +
2855 +               SourceComment? comment = create_comment (element.comment);
2856 +
2857 +               Symbol node = new Api.ErrorCode (parent,
2858 +                                                                                file,
2859 +                                                                                element.name,
2860 +                                                                                comment,
2861 +                                                                                get_cname (element),
2862 +                                                                                Vala.GDBusModule.get_dbus_name_for_member (element),
2863 +                                                                                element);
2864 +               symbol_map.set (element, node);
2865 +               parent.add_child (node);
2866 +
2867 +               process_attributes (node, element.attributes);
2868 +               process_children (node, element);
2869 +       }
2870 +
2871 +       /**
2872 +        * {@inheritDoc}
2873 +        */
2874 +       public override void visit_type_parameter (Vala.TypeParameter element) {
2875 +               Api.Node parent = get_parent_node_for (element);
2876 +               SourceFile? file = get_source_file (element);
2877 +
2878 +               Symbol node = new TypeParameter (parent,
2879 +                                                                                file,
2880 +                                                                                element.name,
2881 +                                                                                element);
2882 +               symbol_map.set (element, node);
2883 +               parent.add_child (node);
2884 +
2885 +               process_children (node, element);
2886 +       }
2887 +
2888 +       /**
2889 +        * {@inheritDoc}
2890 +        */
2891 +       public override void visit_formal_parameter (Vala.Parameter element) {
2892 +               Api.Node parent = get_parent_node_for (element);
2893 +               SourceFile? file = get_source_file (element);
2894 +
2895 +               FormalParameter node = new FormalParameter (parent,
2896 +                                                                                                       file,
2897 +                                                                                                       element.name,
2898 +                                                                                                       get_access_modifier(element),
2899 +                                                                                                       get_formal_parameter_type (element),
2900 +                                                                                                       element.ellipsis,
2901 +                                                                                                       element);
2902 +               node.parameter_type = create_type_reference (element.variable_type, node, node);
2903 +               parent.add_child (node);
2904 +
2905 +               process_children (node, element);
2906 +       }       
2907 +
2908 +
2909 +       //
2910 +       // startpoint:
2911 +       //
2912 +
2913 +       public Api.Tree? build (Settings settings, ErrorReporter reporter) {
2914 +               this.settings = settings;
2915 +               this.reporter = reporter;
2916 +
2917 +               this.tree = new Api.Tree (reporter, settings);
2918 +               var context = create_valac_tree (settings);
2919 +               this.tree.data = context;
2920 +
2921 +               reporter.warnings_offset = context.report.get_warnings ();
2922 +               reporter.errors_offset = context.report.get_errors ();
2923 +
2924 +               if (context == null) {
2925 +                       return null;
2926 +               }
2927 +
2928 +               // TODO: Register all packages here
2929 +               // register packages included by gir-files
2930 +               foreach (Vala.SourceFile vfile in context.get_source_files ()) {
2931 +                       if (vfile.file_type == Vala.SourceFileType.PACKAGE
2932 +                               && vfile.get_nodes ().size > 0
2933 +                               && files.has_key (vfile) == false)
2934 +                       {
2935 +                               Package vdpkg = new Package (get_package_name (vfile.filename), true, null);
2936 +                               register_source_file (register_package (vdpkg), vfile);
2937 +                       }
2938 +               }
2939 +
2940 +               context.accept(this);
2941 +
2942 +               return (reporter.errors == 0)? tree : null;
2943 +       }
2944 +}
2945 +
2946 +
2947 diff --git a/src/driver/Makefile.am b/src/driver/Makefile.am
2948 index 791fe8a..97d594a 100644
2949 --- a/src/driver/Makefile.am
2950 +++ b/src/driver/Makefile.am
2951 @@ -24,6 +24,10 @@ if HAVE_LIBVALA_0_30_X
2952  DRIVER_0_30_X_DIR = 0.30.x
2953  endif
2954  
2955 +if HAVE_LIBVALA_0_32_X
2956 +DRIVER_0_32_X_DIR = 0.32.x
2957 +endif
2958 +
2959  
2960  SUBDIRS = \
2961         $(DRIVER_0_20_X_DIR) \
2962 @@ -32,5 +36,6 @@ SUBDIRS = \
2963         $(DRIVER_0_26_X_DIR) \
2964         $(DRIVER_0_28_X_DIR) \
2965         $(DRIVER_0_30_X_DIR) \
2966 +       $(DRIVER_0_32_X_DIR) \
2967         $(NULL)
2968  
2969 diff --git a/src/libvaladoc/moduleloader.vala b/src/libvaladoc/moduleloader.vala
2970 index 69a3003..97cfb32 100644
2971 --- a/src/libvaladoc/moduleloader.vala
2972 +++ b/src/libvaladoc/moduleloader.vala
2973 @@ -160,7 +160,8 @@ public class Valadoc.ModuleLoader : Object {
2974                                 DriverMetaData (0, 23,  0, 24,  "0.24.x"),
2975                                 DriverMetaData (0, 25,  0, 26,  "0.26.x"),
2976                                 DriverMetaData (0, 27,  0, 28,  "0.28.x"),
2977 -                               DriverMetaData (0, 29,  0, 30,  "0.30.x")
2978 +                               DriverMetaData (0, 29,  0, 30,  "0.30.x"),
2979 +                               DriverMetaData (0, 31,  0, 32,  "0.32.x")
2980                         };
2981  
2982  
2983 diff --git a/tests/Makefile.am b/tests/Makefile.am
2984 index 62b6e72..2c9ccba 100644
2985 --- a/tests/Makefile.am
2986 +++ b/tests/Makefile.am
2987 @@ -29,6 +29,7 @@ TESTS = \
2988         drivers/driver-0-26.vala \
2989         drivers/driver-0-28.vala \
2990         drivers/driver-0-30.vala \
2991 +       drivers/driver-0-32.vala \
2992         $(NULL)
2993  
2994  check-TESTS: $(TESTS)
2995 diff --git a/tests/drivers/driver-0-32.vala b/tests/drivers/driver-0-32.vala
2996 new file mode 100644
2997 index 0000000..2125739
2998 --- /dev/null
2999 +++ b/tests/drivers/driver-0-32.vala
3000 @@ -0,0 +1,6 @@
3001 +
3002 +
3003 +public static void main () {
3004 +       test_driver ("../../src/driver/0.32.x/.libs");
3005 +}
3006 +
3007 -- 
3008 cgit v0.12
3009
This page took 0.670977 seconds and 3 git commands to generate.