Fix #8003 - undo code
[roobuilder] / src / JsRender / NodeToJs.vala
index 7763eb0..a96ad8e 100644 (file)
@@ -46,6 +46,7 @@ public class JsRender.NodeToJs : Object {
                this.node = node;
                this.doubleStringProps = doubleStringProps;
                this.pad = pad;
+               this.node.node_pad = pad;
                
                //this.els = new Gee.ArrayList<string>(); 
                //this.ar_props = new Gee.HashMap<string,string>();
@@ -88,7 +89,12 @@ public class JsRender.NodeToJs : Object {
        public string munge ( )
        {
                //return this.mungeToString(this.node);
-
+               if (this.node.as_source_version > 0 && 
+                       this.node.as_source_version == this.node.updated_count
+                       && this.node.as_source != ""
+               ) {
+                       return this.node.as_source;
+               }
                
                this.checkChildren();
                this.readProps();
@@ -107,7 +113,11 @@ public class JsRender.NodeToJs : Object {
                //}
 
                this.mungeOut();
+               
+               this.node.as_source_version = this.node.updated_count;
+               this.node.as_source == this.ret;
                return this.ret;
+
                 
        } 
                /**
@@ -167,7 +177,7 @@ public class JsRender.NodeToJs : Object {
                var spad = this.pad.substring(0, this.pad.length-indent);
                
                if (this.node.props.has_key("* xinclude")) {
-                       this.addLine("Roo.apply(" + this.node.props.get("* xinclude") + "._tree(), {",0 );
+                       this.addLine("Roo.apply(" + this.node.props.get("* xinclude").val + "._tree(), {",0 );
         
                } else {
                        this.addLine("{", 0);
@@ -179,6 +189,7 @@ public class JsRender.NodeToJs : Object {
                // output xns / xtype first..
                if (this.out_props.has_key("xtype")) {
                        var v = this.out_props.get("xtype");
+                        
                        this.node.setLine(this.cur_line, "p","xtype"); 
                        this.addLine(this.pad + "xtype" + " : " + v + suffix, ',');
                }
@@ -195,9 +206,10 @@ public class JsRender.NodeToJs : Object {
 
                        var v = this.out_props.get(k);
                        this.node.setLine(this.cur_line, "p",k); 
+
                        this.addLine(this.pad + k + " : " + v + suffix, ',');
-                        
-                       this.node.setLine(this.cur_line, "e", "");
+
+                       this.node.setLine(this.cur_line, "e", k);
                        
                }
         
@@ -212,9 +224,11 @@ public class JsRender.NodeToJs : Object {
                                
                                var k = iter.get();
                                var v = this.out_listeners.get(k);
+
                                this.node.setLine(this.cur_line, "l",k); //listener
                                this.addLine(this.pad + indent_str + k + " : " + v , ',');
-                               this.node.setLine(this.cur_line, "e", "");
+
+                               this.node.setLine(this.cur_line, "x", k);
                        }
                        
                        this.closeLine();
@@ -226,11 +240,13 @@ public class JsRender.NodeToJs : Object {
                
                if (this.out_props.has_key("xns")) {
                        var v = this.out_props.get("xns");
+                        
                        this.node.setLine(this.cur_line, "p","xns"); 
                        this.addLine(this.pad + "xns" + " : " + v + suffix, ',');
                        this.node.setLine(this.cur_line, "p","| xns"); 
                        this.addLine(this.pad + "'|xns' : '" + v + "'", ',');
-                       this.node.setLine(this.cur_line, "e", "");
+                       this.node.setLine(this.cur_line, "e", "xns");
+                        
                }
                
                this.node.line_end = this.cur_line;
@@ -240,11 +256,13 @@ public class JsRender.NodeToJs : Object {
                var niter = this.out_nodeprops.map_iterator();
 
                while(niter.next()) {
-                       var addstr = this.mungeChildNew(this.pad + indent_str, niter.get_value());
+
                        //print("add str: %s\n", addstr);
                        this.node.setLine(this.cur_line, "p",niter.get_key());
+                
+                       var addstr = this.mungeChildNew(this.pad + indent_str, niter.get_value());
                        this.addLine(this.pad + niter.get_key() + " : " + addstr, ',');
-                       
+                               
                        this.node.setLine(this.cur_line, "e", "");
                }                        
                // prop arrays...
@@ -252,6 +270,7 @@ public class JsRender.NodeToJs : Object {
                var piter = this.out_props_array.map_iterator();
 
                while(piter.next()) {
+                        
                        this.node.setLine(this.cur_line, "p",piter.get_key());
                        this.addLine(this.pad + piter.get_key() + " : [", 0);
                        
@@ -262,7 +281,9 @@ public class JsRender.NodeToJs : Object {
                                this.node.setLine(this.cur_line, "e", "");
                        }
                        this.closeLine();
+                       
                        this.addLine(this.pad + "]" , ',');                     
+                
                }       
                
                // children..
@@ -366,9 +387,9 @@ public class JsRender.NodeToJs : Object {
                        return;
                }
                // look for '*props'
-          
-               for (var ii =0; ii< this.node.items.size; ii++) {
-                       var pl = this.node.items.get(ii);
+          var items = this.node.readItems(); 
+               for (var ii =0; ii< items.size; ii++) {
+                       var pl =  items.get(ii);
                        if (!pl.props.has_key("* prop")) {
                                //newitems.add(pl);
                                continue;
@@ -469,12 +490,9 @@ public class JsRender.NodeToJs : Object {
                var keys = new Gee.ArrayList<string>();
                var piter = this.node.props.map_iterator();
                while (piter.next() ) {
-                       string k;
-                       string ktype;
-                       string kflag;
-                       this.node.normalize_key(piter.get_key(), out k, out kflag, out ktype);
-                       
-                       keys.add(k);
+               
+
+                       keys.add( piter.get_key()); // since are keys are nice and clean now..
                }
                
                keys.sort((  a,  b) => {
@@ -486,16 +504,12 @@ public class JsRender.NodeToJs : Object {
                var has_cms = this.node.has("cms-id");
                
                for (var i = 0; i< keys.size; i++) {
-                       var key = this.node.get_key(keys.get(i));
+                       var prop = this.node.get_prop(keys.get(i));
                        //("ADD KEY %s\n", key);
-                       string k;
-                       string ktype;
-                       string kflag;
-                       
-                       this.node.normalize_key(key, out k, out kflag, out ktype);
-                       
-                       
-                       var v = this.node.get(key);
+                       var k = prop.name;
+                       var ktype  = prop.rtype;
+                       var kflag = prop.ptype;
+                       var v = prop.val;
                         
                        
                        //if (this.skip.contains(k) ) {
@@ -503,16 +517,15 @@ public class JsRender.NodeToJs : Object {
                        //}
                        if (  Regex.match_simple("\\[\\]$", k)) {
                                // array .. not supported... here?
-                               
-
+                                
                        }
                        
                        string leftv = k;
                        // skip builder stuff. prefixed with  '.' .. just like unix fs..
-                       if (kflag == ".") { // |. or . -- do not output..
-                               continue;
-                       }
-                       if (kflag == "*") {
+                       //if (kflag == ".") { // |. or . -- do not output..
+                       //      continue;
+                       //}
+                       if (kflag == NodePropType.SPECIAL) {
                                // ignore '* prop'; ??? 
                                continue;
                        }
@@ -523,7 +536,7 @@ public class JsRender.NodeToJs : Object {
                        }
                        // html must not be a dynamic property...
                        // note - we do not translate this either...
-                       if (has_cms && k == "html" && kflag != "$") {
+                       if (has_cms && k == "html" && kflag !=  NodePropType.RAW) {
                                 
 
                                this.out_props.set("html", "Pman.Cms.content(" + 
@@ -551,11 +564,11 @@ public class JsRender.NodeToJs : Object {
                         
                        // next.. is it a function.. or a raw string..
                        if (
-                               kflag == "|" 
+                               kflag == NodePropType.METHOD 
                                || 
-                               kflag == "$" 
+                               kflag == NodePropType.RAW 
                                || 
-                               ktype == "function"
+                               ktype == "function" // ??? why woudl return type be function? << messed up..
                               
                                // ??? any others that are raw output..
                                ) {
@@ -621,7 +634,7 @@ public class JsRender.NodeToJs : Object {
                        // doubleStringProps is a list of keys like 'name' 'title' etc.. that we know can be translated..
                   
                        if ((this.doubleStringProps.index_of(k) > -1) || 
-                               (ktype.down() == "string" && k[0] == '_')
+                               (ktype.down() == "string" && k[0] == '_')  // strings starting with '_'
                        
                        ) {
                                // then use the translated version...
@@ -684,7 +697,7 @@ public class JsRender.NodeToJs : Object {
                 
                for (var i = 0; i< keys.size; i++) {
                        var key = keys.get(i);
-                       var val = this.node.listeners.get(key);
+                       var val = this.node.listeners.get(key).val;
                
        
                         // 
@@ -707,15 +720,15 @@ public class JsRender.NodeToJs : Object {
        public void iterChildren()
        {
                
-               
+               var items = this.node.readItems();
                // finally munge the children...
-               if (this.node.items.size < 1) {
+               if (items.size < 1) {
                        return;
                }
                var itms = "items : [\n";
                //var n = 0;
-               for(var i = 0; i < this.node.items.size;i++) {
-                       var ele = this.node.items.get(i);
+               for(var i = 0; i < items.size;i++) {
+                       var ele = items.get(i);
                        if (ele.props.has_key("* prop")) {
                                continue;
                        }