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