//<script type="text/javscript">
-JSDOC = imports['JSDOC.js'].JSDOC;
-Roo = imports['Roo.js'].Roo;
-console = imports['console.js'].console;
+imports['Object.js'].load(Object);
+JSDOC = imports['JSDOC.js'].JSDOC;
+console = imports['console.js'].console;
TokenStream = imports['JSDOC/TokenStream.js'].TokenStream;
/**
*
*
*/
-RooFile = function (ar)
-{
- RooFile.superclass.constructor.call(this, ar);
- // console.log("STARTING OUTPUT");
-
-
-
-}
-
-Roo.extend(RooFile, TokenStream, {
-
- cfg : { },
+RooFile = Object.define(
+ function (ar)
+ {
+ RooFile.superclass.constructor.call(this, ar);
+ // console.log("STARTING OUTPUT");
+
+
- parse: function()
+ },
+ TokenStream,
{
- if (this.tokens[0].data == 'Pman.on') {
- // then it's a layout style..
-
- //Seed.quit();
-
+ cfg : { },
+
+ parse: function()
+ {
- //console.dump(this.tokens);
- // the list of statements inside of function..?
- var stmts = this.tokens[1].items[1][2].items;
- // look for register..
- var topp = false;
- Roo.each(stmts, function(s, i) {
- if (s[0].data == 'Pman.register') {
- topp = brace = s[1].items[0][0].props;
+ if (this.tokens[0].data == 'Pman.on') {
+ // then it's a layout style..
+
+ //Seed.quit();
+
+
+ //console.dump(this.tokens);
+ // the list of statements inside of function..?
+ var stmts = this.tokens[1].items[1][2].items;
+ // look for register..
+ var topp = false;
+ stmts.map( function(s, i) {
+ if (s[0].data == 'Pman.register') {
+ topp = brace = s[1].items[0][0].props;
+ }
+ });
+ if (!topp) {
+ console.dump(this.tokens);
+ throw "could not find top props...";
+
}
- });
- if (!topp) {
- console.dump(this.tokens);
- throw "could not find top props...";
+
+ this.cfg = this.parseProps(topp);
+ this.cfg.name = this.tokens[3].data;
+
+
+ // ( { add { this.panel ( {
+ var cfg = this.tokens[7].items[0][0].props.add.val[2].items[2][3].items[0][0].props;
+ this.cfg.items = [ this.parseProps(cfg) ];
+ // console.dump(this.cfg);
+
+ return;
+ }
+
+ if (this.tokens[2].props && typeof(this.tokens[2].props.create) != 'undefined') {
+ //console.dump(this.tokens);
+ this.cfg.name = this.tokens[0].data;
+
+
+
+ var cfg = this.tokens[2].props.create.val[2].items[1][3].items[0][0].props;
+ //console.dump(this.tokens);
+ this.cfg.items = [ this.parseProps(cfg) ];
}
+ // perfect for dialogs...
- this.cfg = this.parseProps(topp);
- this.cfg.name = this.tokens[3].data;
+ var pos = this.lookFor( 'function');
- // ( { add { this.panel ( {
- var cfg = this.tokens[7].items[0][0].props.add.val[2].items[2][3].items[0][0].props;
- this.cfg.items = [ this.parseProps(cfg) ];
- // console.dump(this.cfg);
+ // XXXXX = function(
+ var cfg = {};
- return;
- }
-
- if (this.tokens[2].props && typeof(this.tokens[2].props.create) != 'undefined') {
- //console.dump(this.tokens);
- this.cfg.name = this.tokens[0].data;
+ if (pos > -1 && (this.tokens[pos-1].data == '=') && (this.tokens[pos-2].type == 'NAME')) {
+
+ this.cfg = {
+ '*class' : this.tokens[pos-2].data,
+ '*extends' : '',
+ '//constructor' : this.tokens[pos-2].prefix,
+ '|constructor' : 'function ' + this.tokens[pos+1].toRaw() +
+ this.tokens[pos+2].toRaw(),
+
+ };
+ this.cursor = pos+2;
+
+ }
+ if (pos < 0) {
+ // no function - we have a static one...
+ pos = this.lookFor( '=');
+ if (pos > 1 &&
+ (this.tokens[pos-1].type == 'NAME') &&
+ (this.tokens[pos+1].data == '{')
+ ) {
+ this.cfg = {
+ '*class' : this.tokens[pos-1].data,
+ '//*class' : this.tokens[pos-1].prefix,
+
+
+ };
+ Object.extend(this.cfg, this.parseProps(this.tokens[pos+1].props));
+ return;
+
+ }
+
+
+
+ }
- var cfg = this.tokens[2].props.create.val[2].items[1][3].items[0][0].props;
+ // Roo.apply (l
+ var pos = this.lookFor( 'Roo.apply');
//console.dump(this.tokens);
- this.cfg.items = [ this.parseProps(cfg) ];
- }
- // perfect for dialogs...
-
-
- var pos = this.lookFor( 'function');
-
- // XXXXX = function(
- var cfg = {};
-
- if (pos > -1 && (this.tokens[pos-1].data == '=') && (this.tokens[pos-2].type == 'NAME')) {
- this.cfg = {
- '*class' : this.tokens[pos-2].data,
- '*extends' : '',
- '//constructor' : this.tokens[pos-2].prefix,
- '|constructor' : 'function ' + this.tokens[pos+1].toRaw() +
- this.tokens[pos+2].toRaw(),
+ if (
+ (pos > -1) &&
+ (this.tokens[pos+1].items[0][0].data == this.cfg['*class'] + '.prototype')
+ ) {
+ // XXXXXx.prototype = {
+
+
+
+ Object.extend(this.cfg, this.parseProps(this.tokens[pos+1].items[1][0].props));
+ return;
- };
- this.cursor = pos+2;
+ }
- }
-
- if (pos < 0) {
- // no function - we have a static one...
- pos = this.lookFor( '=');
- if (pos > 1 &&
- (this.tokens[pos-1].type == 'NAME') &&
- (this.tokens[pos+1].data == '{')
+
+ var pos = this.lookFor('new');
+
+ if (pos > -1 &&
+ (this.tokens[pos-2].type == 'NAME') &&
+ (this.tokens[pos-1].data == '=') &&
+ (this.tokens[pos+1].type == 'NAME') &&
+ (this.tokens[pos+2].data == '(')
) {
+
this.cfg = {
- '*class' : this.tokens[pos-1].data,
- '//*class' : this.tokens[pos-1].prefix,
-
-
+ '//*class' : this.tokens[pos-2].prefix,
+ '*class' : this.tokens[pos-2].data,
+ '*extends' : this.tokens[pos+1].data
};
- Roo.apply(this.cfg, this.parseProps(this.tokens[pos+1].props));
+
+ Object.extend(this.cfg, this.parseProps(this.tokens[pos+2].items[0][0].props));
+
return;
}
+ ///Builder.Provider.ProjectManager = new Roo.Observable({
+
- }
-
-
- // Roo.apply (l
- var pos = this.lookFor( 'Roo.apply');
- //console.dump(this.tokens);
-
-
- if (
- (pos > -1) &&
- (this.tokens[pos+1].items[0][0].data == this.cfg['*class'] + '.prototype')
- ) {
- // XXXXXx.prototype = {
-
-
+ var pos = this.lookFor( 'Roo.extend');
+ if (pos > -1) {
- Roo.apply(this.cfg, this.parseProps(this.tokens[pos+1].items[1][0].props));
- return;
-
- }
-
-
- var pos = this.lookFor('new');
-
- if (pos > -1 &&
- (this.tokens[pos-2].type == 'NAME') &&
- (this.tokens[pos-1].data == '=') &&
- (this.tokens[pos+1].type == 'NAME') &&
- (this.tokens[pos+2].data == '(')
- ) {
+ this.cfg['*extends'] = this.tokens[pos+1].items[1][0].data;
+ Object.extend(this.cfg, this.parseProps(this.tokens[pos+1].items[2][0].props));
+
+ // no more..
+ return;
+ }
- this.cfg = {
- '//*class' : this.tokens[pos-2].prefix,
- '*class' : this.tokens[pos-2].data,
- '*extends' : this.tokens[pos+1].data
- };
+
- Roo.apply(this.cfg, this.parseProps(this.tokens[pos+2].items[0][0].props));
+ var pos = this.lookFor( 'Roo.extend');
+ if (pos > -1) {
+
+ this.cfg['*extends'] = this.tokens[pos+1].items[1][0].data;
+ Object.extend(this.cfg, this.parseProps(this.tokens[pos+1].items[2][0].props));
+
+ // no more..
+ return;
+ }
- return;
- }
-
- ///Builder.Provider.ProjectManager = new Roo.Observable({
-
-
- var pos = this.lookFor( 'Roo.extend');
- if (pos > -1) {
+ //console.dump(cfg);
+ //Seed.quit();
- this.cfg['*extends'] = this.tokens[pos+1].items[1][0].data;
- Roo.apply(this.cfg, this.parseProps(this.tokens[pos+1].items[2][0].props));
- // no more..
- return;
- }
-
-
- var pos = this.lookFor( 'Roo.extend');
- if (pos > -1) {
+ // other type of layout
+ // console.dump(this.tokens);
- this.cfg['*extends'] = this.tokens[pos+1].items[1][0].data;
- Roo.apply(this.cfg, this.parseProps(this.tokens[pos+1].items[2][0].props));
+ // this type of file..
+ // xxxx.xxx = function
+ // -> into |constructor..
+ // -> extend + prototype
+
- // no more..
- return;
- }
-
-
-
- //console.dump(cfg);
- //Seed.quit();
-
-
-
- // other type of layout
- // console.dump(this.tokens);
-
- // this type of file..
- // xxxx.xxx = function
- // -> into |constructor..
- // -> extend + prototype
-
-
-
-
- },
-
- parseProps: function(o)
- {
- var ret = { };
- var fakeItems = [];
- for(var k in o) {
-
-
- if (o[k].key.data == '}') {
- // typo trailing comma in object def.
- continue;
- }
- var kv = k;
- if (o[k].key.type == 'STRN') {
- kv = o[k].key.toJS();
- }
- if (!o[k].val.length) {
- console.dump(o[k]);
- }
- //console.dump(o[k]);
- if (o[k].val[0].data == "function") {
- // add comments..
- // console.dump(o[k].key.prefix);
- var pr = typeof(o[k].key.prefix) == 'undefined' ? '' : o[k].key.prefix ;
- pr = this.clean_prefix( pr) ;
- if (pr.length) {
- ret['//' +kv ] = pr;
- }
- ret['|' +kv ] = this.clean_body( this.expand(o[k].val));
- continue;
- }
- if (o[k].val[0].data == "[") {
+ },
+
+ parseProps: function(o)
+ {
+ var ret = { };
+ var fakeItems = [];
+ for(var k in o) {
- if (o[k].val[0].items[0][0].data == '{') {
- // array of objects..
+
+ if (o[k].key.data == '}') {
+ // typo trailing comma in object def.
+ continue;
+ }
+
+ var kv = k;
+ if (o[k].key.type == 'STRN') {
+ kv = o[k].key.toJS();
+ }
+ if (!o[k].val.length) {
+ console.dump(o[k]);
+ }
+ //console.dump(o[k]);
+ if (o[k].val[0].data == "function") {
+ // add comments..
+ // console.dump(o[k].key.prefix);
+ var pr = typeof(o[k].key.prefix) == 'undefined' ? '' : o[k].key.prefix ;
+ pr = this.clean_prefix( pr) ;
+ if (pr.length) {
+ ret['//' +kv ] = pr;
+ }
- // this works for items..
+ ret['|' +kv ] = this.clean_body( this.expand(o[k].val));
+ continue;
+ }
+ if (o[k].val[0].data == "[") {
- // used elsewhere for buttons: -> in which case we have a fake xtype
+ if (o[k].val[0].items[0][0].data == '{') {
+ // array of objects..
+
+ // this works for items..
+
+ // used elsewhere for buttons: -> in which case we have a fake xtype
+
+
+
+ // if K is not ITEMS - we need to add '*prop' -> and add it to the items array..
+ var add = this.parseArray(o[k].val[0].items);
+ if (kv == 'items') {
+ ret[kv] = add;
+ continue;
+ }
+ var fake_array = {
+ xtype : 'Array.' + kv,
+ '*prop' : kv,
+ items : add
+ }
+ fakeItems.push(fake_array);
+ continue;
+ }
+ // raw array
+ ret['|' +kv ] = this.clean_body(this.expand(o[k].val)); // remove ','...
+ continue;
+ }
+ if (o[k].val[0].data == "(") {
+ ret['|' +kv ] = this.expand(o[k].val);
+ continue;
+ }
+ if (o[k].val[0].data == "{") {
- // if K is not ITEMS - we need to add '*prop' -> and add it to the items array..
- var add = this.parseArray(o[k].val[0].items);
- if (kv == 'items') {
- ret[kv] = add;
+ // things that can be property of object type:
+ // listeners, set,
+ var add = this.parseProps(o[k].val[0].props);
+ if (kv == 'set' || kv =='listeners') {
+ ret[kv ] = add;
continue;
}
- var fake_array = {
- xtype : 'Array.' + kv,
- '*prop' : kv,
- items : add
+ if ((typeof(add.xtype) != 'undefined') || ['sortInfo', 'center', 'east', 'west', 'north', 'south'].indexOf(kv) > -1) {
+ add['*prop'] = kv;
+ fakeItems.push(add);
+ continue;
}
- fakeItems.push(fake_array);
- continue;
- }
- // raw array
-
-
- ret['|' +kv ] = this.clean_body(this.expand(o[k].val)); // remove ','...
- continue;
- }
- if (o[k].val[0].data == "(") {
- ret['|' +kv ] = this.expand(o[k].val);
- continue;
- }
- if (o[k].val[0].data == "{") {
-
- // things that can be property of object type:
- // listeners, set,
- var add = this.parseProps(o[k].val[0].props);
- if (kv == 'set' || kv =='listeners') {
- ret[kv ] = add;
- continue;
- }
- if ((typeof(add.xtype) != 'undefined') || ['sortInfo', 'center', 'east', 'west', 'north', 'south'].indexOf(kv) > -1) {
- add['*prop'] = kv;
- fakeItems.push(add);
+
+
+ ret[ '|' + kv ] = this.expand(o[k].val);
+
+
+ // this hsould be added to 'items', with a *prop element..
continue;
}
+ //console.dump(o[k].val);
-
+ if (o[k].val[1].data == ',' || o[k].val[1].data == '}') {
+ // single item piece of data...
+ var t1= o[k].val[0];
+ switch(o[k].val[0].type) {
+ case 'STRN':
+ case 'NUMB':
+ case 'KEYW':
+ ret[ kv ] = t1.toJS();
+ continue;
+ case 'NAME':
+ ret[ '|' + kv ] = t1.data;
+ continue;
+
+ }
+ }
+
ret[ '|' + kv ] = this.expand(o[k].val);
-
- // this hsould be added to 'items', with a *prop element..
- continue;
}
- //console.dump(o[k].val);
-
- if (o[k].val[1].data == ',' || o[k].val[1].data == '}') {
- // single item piece of data...
- var t1= o[k].val[0];
- switch(o[k].val[0].type) {
- case 'STRN':
- case 'NUMB':
- case 'KEYW':
- ret[ kv ] = t1.toJS();
- continue;
- case 'NAME':
- ret[ '|' + kv ] = t1.data;
- continue;
-
- }
+ if (!ret.items && fakeItems.length) {
+ ret.items = [];
}
+ Object.extend(fakeItems, function(e) {
+ ret.items.push(e);
+ })
+ // merge fakeItems;
+ //console.dump(ret);
+
+ return ret;
+ },
+ parseArray: function(ar) {
+ // console.dump(ar);
+ // Seed.quit();
+ var ret = [];
+ ar.map(function (e) {
+ // has no props...
+ if (typeof(e[0].props) == 'undefined') {
+ return;
+ }
+
+
+ ret.push( this.parseProps(e[0].props));
+
+ },this);
+
+ return ret;
+
+ },
+
+
+ expand: function(ar)
+ {
+ var ret = '';
- ret[ '|' + kv ] = this.expand(o[k].val);
-
- }
- if (!ret.items && fakeItems.length) {
- ret.items = [];
- }
- Roo.each(fakeItems, function(e) {
- ret.items.push(e);
- })
- // merge fakeItems;
- //console.dump(ret);
-
- return ret;
- },
- parseArray: function(ar) {
- // console.dump(ar);
- // Seed.quit();
- var ret = [];
- Roo.each(ar, function (e) {
- // has no props...
- if (typeof(e[0].props) == 'undefined') {
- return;
+
+ for(var i =0 ; i < ar.length -1; i++) {
+ ret += ar[i].toRaw();
}
+
+
+ return ret;
- ret.push( this.parseProps(e[0].props));
-
- },this);
-
- return ret;
-
- },
-
-
- expand: function(ar)
- {
- var ret = '';
-
-
- for(var i =0 ; i < ar.length -1; i++) {
- ret += ar[i].toRaw();
- }
-
-
-
- return ret;
-
-
- },
- clean_body : function(str)
- {
- var lns = str.split("\n");
- var mindent = -1;
- Roo.each(lns, function(l, i) {
- if (!i || !l.length || l.match(/^\s+$/)) {
- return;
- }
- var spc = l.match(/\s+/);
- if (!spc || !spc[0].length) {
- return;
+ },
+ clean_body : function(str)
+ {
+ var lns = str.split("\n");
+ var mindent = -1;
+ lns.map( function(l, i) {
+ if (!i || !l.length || l.match(/^\s+$/)) {
+ return;
+ }
+
+ var spc = l.match(/\s+/);
+ if (!spc || !spc[0].length) {
+ return;
+ }
+ mindent = mindent < 0 ? spc[0].length : Math.min(spc[0].length, mindent);
+
+ });
+ //console.log(mindent + ":" + lns[0]);
+ var ar = [];
+ if (mindent < 0) {
+ return str;
}
- mindent = mindent < 0 ? spc[0].length : Math.min(spc[0].length, mindent);
-
- });
- //console.log(mindent + ":" + lns[0]);
- var ar = [];
- if (mindent < 0) {
- return str;
- }
- Roo.each(lns, function(l,i) {
- if (!i) {
- ar.push(l.replace(/^\s+/, ''));
- return;
+ lns.map( function(l,i) {
+ if (!i) {
+ ar.push(l.replace(/^\s+/, ''));
+ return;
+ }
+ ar.push(l.substring(mindent));
+ });
+ return ar.join("\n");
+ },
+ clean_prefix: function(str) {
+
+
+
+ if (!str.length) {
+ return '';
}
- ar.push(l.substring(mindent));
- });
- return ar.join("\n");
- },
- clean_prefix: function(str) {
-
-
-
- if (!str.length) {
- return '';
- }
- var ret = str.replace(/^\s+/gm, "\n").replace(/\n+/gm, "\n");
- return ret == "\n" ? '' : ret;
-
- }
-
-
+ var ret = str.replace(/^\s+/gm, "\n").replace(/\n+/gm, "\n");
+ return ret == "\n" ? '' : ret;
+
+ }
+
});
\ No newline at end of file