haxeshim
Version:
Haxe shim to deal with cooexisting versions.
627 lines (624 loc) • 16.3 kB
JavaScript
// Generated by Haxe 3.4.2 (git build development @ e033003)
if (typeof process !== "undefined") if (process.version < "v4.0.0") console.warn("Module " + (typeof(module) == "undefined" ? "" : module.filename) + " requires node.js version 4.0.0 or higher");
(function ($global) { "use strict";
var $estr = function() { return js_Boot.__string_rec(this,''); };
function $extend(from, fields) {
function Inherit() {} Inherit.prototype = from; var proto = new Inherit();
for (var name in fields) proto[name] = fields[name];
if( fields.toString !== Object.prototype.toString ) proto.toString = fields.toString;
return proto;
}
var HxOverrides = function() { };
HxOverrides.__name__ = true;
HxOverrides.iter = function(a) {
return { cur : 0, arr : a, hasNext : function() {
return this.cur < this.arr.length;
}, next : function() {
return this.arr[this.cur++];
}};
};
Math.__name__ = true;
var Reflect = function() { };
Reflect.__name__ = true;
Reflect.field = function(o,field) {
try {
return o[field];
} catch( e ) {
return null;
}
};
Reflect.fields = function(o) {
var a = [];
if(o != null) {
var hasOwnProperty = Object.prototype.hasOwnProperty;
for( var f in o ) {
if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
a.push(f);
}
}
}
return a;
};
Reflect.copy = function(o) {
var o2 = { };
var _g = 0;
var _g1 = Reflect.fields(o);
while(_g < _g1.length) {
var f = _g1[_g];
++_g;
o2[f] = Reflect.field(o,f);
}
return o2;
};
var Std = function() { };
Std.__name__ = true;
Std.string = function(s) {
return js_Boot.__string_rec(s,"");
};
var StringTools = function() { };
StringTools.__name__ = true;
StringTools.replace = function(s,sub,by) {
return s.split(sub).join(by);
};
var Sys = function() { };
Sys.__name__ = true;
Sys.systemName = function() {
var _g = process.platform;
switch(_g) {
case "darwin":
return "Mac";
case "freebsd":
return "BSD";
case "linux":
return "Linux";
case "win32":
return "Windows";
default:
var other = _g;
return other;
}
};
var haxe_StackItem = { __ename__ : true, __constructs__ : ["CFunction","Module","FilePos","Method","LocalFunction"] };
haxe_StackItem.CFunction = ["CFunction",0];
haxe_StackItem.CFunction.toString = $estr;
haxe_StackItem.CFunction.__enum__ = haxe_StackItem;
haxe_StackItem.Module = function(m) { var $x = ["Module",1,m]; $x.__enum__ = haxe_StackItem; $x.toString = $estr; return $x; };
haxe_StackItem.FilePos = function(s,file,line) { var $x = ["FilePos",2,s,file,line]; $x.__enum__ = haxe_StackItem; $x.toString = $estr; return $x; };
haxe_StackItem.Method = function(classname,method) { var $x = ["Method",3,classname,method]; $x.__enum__ = haxe_StackItem; $x.toString = $estr; return $x; };
haxe_StackItem.LocalFunction = function(v) { var $x = ["LocalFunction",4,v]; $x.__enum__ = haxe_StackItem; $x.toString = $estr; return $x; };
var haxe_IMap = function() { };
haxe_IMap.__name__ = true;
var haxe_ds_StringMap = function() {
this.h = { };
};
haxe_ds_StringMap.__name__ = true;
haxe_ds_StringMap.__interfaces__ = [haxe_IMap];
haxe_ds_StringMap.prototype = {
setReserved: function(key,value) {
if(this.rh == null) {
this.rh = { };
}
this.rh["$" + key] = value;
}
,getReserved: function(key) {
if(this.rh == null) {
return null;
} else {
return this.rh["$" + key];
}
}
,keys: function() {
return HxOverrides.iter(this.arrayKeys());
}
,arrayKeys: function() {
var out = [];
for( var key in this.h ) {
if(this.h.hasOwnProperty(key)) {
out.push(key);
}
}
if(this.rh != null) {
for( var key in this.rh ) {
if(key.charCodeAt(0) == 36) {
out.push(key.substr(1));
}
}
}
return out;
}
,__class__: haxe_ds_StringMap
};
var haxe_io_Bytes = function() { };
haxe_io_Bytes.__name__ = true;
haxe_io_Bytes.prototype = {
__class__: haxe_io_Bytes
};
var haxe_io_Eof = function() { };
haxe_io_Eof.__name__ = true;
haxe_io_Eof.prototype = {
toString: function() {
return "Eof";
}
,__class__: haxe_io_Eof
};
var haxeshim__$Env_Env_$Impl_$ = {};
haxeshim__$Env_Env_$Impl_$.__name__ = true;
haxeshim__$Env_Env_$Impl_$.ofVars = function(vars) {
var this1 = { };
var ret = this1;
var _g = 0;
var _g1 = Reflect.fields(vars);
while(_g < _g1.length) {
var k = _g1[_g];
++_g;
ret[haxeshim_Os.IS_WINDOWS ? k.toUpperCase() : k] = vars[k];
}
var this2 = ret;
return this2;
};
haxeshim__$Env_Env_$Impl_$.ofMap = function(map) {
var this1 = { };
var ret = this1;
var k = map.keys();
while(k.hasNext()) {
var k1 = k.next();
ret[haxeshim_Os.IS_WINDOWS ? k1.toUpperCase() : k1] = __map_reserved[k1] != null ? map.getReserved(k1) : map.h[k1];
}
var this2 = ret;
return this2;
};
haxeshim__$Env_Env_$Impl_$.vars = function(this1) {
return this1;
};
haxeshim__$Env_Env_$Impl_$.toVars = function(this1) {
return Reflect.copy(this1);
};
haxeshim__$Env_Env_$Impl_$.get = function(this1,s) {
return this1[haxeshim_Os.IS_WINDOWS ? s.toUpperCase() : s];
};
haxeshim__$Env_Env_$Impl_$.mergeInto = function(this1,that) {
var _g = haxeshim__$Env_Env_$Impl_$.vars(that);
if(this1 == null) {
var v = _g;
var this2 = v;
return this2;
} else if(_g == null) {
var v1 = this1;
var this3 = v1;
return this3;
} else {
var a = this1;
var b = _g;
var this4 = { };
var ret = this4;
var _g1 = 0;
var _g11 = [b,a];
while(_g1 < _g11.length) {
var vars = _g11[_g1];
++_g1;
var _g2 = 0;
var _g3 = Reflect.fields(vars);
while(_g2 < _g3.length) {
var k = _g3[_g2];
++_g2;
ret[k] = vars[k];
}
}
var this5 = ret;
return this5;
}
};
var haxeshim_Exec = function() { };
haxeshim_Exec.__name__ = true;
haxeshim_Exec.mergeEnv = function(env) {
return haxeshim__$Env_Env_$Impl_$.mergeInto(env,haxeshim__$Env_Env_$Impl_$.ofVars(process.env));
};
haxeshim_Exec.sync = function(cmd,cwd,args,env) {
var _g = js_node_ChildProcess.spawnSync(cmd,args,{ cwd : cwd, stdio : "inherit", env : haxeshim__$Env_Env_$Impl_$.toVars(haxeshim_Exec.mergeEnv(env))});
var x = _g;
if(x.error == null) {
return tink_core_Outcome.Success(x.status);
} else {
var e = _g.error;
return tink_core_Outcome.Failure(new tink_core_TypedError(null,"Failed to call " + cmd + " because " + Std.string(e),{ fileName : "Exec.hx", lineNumber : 39, className : "haxeshim.Exec", methodName : "sync"}));
}
};
var haxeshim_Os = function() { };
haxeshim_Os.__name__ = true;
haxeshim_Os.slashes = function(path) {
if(haxeshim_Os.IS_WINDOWS) {
return StringTools.replace(path,"/","\\");
} else {
return path;
}
};
var haxeshim_Scope = function() { };
haxeshim_Scope.__name__ = true;
var haxeshim_Neko = function() { };
haxeshim_Neko.__name__ = true;
haxeshim_Neko.setEnv = function() {
if(haxeshim_Neko.isset) {
if(haxeshim_Os.IS_WINDOWS) {
var _g = 0;
var this1 = haxeshim_Neko.ENV;
var _g1 = this1 == null ? [] : Reflect.fields(this1);
while(_g < _g1.length) {
var k = _g1[_g];
++_g;
var v = haxeshim__$Env_Env_$Impl_$.get(haxeshim_Neko.ENV,k);
process.env[k] = v;
}
}
haxeshim_Neko.isset = false;
}
};
var haxeshim_NekoCli = function() { };
haxeshim_NekoCli.__name__ = true;
haxeshim_NekoCli.main = function() {
haxeshim_Neko.setEnv();
var binary = haxeshim_Os.IS_WINDOWS ? "neko.exe" : "neko";
var code;
var _g = haxeshim_Exec.sync(haxeshim_Neko.PATH + ("/" + binary),process.cwd(),process.argv.slice(2),haxeshim_Neko.ENV);
switch(_g[1]) {
case 0:
var c = _g[2];
code = c;
break;
case 1:
var e = _g[2];
code = e.code;
break;
}
process.exit(code);
};
var js__$Boot_HaxeError = function(val) {
Error.call(this);
this.val = val;
this.message = String(val);
if(Error.captureStackTrace) {
Error.captureStackTrace(this,js__$Boot_HaxeError);
}
};
js__$Boot_HaxeError.__name__ = true;
js__$Boot_HaxeError.wrap = function(val) {
if((val instanceof Error)) {
return val;
} else {
return new js__$Boot_HaxeError(val);
}
};
js__$Boot_HaxeError.__super__ = Error;
js__$Boot_HaxeError.prototype = $extend(Error.prototype,{
__class__: js__$Boot_HaxeError
});
var js_Boot = function() { };
js_Boot.__name__ = true;
js_Boot.getClass = function(o) {
if((o instanceof Array) && o.__enum__ == null) {
return Array;
} else {
var cl = o.__class__;
if(cl != null) {
return cl;
}
var name = js_Boot.__nativeClassName(o);
if(name != null) {
return js_Boot.__resolveNativeClass(name);
}
return null;
}
};
js_Boot.__string_rec = function(o,s) {
if(o == null) {
return "null";
}
if(s.length >= 5) {
return "<...>";
}
var t = typeof(o);
if(t == "function" && (o.__name__ || o.__ename__)) {
t = "object";
}
switch(t) {
case "function":
return "<function>";
case "object":
if(o instanceof Array) {
if(o.__enum__) {
if(o.length == 2) {
return o[0];
}
var str = o[0] + "(";
s += "\t";
var _g1 = 2;
var _g = o.length;
while(_g1 < _g) {
var i = _g1++;
if(i != 2) {
str += "," + js_Boot.__string_rec(o[i],s);
} else {
str += js_Boot.__string_rec(o[i],s);
}
}
return str + ")";
}
var l = o.length;
var i1;
var str1 = "[";
s += "\t";
var _g11 = 0;
var _g2 = l;
while(_g11 < _g2) {
var i2 = _g11++;
str1 += (i2 > 0 ? "," : "") + js_Boot.__string_rec(o[i2],s);
}
str1 += "]";
return str1;
}
var tostr;
try {
tostr = o.toString;
} catch( e ) {
return "???";
}
if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
var s2 = o.toString();
if(s2 != "[object Object]") {
return s2;
}
}
var k = null;
var str2 = "{\n";
s += "\t";
var hasp = o.hasOwnProperty != null;
for( var k in o ) {
if(hasp && !o.hasOwnProperty(k)) {
continue;
}
if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
continue;
}
if(str2.length != 2) {
str2 += ", \n";
}
str2 += s + k + " : " + js_Boot.__string_rec(o[k],s);
}
s = s.substring(1);
str2 += "\n" + s + "}";
return str2;
case "string":
return o;
default:
return String(o);
}
};
js_Boot.__interfLoop = function(cc,cl) {
if(cc == null) {
return false;
}
if(cc == cl) {
return true;
}
var intf = cc.__interfaces__;
if(intf != null) {
var _g1 = 0;
var _g = intf.length;
while(_g1 < _g) {
var i = _g1++;
var i1 = intf[i];
if(i1 == cl || js_Boot.__interfLoop(i1,cl)) {
return true;
}
}
}
return js_Boot.__interfLoop(cc.__super__,cl);
};
js_Boot.__instanceof = function(o,cl) {
if(cl == null) {
return false;
}
switch(cl) {
case Array:
if((o instanceof Array)) {
return o.__enum__ == null;
} else {
return false;
}
break;
case Bool:
return typeof(o) == "boolean";
case Dynamic:
return true;
case Float:
return typeof(o) == "number";
case Int:
if(typeof(o) == "number") {
return (o|0) === o;
} else {
return false;
}
break;
case String:
return typeof(o) == "string";
default:
if(o != null) {
if(typeof(cl) == "function") {
if(o instanceof cl) {
return true;
}
if(js_Boot.__interfLoop(js_Boot.getClass(o),cl)) {
return true;
}
} else if(typeof(cl) == "object" && js_Boot.__isNativeObj(cl)) {
if(o instanceof cl) {
return true;
}
}
} else {
return false;
}
if(cl == Class ? o.__name__ != null : false) {
return true;
}
if(cl == Enum ? o.__ename__ != null : false) {
return true;
}
return o.__enum__ == cl;
}
};
js_Boot.__nativeClassName = function(o) {
var name = js_Boot.__toStr.call(o).slice(8,-1);
if(name == "Object" || name == "Function" || name == "Math" || name == "JSON") {
return null;
}
return name;
};
js_Boot.__isNativeObj = function(o) {
return js_Boot.__nativeClassName(o) != null;
};
js_Boot.__resolveNativeClass = function(name) {
return $global[name];
};
var js_node_ChildProcess = require("child_process");
var js_node_buffer_Buffer = require("buffer").Buffer;
var tink_core_TypedError = function(code,message,pos) {
if(code == null) {
code = 500;
}
this.code = code;
this.message = message;
this.pos = pos;
this.exceptionStack = [];
this.callStack = [];
};
tink_core_TypedError.__name__ = true;
tink_core_TypedError.withData = function(code,message,data,pos) {
return tink_core_TypedError.typed(code,message,data,pos);
};
tink_core_TypedError.typed = function(code,message,data,pos) {
var ret = new tink_core_TypedError(code,message,pos);
ret.data = data;
return ret;
};
tink_core_TypedError.catchExceptions = function(f,report,pos) {
try {
return tink_core_Outcome.Success(f());
} catch( $e0 ) {
if ($e0 instanceof js__$Boot_HaxeError) $e0 = $e0.val;
if( js_Boot.__instanceof($e0,tink_core_TypedError) ) {
var e = $e0;
return tink_core_Outcome.Failure(e);
} else {
var e1 = $e0;
return tink_core_Outcome.Failure(report == null ? tink_core_TypedError.withData(null,"Unexpected Error",e1,pos) : report(e1));
}
}
};
tink_core_TypedError.reporter = function(code,message,pos) {
return function(e) {
return tink_core_TypedError.withData(code,message,e,pos);
};
};
tink_core_TypedError.rethrow = function(any) {
throw js__$Boot_HaxeError.wrap(any);
};
tink_core_TypedError.prototype = {
printPos: function() {
return this.pos.className + "." + this.pos.methodName + ":" + this.pos.lineNumber;
}
,toString: function() {
var ret = "Error#" + this.code + ": " + this.message;
if(this.pos != null) {
ret += " @ " + this.printPos();
}
return ret;
}
,throwSelf: function() {
throw new js__$Boot_HaxeError(this);
}
,__class__: tink_core_TypedError
};
var tink_core_Outcome = { __ename__ : true, __constructs__ : ["Success","Failure"] };
tink_core_Outcome.Success = function(data) { var $x = ["Success",0,data]; $x.__enum__ = tink_core_Outcome; $x.toString = $estr; return $x; };
tink_core_Outcome.Failure = function(failure) { var $x = ["Failure",1,failure]; $x.__enum__ = tink_core_Outcome; $x.toString = $estr; return $x; };
String.prototype.__class__ = String;
String.__name__ = true;
Array.__name__ = true;
var Int = { __name__ : ["Int"]};
var Dynamic = { __name__ : ["Dynamic"]};
var Float = Number;
Float.__name__ = ["Float"];
var Bool = Boolean;
Bool.__ename__ = ["Bool"];
var Class = { __name__ : ["Class"]};
var Enum = { };
var __map_reserved = {}
haxeshim_Os.IS_WINDOWS = Sys.systemName() == "Windows";
haxeshim_Os.DELIMITER = haxeshim_Os.IS_WINDOWS ? ";" : ":";
haxeshim_Scope.DEFAULT_ROOT = (function($this) {
var $r;
var _g = process.env["HAXESHIM_ROOT"];
$r = _g == null ? process.env[haxeshim_Os.IS_WINDOWS ? "APPDATA" : "HOME"] + "/haxe" : _g == "" ? process.env[haxeshim_Os.IS_WINDOWS ? "APPDATA" : "HOME"] + "/haxe" : (function($this) {
var $r;
var v = _g;
$r = v;
return $r;
}($this));
return $r;
}(this));
haxeshim_Neko.PATH = haxeshim_Os.slashes(haxeshim_Scope.DEFAULT_ROOT + "/neko");
haxeshim_Neko.isset = false;
haxeshim_Neko.ENV = (function($this) {
var $r;
var varName;
var _g = Sys.systemName();
switch(_g) {
case "Mac":
varName = "DYLD_LIBRARY_PATH";
break;
case "Windows":
varName = "PATH";
break;
default:
varName = "LD_LIBRARY_PATH";
}
var _g1 = process.env[varName];
$r = _g1 == null ? (function($this) {
var $r;
var _g11 = new haxe_ds_StringMap();
{
var value = haxeshim_Neko.PATH;
if(__map_reserved[varName] != null) {
_g11.setReserved(varName,value);
} else {
_g11.h[varName] = value;
}
}
$r = haxeshim__$Env_Env_$Impl_$.ofMap(_g11);
return $r;
}($this)) : (function($this) {
var $r;
var withNeko = _g1;
$r = withNeko.indexOf(haxeshim_Neko.PATH) != -1 ? haxeshim__$Env_Env_$Impl_$.ofVars({ }) : (function($this) {
var $r;
var v = _g1;
var _g12 = new haxe_ds_StringMap();
{
var value1 = v + haxeshim_Os.DELIMITER + haxeshim_Neko.PATH;
if(__map_reserved[varName] != null) {
_g12.setReserved(varName,value1);
} else {
_g12.h[varName] = value1;
}
}
$r = haxeshim__$Env_Env_$Impl_$.ofMap(_g12);
return $r;
}($this));
return $r;
}($this));
return $r;
}(this));
js_Boot.__toStr = ({ }).toString;
haxeshim_NekoCli.main();
})(typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this);