string ret;
Gee.ArrayList<string> ignoreList;
+ GLib.List<Node> vitems; // top level items
NodeToVala top;
public NodeToVala( Node node, int depth, NodeToVala? top)
this.ret = "";
this.top = top == null ? this : top;
this.ignoreList = new Gee.ArrayList<string>();
+ this.vitems = new GLib.List<Node>();
+ }
+
+ public int vcnt = 0;
+ string toValaNS(Node item)
+ {
+ var ns = item.get("* xns") ;
+ //if (ns == "GtkSource") {
+ //return "Gtk.Source.";
+ //}
+ return ns + ".";
+ }
+ public void toValaName(Node item)
+ {
+ this.vcnt++;
+
+ var cls = this.toValaNS(item) + item.get("xtype");
+
+ string id = item.get("id").length > 0 ?
+ item.get("id") : "%s%d".printf(item.get("xtype"), this.vcnt);
+
+ item.xvala_cls = cls;
+ item.xvala_xcls = "Xcls_" + id;
+ item.xvala_id = item.get("id").length > 0 ? item.get("id") : "";
+
+ this.vitems.append(item);
+ // loop children..
+
+ if (item.items.size < 1) {
+ return;
+ }
+ for(var i =0;i<item.items.size;i++) {
+ this.toValaName(item.items.get(i));
+ }
+
+ }
+
+ static string mungeFile(JsRender file)
+ {
+ var n = new NodeToVala(file.tree, 0, null);
+ n.vcnt = 0;
+ n.toValaName(file.tree);
+ return n.munge();
+
+
}
-
public string munge ( )
{
this.addValaCtor();
this.addUnderThis();
this.addWrappedCtor();
+
+ this.addInitMyVars();
+ this.addWrappedProperties();
+ this.addChildren();
+ this.addInit();
+ this.addListeners();
+ this.addEndCtor();
+ this.addUserMethods();
+ this.iterChildren();
return this.ret;
return;
}
// Global Vars..
- this.ret += this.inpad + "public static " + this.xcls + " " ; //+ this.node.name + ";\n\n";
+ this.ret += this.inpad + "public static " + this.xcls + " " this.xvala_id+ ";\n\n";
}
// ctor..
this.ret += "\n" + ipad + "// ctor \n";
if (this.node.has("* args")) {
-
+ // not sure what this is supposed to be ding..
+
cargs_str = ", " + this.node.get("* args");
//var ar = this.node.get("* args");.split(",");
//for (var ari =0; ari < ar.length; ari++) {
if (this.depth < 1) {
this.ret += this.pad + "public " + this.xcls + "(" +
- cargs_str.substring(1) +")\n" + this.pad + "{\n";
+ cargs_str +")\n" + this.pad + "{\n";
} else {
//code
// see what the
var default_ctor = Palete.Gir.factoryFqn(this.node.fqn() + ".new");
- if (default_ctor.paramset.params.size > 0) {
+ if (default_ctor.paramset != null && default_ctor.paramset.params.size > 0) {
string[] args = {};
var iter =default_ctor.paramset.params.list_iterator();
while (iter.next()) {
}
void ignore(string i) {
-
+ this.ignoreList.add(i);
}
bool shouldIgnore(string i)
{
- return true;
+ return ignoreList.contains(i);
}
GLib.Log.set_always_fatal(LogLevelFlags.LEVEL_ERROR | LogLevelFlags.LEVEL_CRITICAL);
- //var g = Palete.Gir.factory("Gtk");
- //var test = g.classes.get("Label");
+ Project.Project.loadAll();
+ var p = Project.Project.getProject("BuilderTest");
+ p.scanDirs();
+ var ar = p.sortedFiles();
+ var iter = ar.list_iterator();
+ while (iter.next()) {
+ var f= iter.get();
+ f.loadItems();
+ var nv = new JsRender.NodeToVala( f.tree, 0, null);
+ print("\n%s\n",nv.munge());
+ return 0;
+ }
+
+
+ return 0;
+}
+
+
+void testGir() {
+
+
var test = Palete.Gir.factoryFqn("Gtk.Label.new");
if (test == null) {
print("could not find Gtk.Label.new\n");
- return 0;
+ return;
}
generator.pretty = true;
print(generator.to_data(null));
- return 0;
-
- Project.Project.loadAll();
- var p = Project.Project.getProject("BuilderTest");
- p.scanDirs();
- var ar = p.sortedFiles();
- var iter = ar.list_iterator();
- while (iter.next()) {
- var f= iter.get();
- f.save();
- }
-
-
- return 0;
-}
+}
\ No newline at end of file