namespace Palete {
-
+ public errordomain VapiParserError {
+ PARSE_FAILED
+ }
public class VapiParser : Vala.CodeVisitor {
return;
}
- print("parsing namespace %s\n", element.name);
+
+
+ //print("parsing namespace %s\n", element.name);
if (element.name == null) {
element.accept_children(this); // catch sub namespaces..
return;
}
+ this.add_namespace(null, element);
+ }
+ public void add_namespace(GirObject? parent, Vala.Namespace element)
+ {
+
- var g = new Gir(element.name);
- Gir.cache.set(element.name, g);
+ var g = new GirObject("Package",element.name) ;
+ if (parent == null) {
+ Gir.cache.set(element.name, (Gir)g);
+ } else {
+ // we add it as a class of the package.. even though its a namespace..
+ parent.classes.set(element.name, g);
+ }
foreach(var c in element.get_classes()) {
foreach(var c in element.get_enums()) {
this.add_enum(g, c);
}
-
-
+ foreach(var c in element.get_interfaces()) {
+ this.add_interface(g, c);
+ }
+ foreach(var c in element.get_namespaces()) {
+ this.add_namespace(g, c);
+ }
+ foreach(var c in element.get_methods()) {
+ this.add_method(g, c);
+ }
element.accept_children(this); // catch sub namespaces..
}
-
+
public void add_enum(GirObject parent, Vala.Enum cls)
{
}
+ public void add_interface(GirObject parent, Vala.Interface cls)
+ {
+
+ var c = new GirObject("Interface", parent.name + "." + cls.name);
+ parent.classes.set(cls.name, c);
+ c.ns = parent.name;
+ //c.parent = cls.base_class == null ? "" : cls.base_class.get_full_name() ; // extends...
+ c.gparent = parent;
+
+ foreach(var p in cls.get_properties()) {
+ this.add_property(c, p);
+ }
+ // methods...
+ foreach(var p in cls.get_signals()) {
+ this.add_signal(c, p);
+ }
+
+ foreach(var p in cls.get_methods()) {
+ // skip static methods..
+ if (p.binding != Vala.MemberBinding.INSTANCE &&
+ !(p is Vala.CreationMethod)
+ ) {
+ continue;
+ }
+
+ this.add_method(c, p);
+ }
+
+ //if (cls.base_class != null) {
+ // c.inherits.add(cls.base_class.get_full_name());
+ //}
+ //foreach(var p in cls.get_base_types()) {
+ // if (p.data_type != null) {
+ // c.implements.add(p.data_type.get_full_name());
+ // }
+ //}
+
+
+
+
+ }
public void add_class(GirObject parent, Vala.Class cls)
{
c.gparent = parent;
c.ns = parent.ns;
c.propertyof = parent.name;
+
c.type = prop.property_type.data_type == null ? "" : prop.property_type.data_type.get_full_name();
parent.props.set(prop.name,c);
public void add_method(GirObject parent, Vala.Method met)
{
- var n = met.name == null ? parent.name : "";
+ var n = met.name == null ? "" : met.name;
var ty = "Method";
- if (met is Vala.CreationMethod && n == "") {
- n = ".new";
+ if (met is Vala.CreationMethod) {
ty = "Ctor";
+ if(n == "" || n == ".new") {
+ n = "new";
+ }
+
}
+ //print("add_method : %s\n", n);
var c = new GirObject(ty,n);
c.gparent = parent;
cc.gparent = c;
cc.ns = c.ns;
c.paramset = cc;
-
+ c.sig = "(";
foreach(var p in params) {
- if (p.name == null) {
+ if (p.name == null && !p.ellipsis) {
continue;
}
- this.add_param(cc, p);
+ var pp = this.add_param(cc, p);
+ c.sig += (c.sig == "(" ? "" : ",");
+ c.sig += " " + (pp.direction == "in" ? "" : pp.direction) + " " + pp.type + " " + pp.name;
}
+ c.sig += (c.sig == "(" ? ")" : " )");
}
- public void add_param(GirObject parent, Vala.Parameter pam)
+ public GirObject add_param(GirObject parent, Vala.Parameter pam)
{
- var c = new GirObject("Param",pam.name);
+
+ var n = pam.name;
+ if (pam.ellipsis) {
+ n = "___";
+ }
+ var c = new GirObject("Param",n);
c.gparent = parent;
c.ns = parent.ns;
+ c.direction = "??";
+ switch (pam.direction) {
+ case Vala.ParameterDirection.IN:
+ c.direction = "in";
+ break;
+ case Vala.ParameterDirection.OUT:
+ c.direction = "out";
+ break;
+ case Vala.ParameterDirection.REF:
+ c.direction = "ref";
+ break;
+ }
+
parent.params.add(c);
- c.type = pam.variable_type.data_type == null ? "" : pam.variable_type.data_type.get_full_name();
- // this.checkParamOverride(c); - this is an old kludge for Gir files..
+
+ if (!pam.ellipsis) {
+ c.type = pam.variable_type.data_type == null ? "" : pam.variable_type.data_type.get_full_name();
+ }
+ Gir.checkParamOverride(c);
+ return c;
}
context.experimental = false;
context.experimental_non_null = false;
-
-#if VALA_0_28
+#if VALA_0_32
+ var ver=32;
+#elif VALA_0_30
+ var ver=30;
+#elif VALA_0_28
var ver=28;
#elif VALA_0_26
var ver=26;
//vapidirs += Path.get_dirname (context.get_vapi_path("glib-2.0")) ;
-
+ var vapidirs = context.vapi_directories;
+ vapidirs += (BuilderApplication.configDirectory() + "/resources/vapi");
+ context.vapi_directories = vapidirs;
// or context.get_vapi_path("glib-2.0"); // should return path..
//context.vapi_directories = vapidirs;
context.report.enable_warnings = true;
// some of these may fail... - we probalby need a better way to handle this..
context.add_external_package ("gtk+-3.0");
+ context.add_external_package ("libsoup-2.4");
if (!context.add_external_package ("webkit2gtk-4.0")) {
context.add_external_package ("webkit2gtk-3.0");
}
+ // these are supposed to be in the 'deps' file, but it's not getting read..
+ context.add_external_package ("cogl-1.0");
+ context.add_external_package ("json-glib-1.0");
context.add_external_package ("clutter-gtk-1.0");
+
+
+
context.add_external_package ("gdl-3.0");
context.add_external_package ("gtksourceview-3.0");
- //context.add_external_package ("vte"); //??? -- hopefullly that works..
+ context.add_external_package ("vte-2.90"); //??? -- hopefullly that works..
//add_documented_files (context, settings.source_files);
Vala.Parser parser = new Vala.Parser ();
parser.parse (context);
//gir_parser.parse (context);
if (context.report.get_errors () > 0) {
+
+ throw new VapiParserError.PARSE_FAILED("failed parse VAPIS, so we can not write file correctly");
+
print("parse got errors");
context.check ();
if (context.report.get_errors () > 0) {
print("check got errors");
-
+ throw new VapiParserError.PARSE_FAILED("failed check VAPIS, so we can not write file correctly");
Vala.CodeContext.pop ();
return;
}
- Vala.CodeContext.pop ();
+
context.accept(this);
+ context = null;
// dump the tree for Gtk?
-
+ Vala.CodeContext.pop ();
print("ALL OK?\n");
/*
int main (string[] args) {
- var g = Palete.Gir.factory("Gdk");
+ var g = Palete.Gir.factoryFqn("Gtk.SourceView");
print("%s\n", g.asJSONString());
return 0;
}
- */
-
+*/