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
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
27 diff --git a/configure.ac b/configure.ac
28 index ff0b2c9..cd7b619 100644
31 @@ -80,6 +80,9 @@ AM_CONDITIONAL(HAVE_CGRAPH, test "$have_cgraph" = "yes")
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")
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")
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
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
51 index 0000000..3803a69
53 +++ b/src/driver/0.32.x/Makefile.am
57 +VERSIONED_VAPI_DIR = $(shell pkg-config libvala-0.32 --variable vapidir)
60 + -DPACKAGE_ICONDIR=\"$(datadir)/valadoc/icons/\" \
61 + -I $(top_builddir)/src/libvaladoc/ \
65 + $(LIBVALA_0_32_X_CFLAGS) \
72 + --vapidir $(VERSIONED_VAPI_DIR) \
73 + --vapidir $(top_srcdir)/src/vapi \
74 + --vapidir $(top_srcdir)/src/libvaladoc \
75 + --basedir $(srcdir) \
76 + --directory $(builddir) \
81 +BUILT_SOURCES = libdriver.vala.stamp
83 +driver_LTLIBRARIES = libdriver.la
85 +driverdir = $(libdir)/valadoc/drivers/0.32.x
87 +libdriver_la_LDFLAGS = -module -avoid-version -no-undefined
89 +libdriver_la_VALASOURCES = \
90 + initializerbuilder.vala \
91 + symbolresolver.vala \
97 +nodist_libdriver_la_SOURCES = \
98 + $(libdriver_la_VALASOURCES:.vala=.c) \
101 +libdriver.vala.stamp: $(libdriver_la_VALASOURCES) Makefile
104 + --pkg libvala-0.32 \
106 + --pkg valadoc-1.0 \
107 + $(filter %.vala %.c,$^)
110 +libdriver_la_LIBADD = \
111 + $(top_builddir)/src/libvaladoc/libvaladoc.la \
113 + $(LIBVALA_0_32_X_LIBS) \
119 + $(libdriver_la_VALASOURCES) \
124 + $(nodist_libdriver_la_SOURCES) \
127 diff --git a/src/driver/0.32.x/driver.vala b/src/driver/0.32.x/driver.vala
129 index 0000000..902d28d
131 +++ b/src/driver/0.32.x/driver.vala
135 + * Copyright (C) 2011 Florian Brosch
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.
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.
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
152 + * Florian Brosch <flo.brosch@gmail.com>
161 + * Creates an simpler, minimized, more abstract AST for valacs AST.
163 +public class Valadoc.Drivers.Driver : Object, Valadoc.Driver {
164 + private SymbolResolver resolver;
165 + private Api.Tree? tree;
167 + public void write_gir (Settings settings, ErrorReporter reporter) {
168 + var gir_writer = new Drivers.GirWriter (resolver);
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;
176 + gir_writer.write_file ((Vala.CodeContext) tree.data,
178 + "%s-%s.gir".printf (settings.gir_namespace, settings.gir_version),
179 + settings.gir_namespace,
180 + settings.gir_version,
181 + settings.pkg_name);
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) {
191 + resolver = new SymbolResolver (builder);
192 + tree.accept (resolver);
199 +public Type register_plugin (Valadoc.ModuleLoader module_loader) {
200 + return typeof (Valadoc.Drivers.Driver);
203 diff --git a/src/driver/0.32.x/girwriter.vala b/src/driver/0.32.x/girwriter.vala
205 index 0000000..c250854
207 +++ b/src/driver/0.32.x/girwriter.vala
211 + * Copyright (C) 2011 Florian Brosch
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.
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.
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
228 + * Florian Brosch <flo.brosch@gmail.com>
236 + * Code visitor generating .gir file for the public interface.
238 +public class Valadoc.Drivers.GirWriter : Vala.GIRWriter {
239 + private GtkdocRenderer renderer;
240 + private SymbolResolver resolver;
242 + public GirWriter (SymbolResolver resolver) {
243 + this.renderer = new GtkdocRenderer ();
244 + this.resolver = resolver;
247 + private string? translate (Content.Comment? documentation) {
248 + if (documentation == null) {
252 + renderer.render_symbol (documentation);
254 + return MarkupWriter.escape (renderer.content);
257 + private string? translate_taglet (Content.Taglet? taglet) {
258 + if (taglet == null) {
262 + renderer.render_children (taglet);
264 + return MarkupWriter.escape (renderer.content);
267 + protected override string? get_interface_comment (Vala.Interface viface) {
268 + Interface iface = resolver.resolve (viface) as Interface;
269 + return translate (iface.documentation);
272 + protected override string? get_struct_comment (Vala.Struct vst) {
273 + Struct st = resolver.resolve (vst) as Struct;
274 + return translate (st.documentation);
277 + protected override string? get_enum_comment (Vala.Enum ven) {
278 + Enum en = resolver.resolve (ven) as Enum;
279 + return translate (en.documentation);
282 + protected override string? get_class_comment (Vala.Class vc) {
283 + Class c = resolver.resolve (vc) as Class;
284 + return translate (c.documentation);
287 + protected override string? get_error_code_comment (Vala.ErrorCode vecode) {
288 + ErrorCode ecode = resolver.resolve (vecode) as ErrorCode;
289 + return translate (ecode.documentation);
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);
297 + protected override string? get_constant_comment (Vala.Constant vc) {
298 + Constant c = resolver.resolve (vc) as Constant;
299 + return translate (c.documentation);
302 + protected override string? get_error_domain_comment (Vala.ErrorDomain vedomain) {
303 + ErrorDomain edomain = resolver.resolve (vedomain) as ErrorDomain;
304 + return translate (edomain.documentation);
307 + protected override string? get_field_comment (Vala.Field vf) {
308 + Field f = resolver.resolve (vf) as Field;
309 + return translate (f.documentation);
312 + protected override string? get_delegate_comment (Vala.Delegate vcb) {
313 + Delegate cb = resolver.resolve (vcb) as Delegate;
314 + return translate (cb.documentation);
317 + protected override string? get_method_comment (Vala.Method vm) {
318 + Method m = resolver.resolve (vm) as Method;
319 + return translate (m.documentation);
322 + protected override string? get_property_comment (Vala.Property vprop) {
323 + Property prop = resolver.resolve (vprop) as Property;
324 + return translate (prop.documentation);
327 + protected override string? get_delegate_return_comment (Vala.Delegate vcb) {
328 + Delegate cb = resolver.resolve (vcb) as Delegate;
329 + if (cb.documentation == null) {
333 + Content.Comment? documentation = cb.documentation;
334 + if (documentation == null) {
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);
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) {
352 + Content.Comment? documentation = sig.documentation;
353 + if (documentation == null) {
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);
365 + protected override string? get_method_return_comment (Vala.Method vm) {
366 + Method m = resolver.resolve (vm) as Method;
367 + if (m.documentation == null) {
371 + Content.Comment? documentation = m.documentation;
372 + if (documentation == null) {
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);
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);
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) {
395 + Content.Comment? documentation = symbol.documentation;
396 + if (documentation == null) {
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);
413 diff --git a/src/driver/0.32.x/initializerbuilder.vala b/src/driver/0.32.x/initializerbuilder.vala
415 index 0000000..7b26ab5
417 +++ b/src/driver/0.32.x/initializerbuilder.vala
419 +/* initializerbuilder.vala
421 + * Copyright (C) 2011 Florian Brosch
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.
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.
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
438 + * Florian Brosch <flo.brosch@gmail.com>
442 +using Valadoc.Content;
446 +private class Valadoc.Api.InitializerBuilder : Vala.CodeVisitor {
447 + private HashMap<Vala.Symbol, Symbol> symbol_map;
448 + private SignatureBuilder signature;
450 + private Symbol? resolve (Vala.Symbol symbol) {
451 + return symbol_map.get (symbol);
454 + private void write_node (Vala.Symbol vsymbol) {
455 + signature.append_symbol (resolve (vsymbol));
458 + private void write_type (Vala.DataType vsymbol) {
459 + if (vsymbol.data_type != null) {
460 + write_node (vsymbol.data_type);
462 + signature.append_literal ("null");
465 + var type_args = vsymbol.get_type_arguments ();
466 + if (type_args.size > 0) {
467 + signature.append ("<");
469 + foreach (Vala.DataType type_arg in type_args) {
471 + signature.append (",");
475 + if (!type_arg.value_owned) {
476 + signature.append_keyword ("weak");
478 + signature.append (type_arg.to_qualified_string (null));
480 + signature.append (">");
483 + if (vsymbol.nullable) {
484 + signature.append ("?");
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);
497 + foreach (Vala.Expression size in expr.get_sizes ()) {
499 + signature.append (", ", false);
501 + size.accept (this);
505 + signature.append ("]", false);
507 + if (expr.initializer_list != null) {
508 + signature.append (" ", false);
509 + expr.initializer_list.accept (this);
513 + public InitializerBuilder (SignatureBuilder signature, HashMap<Vala.Symbol, Symbol> symbol_map) {
514 + this.symbol_map = symbol_map;
515 + this.signature = signature;
521 + public override void visit_binary_expression (Vala.BinaryExpression expr) {
522 + expr.left.accept (this);
524 + switch (expr.operator) {
525 + case Vala.BinaryOperator.PLUS:
526 + signature.append ("+ ");
529 + case Vala.BinaryOperator.MINUS:
530 + signature.append ("- ");
533 + case Vala.BinaryOperator.MUL:
534 + signature.append ("* ");
537 + case Vala.BinaryOperator.DIV:
538 + signature.append ("/ ");
541 + case Vala.BinaryOperator.MOD:
542 + signature.append ("% ");
545 + case Vala.BinaryOperator.SHIFT_LEFT:
546 + signature.append ("<< ");
549 + case Vala.BinaryOperator.SHIFT_RIGHT:
550 + signature.append (">> ");
553 + case Vala.BinaryOperator.LESS_THAN:
554 + signature.append ("< ");
557 + case Vala.BinaryOperator.GREATER_THAN:
558 + signature.append ("> ");
561 + case Vala.BinaryOperator.LESS_THAN_OR_EQUAL:
562 + signature.append ("<= ");
565 + case Vala.BinaryOperator.GREATER_THAN_OR_EQUAL:
566 + signature.append (">= ");
569 + case Vala.BinaryOperator.EQUALITY:
570 + signature.append ("== ");
573 + case Vala.BinaryOperator.INEQUALITY:
574 + signature.append ("!= ");
577 + case Vala.BinaryOperator.BITWISE_AND:
578 + signature.append ("& ");
581 + case Vala.BinaryOperator.BITWISE_OR:
582 + signature.append ("| ");
585 + case Vala.BinaryOperator.BITWISE_XOR:
586 + signature.append ("^ ");
589 + case Vala.BinaryOperator.AND:
590 + signature.append ("&& ");
593 + case Vala.BinaryOperator.OR:
594 + signature.append ("|| ");
597 + case Vala.BinaryOperator.IN:
598 + signature.append_keyword ("in");
599 + signature.append (" ");
602 + case Vala.BinaryOperator.COALESCE:
603 + signature.append ("?? ");
607 + assert_not_reached ();
610 + expr.right.accept (this);
616 + public override void visit_unary_expression (Vala.UnaryExpression expr) {
617 + switch (expr.operator) {
618 + case Vala.UnaryOperator.PLUS:
619 + signature.append ("+");
622 + case Vala.UnaryOperator.MINUS:
623 + signature.append ("-");
626 + case Vala.UnaryOperator.LOGICAL_NEGATION:
627 + signature.append ("!");
630 + case Vala.UnaryOperator.BITWISE_COMPLEMENT:
631 + signature.append ("~");
634 + case Vala.UnaryOperator.INCREMENT:
635 + signature.append ("++");
638 + case Vala.UnaryOperator.DECREMENT:
639 + signature.append ("--");
642 + case Vala.UnaryOperator.REF:
643 + signature.append_keyword ("ref");
646 + case Vala.UnaryOperator.OUT:
647 + signature.append_keyword ("out");
651 + assert_not_reached ();
653 + expr.inner.accept (this);
659 + public override void visit_assignment (Vala.Assignment a) {
660 + a.left.accept (this);
662 + switch (a.operator) {
663 + case Vala.AssignmentOperator.SIMPLE:
664 + signature.append ("=");
667 + case Vala.AssignmentOperator.BITWISE_OR:
668 + signature.append ("|");
671 + case Vala.AssignmentOperator.BITWISE_AND:
672 + signature.append ("&");
675 + case Vala.AssignmentOperator.BITWISE_XOR:
676 + signature.append ("^");
679 + case Vala.AssignmentOperator.ADD:
680 + signature.append ("+");
683 + case Vala.AssignmentOperator.SUB:
684 + signature.append ("-");
687 + case Vala.AssignmentOperator.MUL:
688 + signature.append ("*");
691 + case Vala.AssignmentOperator.DIV:
692 + signature.append ("/");
695 + case Vala.AssignmentOperator.PERCENT:
696 + signature.append ("%");
699 + case Vala.AssignmentOperator.SHIFT_LEFT:
700 + signature.append ("<<");
703 + case Vala.AssignmentOperator.SHIFT_RIGHT:
704 + signature.append (">>");
708 + assert_not_reached ();
711 + a.right.accept (this);
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);
724 + if (!expr.is_silent_cast) {
725 + signature.append ("(", false);
726 + write_type (expr.type_reference);
727 + signature.append (")", false);
730 + expr.inner.accept (this);
732 + if (expr.is_silent_cast) {
733 + signature.append_keyword ("as");
734 + write_type (expr.type_reference);
741 + public override void visit_initializer_list (Vala.InitializerList list) {
742 + signature.append ("{", false);
745 + foreach (Vala.Expression initializer in list.get_initializers ()) {
747 + signature.append (", ", false);
750 + initializer.accept (this);
753 + signature.append ("}", false);
759 + public override void visit_member_access (Vala.MemberAccess expr) {
760 + if (expr.symbol_reference != null) {
761 + expr.symbol_reference.accept (this);
763 + signature.append (expr.member_name);
770 + public override void visit_element_access (Vala.ElementAccess expr) {
771 + expr.container.accept (this);
772 + signature.append ("[", false);
775 + foreach (Vala.Expression index in expr.get_indices ()) {
777 + signature.append (", ", false);
781 + index.accept (this);
784 + signature.append ("]", false);
790 + public override void visit_pointer_indirection (Vala.PointerIndirection expr) {
791 + signature.append ("*", false);
792 + expr.inner.accept (this);
798 + public override void visit_addressof_expression (Vala.AddressofExpression expr) {
799 + signature.append ("&", false);
800 + expr.inner.accept (this);
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);
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);
823 + public override void visit_method_call (Vala.MethodCall expr) {
825 + expr.call.symbol_reference.accept (this);
828 + signature.append (" (", false);
830 + foreach (Vala.Expression literal in expr.get_argument_list ()) {
832 + signature.append (", ", false);
835 + literal.accept (this);
838 + signature.append (")", false);
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);
856 + public override void visit_base_access (Vala.BaseAccess expr) {
857 + signature.append_keyword ("base", false);
863 + public override void visit_postfix_expression (Vala.PostfixExpression expr) {
864 + expr.inner.accept (this);
865 + if (expr.increment) {
866 + signature.append ("++", false);
868 + signature.append ("--", false);
875 + public override void visit_object_creation_expression (Vala.ObjectCreationExpression expr) {
876 + if (!expr.struct_creation) {
877 + signature.append_keyword ("new");
880 + signature.append_symbol (resolve (expr.symbol_reference));
882 + signature.append (" (", false);
884 + //TODO: rm conditional space
886 + foreach (Vala.Expression arg in expr.get_argument_list ()) {
888 + signature.append (", ", false);
894 + signature.append (")", false);
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);
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);
918 + public override void visit_lambda_expression (Vala.LambdaExpression expr) {
919 + signature.append ("(", false);
922 + foreach (Vala.Parameter param in expr.get_parameters ()) {
924 + signature.append (", ", false);
926 + signature.append (param.name, false);
931 + signature.append (") => {", false);
932 + signature.append_highlighted (" [...] ", false);
933 + signature.append ("}", false);
941 + public override void visit_boolean_literal (Vala.BooleanLiteral lit) {
942 + signature.append_literal (lit.to_string (), false);
948 + public override void visit_character_literal (Vala.CharacterLiteral lit) {
949 + signature.append_literal (lit.to_string (), false);
955 + public override void visit_integer_literal (Vala.IntegerLiteral lit) {
956 + signature.append_literal (lit.to_string (), false);
962 + public override void visit_real_literal (Vala.RealLiteral lit) {
963 + signature.append_literal (lit.to_string (), false);
969 + public override void visit_regex_literal (Vala.RegexLiteral lit) {
970 + signature.append_literal (lit.to_string (), false);
976 + public override void visit_string_literal (Vala.StringLiteral lit) {
977 + signature.append_literal (lit.to_string (), false);
983 + public override void visit_null_literal (Vala.NullLiteral lit) {
984 + signature.append_literal (lit.to_string (), false);
992 + public override void visit_field (Vala.Field field) {
993 + write_node (field);
999 + public override void visit_constant (Vala.Constant constant) {
1000 + write_node (constant);
1006 + public override void visit_enum_value (Vala.EnumValue ev) {
1013 + public override void visit_error_code (Vala.ErrorCode ec) {
1020 + public override void visit_delegate (Vala.Delegate d) {
1027 + public override void visit_method (Vala.Method m) {
1034 + public override void visit_creation_method (Vala.CreationMethod m) {
1041 + public override void visit_signal (Vala.Signal sig) {
1048 + public override void visit_class (Vala.Class c) {
1055 + public override void visit_struct (Vala.Struct s) {
1062 + public override void visit_interface (Vala.Interface i) {
1069 + public override void visit_enum (Vala.Enum en) {
1076 + public override void visit_error_domain (Vala.ErrorDomain ed) {
1083 + public override void visit_property (Vala.Property prop) {
1084 + write_node (prop);
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
1092 +++ b/src/driver/0.32.x/symbolresolver.vala
1094 +/* symbolresolver.vala
1096 + * Copyright (C) 2011 Florian Brosch
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.
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.
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
1113 + * Florian Brosch <flo.brosch@gmail.com>
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;
1125 + public SymbolResolver (TreeBuilder builder) {
1126 + this.symbol_map = builder.get_symbol_map ();
1127 + this.glib_error = builder.get_glib_error ();
1130 + public Symbol? resolve (Vala.Symbol symbol) {
1131 + return symbol_map.get (symbol);
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);
1142 + private void resolve_array_type_references (Api.Array ptr) {
1143 + Api.Item data_type = ptr.data_type;
1144 + if (data_type == null) {
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);
1151 + resolve_type_reference ((TypeReference) data_type);
1155 + private void resolve_pointer_type_references (Pointer ptr) {
1156 + Api.Item type = ptr.data_type;
1157 + if (type == null) {
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);
1164 + resolve_type_reference ((TypeReference) type);
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);
1175 + reference.data_type = glib_error;
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);
1185 + // Type parameters:
1186 + foreach (TypeReference type_param_ref in reference.get_type_arguments ()) {
1187 + resolve_type_reference (type_param_ref);
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);
1200 + public override void visit_tree (Api.Tree item) {
1202 + item.accept_children (this);
1209 + public override void visit_package (Package item) {
1210 + item.accept_all_children (this, false);
1216 + public override void visit_namespace (Namespace item) {
1217 + item.accept_all_children (this, false);
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);
1229 + if (item.base_type != null) {
1230 + resolve_type_reference (item.base_type);
1233 + item.accept_all_children (this, false);
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);
1245 + if (item.base_type != null) {
1246 + resolve_type_reference (item.base_type);
1249 + item.accept_all_children (this, false);
1255 + public override void visit_struct (Struct item) {
1256 + if (item.base_type != null) {
1257 + resolve_type_reference (item.base_type);
1260 + item.accept_all_children (this, false);
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;
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;
1275 + if (base_vala_property == vala_property && vala_property.base_interface_property != null) {
1276 + base_vala_property = vala_property.base_interface_property;
1278 + if (base_vala_property != null) {
1279 + item.base_property = (Property?) resolve (base_vala_property);
1282 + resolve_type_reference (item.property_type);
1284 + item.accept_all_children (this, false);
1290 + public override void visit_field (Field item) {
1291 + resolve_type_reference (item.field_type);
1293 + item.accept_all_children (this, false);
1299 + public override void visit_constant (Constant item) {
1300 + resolve_type_reference (item.constant_type);
1302 + item.accept_all_children (this, false);
1308 + public override void visit_delegate (Delegate item) {
1309 + Vala.Delegate vala_delegate = item.data as Vala.Delegate;
1311 + resolve_type_reference (item.return_type);
1313 + resolve_thrown_list (item, vala_delegate.get_error_types ());
1315 + item.accept_all_children (this, false);
1321 + public override void visit_signal (Api.Signal item) {
1322 + resolve_type_reference (item.return_type);
1324 + item.accept_all_children (this, false);
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;
1338 + if (base_vala_method == vala_method && vala_method.base_interface_method != null) {
1339 + base_vala_method = vala_method.base_interface_method;
1341 + if (base_vala_method != null) {
1342 + item.base_method = (Method?) resolve (base_vala_method);
1345 + resolve_thrown_list (item, vala_method.get_error_types ());
1347 + resolve_type_reference (item.return_type);
1349 + item.accept_all_children (this, false);
1355 + public override void visit_type_parameter (TypeParameter item) {
1356 + item.accept_all_children (this, false);
1362 + public override void visit_formal_parameter (FormalParameter item) {
1363 + if (item.ellipsis) {
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 ();
1374 + resolve_type_reference (item.parameter_type);
1375 + item.accept_all_children (this, false);
1381 + public override void visit_error_domain (ErrorDomain item) {
1382 + item.accept_all_children (this, false);
1388 + public override void visit_error_code (ErrorCode item) {
1389 + item.accept_all_children (this, false);
1395 + public override void visit_enum (Enum item) {
1396 + item.accept_all_children (this, false);
1402 + public override void visit_enum_value (Api.EnumValue item) {
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 ();
1411 + item.accept_all_children (this, false);
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
1421 +++ b/src/driver/0.32.x/treebuilder.vala
1423 +/* treebuilder.vala
1425 + * Copyright (C) 2011 Florian Brosch
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.
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.
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
1442 + * Florian Brosch <flo.brosch@gmail.com>
1451 + * Creates an simpler, minimized, more abstract AST for valacs AST.
1453 +public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
1454 + private ArrayList<PackageMetaData> packages = new ArrayList<PackageMetaData> ();
1455 + private PackageMetaData source_package;
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> ();
1460 + private ErrorReporter reporter;
1461 + private Settings settings;
1463 + private Api.Node current_node;
1464 + private Api.Tree tree;
1466 + private Valadoc.Api.Class glib_error = null;
1473 + public Api.Class get_glib_error () {
1474 + return glib_error;
1477 + public HashMap<Vala.Symbol, Symbol> get_symbol_map () {
1478 + return symbol_map;
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> ();
1491 + public PackageMetaData (Package package) {
1492 + this.package = package;
1495 + public Namespace get_namespace (Vala.Namespace vns, SourceFile file) {
1496 + Namespace? ns = namespaces.get (vns);
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)
1509 + Vala.SourceReference pos = c.source_reference;
1510 + if (c is Vala.GirComment) {
1511 + comment = new GirSourceComment (c.content,
1518 + comment = new SourceComment (c.content,
1530 + // find parent if existing
1531 + var parent_vns = vns.parent_symbol;
1533 + if (parent_vns == null) {
1534 + ns = new Namespace (package, file, vns.name, comment, vns);
1535 + package.add_child (ns);
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);
1542 + namespaces.set (vns, ns);
1546 + public void register_source_file (Vala.SourceFile file) {
1550 + public bool is_package_for_file (Vala.SourceFile source_file) {
1551 + if (source_file.file_type == Vala.SourceFileType.SOURCE && !package.is_package) {
1555 + return files.contains (source_file);
1561 + // Type constructor translation helpers:
1564 + private Pointer create_pointer (Vala.PointerType vtyperef, Item parent, Api.Node caller) {
1565 + Pointer ptr = new Pointer (parent, vtyperef);
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);
1573 + ptr.data_type = create_type_reference (vntype, ptr, caller);
1579 + private Api.Array create_array (Vala.ArrayType vtyperef, Item parent, Api.Node caller) {
1580 + Api.Array arr = new Api.Array (parent, vtyperef);
1582 + Vala.DataType vntype = vtyperef.element_type;
1583 + if (vntype is Vala.ArrayType) {
1584 + arr.data_type = create_type_reference (vntype, arr, caller);
1586 + arr.data_type = create_type_reference (vntype, arr, caller);
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;
1603 + TypeReference type_ref = new TypeReference (parent,
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,
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);
1636 + // Translation helpers:
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",
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);
1680 + if ((tmp = att.args.get ("replacement")) != null) {
1681 + new_attribute.add_string ("replacement", tmp, att);
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);
1690 + private string? get_ccode_type_id (Vala.CodeNode node) {
1691 + return Vala.CCodeBaseModule.get_ccode_type_id (node);
1694 + private bool is_reference_counting (Vala.TypeSymbol sym) {
1695 + return Vala.CCodeBaseModule.is_reference_counting (sym);
1698 + private string? get_ref_function (Vala.Class sym) {
1699 + return Vala.CCodeBaseModule.get_ccode_ref_function (sym);
1702 + private string? get_unref_function (Vala.Class sym) {
1703 + return Vala.CCodeBaseModule.get_ccode_unref_function (sym);
1706 + private string? get_finalize_function_name (Vala.Class element) {
1707 + if (!element.is_fundamental ()) {
1711 + return "%s_finalize".printf (Vala.CCodeBaseModule.get_ccode_lower_case_name (element, null));
1714 + private string? get_free_function_name (Vala.Class element) {
1715 + if (!element.is_compact) {
1719 + return Vala.CCodeBaseModule.get_ccode_free_function (element);
1722 + private string? get_finish_name (Vala.Method m) {
1723 + return Vala.CCodeBaseModule.get_ccode_finish_name (m);
1726 + private string? get_take_value_function (Vala.Class sym) {
1727 + return Vala.CCodeBaseModule.get_ccode_take_value_function (sym);
1730 + private string? get_get_value_function (Vala.Class sym) {
1731 + return Vala.CCodeBaseModule.get_ccode_get_value_function (sym);
1734 + private string? get_set_value_function (Vala.Class sym) {
1735 + return Vala.CCodeBaseModule.get_ccode_set_value_function (sym);
1739 + private string? get_param_spec_function (Vala.CodeNode sym) {
1740 + return Vala.CCodeBaseModule.get_ccode_param_spec_function (sym);
1743 + private string? get_dup_function (Vala.TypeSymbol sym) {
1744 + return Vala.CCodeBaseModule.get_ccode_dup_function (sym);
1747 + private string? get_copy_function (Vala.TypeSymbol sym) {
1748 + return Vala.CCodeBaseModule.get_ccode_copy_function (sym);
1751 + private string? get_destroy_function (Vala.TypeSymbol sym) {
1752 + return Vala.CCodeBaseModule.get_ccode_destroy_function (sym);
1755 + private string? get_free_function (Vala.TypeSymbol sym) {
1756 + return Vala.CCodeBaseModule.get_ccode_free_function (sym);
1759 + private string? get_nick (Vala.Property prop) {
1760 + return Vala.CCodeBaseModule.get_ccode_nick (prop);
1763 + private string? get_cname (Vala.Symbol symbol) {
1764 + return Vala.CCodeBaseModule.get_ccode_name (symbol);
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,
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,
1782 + return_pos.begin.line,
1783 + return_pos.begin.column,
1784 + return_pos.end.line,
1785 + return_pos.end.column);
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,
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);
1802 + return new SourceComment (comment.content,
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;
1819 + return element.parent_symbol.name + "." + element.name;
1823 + return element.name;
1826 + private string? get_quark_macro_name (Vala.ErrorDomain element) {
1827 + return Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null);
1830 + private string? get_private_cname (Vala.Class element) {
1831 + if (element.is_compact) {
1835 + string? cname = get_cname (element);
1836 + return (cname != null)? cname + "Private" : null;
1839 + private string? get_class_macro_name (Vala.Class element) {
1840 + if (element.is_compact) {
1844 + return "%s_GET_CLASS".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null));
1847 + private string? get_class_type_macro_name (Vala.Class element) {
1848 + if (element.is_compact) {
1852 + return "%s_CLASS".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null));
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;
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;
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)
1874 + return "%s_get_type".printf (Vala.CCodeBaseModule.get_ccode_lower_case_name (element, null));
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)
1886 + return Vala.CCodeBaseModule.get_ccode_type_id (element);
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)
1894 + return Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null);
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));
1904 + private string get_quark_function_name (Vala.ErrorDomain element) {
1905 + return Vala.CCodeBaseModule.get_ccode_lower_case_prefix (element) + "quark";
1908 + private PackageMetaData? get_package_meta_data (Package pkg) {
1909 + foreach (PackageMetaData data in packages) {
1910 + if (data.package == pkg) {
1918 + private PackageMetaData register_package (Package package) {
1919 + PackageMetaData meta_data = new PackageMetaData (package);
1920 + tree.add_package (package);
1921 + packages.add (meta_data);
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 (),
1930 + files.set (source_file, file);
1932 + meta_data.register_source_file (source_file);
1936 + private SourceFile? get_source_file (Vala.Symbol symbol) {
1937 + Vala.SourceReference source_ref = symbol.source_reference;
1938 + if (source_ref == null) {
1942 + SourceFile? file = files.get (source_ref.file);
1943 + assert (file != null);
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;
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;
1965 + PackageMetaData? meta_data = get_package_meta_data (pkg);
1966 + assert (meta_data != null);
1968 + return meta_data.get_namespace ((Vala.Namespace) namespace_symbol, file);
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;
1985 + return MethodBindingType.UNMODIFIED;
1989 + private SymbolAccessibility get_access_modifier(Vala.Symbol symbol) {
1990 + switch (symbol.access) {
1991 + case Vala.SymbolAccessibility.PROTECTED:
1992 + return SymbolAccessibility.PROTECTED;
1994 + case Vala.SymbolAccessibility.INTERNAL:
1995 + return SymbolAccessibility.INTERNAL;
1997 + case Vala.SymbolAccessibility.PRIVATE:
1998 + return SymbolAccessibility.PRIVATE;
2000 + case Vala.SymbolAccessibility.PUBLIC:
2001 + return SymbolAccessibility.PUBLIC;
2004 + error ("Unknown symbol accessibility modifier found");
2008 + private PropertyAccessorType get_property_accessor_type (Vala.PropertyAccessor element) {
2009 + if (element.construction) {
2010 + if (element.writable) {
2011 + return (PropertyAccessorType.CONSTRUCT | PropertyAccessorType.SET);
2013 + return PropertyAccessorType.CONSTRUCT;
2014 + } else if (element.writable) {
2015 + return PropertyAccessorType.SET;
2016 + } else if (element.readable) {
2017 + return PropertyAccessorType.GET;
2020 + error ("Unknown symbol accessibility type");
2023 + private bool type_reference_pass_ownership (Vala.DataType? element) {
2024 + if (element == null) {
2028 + weak Vala.CodeNode? node = element.parent_node;
2029 + if (node == null) {
2032 + if (node is Vala.Parameter) {
2033 + return (((Vala.Parameter)node).direction == Vala.ParameterDirection.IN &&
2034 + ((Vala.Parameter)node).variable_type.value_owned);
2036 + if (node is Vala.Property) {
2037 + return ((Vala.Property)node).property_type.value_owned;
2043 + private bool is_type_reference_unowned (Vala.DataType? element) {
2044 + if (element == null) {
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)
2055 + // FormalParameters are weak by default
2056 + return (element.parent_node is Vala.Parameter == false)
2057 + ? element.is_weak ()
2061 + private bool is_type_reference_owned (Vala.DataType? element) {
2062 + if (element == null) {
2066 + weak Vala.CodeNode parent = element.parent_node;
2069 + if (parent is Vala.Parameter) {
2070 + if (((Vala.Parameter)parent).direction != Vala.ParameterDirection.IN) {
2073 + return ((Vala.Parameter)parent).variable_type.value_owned;
2079 + private bool is_type_reference_weak (Vala.DataType? element) {
2080 + if (element == null) {
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)
2091 + // arrays are unowned, not weak
2092 + if (element is Vala.ArrayType) {
2096 + // FormalParameters are weak by default
2097 + return (element.parent_node is Vala.Parameter == false)? element.is_weak () : false;
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;
2109 + return Ownership.DEFAULT;
2112 + private Ownership get_property_ownership (Vala.PropertyAccessor element) {
2113 + if (element.value_type.value_owned) {
2114 + return Ownership.OWNED;
2117 + // the exact type (weak, unowned) does not matter
2118 + return Ownership.UNOWNED;
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;
2130 + return PropertyBindingType.UNMODIFIED;
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;
2142 + error ("Unknown formal parameter type");
2147 + // Vala tree creation:
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 ('.'));
2155 + private bool add_package (Vala.CodeContext context, string pkg) {
2156 + // ignore multiple occurences of the same package
2157 + if (context.has_package (pkg)) {
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) {
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));
2177 + context.add_package (pkg);
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);
2184 + add_deps (context, Path.build_filename (Path.get_dirname (package_path), "%s.deps".printf (pkg)), pkg);
2188 + private void add_deps (Vala.CodeContext context, string file_path, string pkg_name) {
2189 + if (FileUtils.test (file_path, FileTest.EXISTS)) {
2191 + string deps_content;
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 ();
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));
2202 + } catch (FileError e) {
2203 + Vala.Report.error (null, "Unable to read dependency file: %s".printf (e.message));
2209 + * Adds the specified packages to the list of used packages.
2211 + * @param context The code context
2212 + * @param packages a list of package names
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));
2223 + * Add the specified source file to the context. Only .vala, .vapi, .gs,
2224 + * and .c files are supported.
2226 + private void add_documented_files (Vala.CodeContext context, string[] sources) {
2227 + if (sources == null) {
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);
2237 + if (source_package == null) {
2238 + source_package = register_package (new Package (settings.pkg_name, false, null));
2241 + register_source_file (source_package, source_file);
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);
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);
2254 + var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, rpath);
2255 + context.add_source_file (vfile);
2257 + if (source_package == null) {
2258 + source_package = register_package (new Package (settings.pkg_name, false, null));
2261 + register_source_file (source_package, vfile);
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);
2268 + Vala.Report.error (null, "%s is not a supported source file type. Only .vala, .vapi, .gs, and .c files are supported.".printf (source));
2271 + Vala.Report.error (null, "%s not found".printf (source));
2276 + private Vala.CodeContext create_valac_tree (Settings settings) {
2278 + var context = new Vala.CodeContext ();
2279 + Vala.CodeContext.push (context);
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;
2290 + if (settings.basedir == null) {
2291 + context.basedir = realpath (".");
2293 + context.basedir = realpath (settings.basedir);
2296 + if (settings.directory != null) {
2297 + context.directory = realpath (settings.directory);
2299 + context.directory = context.basedir;
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");
2310 + if (settings.defines != null) {
2311 + foreach (string define in settings.defines) {
2312 + context.add_define (define);
2316 + for (int i = 2; i <= 32; i += 2) {
2317 + context.add_define ("VALA_0_%d".printf (i));
2320 + if (context.profile == Vala.Profile.GOBJECT) {
2321 + int glib_major = 2;
2322 + int glib_minor = 24;
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");
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");
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");
2340 + for (int i = 16; i <= glib_minor; i += 2) {
2341 + context.add_define ("GLIB_2_%d".printf (i));
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");
2349 + if (!this.add_package (context, "gobject-2.0")) { //
2350 + Vala.Report.error (null, "gobject-2.0 not found in specified Vala API directories");
2354 + // add user defined files:
2355 + add_depencies (context, settings.packages);
2356 + if (reporter.errors > 0) {
2360 + add_documented_files (context, settings.source_files);
2361 + if (reporter.errors > 0) {
2366 + // parse vala-code:
2367 + Vala.Parser parser = new Vala.Parser ();
2369 + parser.parse (context);
2370 + if (context.report.get_errors () > 0) {
2375 + Vala.GirParser gir_parser = new Vala.GirParser ();
2377 + gir_parser.parse (context);
2378 + if (context.report.get_errors () > 0) {
2386 + if (context.report.get_errors () > 0) {
2396 + // Valadoc tree creation:
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;
2406 + private Api.Node get_parent_node_for (Vala.Symbol element) {
2407 + if (current_node != null) {
2408 + return current_node;
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);
2415 + return get_namespace (package, element, source_file);
2421 + public override void visit_namespace (Vala.Namespace element) {
2422 + element.accept_children (this);
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);
2433 + bool is_basic_type = element.base_class == null && element.name == "string";
2435 + Class node = new Class (parent,
2438 + get_access_modifier (element),
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,
2463 + symbol_map.set (element, node);
2464 + parent.add_child (node);
2467 + foreach (Vala.DataType vala_type_ref in element.get_base_types ()) {
2468 + var type_ref = create_type_reference (vala_type_ref, node, node);
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;
2477 + process_attributes (node, element.attributes);
2478 + process_children (node, element);
2480 + // save GLib.Error
2481 + if (glib_error == null && node.get_full_name () == "GLib.Error") {
2482 + glib_error = node;
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);
2494 + Interface node = new Interface (parent,
2497 + get_access_modifier (element),
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),
2507 + symbol_map.set (element, node);
2508 + parent.add_child (node);
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);
2516 + node.base_type = type_ref;
2520 + process_attributes (node, element.attributes);
2521 + process_children (node, element);
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);
2532 + bool is_basic_type = element.base_type == null
2533 + && (element.is_boolean_type ()
2534 + || element.is_floating_type ()
2535 + || element.is_integer_type ());
2537 + Struct node = new Struct (parent,
2540 + get_access_modifier (element),
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),
2552 + symbol_map.set (element, node);
2553 + parent.add_child (node);
2556 + Vala.ValueType? basetype = element.base_type as Vala.ValueType;
2557 + if (basetype != null) {
2558 + node.base_type = create_type_reference (basetype, node, node);
2561 + process_attributes (node, element.attributes);
2562 + process_children (node, element);
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);
2573 + Field node = new Field (parent,
2576 + get_access_modifier (element),
2578 + get_cname (element),
2579 + element.binding == Vala.MemberBinding.STATIC,
2580 + element.is_volatile,
2582 + node.field_type = create_type_reference (element.variable_type, node, node);
2583 + symbol_map.set (element, node);
2584 + parent.add_child (node);
2586 + process_attributes (node, element.attributes);
2587 + process_children (node, element);
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);
2598 + Property node = new Property (parent,
2601 + get_access_modifier (element),
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),
2608 + node.property_type = create_type_reference (element.property_type, node, node);
2609 + symbol_map.set (element, node);
2610 + parent.add_child (node);
2612 + // Process property type
2613 + if (element.get_accessor != null) {
2614 + var accessor = element.get_accessor;
2615 + node.getter = new PropertyAccessor (node,
2618 + get_access_modifier (accessor),
2619 + get_cname (accessor),
2620 + get_property_accessor_type (accessor),
2621 + get_property_ownership (accessor),
2625 + if (element.set_accessor != null) {
2626 + var accessor = element.set_accessor;
2627 + node.setter = new PropertyAccessor (node,
2630 + get_access_modifier (accessor),
2631 + get_cname (accessor),
2632 + get_property_accessor_type (accessor),
2633 + get_property_ownership (accessor),
2637 + process_attributes (node, element.attributes);
2638 + process_children (node, element);
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);
2649 + Method node = new Method (parent,
2651 + get_method_name (element),
2652 + get_access_modifier (element),
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,
2663 + node.return_type = create_type_reference (element.return_type, node, node);
2664 + symbol_map.set (element, node);
2665 + parent.add_child (node);
2667 + process_attributes (node, element.attributes);
2668 + process_children (node, element);
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);
2679 + Method node = new Method (parent,
2681 + get_method_name (element),
2682 + get_access_modifier (element),
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,
2693 + node.return_type = create_type_reference (element.return_type, node, node);
2694 + symbol_map.set (element, node);
2695 + parent.add_child (node);
2697 + process_attributes (node, element.attributes);
2698 + process_children (node, element);
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);
2709 + Api.Signal node = new Api.Signal (parent,
2712 + get_access_modifier (element),
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,
2720 + node.return_type = create_type_reference (element.return_type, node, node);
2721 + symbol_map.set (element, node);
2722 + parent.add_child (node);
2724 + process_attributes (node, element.attributes);
2725 + process_children (node, element);
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);
2736 + Delegate node = new Delegate (parent,
2739 + get_access_modifier (element),
2741 + get_cname (element),
2742 + !element.has_target,
2744 + node.return_type = create_type_reference (element.return_type, node, node);
2745 + symbol_map.set (element, node);
2746 + parent.add_child (node);
2748 + process_attributes (node, element.attributes);
2749 + process_children (node, element);
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);
2760 + Symbol node = new Enum (parent,
2763 + get_access_modifier (element),
2765 + get_cname (element),
2766 + get_type_macro_name (element),
2767 + get_type_function_name (element),
2769 + symbol_map.set (element, node);
2770 + parent.add_child (node);
2772 + process_attributes (node, element.attributes);
2773 + process_children (node, element);
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);
2784 + Symbol node = new Api.EnumValue (parent,
2788 + get_cname (element),
2790 + symbol_map.set (element, node);
2791 + parent.add_child (node);
2793 + process_attributes (node, element.attributes);
2794 + process_children (node, element);
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);
2805 + Constant node = new Constant (parent,
2808 + get_access_modifier (element),
2810 + get_cname (element),
2812 + node.constant_type = create_type_reference (element.type_reference, node, node);
2813 + symbol_map.set (element, node);
2814 + parent.add_child (node);
2816 + process_attributes (node, element.attributes);
2817 + process_children (node, element);
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);
2828 + Symbol node = new ErrorDomain (parent,
2831 + get_access_modifier (element),
2833 + get_cname (element),
2834 + get_quark_macro_name (element),
2835 + get_quark_function_name (element),
2836 + Vala.GDBusModule.get_dbus_name (element),
2838 + symbol_map.set (element, node);
2839 + parent.add_child (node);
2841 + process_attributes (node, element.attributes);
2842 + process_children (node, element);
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 ();
2855 + SourceComment? comment = create_comment (element.comment);
2857 + Symbol node = new Api.ErrorCode (parent,
2861 + get_cname (element),
2862 + Vala.GDBusModule.get_dbus_name_for_member (element),
2864 + symbol_map.set (element, node);
2865 + parent.add_child (node);
2867 + process_attributes (node, element.attributes);
2868 + process_children (node, element);
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);
2878 + Symbol node = new TypeParameter (parent,
2882 + symbol_map.set (element, node);
2883 + parent.add_child (node);
2885 + process_children (node, element);
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);
2895 + FormalParameter node = new FormalParameter (parent,
2898 + get_access_modifier(element),
2899 + get_formal_parameter_type (element),
2902 + node.parameter_type = create_type_reference (element.variable_type, node, node);
2903 + parent.add_child (node);
2905 + process_children (node, element);
2913 + public Api.Tree? build (Settings settings, ErrorReporter reporter) {
2914 + this.settings = settings;
2915 + this.reporter = reporter;
2917 + this.tree = new Api.Tree (reporter, settings);
2918 + var context = create_valac_tree (settings);
2919 + this.tree.data = context;
2921 + reporter.warnings_offset = context.report.get_warnings ();
2922 + reporter.errors_offset = context.report.get_errors ();
2924 + if (context == null) {
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)
2935 + Package vdpkg = new Package (get_package_name (vfile.filename), true, null);
2936 + register_source_file (register_package (vdpkg), vfile);
2940 + context.accept(this);
2942 + return (reporter.errors == 0)? tree : null;
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
2955 +if HAVE_LIBVALA_0_32_X
2956 +DRIVER_0_32_X_DIR = 0.32.x
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) \
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")
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 \
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
2999 +++ b/tests/drivers/driver-0-32.vala
3003 +public static void main () {
3004 + test_driver ("../../src/driver/0.32.x/.libs");