From: Alan Knowles Date: Thu, 28 Feb 2013 15:59:37 +0000 (+0800) Subject: gjs compatibility X-Git-Url: http://git.roojs.org/?p=gnome.introspection-doc-generator;a=commitdiff_plain;h=6ee0a01d3485b87e0514c6da4665a12aa00562b0 gjs compatibility --- diff --git a/File.js b/File.js index ebb74cf..b34a8df 100755 --- a/File.js +++ b/File.js @@ -2,7 +2,7 @@ const GLib = imports.gi.GLib; const Gio = imports.gi.Gio; -const String = imports.String.String; +var String = imports.String.String; /** * @namespace File * @@ -62,8 +62,11 @@ const File = { }, read : function (path) { var out = {}; - GLib.file_get_contents(path, out, null, null); - return out['value']; + + var ret = GLib.file_get_contents(path, out, null, null); + //print(ret[1]); + //throw "oops"; + return '' + ((typeof(ret) == 'object') ? ret[1] : out['value']); }, isFile : function (path) { @@ -79,7 +82,7 @@ const File = { list : function (path) { var listing = []; - var f = Gio.file_new_for_path(String(path)); + var f = Gio.file_new_for_path('' +(path)); var file_enum = f.enumerate_children(Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, Gio.FileQueryInfoFlags.NONE, null); var next_file = null; @@ -96,7 +99,7 @@ const File = { }, mtime : function (path) { - var f = Gio.file_new_for_path(String(path)); + var f = Gio.file_new_for_path('' +(path)); var mtime = new GLib.TimeVal(); var info = f.query_info(Gio.FILE_ATTRIBUTE_TIME_MODIFIED, Gio.FileQueryInfoFlags.NONE, null); @@ -106,7 +109,7 @@ const File = { }, canonical : function (path) { - var f = Gio.file_new_for_path(String(path)); + var f = Gio.file_new_for_path('' +(path)); var can = f.resolve_relative_path(''); return can.get_path(); }, @@ -118,7 +121,7 @@ const File = { * */ write : function (path, string) { - var f = Gio.file_new_for_path(String(path)); + var f = Gio.file_new_for_path('' +(path)); var data_out = new Gio.DataOutputStream({base_stream:f.replace(null, false, Gio.FileCreateFlags.NONE, null)}); data_out.put_string(string, null); data_out.close(null); @@ -130,7 +133,7 @@ const File = { * */ append : function (path, string) { - var f = Gio.file_new_for_path(String(path)); + var f = Gio.file_new_for_path('' +(path)); var data_out = new Gio.DataOutputStream({ base_stream:f.append_to(Gio.FileCreateFlags.NONE, null) }); @@ -146,8 +149,9 @@ const File = { */ remove : function (path) { - var f = Gio.file_new_for_path(String(path)); - return f['delete'](); + var f = Gio.file_new_for_path('' +(path)); + var c = new Gio.Cancellable(); + return f['delete'](c); }, /** * silentRecursiveCopy @@ -168,8 +172,8 @@ const File = { } for (var index in filesToCopy) { - srcPath = File.join(String(fromDir), filesToCopy[index]); - destPath = File.join(String(toDir), filesToCopy[index]); + srcPath = File.join('' +(fromDir), filesToCopy[index]); + destPath = File.join('' +(toDir), filesToCopy[index]); if (File.isDirectory(srcPath) && !File.isDirectory(destPath)) { File.mkdir(destPath); @@ -195,7 +199,7 @@ const File = { * @arg {String} dstPath directory to make */ mkdir : function (destPath) { - var dest = Gio.file_new_for_path(String(destPath)); + var dest = Gio.file_new_for_path('' +(destPath)); return dest.make_directory(null, null); }, @@ -210,8 +214,8 @@ const File = { if (typeof(opts) =='undefined') { opts = Gio.FileCopyFlags.NONE; } - var dest = Gio.file_new_for_path(String(destPath)); - var src = Gio.file_new_for_path(String(srcPath)); + var dest = Gio.file_new_for_path('' +(destPath)); + var src = Gio.file_new_for_path('' +(srcPath)); // a bit of a hack for the fact that Gio.File.copy arguments // can be nulled, but not according to the GIR file diff --git a/JSDOC/TokenReader.js b/JSDOC/TokenReader.js index 63cb7f2..b5f46be 100644 --- a/JSDOC/TokenReader.js +++ b/JSDOC/TokenReader.js @@ -150,7 +150,7 @@ const TokenReader = XObject.define( //Seed.print('(@' + n); var lt = this.lastSym(tokens, n); - Seed.print(JSON.stringify(lt)); + print(JSON.stringify(lt)); if (lt.type != 'KEYW' || ['IF', 'WHILE'].indexOf(lt.name) < -1) { if (!this.ignoreBadGrammer) { throw { diff --git a/pack.js b/pack.js index 0f4a772..e064aad 100644 --- a/pack.js +++ b/pack.js @@ -92,6 +92,7 @@ for(var i =0; i < args.length;i++) { } cfg.files.push(args[i]); } +print(JSON.stringify(args,null,4)); var pack; try { pack = new Packer(cfg)