diff --git a/haxelib.json b/haxelib.json index 6f587b0..b8e1a1d 100644 --- a/haxelib.json +++ b/haxelib.json @@ -8,6 +8,6 @@ "releasenote": "Fixes to make tests pass on JS, C++ and HL targets (more targets to be tested soon)", "contributors": ["jeremyfa"], "dependencies": { - "hscript": "2.3.0" + "hscript": "2.4.0" } - } \ No newline at end of file + } diff --git a/interpret/Env.hx b/interpret/Env.hx index 8eb1814..46d52d3 100644 --- a/interpret/Env.hx +++ b/interpret/Env.hx @@ -75,7 +75,7 @@ class Env { var stdModule:DynamicModule = DynamicModule.fromStatic(Std); // Patch Std.is to work in scripting env - stdModule.items.set('Std.is', ClassFieldItem(is, stdModule.id, 'Std.is', true, 'Bool', [null, null])); + stdModule.items.set('Std.isOfType', ClassFieldItem(is, stdModule.id, 'Std.isOfType', true, 'Bool', [null, null])); addModule('Std', stdModule); addModule('String', DynamicModule.fromStatic(String)); @@ -224,23 +224,23 @@ class Env { var vType:String = null; var tClassType:String = null; - if (Std.is(v, DynamicClass._contextType) && v.exists('__interpretType')) { + if (Std.isOfType(v, DynamicClass._contextType) && v.exists('__interpretType')) { vType = v.get('__interpretType'); } - else if (Std.is(v, DynamicClass) || Std.is(v, DynamicInstance)) { + else if (Std.isOfType(v, DynamicClass) || Std.isOfType(v, DynamicInstance)) { vType = TypeUtils.typeOf(v, this); } - if (Std.is(t, DynamicClass._contextType) && t.exists('__interpretType')) { + if (Std.isOfType(t, DynamicClass._contextType) && t.exists('__interpretType')) { tClassType = t.get('__interpretType'); } - else if (Std.is(t, DynamicClass)) { + else if (Std.isOfType(t, DynamicClass)) { tClassType = TypeUtils.typeOf(t, this); } if (vType == null && tClassType == null) { // Nothing dynamic, use standard Std.is() - return Std.is(v, t); + return Std.isOfType(v, t); } else { // Need to do runtime checks diff --git a/interpret/Interpreter.hx b/interpret/Interpreter.hx index a22a3f4..8a4bbdf 100644 --- a/interpret/Interpreter.hx +++ b/interpret/Interpreter.hx @@ -126,7 +126,7 @@ class Interpreter extends hscript.Interp { } var superInstance = self.get('super'); if (superInstance != null) { - if (Std.is(superInstance, DynamicInstance)) { + if (Std.isOfType(superInstance, DynamicInstance)) { var dynInst:DynamicInstance = cast superInstance; var prevQueryingInterpreter = dynInst.interpreter._queryingInterpreter; var prevUnresolved = dynInst.interpreter._unresolved; @@ -280,7 +280,7 @@ class Interpreter extends hscript.Interp { } var superInstance = self.get('super'); if (superInstance != null) { - if (Std.is(superInstance, DynamicInstance)) { + if (Std.isOfType(superInstance, DynamicInstance)) { var dynInst:DynamicInstance = cast superInstance; var prevQueryingInterpreter = dynInst.interpreter._queryingInterpreter; var prevUnresolved = dynInst.interpreter._unresolved; @@ -387,7 +387,7 @@ class Interpreter extends hscript.Interp { } var superInstance = self.get('super'); if (superInstance != null) { - if (Std.is(superInstance, DynamicInstance)) { + if (Std.isOfType(superInstance, DynamicInstance)) { var dynInst:DynamicInstance = cast superInstance; var prevQueryingInterpreter = dynInst.interpreter._queryingInterpreter; var prevUnresolved = dynInst.interpreter._unresolved; @@ -466,7 +466,7 @@ class Interpreter extends hscript.Interp { } return null; } - else if (Std.is(o, RuntimeItem)) { + else if (Std.isOfType(o, RuntimeItem)) { //trace('is runtime item'); var moduleItem:RuntimeItem = cast o; switch (moduleItem) { @@ -511,7 +511,7 @@ class Interpreter extends hscript.Interp { return null; } } - else if (Std.is(o, DynamicInstance)) { + else if (Std.isOfType(o, DynamicInstance)) { var dynInst:DynamicInstance = cast o; var prevQueryingInterpreter = dynInst.interpreter._queryingInterpreter; dynInst.interpreter._queryingInterpreter = this; @@ -519,7 +519,7 @@ class Interpreter extends hscript.Interp { dynInst.interpreter._queryingInterpreter = prevQueryingInterpreter; return result; } - else if (Std.is(o, DynamicClass)) { + else if (Std.isOfType(o, DynamicClass)) { var dynClass:DynamicClass = cast o; dynClass.initIfNeeded(); var prevQueryingInterpreter = dynClass.interpreter._queryingInterpreter; @@ -535,17 +535,17 @@ class Interpreter extends hscript.Interp { return resolved; } } - else if (Std.is(o, DynamicAbstract)) { + else if (Std.isOfType(o, DynamicAbstract)) { var abs:DynamicAbstract = cast o; return abs.get(f, false); } - else if (Std.is(o, DynamicPackage)) { + else if (Std.isOfType(o, DynamicPackage)) { var dynPack:DynamicPackage = cast o; var sub = dynPack.getSub(f); //trace('sub($f) -> $sub'); return sub; } - else if (Std.is(o, DynamicModule)) { + else if (Std.isOfType(o, DynamicModule)) { var dynMod:DynamicModule = cast o; var result = dynMod.items.get(dynMod.typePath + '.' + f); return unwrap(result); @@ -609,7 +609,7 @@ class Interpreter extends hscript.Interp { } return v; } - if (Std.is(o, RuntimeItem)) { + if (Std.isOfType(o, RuntimeItem)) { var moduleItem:RuntimeItem = cast o; switch (moduleItem) { case ClassFieldItem(rawItem, moduleId, name, isStatic, type, argTypes) | ExtensionItem(ClassFieldItem(rawItem, moduleId, name, isStatic, type, argTypes), _): @@ -642,7 +642,7 @@ class Interpreter extends hscript.Interp { return null; } } - else if (Std.is(o, DynamicInstance)) { + else if (Std.isOfType(o, DynamicInstance)) { var dynInst:DynamicInstance = cast o; var prevQueryingInterpreter = dynInst.interpreter._queryingInterpreter; dynInst.interpreter._queryingInterpreter = this; @@ -650,7 +650,7 @@ class Interpreter extends hscript.Interp { dynInst.interpreter._queryingInterpreter = prevQueryingInterpreter; return result; } - else if (Std.is(o, DynamicClass)) { + else if (Std.isOfType(o, DynamicClass)) { var dynClass:DynamicClass = cast o; dynClass.initIfNeeded(); var prevQueryingInterpreter = dynClass.interpreter._queryingInterpreter; @@ -659,7 +659,7 @@ class Interpreter extends hscript.Interp { dynClass.interpreter._queryingInterpreter = prevQueryingInterpreter; return result; } - else if (Std.is(o, DynamicAbstract)) { + else if (Std.isOfType(o, DynamicAbstract)) { var abs:DynamicAbstract = cast o; return abs.set(f, v, false); } @@ -672,7 +672,7 @@ class Interpreter extends hscript.Interp { //trace('CALL $o $f $args'); - if (Std.is(f, RuntimeItem)) { + if (Std.isOfType(f, RuntimeItem)) { switch (f) { case ExtensionItem(ClassFieldItem(rawItem, moduleId, name, isStatic, type, argTypes), _): if (rawItem == null) { @@ -718,7 +718,7 @@ class Interpreter extends hscript.Interp { if (dotIndex != -1) { fieldName = fieldName.substring(dotIndex + 1); } - if (Std.is(o, DynamicAbstract)) { + if (Std.isOfType(o, DynamicAbstract)) { var abs:DynamicAbstract = cast o; return abs.call(fieldName, args, false); } @@ -726,7 +726,7 @@ class Interpreter extends hscript.Interp { return DynamicAbstract.callStatic(o, env, null, fieldName, args, false); } case EnumFieldItem(rawItem, _, _): - if (Std.is(rawItem, DynamicClass)) { + if (Std.isOfType(rawItem, DynamicClass)) { return null; // TODO? } return Reflect.callMethod(o, rawItem, args); @@ -784,7 +784,7 @@ class Interpreter extends hscript.Interp { var instanciable:Dynamic = resolveInstanciable(cl); // Abstract? - if (Std.is(instanciable, RuntimeItem)) { + if (Std.isOfType(instanciable, RuntimeItem)) { var item:RuntimeItem = cast instanciable; switch (item) { case ClassItem(rawItem, moduleId, name): @@ -792,11 +792,11 @@ class Interpreter extends hscript.Interp { var dynClass = env.resolveDynamicClass(moduleId, name); if (dynClass != null) return dynClass.createInstance(args); } - else if (Std.is(rawItem, DynamicClass)) { + else if (Std.isOfType(rawItem, DynamicClass)) { var dynClass:DynamicClass = cast rawItem; return dynClass.createInstance(args); } - else if (Std.is(rawItem, Class)) { + else if (Std.isOfType(rawItem, Class)) { return Type.createInstance(rawItem, args); } case AbstractItem(rawItem, moduleId, name, runtimeType): @@ -805,11 +805,11 @@ class Interpreter extends hscript.Interp { } } // Dynamic class? - if (Std.is(instanciable, DynamicClass)) { + if (Std.isOfType(instanciable, DynamicClass)) { var dynClass:DynamicClass = cast instanciable; return dynClass.createInstance(args); } - else if (Std.is(instanciable, Class)) { + else if (Std.isOfType(instanciable, Class)) { return Type.createInstance(instanciable, args); } @@ -821,7 +821,7 @@ class Interpreter extends hscript.Interp { function unwrapIfUnwrappable(value:Dynamic):Dynamic { if (value == null) return null; - if (Std.is(value, RuntimeItem)) { + if (Std.isOfType(value, RuntimeItem)) { var item:RuntimeItem = cast value; switch (item) { case ExtensionItem(subItem, _): @@ -870,7 +870,7 @@ class Interpreter extends hscript.Interp { if (value == null) return null; if (value == Unresolved.UNRESOLVED) return null; - if (Std.is(value, RuntimeItem)) { + if (Std.isOfType(value, RuntimeItem)) { var item:RuntimeItem = cast value; switch (item) { case ExtensionItem(subItem, _): @@ -917,7 +917,7 @@ class Interpreter extends hscript.Interp { } } - if (Std.is(value, DynamicAbstract)) { + if (Std.isOfType(value, DynamicAbstract)) { var abs:DynamicAbstract = cast value; return abs.value; } diff --git a/interpret/TypeUtils.hx b/interpret/TypeUtils.hx index 5815323..cab4a27 100644 --- a/interpret/TypeUtils.hx +++ b/interpret/TypeUtils.hx @@ -19,23 +19,23 @@ class TypeUtils { /** Return a type string (with dot path if any) from the given object */ public static function typeOf(obj:Dynamic, ?env:Env):String { - if (Std.is(obj, String)) return 'String'; - if (Std.is(obj, Int)) return 'Int'; - if (Std.is(obj, Float)) return 'Float'; - if (Std.is(obj, Bool)) return 'Bool'; - if (Std.is(obj, Array)) return 'Array'; - if (Std.is(obj, IMap)) return 'Map'; - - if (Std.is(obj, DynamicClass)) { + if (Std.isOfType(obj, String)) return 'String'; + if (Std.isOfType(obj, Int)) return 'Int'; + if (Std.isOfType(obj, Float)) return 'Float'; + if (Std.isOfType(obj, Bool)) return 'Bool'; + if (Std.isOfType(obj, Array)) return 'Array'; + if (Std.isOfType(obj, IMap)) return 'Map'; + + if (Std.isOfType(obj, DynamicClass)) { var c:DynamicClass = cast obj; return c.classType; } - if (Std.is(obj, DynamicInstance)) { + if (Std.isOfType(obj, DynamicInstance)) { var i:DynamicInstance = cast obj; return i.dynamicClass.instanceType; } - if (Std.is(obj, RuntimeItem)) { + if (Std.isOfType(obj, RuntimeItem)) { var item:RuntimeItem = cast obj; switch (item) { case ExtensionItem(item, extendedType): @@ -58,13 +58,13 @@ class TypeUtils { } } - if (Std.is(obj, Class)) { + if (Std.isOfType(obj, Class)) { var classType = Type.getClassName(obj); if (classType == null) classType = 'Dynamic'; return 'Class<'+classType+'>'; } - if (Std.is(obj, Enum)) { + if (Std.isOfType(obj, Enum)) { var enumType = Type.getEnumName(obj); if (enumType == null) enumType = 'Dynamic'; return 'Enum<'+enumType+'>'; @@ -133,7 +133,7 @@ class TypeUtils { if (value == null) return null; if (value == Unresolved.UNRESOLVED) return null; - if (Std.is(value, RuntimeItem)) { + if (Std.isOfType(value, RuntimeItem)) { var item:RuntimeItem = cast value; switch (item) { case ExtensionItem(item, _) | SuperClassItem(item): @@ -172,7 +172,7 @@ class TypeUtils { } } - if (Std.is(value, DynamicAbstract)) { + if (Std.isOfType(value, DynamicAbstract)) { var abs:DynamicAbstract = cast value; return abs.value; } @@ -183,7 +183,7 @@ class TypeUtils { public static function wrapIfNeeded(value:Dynamic, type:String, ?env:Env):Dynamic { - if (value != null && Std.is(value, RuntimeItem)) { + if (value != null && Std.isOfType(value, RuntimeItem)) { // Already wrapped return value; } diff --git a/sample-dynclass-js.hxml b/sample-dynclass-js.hxml index 6566c4a..2f48349 100644 --- a/sample-dynclass-js.hxml +++ b/sample-dynclass-js.hxml @@ -1,4 +1,4 @@ --lib hscript:2.3.0 +-lib hscript:2.4.0 -main sample.DynamicClassSample -cp . -debug diff --git a/sample-dynclass.hxml b/sample-dynclass.hxml index e5f958c..100849e 100644 --- a/sample-dynclass.hxml +++ b/sample-dynclass.hxml @@ -1,4 +1,4 @@ --lib hscript:2.3.0 +-lib hscript:2.4.0 -main sample.DynamicClassSample -cp . -debug diff --git a/sample-livereload-hl.hxml b/sample-livereload-hl.hxml index 6d54bb4..5aa32b5 100644 --- a/sample-livereload-hl.hxml +++ b/sample-livereload-hl.hxml @@ -1,4 +1,4 @@ --lib hscript:2.3.0 +-lib hscript:2.4.0 -main sample.LiveReloadSample -cp . -debug diff --git a/sample-livereload-js.hxml b/sample-livereload-js.hxml index 7e8c8eb..502df67 100644 --- a/sample-livereload-js.hxml +++ b/sample-livereload-js.hxml @@ -1,4 +1,4 @@ --lib hscript:2.3.0 +-lib hscript:2.4.0 -main sample.LiveReloadSample -cp . -debug diff --git a/sample-livereload.hxml b/sample-livereload.hxml index 6b679e6..981b1d8 100644 --- a/sample-livereload.hxml +++ b/sample-livereload.hxml @@ -1,4 +1,4 @@ --lib hscript:2.3.0 +-lib hscript:2.4.0 -main sample.LiveReloadSample -cp . -debug diff --git a/test.hxml b/test.hxml index da4bc9c..c9cb5aa 100644 --- a/test.hxml +++ b/test.hxml @@ -1,4 +1,4 @@ --lib hscript:2.3.0 +-lib hscript:2.4.0 -lib buddy -D buddy-colors -main test.Test diff --git a/test/native/Quad.hx b/test/native/Quad.hx index 18647b5..af1abbe 100644 --- a/test/native/Quad.hx +++ b/test/native/Quad.hx @@ -9,7 +9,7 @@ class Quad { } public function colorInfo():String { - return 'isInt=' + (Std.is(color, Int) ? '1' : '0') + ' / ' + color.toWebString(); + return 'isInt=' + (Std.isOfType(color, Int) ? '1' : '0') + ' / ' + color.toWebString(); } } //Quad diff --git a/test/script/AnotherClass.hx b/test/script/AnotherClass.hx index cb06d7a..40aa18a 100644 --- a/test/script/AnotherClass.hx +++ b/test/script/AnotherClass.hx @@ -24,7 +24,7 @@ class AnotherClass { public function someInstanceMethod2() { - return Std.is(this, AnotherClass) ? 'true' : 'false'; + return Std.isOfType(this, AnotherClass) ? 'true' : 'false'; } //someInstanceMethod2 diff --git a/test/script/BasicClass.hx b/test/script/BasicClass.hx index f168535..b9beff4 100644 --- a/test/script/BasicClass.hx +++ b/test/script/BasicClass.hx @@ -105,13 +105,13 @@ class BasicClass { public function isBasicClass() { - return Std.is(this, BasicClass); + return Std.isOfType(this, BasicClass); } //isBasicClass public function isBasicClass2() { - return Std.is(this, test.script.BasicClass); + return Std.isOfType(this, test.script.BasicClass); } //isBasicClass2 diff --git a/test/script/ChildClass.hx b/test/script/ChildClass.hx index 2801141..1c65c60 100644 --- a/test/script/ChildClass.hx +++ b/test/script/ChildClass.hx @@ -11,7 +11,7 @@ class ChildClass extends BasicClass { public function isNativeClass() { - return Std.is(this, test.native.NativeClass); + return Std.isOfType(this, test.native.NativeClass); } //isNativeClass diff --git a/test/script/ImplementingClass.hx b/test/script/ImplementingClass.hx index ab87c77..6f1e897 100644 --- a/test/script/ImplementingClass.hx +++ b/test/script/ImplementingClass.hx @@ -14,7 +14,7 @@ class ImplementingClass implements NativeInterface { public function isNativeInterface() { - return Std.is(this, NativeInterface); + return Std.isOfType(this, NativeInterface); } //isNativeInterface diff --git a/test/script/NativeChildClass.hx b/test/script/NativeChildClass.hx index b18007e..127fad4 100644 --- a/test/script/NativeChildClass.hx +++ b/test/script/NativeChildClass.hx @@ -13,7 +13,7 @@ class NativeChildClass extends NativeClass { public function isNativeClass() { - return Std.is(this, test.native.NativeClass); + return Std.isOfType(this, test.native.NativeClass); } //isNativeClass