3 // valac VapiParser.vala --pkg libvala-0.24 --pkg posix -o /tmp/treebuilder
10 public class VapiParser : Vala.CodeVisitor {
11 Vala.CodeContext context;
18 public void create_valac_tree( )
21 context = new Vala.CodeContext ();
22 Vala.CodeContext.push (context);
24 context.experimental = false;
25 context.experimental_non_null = false;
37 for (int i = 2; i <= ver; i += 2) {
38 context.add_define ("VALA_0_%d".printf (i));
42 //var vapidirs = ((Project.Gtk)this.file.project).vapidirs();
43 // what's the current version of vala???
46 //vapidirs += Path.get_dirname (context.get_vapi_path("glib-2.0")) ;
50 // or context.get_vapi_path("glib-2.0"); // should return path..
51 //context.vapi_directories = vapidirs;
52 context.report.enable_warnings = true;
53 context.metadata_directories = { };
54 context.gir_directories = {};
55 context.thread = true;
58 //this.report = new ValaSourceReport(this.file);
59 //context.report = this.report;
62 context.basedir = "/tmp"; //Posix.realpath (".");
64 context.directory = context.basedir;
67 // add default packages:
68 //if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) {
69 context.profile = Vala.Profile.GOBJECT;
71 var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null));
72 context.root.add_using_directive (ns_ref);
74 // default.. packages..
75 context.add_external_package ("glib-2.0");
76 context.add_external_package ("gobject-2.0");
77 context.add_external_package ("gdk-3.0");
78 // user defined ones..
79 //context.add_package ("Gtk");
81 var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, "/usr/share/vala-0.26/vapi/gtk+-3.0.vapi");
82 context.add_source_file (vfile);
84 //context.add_external_package ("libvala-0.24");
88 //add_documented_files (context, settings.source_files);
90 Vala.Parser parser = new Vala.Parser ();
91 parser.parse (context);
92 //gir_parser.parse (context);
93 if (context.report.get_errors () > 0) {
94 print("parse got errors");
97 Vala.CodeContext.pop ();
105 if (context.report.get_errors () > 0) {
106 print("check got errors");
108 Vala.CodeContext.pop ();
114 Vala.CodeContext.pop ();
127 int main (string[] args) {
129 var a = new Palete.VapiParser( );
130 a.create_valac_tree();