X-Git-Url: http://git.roojs.org/?p=gnome.introspection-doc-generator;a=blobdiff_plain;f=JSDOC%2FPacker.js;h=dde208516007d2ae72fb541999c82f3a23f76135;hp=8743c5add535b65f1b4a22afffde8c8bb1f70b9c;hb=db7f0739d8000a3a6acadd881d562ced33a16a3b;hpb=b3b0082d2dd485baca05d5e72b0c7b4469eda3aa diff --git a/JSDOC/Packer.js b/JSDOC/Packer.js index 8743c5a..dde2085 100644 --- a/JSDOC/Packer.js +++ b/JSDOC/Packer.js @@ -2,11 +2,12 @@ XObject = imports.XObject.XObject; File = imports.File.File; -TextStream = imports['JSDOC/TextStream.js'].TextStream; -TokenReader = imports['JSDOC/TokenReader.js'].TokenReader; -ScopeParser = imports['JSDOC/ScopeParser.js'].ScopeParser; -TokenStream = imports['JSDOC/TokenStream.js'].TokenStream; -CompressWhite = imports['JSDOC/CompressWhite.js'].CompressWhite; +TextStream = imports.TextStream.TextStream; +TokenReader = imports.TokenReader.TokenReader; +ScopeParser = imports.ScopeParser.ScopeParser; +TokenStream = imports.TokenStream.TokenStream; +CompressWhite = imports.CompressWhite.CompressWhite; +Collapse = imports.Collapse.Collapse; GLib = imports.gi.GLib; /** @@ -70,6 +71,11 @@ Packer = function(cfg) { XObject.extend(this, cfg); + + if (this.srcfile) { + this.loadSourceFile(); + } + if (!this.files) { throw "No Files"; } @@ -81,6 +87,11 @@ Packer = function(cfg) } Packer.prototype = { + /** + * @prop srcfiles {String} file containing a list of files/or classes to use. + */ + srcfiles : false, + /** * @prop files {Array} list of files to compress (must be full path) */ @@ -114,6 +125,33 @@ Packer.prototype = { prefix : '', out : '', // if no target is specified - then this will contain the result + + loadSourceFile : function() + { + var lines = File.read(this.srcfile).split("\n"); + var _this = this; + lines.forEach(function(f) { + + if (/^\s*\//.test(f) || !/[a-z]+/i.test(f)) { // skip comments.. + return; + } + if (/\.js$/.test(f)) { + _this.files.push( f); + // js file.. + return; + } + + //println("ADD"+ f.replace(/\./g, '/')); + var add = f.replace(/\./g, '/').replace(/\s+/g,'')+'.js'; + if (_this.files.indexOf(f) > -1) { + return; + } + _this.files.push( add ); + + }) + }, + + packAll : function() // do the packing (run from constructor) { @@ -273,7 +311,13 @@ Packer.prototype = { pack : function (str,fn,minfile) { - var tr = new TokenReader( { keepDocs :true, keepWhite : true, keepComments : true, sepIdents : true }); + var tr = new TokenReader( { + keepDocs :true, + keepWhite : true, + keepComments : true, + sepIdents : true, + collapseWhite : false + }); this.timerPrint("START" + fn); // we can load translation map here... @@ -291,8 +335,12 @@ Packer.prototype = { // and replace if we are generating a different language.. this.timerPrint("Tokenized"); + //var ts = new TokenStream(toks); + //print(JSON.stringify(toks, null,4 )); Seed.quit(); + var ts = new Collapse(toks); + // print(JSON.stringify(ts.tokens, null,4 )); Seed.quit(); //return;// - var sp = new ScopeParser(new TokenStream(toks)); + var sp = new ScopeParser(ts); this.timerPrint("Converted to Parser"); sp.packer = this; sp.buildSymbolTree(); @@ -300,7 +348,10 @@ Packer.prototype = { sp.mungeSymboltree(); this.timerPrint("Munged Sym tree"); print(sp.warnings.join("\n")); - var out = CompressWhite(sp.ts, this); + + + //var out = CompressWhite(new TokenStream(toks), this, true); // do not kill whitespace.. + var out = CompressWhite(new TokenStream(toks), this, false); this.timerPrint("Compressed"); return out; @@ -334,7 +385,7 @@ Packer.prototype = { if (t.type == 'STRN' && t.name == 'DOUBLE_QUOTE') { var sval = t.data.substring(1,t.data.length-1); var ffn = fn.substring(_this.prefix.length); - map[] = _this.md5(ffn + '-' + sval) + map[sval] = _this.md5(ffn + '-' + sval); } })