2 // valac TreeBuilder.vala --pkg libvala-0.24 --pkg posix -o /tmp/treebuilder
4 public class MyReport : Vala.Report {
6 public override void err (Vala.SourceReference? source, string message) {
9 stderr.printf ("My error: %s\n", message);
11 stderr.printf ("%s: My error: %s\n", source.to_string (), message);
13 //Vala.Report.report_source (source);
21 public class TreeBuilder : Vala.CodeVisitor {
23 public Vala.CodeContext create_valac_tree () {
25 var context = new Vala.CodeContext ();
26 Vala.CodeContext.push (context);
28 context.experimental = false;
29 context.experimental_non_null = false;
30 context.vapi_directories = { "/usr/share/vala-0.24/vapi" };
31 context.report.enable_warnings = true;
32 context.metadata_directories = { };
33 context.gir_directories = {};
34 context.report = new MyReport();
36 context.basedir = Posix.realpath (".");
38 context.directory = context.basedir;
41 // add default packages:
42 //if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) {
43 context.profile = Vala.Profile.GOBJECT;
44 // context.add_define ("GOBJECT");
46 //add_depencies (context, settings.packages);
47 //if (reporter.errors > 0) {
51 var source_file = new Vala.SourceFile (context,
52 Vala.SourceFileType.SOURCE,
53 "/home/alan/gitlive/app.Builder.js/tests/TreeBuilder.vala");
55 //if (source_package == null) {
56 //source_package = register_package (new Package (settings.pkg_name, false, null));
59 //register_source_file (source_package, source_file);
61 context.add_external_package ("glib-2.0");
62 context.add_external_package ("gobject-2.0");
63 context.add_external_package ("libvala-0.24");
64 //if (context.profile == Vala.Profile.GOBJECT) {
65 // import the GLib namespace by default (namespace of backend-specific standard library)
66 var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null));
67 source_file.add_using_directive (ns_ref);
68 context.root.add_using_directive (ns_ref);
71 context.add_source_file (source_file);
74 //add_documented_files (context, settings.source_files);
76 Vala.Parser parser = new Vala.Parser ();
77 parser.parse (context);
78 //gir_parser.parse (context);
79 if (context.report.get_errors () > 0) {
88 if (context.report.get_errors () > 0) {
99 int main (string[] args) {
101 var a = new TreeBuilder();
102 a.create_valac_tree();