*/
namespace JSDOC
{
-
+ public errordomain PackerError {
+ ArgumentError
+ }
public class Packer : Object
{
* @cfg {String} target to write files to - must be full path.
*/
string target;
- FileOutputStream targetStream = null;
+ GLib.FileOutputStream targetStream = null;
/**
* @cfg {String} debugTarget target to write files debug version to (uncompacted)- must be full path.
*/
string targetDebug;
- FileOutputStream targetDebugStream = null;
+ GLib.FileOutputStream targetDebugStream = null;
/**
* @cfg {String} tmpDir (optional) where to put the temporary files.
* if you set this, then files will not be cleaned up
public void pack()
{
- if (!this.files) {
- throw new Packer.ArgumentError("No Files loaded before pack() called");
+ if (this.files.size < 1) {
+ throw new PackerError.ArgumentError("No Files loaded before pack() called");
}
if (this.target.length > 0 ) {
this.targetStream = File.new_for_path(this.target).replace(null, false,FileCreateFlags.NONE);
// should we prefix? =- or should this be done elsewhere?
var add = f.replace(".", "/") + ".js";
- if (_this.files.contains(add)) {
+ if (this.files.contains(add)) {
continue;
}
- _this.files.add( add );
+ this.files.add( add );
}
}
//this.transOrigFile= bpath + '/../lang.en.js'; // needs better naming...
//File.write(this.transfile, "");
if (this.target.length > 0) {
- this.targetStream.write("");
+ this.targetStream.write("".data);
}
- if (this.debugTarget > 0) {
- this.targetDebugStream.write("");
+ if (this.targetDebugStream != null) {
+ this.targetDebugStream.write("".data);
}
+
+
foreach(var file in this.files) {
print("reading %s\n",file );
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!!
}
- /**
- * Core packing routine for a file
- *
- * @param str - str source text..
- * @param fn - filename (for reference?)
- * @param minfile - min file location...
- *
- */
-
- void packFile (string str,string fn, string minfile)
- {
-
- var tr = new TokenReader();
- tr.keepDocs =true;
- tr.keepWhite = true;
- tr.keepComments = true;
- tr.sepIdents = true;
- tr.collapseWhite = false;
- tr.filename = fn;
+ /**
+ * Core packing routine for a file
+ *
+ * @param str - str source text..
+ * @param fn - filename (for reference?)
+ * @param minfile - min file location...
+ *
+ */
- this.timerPrint("START" + fn);
-
- // we can load translation map here...
-
- var toks = tr.tokenize(new TextStream(str)); // dont merge xxx + . + yyyy etc.
-
-
-
- this.activeFile = fn;
-
- // and replace if we are generating a different language..
-
-
- //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(ts);
-
- sp.packer = this;
- sp.buildSymbolTree();
-
- sp.mungeSymboltree();
-
- print(sp.warnings.join("\n"));
-
-
- var out = CompressWhite(new TokenStream(toks), this, this.keepWhite); // do not kill whitespace..
-
-
-
-
- if (out.length) {
- File.write(minfile, out);
- this.timerPrint("Write (" + out.length + "bytes) " + minfile);
- }
-
- return out;
-
-
-
- },
-
-
- md5 : function (string)
- {
-
- return GLib.compute_checksum_for_string(GLib.ChecksumType.MD5, string, string.length);
-
- },
-
- //stringHandler : function(tok) -- not used...
+ private string packFile (string str,string fn, string minfile)
+ {
+
+ var tr = new TokenReader();
+ tr.keepDocs =true;
+ tr.keepWhite = true;
+ tr.keepComments = true;
+ 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.
+
+
+
+ this.activeFile = fn;
+
+ // and replace if we are generating a different language..
+
+
+ //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(ts);
+
+ sp.packer = this;
+ sp.buildSymbolTree();
+
+ sp.mungeSymboltree();
+
+ print(sp.warnings.join("\n"));
+
+
+ var outf = CompressWhite(new TokenStream(toks), this, this.keepWhite); // do not kill whitespace..
+
+
+
+
+ if (out.length > 0) {
+ FileUtils.put_contents(minfile, outf);
+
+ }
+
+ return out;
+
+
+
+ }
+
+
+ public string md5(string str)
+ {
+
+ return GLib.compute_checksum_for_string(GLib.ChecksumType.MD5, str);
+
+ }
+ //stringHandler : function(tok) -- not used...
+ }
-};
+}