1 //<script type="text/javscript">
3 imports['Object.js'].load(Object);
4 JSDOC = imports['JSDOC.js'].JSDOC;
5 console = imports['console.js'].console;
6 TokenStream = imports['JSDOC/TokenStream.js'].TokenStream;
9 * this takes our collased file, and turns it into the config array..
18 RooFile = Object.define(
21 RooFile.superclass.constructor.call(this, ar);
22 // console.log("STARTING OUTPUT");
35 if (this.tokens[0].data == 'Pman.on') {
36 // then it's a layout style..
41 //console.dump(this.tokens);
42 // the list of statements inside of function..?
43 var stmts = this.tokens[1].items[1][2].items;
44 // look for register..
46 stmts.map( function(s, i) {
47 if (s[0].data == 'Pman.register') {
48 topp = brace = s[1].items[0][0].props;
52 console.dump(this.tokens);
53 throw "could not find top props...";
57 this.cfg = this.parseProps(topp);
58 this.cfg.name = this.tokens[3].data;
61 // ( { add { this.panel ( {
62 var cfg = this.tokens[7].items[0][0].props.add.val[2].items[2][3].items[0][0].props;
63 this.cfg.items = [ this.parseProps(cfg) ];
64 // console.dump(this.cfg);
69 if (this.tokens[2].props && typeof(this.tokens[2].props.create) != 'undefined') {
70 //console.dump(this.tokens);
71 this.cfg.name = this.tokens[0].data;
75 var cfg = this.tokens[2].props.create.val[2].items[1][3].items[0][0].props;
76 //console.dump(this.tokens);
77 this.cfg.items = [ this.parseProps(cfg) ];
80 // perfect for dialogs...
83 var pos = this.lookFor( 'function');
88 if (pos > -1 && (this.tokens[pos-1].data == '=') && (this.tokens[pos-2].type == 'NAME')) {
91 '*class' : this.tokens[pos-2].data,
93 '//constructor' : this.tokens[pos-2].prefix,
94 '|constructor' : 'function ' + this.tokens[pos+1].toRaw() +
95 this.tokens[pos+2].toRaw(),
103 // no function - we have a static one...
104 pos = this.lookFor( '=');
106 (this.tokens[pos-1].type == 'NAME') &&
107 (this.tokens[pos+1].data == '{')
110 '*class' : this.tokens[pos-1].data,
111 '//*class' : this.tokens[pos-1].prefix,
115 Object.extend(this.cfg, this.parseProps(this.tokens[pos+1].props));
126 var pos = this.lookFor( 'Roo.apply');
127 //console.dump(this.tokens);
132 (this.tokens[pos+1].items[0][0].data == this.cfg['*class'] + '.prototype')
134 // XXXXXx.prototype = {
138 Object.extend(this.cfg, this.parseProps(this.tokens[pos+1].items[1][0].props));
144 var pos = this.lookFor('new');
147 (this.tokens[pos-2].type == 'NAME') &&
148 (this.tokens[pos-1].data == '=') &&
149 (this.tokens[pos+1].type == 'NAME') &&
150 (this.tokens[pos+2].data == '(')
154 '//*class' : this.tokens[pos-2].prefix,
155 '*class' : this.tokens[pos-2].data,
156 '*extends' : this.tokens[pos+1].data
159 Object.extend(this.cfg, this.parseProps(this.tokens[pos+2].items[0][0].props));
165 ///Builder.Provider.ProjectManager = new Roo.Observable({
169 var pos = this.lookFor( 'Roo.extend');
172 this.cfg['*extends'] = this.tokens[pos+1].items[1][0].data;
173 Object.extend(this.cfg, this.parseProps(this.tokens[pos+1].items[2][0].props));
181 var pos = this.lookFor( 'Roo.extend');
184 this.cfg['*extends'] = this.tokens[pos+1].items[1][0].data;
185 Object.extend(this.cfg, this.parseProps(this.tokens[pos+1].items[2][0].props));
198 // other type of layout
199 // console.dump(this.tokens);
201 // this type of file..
202 // xxxx.xxx = function
203 // -> into |constructor..
204 // -> extend + prototype
211 parseProps: function(o)
218 if (o[k].key.data == '}') {
219 // typo trailing comma in object def.
224 if (o[k].key.type == 'STRN') {
225 kv = o[k].key.toJS();
227 if (!o[k].val.length) {
230 //console.dump(o[k]);
231 if (o[k].val[0].data == "function") {
233 // console.dump(o[k].key.prefix);
234 var pr = typeof(o[k].key.prefix) == 'undefined' ? '' : o[k].key.prefix ;
235 pr = this.clean_prefix( pr) ;
240 ret['|' +kv ] = this.clean_body( this.expand(o[k].val));
243 if (o[k].val[0].data == "[") {
245 if (o[k].val[0].items[0][0].data == '{') {
246 // array of objects..
248 // this works for items..
250 // used elsewhere for buttons: -> in which case we have a fake xtype
254 // if K is not ITEMS - we need to add '*prop' -> and add it to the items array..
255 var add = this.parseArray(o[k].val[0].items);
261 xtype : 'Array.' + kv,
265 fakeItems.push(fake_array);
271 ret['|' +kv ] = this.clean_body(this.expand(o[k].val)); // remove ','...
274 if (o[k].val[0].data == "(") {
275 ret['|' +kv ] = this.expand(o[k].val);
278 if (o[k].val[0].data == "{") {
280 // things that can be property of object type:
282 var add = this.parseProps(o[k].val[0].props);
283 if (kv == 'set' || kv =='listeners') {
287 if ((typeof(add.xtype) != 'undefined') || ['sortInfo', 'center', 'east', 'west', 'north', 'south'].indexOf(kv) > -1) {
294 ret[ '|' + kv ] = this.expand(o[k].val);
297 // this hsould be added to 'items', with a *prop element..
300 //console.dump(o[k].val);
302 if (o[k].val[1].data == ',' || o[k].val[1].data == '}') {
303 // single item piece of data...
305 switch(o[k].val[0].type) {
309 ret[ kv ] = t1.toJS();
312 ret[ '|' + kv ] = t1.data;
318 ret[ '|' + kv ] = this.expand(o[k].val);
321 if (!ret.items && fakeItems.length) {
324 Object.extend(fakeItems, function(e) {
332 parseArray: function(ar) {
336 ar.map(function (e) {
338 if (typeof(e[0].props) == 'undefined') {
343 ret.push( this.parseProps(e[0].props));
357 for(var i =0 ; i < ar.length -1; i++) {
358 ret += ar[i].toRaw();
367 clean_body : function(str)
369 var lns = str.split("\n");
371 lns.map( function(l, i) {
372 if (!i || !l.length || l.match(/^\s+$/)) {
376 var spc = l.match(/\s+/);
377 if (!spc || !spc[0].length) {
380 mindent = mindent < 0 ? spc[0].length : Math.min(spc[0].length, mindent);
383 //console.log(mindent + ":" + lns[0]);
388 lns.map( function(l,i) {
390 ar.push(l.replace(/^\s+/, ''));
393 ar.push(l.substring(mindent));
395 return ar.join("\n");
397 clean_prefix: function(str) {
404 var ret = str.replace(/^\s+/gm, "\n").replace(/\n+/gm, "\n");
405 return ret == "\n" ? '' : ret;