resources/RooUsage.txt
[app.Builder.js] / src / JsRender / NodeToVala.vala
index 4f76c72..1350c0d 100644 (file)
@@ -1,8 +1,8 @@
 /**
  * 
- * Code to convert node tree to Javascript...
+ * Code to convert node tree to Vala...
  * 
- * usage : x = (new JsRender.NodeToJs(node)).munge();
+ * usage : x = (new JsRender.NodeToVala(node)).munge();
  * 
  * 
  * 
@@ -64,12 +64,12 @@ public class JsRender.NodeToVala : Object {
                // initialize line data..
                node.line_start = this.cur_line;
                node.line_end  = this.cur_line;
-               node.lines = new Gee.ArrayList();
+               node.lines = new Gee.ArrayList<int>();
                node.line_map = new Gee.HashMap<int,string>();
-               
-                
-               
-               
+               if (parent == null) {
+                       node.node_lines = new Gee.ArrayList<int>();
+                       node.node_lines_map = new Gee.HashMap<int,Node>();
+                }
                
        }
 
@@ -191,13 +191,15 @@ public class JsRender.NodeToVala : Object {
        public void addLine(string str= "")
        {
                this.cur_line++;
+               //this.ret += "/*%d*/ ".printf(this.cur_line-1) + str + "\n";
                this.ret += str + "\n";
        }
        public void addMultiLine(string str= "")
        {
-               this.cur_line++;
+                
                this.cur_line += str.split("\n").length;
-               this.ret += str + "\n";
+               //this.ret +=  "/*%d*/ ".printf(l) + str + "\n";
+               this.ret +=   str + "\n";
        }
         
        
@@ -220,7 +222,11 @@ public class JsRender.NodeToVala : Object {
                // class header..
                // class xxx {   WrappedGtk  el; }
                this.node.line_start = this.cur_line;
-               this.addLine(inpad + "public class " + this.xcls + " : Object \n" + this.inpad + "{");
+               
+               this.top.node.setNodeLine(this.cur_line, this.node);
+               
+               this.addLine(inpad + "public class " + this.xcls + " : Object");
+               this.addLine(this.inpad + "{");
                
                 
                this.addLine(this.pad + "public " + this.cls + " el;");
@@ -315,7 +321,7 @@ public class JsRender.NodeToVala : Object {
                        }
                                
                        if (vv[0] == "@") {
-                               this.node.proplines.set(k, this.cur_line);
+                               this.node.setLine(this.cur_line, "p", k);
                                this.addLine(this.pad + "public signal" + k.substring(1)  + " "  + iter.get_value() + ";");
                                
                                this.ignore(k);
@@ -339,8 +345,8 @@ public class JsRender.NodeToVala : Object {
                        }
                        
                        this.myvars.add(k);
-
-                       this.node.proplines.set(k, this.cur_line);
+                       this.node.setLine(this.cur_line, "p", k);
+                       
                        this.addLine(this.pad + "public " + 
                                (k[0] == '$' || k[0] == '#' ? k.substring(2) : k ) + ";");
                                
@@ -457,7 +463,7 @@ public class JsRender.NodeToVala : Object {
                }
                */
                if (this.node.has("* ctor")) {
-                       this.node.proplines.set("* ctor", this.cur_line);
+                       this.node.setLine(this.cur_line, "p", "* ctor");
                        this.addLine(this.ipad + "this.el = " + this.node.get("* ctor")+ ";");
                        return;
                }
@@ -505,12 +511,13 @@ public class JsRender.NodeToVala : Object {
                                args += v;
 
                        }
-                       this.node.proplines.set("* xtype", this.cur_line);
+                       this.node.setLine(this.cur_line, "p", "* xtype");
+                       
                        this.addLine(this.ipad + "this.el = new " + cls + "( "+ string.joinv(", ",args) + " );") ;
                        return;
                        
                }
-               this.node.proplines.set("* xtype", this.cur_line);
+               this.node.setLine(this.cur_line, "p", "* xtype");;
                
                this.addLine(this.ipad + "this.el = new " + this.cls + "();");
 
@@ -571,7 +578,7 @@ public class JsRender.NodeToVala : Object {
                var iter = cls.props.map_iterator();
                while (iter.next()) {
                        var p = iter.get_key();
-                       print("Check Write %s\n", p);
+                       //print("Check Write %s\n", p);
                        if (!this.node.has(p)) {
                                continue;
                        }
@@ -699,7 +706,8 @@ public class JsRender.NodeToVala : Object {
                this.addLine();
                this.addLine(ipad + "// init method");
                this.addLine();
-               this.node.proplines.set("init", this.cur_line);
+               this.node.setLine(this.cur_line, "p", "init");
+               
                this.addMultiLine(ipad + this.padMultiline(ipad, this.node.get("init")) );
 
         }
@@ -718,11 +726,12 @@ public class JsRender.NodeToVala : Object {
                while (iter.next()) {
                        var k = iter.get_key();
                        var v = iter.get_value();
-                               this.node.listenlines.set(k, this.cur_line);
-                               this.addMultiLine(this.ipad + "this.el." + k + ".connect( " + 
+                       
+                       this.node.setLine(this.cur_line, "l", k);
+                       this.addMultiLine(this.ipad + "this.el." + k + ".connect( " + 
                                        this.padMultiline(this.ipad,v) +");"); 
                                
-                       }
+               }
        }    
        void addEndCtor()
        {
@@ -795,7 +804,7 @@ public class JsRender.NodeToVala : Object {
                        // function in the format of {type} (args) { .... }
                        var kk = k.substring(2);
                        var vv = iter.get_value();
-                       this.node.proplines.set(k, this.cur_line);
+                       this.node.setLine(this.cur_line, "p", k);
                        this.addMultiLine(this.pad + "public " + kk + " " + this.padMultiline(this.pad, vv));;
                        
                                
@@ -805,13 +814,15 @@ public class JsRender.NodeToVala : Object {
        void iterChildren()
        {
                this.node.line_end = this.cur_line;
+               this.node.sortLines();
+               
                        
                if (this.depth > 0) {
                        this.addLine(this.inpad + "}");
                }
                
                var iter = this.node.items.list_iterator();
-               var i = -1;
+                
                while (iter.next()) {
                        this.addMultiLine(this.mungeChild(iter.get()));
                }