JSDOC/Packer.vala
[gnome.introspection-doc-generator] / JSDOC / Packer.vala
index ce3f615..21782f1 100644 (file)
@@ -100,6 +100,11 @@ namespace JSDOC
                // list of files to compile...
                Gee.ArrayList<string> files;
                
+               
+               
+               public string activeFile = "";
+               
+               
                public  string out = ""; // if no target is specified - then this will contain the result
     
                public Packer(string target, string targetDebug = "")
@@ -195,9 +200,11 @@ namespace JSDOC
                        this.targetStream.write("".data);
                    }
                    
-                   if (this.debugTarget > 0) {
+                   if (this.targetDebugStream != null) {
                            this.targetDebugStream.write("".data);
                    }
+                   
+                   
                    foreach(var file in this.files) {
                        
                        print("reading %s\n",file );
@@ -214,7 +221,7 @@ namespace JSDOC
                        if (this.targetDebugStream !=null) {
                                
                                FileUtils.get_contents(file,out file_contents);
-                           this.targetDebugStream.write(file_contents);
+                           this.targetDebugStream.write(file_contents.data);
                            loaded_string = false;
                        }
                        // it's a good idea to check with 0 compression to see if the code can parse!!
@@ -224,7 +231,7 @@ namespace JSDOC
                        
                   
                        
-                       var minfile = this.tmpDir + '/' + file.replace("/", '.');
+                       var minfile = this.tmpDir + "/" + file.replace("/", ".");
                        
                        
                        // let's see if we have a min file already?
@@ -313,20 +320,21 @@ namespace JSDOC
                    */
                    print("MERGING SOURCE");
                    
-                   for(var i=0; i < this.files.length; i++)  {
+                   for(var i=0; i < this.files.size; i++)  {
                        var file = this.files[i];
-                       var minfile = this.tmpDir + '/' + file.replace('/', '.');
+                       var minfile = this.tmpDir + "/" + file.replace("/", ".");
                        
                        
-                       if (!File.exists(minfile)) {
+                       if ( FileUtils.test(minfile, FileTest.EXISTS)) {
                            continue;
                        }
-                       var str = File.read(minfile);
-                       print("using MIN FILE  "+ minfile);
-                       if (str.length) {
+                       string str;
+                       FileUtils.get_contents(minfile, out str);
+                       print("using MIN FILE  %s\n", minfile);
+                       if (str.length > 0) {
                            if (this.targetStream != null) {
-                                       this.targetStream.write("//" + file + "\n"); 
-                                       this.targetStream.write(str + "\n"); 
+                                       this.targetStream.write(("//" + file + "\n").data); 
+                                       this.targetStream.write((str + "\n").data); 
 
                            } else {
                                this.out += "//" + file + "\n";
@@ -340,7 +348,9 @@ namespace JSDOC
                        
                    }
                    print("Output file: " + this.target);
-                   if (this.debugTarget) print("Output debug file: " + this.debugTarget);
+                   if (this.targetDebug.length > 0) {
+                                print("Output debug file: " + this.targetDebug);
+                        }
                    
                     
                
@@ -365,12 +375,10 @@ namespace JSDOC
                        tr.sepIdents = true;
                        tr.collapseWhite = false;
                        tr.filename = fn;
-
-                       this.timerPrint("START" + fn);
-               
                        // we can load translation map here...
                
-                       var toks = tr.tokenize(new TextStream(str)); // dont merge xxx + . + yyyy etc.
+                       TokenArray toks = tr.tokenize(new TextStream(str)); // dont merge xxx + . + yyyy etc.
                
                
                
@@ -381,26 +389,26 @@ namespace JSDOC
 
                        //var ts = new TokenStream(toks);
                        //print(JSON.stringify(toks, null,4 )); Seed.quit();
-                       var ts = new Collapse(toks);
+                       var ts = new Collapse(toks.tokens);
                   // print(JSON.stringify(ts.tokens, null,4 )); Seed.quit();
                        //return;//
                        var sp = new ScopeParser(ts);
-
-                       sp.packer = this;
+                       //sp.packer = this;
                        sp.buildSymbolTree();
 
                        sp.mungeSymboltree();
-
-                       print(sp.warnings.join("\n"));
+                       sp.printWarnings();
+                       //print(sp.warnings.join("\n"));
 
                
-                       var outf = CompressWhite(new TokenStream(toks), this, this.keepWhite); // do not kill whitespace..
+                       var outf = CompressWhite(new TokenStream(toks.tokens), this, this.keepWhite); // do not kill whitespace..
                
                
                
                
-                        if (out.length > 0) {
-                               FileUtils.put_contents(minfile, outf);
+                        if (outf.length > 0) {
+                               FileUtils.set_contents(minfile, outf);
                                 
                        }
                
@@ -414,7 +422,7 @@ namespace JSDOC
                public string md5(string str)
                {
                
-                       return GLib.compute_checksum_for_string(GLib.ChecksumType.MD5, str);
+                       return GLib.Checksum.compute_for_string(GLib.ChecksumType.MD5, str);
                
                }