JSDOC/Packer.js
[gnome.introspection-doc-generator] / JSDOC / Packer.js
index aa6711e..93aebf6 100644 (file)
@@ -151,9 +151,16 @@ Packer.prototype = {
      */
     module: false,
     /**
-     * @cfg {String} debugTargettarget to write files debug version to (uncompacted)- must be full path.
+     * @cfg {String} debugTarget target to write files debug version to (uncompacted)- must be full path.
      */
     debugTarget : '', // merged file without compression.
+    /**
+     * @cfg {String} debugTranslateTarget target to write files debug version
+     *            to (uncompacted) but with translation- must be full path.
+     */
+    
+    debugTranslateTarget : '', 
+    
     /**
      * @cfg {String} tmpDir  (optional) where to put the temporary files. 
      *      if you set this, then files will not be cleaned up
@@ -225,6 +232,9 @@ Packer.prototype = {
         if (this.debugTarget) {
             File.write(this.debugTarget, "");
         }
+        if (this.debugTranslateTarget) {
+            File.write(this.debugTarget, "");
+        }
         
         for(var i=0; i < this.files.length; i++)  {
             var file = this.files[i];
@@ -262,7 +272,7 @@ Packer.prototype = {
                 }
                 
             }
-            
+             
             print("COMPRESSING ");
             //var codeComp = pack(str, 10, 0, 0);
             if (File.exists(minfile)) {
@@ -270,13 +280,15 @@ Packer.prototype = {
             }
             var str = File.read(file);
             var str = this.pack(str, file, minfile);
-            if (str.length) {
-                File.write(minfile, str);
-            }
-            
              
           
-        }  
+        }
+        
+        
+        
+        // if we are translating, write the translations strings at the top
+        // of the file..
+        
         if (this.translateJSON) {
             
                
@@ -287,9 +299,7 @@ Packer.prototype = {
             } else {
                 this.out += out;
             }
-            
-            
-            
+             
             File.write(this.translateJSON, "");
             for(var i=0; i < this.files.length; i++)  {
                 var file = this.files[i];
@@ -405,12 +415,17 @@ Packer.prototype = {
         sp.mungeSymboltree();
         this.timerPrint("Munged Sym tree");
         print(sp.warnings.join("\n"));
-        
+        this.timerPrint("Compressed");
         
         var out = CompressWhite(new TokenStream(toks), this, this.keepWhite); // do not kill whitespace..
         
         
         this.timerPrint("Compressed");
+        
+         if (out.length) {
+            File.write(minfile, out);
+        }
+        
         return out;
         
         
@@ -431,19 +446,24 @@ Packer.prototype = {
      * -> this file will need inserting at the start of the application....
      * -> we need to generate 2 files, 
      * -> a reference used to do the translation, and the _T file..
+     *
+     *
+     * We store the trsum on the token...
      * 
      */
     
     writeTranslateFile : function(fn, minfile, toks) 
     {
         
-        var map = {};
+        var map = {};  // 'string=> md5sum'
         var _this = this;
         toks.forEach(function (t) {
             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[sval] = _this.md5(ffn + '-' + sval);
+                
+                t.trsum = _this.md5(ffn + '-' + sval);
+                map[sval] = t.trsum;
             }
         })
         
@@ -502,6 +522,12 @@ Packer.prototype = {
             return data;
         }
         
+        if (typeof(tok.trsum) == 'undefined') {
+            return data;
+        }
+        
+        return '_T["' + tok.trsum + '"]';
+        
         var sval = data.substring(1,data.length-1);
         // we do not clean up... quoting here!??!!?!?!?!?