770e506a6538cc5ecff0b22773b48f9238d50707
[roobuilder] / src / JsRender / NodeToVala.vala
1 /**
2  * 
3  * Code to convert node tree to Vala...
4  * 
5  * usage : x = (new JsRender.NodeToVala(node)).munge();
6  * 
7  * Fixmes?
8  *
9  *  pack - can we come up with a replacement?
10      - parent.child == child_widget -- actually uses getters and effectively does 'add'?
11        (works on most)?
12     
13      
14  * 
15  * 
16  * 
17 */
18
19
20
21
22 public class JsRender.NodeToVala : Object {
23
24         Node node;
25
26         int depth;
27         string inpad;
28         string pad;
29         string ipad;
30         string cls;
31         string xcls;
32         
33         string ret;
34         
35         int cur_line;
36
37         Gee.ArrayList<string> ignoreList;
38         Gee.ArrayList<string> ignoreWrappedList; 
39         Gee.ArrayList<string> myvars;
40         Gee.ArrayList<Node> vitems; // top level items
41         NodeToVala top;
42         JsRender file;
43         
44         /* 
45          * ctor - just initializes things
46          * - wraps a render node 
47          */
48         public NodeToVala( JsRender file,  Node node,  int depth, NodeToVala? parent) 
49         {
50
51                 
52                 this.node = node;
53                 this.depth = depth;
54                 this.inpad = string.nfill(depth > 0 ? 4 : 0, ' ');
55                 this.pad = this.inpad + "    ";
56                 this.ipad = this.inpad + "        ";
57                 this.cls = node.xvala_cls;
58                 this.xcls = node.xvala_xcls;
59                 this.ret = "";
60                 this.cur_line = parent == null ? 0 : parent.cur_line;
61                 
62                 
63                 this.top = parent == null ? this : parent.top;
64                 this.ignoreList = new Gee.ArrayList<string>();
65                 this.ignoreWrappedList  = new Gee.ArrayList<string>();
66                 this.myvars = new Gee.ArrayList<string>();
67                 this.vitems = new Gee.ArrayList<Node>();
68                 this.file = file;
69                 
70                 // initialize line data..
71                 node.line_start = this.cur_line;
72                 node.line_end  = this.cur_line;
73                 node.lines = new Gee.ArrayList<int>();
74                 node.line_map = new Gee.HashMap<int,string>();
75                 if (parent == null) {
76                         node.node_lines = new Gee.ArrayList<int>();
77                         node.node_lines_map = new Gee.HashMap<int,Node>();
78                  }
79                 
80         }
81
82         public int vcnt = 0;
83         string toValaNS(Node item)
84         {
85                 var ns = item.get("xns") ;
86                 if (ns == "GtkSource") {
87                         return "Gtk.Source";
88                 }
89                 return ns + ".";
90         }
91         public void  toValaName(Node item, int depth =0) 
92         {
93                 this.vcnt++;
94
95                 var ns =  this.toValaNS(item) ;
96                 var cls = ns + item.get("xtype");
97                 
98                 
99                 item.xvala_cls = cls;
100                 
101                 
102                 string id = item.get("id").length > 0 ?
103                         item.get("id") :  "%s%d".printf(item.get("xtype"), this.vcnt);
104
105                 
106                 
107                 
108                 if (id[0] == '*' || id[0] == '+') {
109                         item.xvala_xcls = "Xcls_" + id.substring(1);
110                 } else {
111                         item.xvala_xcls = "Xcls_" + id;
112                 }
113                         
114                 
115                 item.xvala_id =  id;
116                 if (depth > 0) {                        
117                         this.vitems.add(item);
118                         
119                 // setting id on top level class changes it classname..                 
120                 // oddly enough we havent really thought about namespacing here.
121                 
122                 } else if (!item.props.has_key("id")) { 
123                         // use the file name..
124                         item.xvala_xcls =  this.file.name;
125                         // is id used?
126                         item.xvala_id = this.file.name;
127
128                 }
129                 // loop children..
130                                                                                                                            
131                 if (item.items.size < 1) {
132                         return;
133                 }
134                 for(var i =0;i<item.items.size;i++) {
135                         this.toValaName(item.items.get(i), depth+1);
136                 }
137                                           
138         }
139         /**
140          *  Main entry point to convert a file into a string..
141          */
142         public static string mungeFile(JsRender file) 
143         {
144                 if (file.tree == null) {
145                         return "";
146                 }
147
148                 var n = new NodeToVala(file, file.tree, 0, null);
149                 n.file = file;
150                 n.vcnt = 0;
151                 
152                 n.toValaName(file.tree);
153                 
154                 
155                 GLib.debug("top cls %s / xlcs %s\n ",file.tree.xvala_cls,file.tree.xvala_cls); 
156                 n.cls = file.tree.xvala_cls;
157                 n.xcls = file.tree.xvala_xcls;
158                 return n.munge();
159                 
160
161         }
162         
163         public string munge ( )
164         {
165                 //return this.mungeToString(this.node);
166
167                 this.ignore("pack");
168                 this.ignore("init");
169                 this.ignore("xns");
170                 this.ignore("xtype");
171                 this.ignore("id");
172                 
173                 this.globalVars();
174                 this.classHeader();
175                 this.addSingleton();
176                 this.addTopProperties();
177                 this.addMyVars();
178                 this.addPlusProperties();
179                 this.addValaCtor();
180                 this.addUnderThis();
181                 this.addWrappedCtor();
182
183                 this.addInitMyVars();
184                 this.addWrappedProperties();
185                 this.addChildren();
186                 this.addInit();
187                 this.addListeners();
188                 this.addEndCtor();
189                 this.addUserMethods();
190                 this.iterChildren();
191                 
192                 return this.ret;
193                  
194                          
195         } 
196         public string mungeChild(  Node cnode)
197         {
198                 var x = new  NodeToVala(this.file, cnode,  this.depth+1, this);
199                 return x.munge();
200         }
201         public void addLine(string str= "")
202         {
203                 this.cur_line++;
204                 //this.ret += "/*%d*/ ".printf(this.cur_line-1) + str + "\n";
205                 this.ret += str + "\n";
206         }
207         public void addMultiLine(string str= "")
208         {
209                  
210                 this.cur_line += str.split("\n").length;
211                 //this.ret +=  "/*%d*/ ".printf(l) + str + "\n";
212                 this.ret +=   str + "\n";
213         }
214          
215         
216         public void globalVars()
217         {
218                 if (this.depth > 0) {
219                         return;
220                 }
221                 // Global Vars..??? when did this get removed..?
222                 //this.ret += this.inpad + "public static " + this.xcls + "  " + this.node.xvala_id+ ";\n\n";
223
224                 this.addLine(this.inpad + "static " + this.xcls + "  _" + this.node.xvala_id+ ";");
225                 this.addLine();
226                    
227         }
228
229         void classHeader()
230         {
231                            
232                 // class header..
233                 // class xxx {   WrappedGtk  el; }
234                 this.node.line_start = this.cur_line;
235                 
236                 this.top.node.setNodeLine(this.cur_line, this.node);
237                 
238                 this.addLine(inpad + "public class " + this.xcls + " : Object");
239                 this.addLine(this.inpad + "{");
240                 
241                  
242                 this.addLine(this.pad + "public " + this.cls + " el;");
243  
244                 this.addLine(this.pad + "private " + this.top.xcls + "  _this;");
245                 this.addLine();
246                         
247                         
248                         
249                         // singleton
250         }
251         void addSingleton() 
252         {
253                 if (depth > 0) {
254                         return;
255                 }
256                 this.addLine(pad + "public static " + xcls + " singleton()");
257                 this.addLine(this.pad + "{");
258                 this.addLine(this.ipad +    "if (_" + this.node.xvala_id  + " == null) {");
259                 this.addLine(this.ipad +    "    _" + this.node.xvala_id + "= new "+ this.xcls + "();");  // what about args?
260                 this.addLine(this.ipad +    "}");
261                 this.addLine(this.ipad +    "return _" + this.node.xvala_id +";");
262                 this.addLine(this.pad + "}");
263         }
264                         
265         /**
266          * when ID is used... on an element, it registeres a property on the top level...
267          * so that _this.ID always works..
268          * 
269          */
270         void addTopProperties()
271         {
272                 if (this.depth > 0) {
273                         return;
274                 }
275                 // properties - global..??
276
277                 var iter = this.vitems.list_iterator();
278                 while(iter.next()) {
279                         var n = iter.get();
280
281                          
282                         if (!n.props.has_key("id") || n.xvala_id.length < 0) {
283                                 continue;
284                                 
285                         }
286                         if (n.xvala_id[0] == '*') {
287                                 continue;
288                         }
289                         if (n.xvala_id[0] == '+') {
290                                 continue;
291                         }
292                         this.addLine(this.pad + "public " + n.xvala_xcls + " " + n.xvala_id + ";");
293                         
294                 }
295                                 
296         }
297         /**
298          * create properties that are not 'part of the wrapped element.
299          * 
300          * 
301          */
302         
303         void addMyVars()
304         {
305                 GLib.debug("callinged addMhyVars");
306                 
307                 this.addLine();
308                 this.addLine(this.ipad + "// my vars (def)");
309                         
310
311  
312                 var cls = Palete.Gir.factoryFqn((Project.Gtk) this.file.project, this.node.fqn());
313                    
314                 if (cls == null) {
315                         GLib.debug("Gir factory failed to find class %s", this.node.fqn());
316                         
317                         return;
318                 }
319           
320                 
321                         // Key = TYPE:name
322                 var iter = this.node.props.map_iterator();
323                 while (iter.next()) {
324                          
325                         var prop = iter.get_value();
326                         
327                         if (this.shouldIgnore(prop.name)) {
328                                 continue;
329                         }
330
331                         // user defined method
332                         if (prop.ptype == NodePropType.METHOD) {
333                                 continue;
334                         }
335                         if (prop.ptype == NodePropType.SPECIAL) {
336                                 continue;
337                         }
338                                 
339                         if (prop.ptype == NodePropType.SIGNAL) {
340                                 this.node.setLine(this.cur_line, "p", prop.name);
341                                 this.addLine(this.pad + "public signal " + prop.rtype + " " + prop.name  + " "  + prop.val + ";");
342                                 
343                                 this.ignore(prop.name);
344                                 continue;
345                         }
346                         
347                         GLib.debug("Got myvars: %s", prop.name.strip());
348                         
349                         if (prop.rtype.strip().length < 1) {
350                                 continue;
351                         }
352                         
353                         // is it a class property...
354                         if (cls.props.has_key(prop.name) && prop.ptype != NodePropType.USER) {
355                                 continue;
356                         }
357                         
358                         this.myvars.add(prop.name);
359                         prop.start_line = this.cur_line;
360                         
361                         this.node.setLine(this.cur_line, "p", prop.name);
362                         
363                         this.addLine(this.pad + "public " + prop.rtype + " " + prop.name + ";"); // definer - does not include value.
364
365
366                         prop.end_line = this.cur_line;                          
367                         this.ignore(prop.name);
368                         
369                                 
370                 }
371         }
372         
373         // if id of child is '+' then it's a property of this..
374         void addPlusProperties()
375         {
376                 if (this.node.items.size < 1) {
377                         return;
378                 }
379                 var iter = this.node.items.list_iterator();
380                 while (iter.next()) {
381                         var ci = iter.get();
382                                 
383                         if (ci.xvala_id[0] != '+') {
384                                 continue; // skip generation of children?
385                                 
386                         }
387                          
388                         this.addLine(this.pad + "public " + ci.xvala_xcls + " " + ci.xvala_id.substring(1) + ";");
389                                            
390                         
391                 }
392         }
393         /**
394          * add the constructor definition..
395          */
396         void addValaCtor()
397         {
398                         
399                 
400                 // .vala props.. 
401                 
402                 string[] cargs = {};
403                 var cargs_str = "";
404                 // ctor..
405                 this.addLine();
406                 this.addLine(this.pad + "// ctor");
407                 
408                 if (this.node.has("* args")) {
409                         // not sure what this is supposed to be ding..
410                 
411                         cargs_str =  this.node.get("* args");
412                         //var ar = this.node.get("* args");.split(",");
413                         //for (var ari =0; ari < ar.length; ari++) {
414                                 //      cargs +=  (ar[ari].trim().split(" ").pop();
415                                   // }
416                         }
417         
418                 if (this.depth < 1) {
419                  
420                         // top level - does not pass the top level element..
421                         this.addLine(this.pad + "public " + this.xcls + "(" +  cargs_str +")");
422                         this.addLine(this.pad + "{");
423                 } else {
424                         if (cargs_str.length > 0) {
425                                 cargs_str = ", " + cargs_str;
426                         }
427                         // for sub classes = we passs the top level as _owner
428                         this.addLine(this.pad + "public " + this.xcls + "(" +  this.top.xcls + " _owner " + cargs_str + ")");
429                         this.addLine(this.pad + "{");
430                 }
431                 
432
433         }
434         /**
435          *  make sure _this is defined..
436          */
437         void addUnderThis() 
438         {
439                 // public static?
440                 if (depth < 1) {
441                         this.addLine( this.ipad + "_this = this;");
442                         return;
443                 }
444                 // for non top level = _this point to owner, and _this.ID is set
445                 
446                 this.addLine( this.ipad + "_this = _owner;");
447
448                 if (this.node.props.has_key("id")
449                         &&
450                         this.node.xvala_id != "" 
451                         && 
452                         this.node.xvala_id[0] != '*' 
453                         && 
454                         this.node.xvala_id[0] != '+' 
455                         ) {
456                                 this.addLine( this.ipad + "_this." + node.xvala_id  + " = this;");
457                    
458                 }
459                          
460         }
461         /**
462          * Initialize this.el to point to the wrapped element.
463          * 
464          * 
465          */
466
467         void addWrappedCtor()
468         {
469                 // wrapped ctor..
470                 // this may need to look up properties to fill in the arguments..
471                 // introspection does not workk..... - as things like gtkmessagedialog
472                 /*
473                 if (cls == 'Gtk.Table') {
474
475                 var methods = this.palete.getPropertiesFor(cls, 'methods');
476
477                 print(JSON.stringify(this.palete.proplist[cls], null,4));
478                 Seed.quit();
479                 }
480                 */
481                 if (this.node.has("* ctor")) {
482                         this.node.setLine(this.cur_line, "p", "* ctor");
483                         this.addLine(this.ipad + "this.el = " + this.node.get("* ctor")+ ";");
484                         return;
485                 }
486                  
487                 var  default_ctor = Palete.Gir.factoryFqn((Project.Gtk) this.file.project, this.node.fqn() + ".new");
488
489                  
490                 if (default_ctor != null && default_ctor.paramset != null && default_ctor.paramset.params.size > 0) {
491                         string[] args  = {};
492                         var iter = default_ctor.paramset.params.list_iterator();
493                         while (iter.next()) {
494                                 var n = iter.get().name;
495                             GLib.debug("building CTOR ARGS: %s, %s", n, iter.get().is_varargs ? "VARARGS": "");
496                                  
497                                 
498                                 if (!this.node.has(n)) {
499                                         if (n == "___") { // for some reason our varargs are converted to '___' ...
500                                                 continue;
501                                         }
502                                                 
503                                         
504                                         if (iter.get().type.contains("int")) {
505                                                 args += "0";
506                                                 continue;
507                                         }
508                                         if (iter.get().type.contains("float")) {
509                                                 args += "0f";
510                                                 continue;
511                                         }
512                                         if (iter.get().type.contains("bool")) {
513                                                 args += "true"; // always default to true?
514                                                 continue;
515                                         }
516                                         // any other types???
517                                         
518                                         args += "null";
519                                         continue;
520                                 }
521                                 this.ignoreWrapped(n);
522                                 this.ignore(n);
523                                 
524                                 var v = this.node.get(n);
525
526                                 if (iter.get().type == "string") {
527                                         v = "\"" +  v.escape("") + "\"";
528                                 }
529                                 if (v == "TRUE" || v == "FALSE") {
530                                         v = v.down();
531                                 }
532
533                                 
534                                 args += v;
535
536                         }
537                         this.node.setLine(this.cur_line, "p", "* xtype");
538                         
539                         this.addLine(this.ipad + "this.el = new " + cls + "( "+ string.joinv(", ",args) + " );") ;
540                         return;
541                         
542                 }
543                 this.node.setLine(this.cur_line, "p", "* xtype");;
544                 
545                 this.addLine(this.ipad + "this.el = new " + this.cls + "();");
546
547                         
548         }
549
550         void addInitMyVars()
551         {
552                         //var meths = this.palete.getPropertiesFor(item['|xns'] + '.' + item.xtype, 'methods');
553                         //print(JSON.stringify(meths,null,4));Seed.quit();
554                         
555                         
556                         
557                         // initialize.. my vars..
558                 this.addLine();
559                 this.addLine( this.ipad + "// my vars (dec)");
560                 
561                 var iter = this.myvars.list_iterator();
562                 while(iter.next()) {
563                         
564                         var k = iter.get();
565                         
566                         var ar  = k.strip().split(" ");
567                         var kname = ar[ar.length-1];
568                         
569                         var prop = this.node.props.get(k);
570                         
571                         var v = prop.val.strip();                       
572                         
573                         if (v.length < 1) {
574                                 continue; 
575                         }
576                         // at this point start using 
577
578                         if (v == "FALSE" || v == "TRUE") {
579                                 v= v.down();
580                         }
581                         //FIXME -- check for raw string.. "string XXXX"
582                         
583                         // if it's a string...
584                         
585                         prop.start_line = this.cur_line;
586                         this.addLine(this.ipad + "this." + prop.name + " = " +   v +";");
587                         prop.end_line = this.cur_line;
588                 }
589         }
590
591         
592
593
594         
595         void addWrappedProperties()
596         {
597                 var cls = Palete.Gir.factoryFqn((Project.Gtk) this.file.project, this.node.fqn());
598                 if (cls == null) {
599                         GLib.debug("Skipping wrapped properties - could not find class  %s" , this.node.fqn());
600                         return;
601                 }
602                         // what are the properties of this class???
603                 this.addLine();
604                 this.addLine(this.ipad + "// set gobject values");
605                 
606
607                 var iter = cls.props.map_iterator();
608                 while (iter.next()) {
609                         var p = iter.get_key();
610                         //print("Check Write %s\n", p);
611                         if (!this.node.has(p)) {
612                                 continue;
613                         }
614                         if (this.shouldIgnoreWrapped(p)) {
615                                 continue;
616                         }
617                         
618                         this.ignore(p);
619
620
621                         var prop = this.node.get_prop(p);
622                         var v = prop.val;
623                         
624                         // user defined properties.
625                         if (prop.ptype == NodePropType.USER) {
626                                 continue;
627                         }
628                                 
629
630                         
631                         var is_raw = prop.ptype == NodePropType.RAW;
632                         
633                         // what's the type.. - if it's a string.. then we quote it..
634                         if (iter.get_value().type == "string" && !is_raw) {
635                                  v = "\"" +  v.escape("") + "\"";
636                         }
637                         if (v == "TRUE" || v == "FALSE") {
638                                 v = v.down();
639                         }
640                         if (iter.get_value().type == "float" && v[v.length-1] != 'f') {
641                                 v += "f";
642                         }
643                         
644                         prop.start_line = this.cur_line;
645                         this.addLine("%sthis.el.%s = %s;".printf(ipad,p,v)); // // %s,  iter.get_value().type);
646                         prop.end_line = this.cur_line;          
647                            // got a property..
648                            
649
650                 }
651                 
652         }
653         /**
654          *  pack the children into the parent.
655          * 
656          * if the child's id starts with '*' then it is not packed...
657          * - this allows you to define children and add them manually..
658          */
659
660         void addChildren()
661         {
662                                 //code
663                 if (this.node.items.size < 1) {
664                         return;
665                 }
666                          
667                 var iter = this.node.items.list_iterator();
668                 var i = -1;
669                 while (iter.next()) {
670                         i++;
671                                 
672                         var ci = iter.get();
673
674                         if (ci.xvala_id[0] == '*') {
675                                 continue; // skip generation of children?
676                         }
677                                         
678                         var xargs = "";
679                         if (ci.has("* args")) {
680                                 
681                                 var ar = ci.get_prop("* args").val.split(",");
682                                 for (var ari = 0 ; ari < ar.length; ari++ ) {
683                                         var arg = ar[ari].split(" ");
684                                         xargs += "," + arg[arg.length -1];
685                                 }
686                         }
687                         // create the element..
688                         this.addLine(this.ipad + "var child_" + "%d".printf(i) + " = new " + ci.xvala_xcls +
689                                         "( _this " + xargs + ");" );
690                         
691                         // this is only needed if it does not have an ID???
692                         this.addLine(this.ipad + "child_" + "%d".printf(i) +".ref();"); // we need to reference increase unnamed children...
693                         
694                         if (ci.has("* prop")) {
695                                 this.addLine(ipad + "this.el." + ci.get_prop("* prop").val + " = child_" + "%d".printf(i) + ".el;");
696                                 continue;
697                         } 
698                                 
699
700         // not sure why we have 'true' in pack?!?
701                         if (!ci.has("* pack") || ci.get("* pack").down() == "false" || ci.get("* pack").down() == "true") {
702                                 continue;
703                         }
704                         
705                         string[]  packing =  { "add" };
706                         if (ci.has("* pack")) {
707                                 packing = ci.get("* pack").split(",");
708                         }
709                         
710                         var pack = packing[0];
711                         this.addLine(this.ipad + "this.el." + pack.strip() + " (  child_" + "%d".printf(i) + ".el " +
712                                    (packing.length > 1 ? 
713                                                 (", " + string.joinv(",", packing).substring(pack.length+1))
714                                         :
715                                                         ""
716                                                 ) + " );");
717         
718                                           
719                         if (ci.xvala_id[0] != '+') {
720                                 continue; // skip generation of children?
721                                                 
722                         }
723                         // this.{id - without the '+'} = the element...
724                         this.addLine(this.ipad + "this." + ci.xvala_id.substring(1) + " =  child_" + "%d".printf(i) +  ";");
725                                   
726                 }
727         }
728
729         void addInit()
730         {
731
732                 
733                 if (!this.node.has("init")) {
734                                 return;
735                 }
736                 this.addLine();
737                 this.addLine(ipad + "// init method");
738                 this.addLine();
739                 this.node.setLine(this.cur_line, "p", "init");
740                 
741                 this.addMultiLine(ipad + this.padMultiline(ipad, this.node.get("init")) );
742
743          }
744          void addListeners()
745          {
746                 if (this.node.listeners.size < 1) {
747                         return;
748                 }
749                                 
750                 this.addLine();
751                 this.addLine(ipad + "//listeners");
752                         
753                          
754
755                 var iter = this.node.listeners.map_iterator();
756                 while (iter.next()) {
757                         var k = iter.get_key();
758                         var prop = iter.get_value();
759                         var v = prop.val;
760                         
761                         prop.start_line = this.cur_line;
762                         this.node.setLine(this.cur_line, "l", k);
763                         this.addMultiLine(this.ipad + "this.el." + k + ".connect( " + 
764                                         this.padMultiline(this.ipad,v) +");"); 
765                         prop.end_line = this.cur_line;
766                 }
767         }    
768         void addEndCtor()
769         {
770                          
771                         // end ctor..
772                         this.addLine(this.pad + "}");
773         }
774
775
776         /*
777  * Standardize this crap...
778  * 
779  * standard properties (use to set)
780  *          If they are long values show the dialog..
781  *
782  * someprop : ....
783  * bool is_xxx  :: can show a pulldown.. (true/false)
784  * string html  
785  * $ string html  = string with value interpolated eg. baseURL + ".." 
786  *  Clutter.ActorAlign x_align  (typed)  -- shows pulldowns if type is ENUM? 
787  * $ untypedvalue = javascript untyped value...  
788  * _ string html ... = translatable..
789
790  * 
791  * object properties (not part of the GOjbect being wrapped?
792  * # Gee.ArrayList<Xcls_fileitem> fileitems
793  * 
794  * signals
795  * @ void open 
796  * 
797  * methods -- always text editor..
798  * | void clearFiles
799  * | someJSmethod
800  * 
801  * specials
802  * * prop -- string
803  * * args  -- string
804  * * ctor -- string
805  * * init -- big string?
806  * 
807  * event handlers (listeners)
808  *   just shown 
809  * 
810  * -----------------
811  * special ID values
812  *  +XXXX -- indicates it's a instance property / not glob...
813  *  *XXXX -- skip writing glob property (used as classes that can be created...)
814  * 
815  * 
816  */
817          
818         void addUserMethods()
819         {
820                 this.addLine();
821                 this.addLine(this.pad + "// user defined functions");
822                         
823                         // user defined functions...
824                 var iter = this.node.props.map_iterator();
825                 while(iter.next()) {
826                         var prop = iter.get_value();
827                         if (this.shouldIgnore(prop.name)) {
828                                 continue;
829                         }
830                         // HOW TO DETERIME if its a method?            
831                         if (prop.ptype != NodePropType.METHOD) {
832                                         //strbuilder("\n" + pad + "// skip " + k + " - not pipe \n"); 
833                                         continue;
834                         }
835                         
836                         // function in the format of {type} (args) { .... }
837
838
839
840                         prop.start_line = this.cur_line;
841                         this.node.setLine(this.cur_line, "p", prop.name);
842                         this.addMultiLine(this.pad + "public " + prop.rtype + " " +  prop.name + " " + this.padMultiline(this.pad, prop.val));;
843                         prop.end_line = this.cur_line;
844                                 
845                 }
846         }
847
848         void iterChildren()
849         {
850                 this.node.line_end = this.cur_line;
851                 this.node.sortLines();
852                 
853                         
854                 if (this.depth > 0) {
855                         this.addLine(this.inpad + "}");
856                 }
857                 
858                 var iter = this.node.items.list_iterator();
859                  
860                 while (iter.next()) {
861                         this.addMultiLine(this.mungeChild(iter.get()));
862                 }
863                          
864                 if (this.depth < 1) {
865                         this.addLine(this.inpad + "}");
866                 }
867                         
868         }
869
870         string padMultiline(string pad, string str)
871         {
872                 var ar = str.strip().split("\n");
873                 return string.joinv("\n" + pad , ar);
874         }
875         
876         void ignore(string i) {
877                 this.ignoreList.add(i);
878                 
879         }
880         void ignoreWrapped(string i) {
881                 this.ignoreWrappedList.add(i);
882                 
883         }
884         bool shouldIgnore(string i)
885         {
886                 return ignoreList.contains(i);
887         }
888         bool shouldIgnoreWrapped(string i)
889         {
890                 return ignoreWrappedList.contains(i);
891         }
892         
893 }
894         
895          
896         
897         
898
899