JSDOC/Packer.js
[gnome.introspection-doc-generator] / JSDOC / Packer.js
index 0c56f3b..ccf4fbd 100644 (file)
@@ -1,16 +1,16 @@
 // <script type="text/javascript">
-XObject         = imports.XObject.XObject;
-File            = imports.File.File;
+const XObject         = imports.XObject.XObject;
+const File            = imports.File.File;
 
-TextStream      = imports.JSDOC.TextStream.TextStream ;
-TokenReader     = imports.TokenReader.TokenReader;
-ScopeParser     = imports.ScopeParser.ScopeParser;
-TokenStream     = imports.TokenStream.TokenStream;
-CompressWhite   = imports.CompressWhite.CompressWhite;
-Collapse        = imports.Collapse.Collapse;
+const TextStream      = imports.JSDOC.TextStream.TextStream ;
+const TokenReader     = imports.TokenReader.TokenReader;
+const ScopeParser     = imports.ScopeParser.ScopeParser;
+const TokenStream     = imports.TokenStream.TokenStream;
+const CompressWhite   = imports.CompressWhite.CompressWhite;
+const Collapse        = imports.Collapse.Collapse;
 
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
+const Gio = imports.gi.Gio;
 /**
  * @namespace JSDOC
  * @class  Packer
@@ -70,7 +70,7 @@ x.packFiles(
  * 
 
  */
-Packer = function(cfg)
+const Packer = function(cfg)
 {
     
     XObject.extend(this, cfg);
@@ -347,8 +347,10 @@ Packer.prototype = {
             print("using MIN FILE  "+ minfile);
             if (str.length) {
                 if (this.target) {
+                    File.append(this.target, '//' + file + "\n");   
                     File.append(this.target, str + "\n");   
                 } else {
+                    this.out += '//' + file + "\n";
                     this.out += str + "\n";
                 }
                 
@@ -401,7 +403,7 @@ Packer.prototype = {
         
         // and replace if we are generating a different language..
         
-        this.timerPrint("Tokenized");
+        this.timerPrint("Tokenized tokens:" + toks.length);
         //var ts = new TokenStream(toks);
         //print(JSON.stringify(toks, null,4 )); Seed.quit();
         var ts = new Collapse(toks);
@@ -424,6 +426,7 @@ Packer.prototype = {
         
          if (out.length) {
             File.write(minfile, out);
+            this.timerPrint("Write (" + out.length + "bytes) " + minfile);
         }
         
         return out;
@@ -460,23 +463,23 @@ Packer.prototype = {
         var t, last, next;
         
         
-        var tokfind =  function (i,dir) {
+        var tokfind =  function (j,dir) {
             while (1) {
-                if ((dir < 0) && (i < 0)) {
+                if ((dir < 0) && (j < 0)) {
                     return false;
                 }
-                if ((dir > 0) && (i >= toks.length)) {
+                if ((dir > 0) && (j >= toks.length)) {
                     return false;
                 }
-                i += dir;
-                if (toks[i].type != 'WHIT') {
-                    return toks[i];
+                j += dir;
+                if (toks[j].type != 'WHIT') {
+                    return toks[j];
                 }
             }
             return false;
             
         }
-         
+        
         
         for (var i=0;i<toks.length;i++) {
             
@@ -545,10 +548,11 @@ Packer.prototype = {
             if (!v.length) {
                 continue;
             }
-            File.append(transfile, l + "\n\t" + JSON.stringify(v) + " : " + JSON.stringify(v));
+            File.append(transfile, l + "\n\t\"" + v  + "\" : \"" + v +"\"");
             l = ',';
             // strings are raw... - as the where encoded to start with!!!
-            File.append(transmd5, '_T["' + this.md5(ffn + '-' + v) + '"]='+JSON.stringify(v)+";\n");
+            // so we should not need to encode them again.. - just wrap with "
+            File.append(transmd5, '_T["' + this.md5(ffn + '-' + v) + '"]="'+v+"\";\n");
         }
         File.append(transfile, "\n},"); // always one trailing..