Browse Source

Fixup for Haxe4.2+ (#917)

Pavel Alexandrov 4 năm trước cách đây
mục cha
commit
11fd5ed5ed

+ 1 - 1
h2d/HtmlText.hx

@@ -801,7 +801,7 @@ class HtmlText extends Text {
 	override function getBoundsRec( relativeTo : Object, out : h2d.col.Bounds, forSize : Bool ) {
 	override function getBoundsRec( relativeTo : Object, out : h2d.col.Bounds, forSize : Bool ) {
 		if( forSize )
 		if( forSize )
 			for( i in elements )
 			for( i in elements )
-				if( hxd.impl.Api.is(i,h2d.Bitmap) )
+				if( hxd.impl.Api.isOfType(i,h2d.Bitmap) )
 					i.visible = false;
 					i.visible = false;
 		super.getBoundsRec(relativeTo, out, forSize);
 		super.getBoundsRec(relativeTo, out, forSize);
 		if( forSize )
 		if( forSize )

+ 1 - 1
h2d/domkit/Style.hx

@@ -360,7 +360,7 @@ class Style extends domkit.CssStyle {
 		var dom = obj.dom;
 		var dom = obj.dom;
 		if(dom != null) {
 		if(dom != null) {
 			for( s in dom.style ) {
 			for( s in dom.style ) {
-				if( s.p.name == "text" || hxd.impl.Api.is(s.value,h2d.Tile) ) continue;
+				if( s.p.name == "text" || hxd.impl.Api.isOfType(s.value,h2d.Tile) ) continue;
 				lines.push(' <font color="#D0D0D0"> ${s.p.name}</font> <font color="#808080">${s.value}</font><font color="#606060"> (style)</font>');
 				lines.push(' <font color="#D0D0D0"> ${s.p.name}</font> <font color="#808080">${s.value}</font><font color="#606060"> (style)</font>');
 			}
 			}
 			for( i in 0...dom.currentSet.length ) {
 			for( i in 0...dom.currentSet.length ) {

+ 1 - 1
h2d/filter/AbstractMask.hx

@@ -82,7 +82,7 @@ class AbstractMask extends Filter {
 		mask = m;
 		mask = m;
 		if( m != null && bindCount > 0 ) {
 		if( m != null && bindCount > 0 ) {
 			if( m.filter != null ) {
 			if( m.filter != null ) {
-				if( hxd.impl.Api.is(m.filter,Hide) ) throw "Same mask can't be part of several filters";
+				if( hxd.impl.Api.isOfType(m.filter,Hide) ) throw "Same mask can't be part of several filters";
 				throw "Can't set mask with filter "+m.filter;
 				throw "Can't set mask with filter "+m.filter;
 			}
 			}
 			m.filter = hide;
 			m.filter = hide;

+ 1 - 1
h3d/scene/Renderer.hx

@@ -69,7 +69,7 @@ class Renderer extends hxd.impl.AnyProps {
 
 
 	public function getPass<T:h3d.pass.Base>( c : Class<T> ) : T {
 	public function getPass<T:h3d.pass.Base>( c : Class<T> ) : T {
 		for( p in allPasses )
 		for( p in allPasses )
-			if( hxd.impl.Api.is(p, c) )
+			if( hxd.impl.Api.isOfType(p, c) )
 				return cast p;
 				return cast p;
 		return null;
 		return null;
 	}
 	}

+ 2 - 2
hxd/fs/FileConverter.hx

@@ -118,7 +118,7 @@ class FileConverter {
 	}
 	}
 
 
 	function makeCommmand( obj : Dynamic ) : { cmd : ConvertCommand, priority : Int } {
 	function makeCommmand( obj : Dynamic ) : { cmd : ConvertCommand, priority : Int } {
-		if( hxd.impl.Api.is(obj,String) )
+		if( hxd.impl.Api.isOfType(obj,String) )
 			return { cmd : { conv : loadConvert(obj) }, priority : 0 };
 			return { cmd : { conv : loadConvert(obj) }, priority : 0 };
 		if( obj.convert == null )
 		if( obj.convert == null )
 			throw "Missing 'convert' in "+obj;
 			throw "Missing 'convert' in "+obj;
@@ -132,7 +132,7 @@ class FileConverter {
 			case "priority": priority = value;
 			case "priority": priority = value;
 			default:
 			default:
 				if( cmd.params == null ) cmd.params = {};
 				if( cmd.params == null ) cmd.params = {};
-				if( Reflect.isObject(value) && !hxd.impl.Api.is(value,String) ) throw "Invalid parameter value "+f+"="+value;
+				if( Reflect.isObject(value) && !hxd.impl.Api.isOfType(value,String) ) throw "Invalid parameter value "+f+"="+value;
 				Reflect.setField(cmd.params, f, value);
 				Reflect.setField(cmd.params, f, value);
 			}
 			}
 		}
 		}

+ 1 - 1
hxd/impl/Api.hx

@@ -10,7 +10,7 @@ class Api {
 		#end
 		#end
 	}
 	}
 
 
-	public static inline function is( v : Dynamic, t : Dynamic) : Bool {
+	public static inline function isOfType( v : Dynamic, t : Dynamic) : Bool {
 		#if (haxe_ver >= 4.1)
 		#if (haxe_ver >= 4.1)
 		return Std.isOfType(v, t);
 		return Std.isOfType(v, t);
 		#else
 		#else

+ 1 - 1
hxd/inspect/PropManager.hx

@@ -194,7 +194,7 @@ class PropManager extends vdom.Client {
 
 
 	public function sameValue( v1 : Dynamic, v2 : Dynamic ) {
 	public function sameValue( v1 : Dynamic, v2 : Dynamic ) {
 		if( v1 == v2 ) return true;
 		if( v1 == v2 ) return true;
-		if( hxd.impl.Api.is(v1, Array) && hxd.impl.Api.is(v2, Array) ) {
+		if( hxd.impl.Api.isOfType(v1, Array) && hxd.impl.Api.isOfType(v2, Array) ) {
 			var a1 : Array<Dynamic> = v1;
 			var a1 : Array<Dynamic> = v1;
 			var a2 : Array<Dynamic> = v2;
 			var a2 : Array<Dynamic> = v2;
 			if( a1.length != a2.length )
 			if( a1.length != a2.length )

+ 9 - 9
hxd/inspect/PropTools.hx

@@ -6,7 +6,7 @@ class PropTools {
 	public static function setPropValue( p : Property, v : Dynamic, lerp = 1. ) {
 	public static function setPropValue( p : Property, v : Dynamic, lerp = 1. ) {
 		switch( p ) {
 		switch( p ) {
 		case PInt(_, get, set):
 		case PInt(_, get, set):
-			if( !Api.is(v, Int) ) throw "Invalid int value " + v;
+			if( !Api.isOfType(v, Int) ) throw "Invalid int value " + v;
 			var v : Int = v;
 			var v : Int = v;
 			if( lerp == 1 )
 			if( lerp == 1 )
 				set(v);
 				set(v);
@@ -16,29 +16,29 @@ class PropTools {
 				set( prev < v ? Math.ceil(u) : Math.floor(u) );
 				set( prev < v ? Math.ceil(u) : Math.floor(u) );
 			}
 			}
 		case PFloat(_, get, set):
 		case PFloat(_, get, set):
-			if( !Api.is(v, Float) ) throw "Invalid float value " + v;
+			if( !Api.isOfType(v, Float) ) throw "Invalid float value " + v;
 			if( lerp == 1 )
 			if( lerp == 1 )
 				set(v);
 				set(v);
 			else
 			else
 				set(hxd.Math.lerp(get(), v, lerp));
 				set(hxd.Math.lerp(get(), v, lerp));
 		case PRange(_, _, _, get, set):
 		case PRange(_, _, _, get, set):
-			if( !Api.is(v, Float) ) throw "Invalid float value " + v;
+			if( !Api.isOfType(v, Float) ) throw "Invalid float value " + v;
 			if( lerp == 1 )
 			if( lerp == 1 )
 				set(v);
 				set(v);
 			else
 			else
 				set(hxd.Math.lerp(get(), v, lerp));
 				set(hxd.Math.lerp(get(), v, lerp));
 		case PBool(_, _, set):
 		case PBool(_, _, set):
-			if( !Api.is(v, Bool) ) throw "Invalid bool value " + v;
+			if( !Api.isOfType(v, Bool) ) throw "Invalid bool value " + v;
 			set(v);
 			set(v);
 		case PString(_, _, set):
 		case PString(_, _, set):
-			if( v != null && !Api.is(v, String) ) throw "Invalid string value " + v;
+			if( v != null && !Api.isOfType(v, String) ) throw "Invalid string value " + v;
 			set(v);
 			set(v);
 		case PEnum(_, en, _, set):
 		case PEnum(_, en, _, set):
 			var e = en.createAll()[v];
 			var e = en.createAll()[v];
-			if( e == null || !Api.is(v, Int) ) throw "Invalid enum " + en.getName() + " value " + v;
+			if( e == null || !Api.isOfType(v, Int) ) throw "Invalid enum " + en.getName() + " value " + v;
 			set(e);
 			set(e);
 		case PColor(_, _, get, set):
 		case PColor(_, _, get, set):
-			if( !Api.is(v, String) ) throw "Invalid color value " + v;
+			if( !Api.isOfType(v, String) ) throw "Invalid color value " + v;
 			var v : String = v;
 			var v : String = v;
 			var newV = h3d.Vector.fromColor(Std.parseInt("0x" + v.substr(1)));
 			var newV = h3d.Vector.fromColor(Std.parseInt("0x" + v.substr(1)));
 			if( lerp == 1 )
 			if( lerp == 1 )
@@ -52,7 +52,7 @@ class PropTools {
 				set(newV);
 				set(newV);
 			}
 			}
 		case PFloats(_, get, set):
 		case PFloats(_, get, set):
-			if( !Api.is(v, Array) ) throw "Invalid floats value " + v;
+			if( !Api.isOfType(v, Array) ) throw "Invalid floats value " + v;
 			var a : Array<Float> = v;
 			var a : Array<Float> = v;
 			var prev = get();
 			var prev = get();
 			var need = prev.length;
 			var need = prev.length;
@@ -66,7 +66,7 @@ class PropTools {
 				set(newA);
 				set(newA);
 			}
 			}
 		case PTexture(_, _, set):
 		case PTexture(_, _, set):
-			if( !Api.is(v, String) ) throw "Invalid texture value " + v;
+			if( !Api.isOfType(v, String) ) throw "Invalid texture value " + v;
 			var path : String = v;
 			var path : String = v;
 			if( path.charCodeAt(0) != '/'.code && path.charCodeAt(1) != ':'.code ) {
 			if( path.charCodeAt(0) != '/'.code && path.charCodeAt(1) != ':'.code ) {
 				set(hxd.res.Loader.currentInstance.load(path).toTexture());
 				set(hxd.res.Loader.currentInstance.load(path).toTexture());

+ 6 - 6
hxd/inspect/ScenePanel.hx

@@ -334,17 +334,17 @@ class ScenePanel extends Panel {
 	}
 	}
 
 
 	function getObjectIcon( o : h3d.scene.Object) {
 	function getObjectIcon( o : h3d.scene.Object) {
-		if( Api.is(o, h3d.scene.Skin) )
+		if( Api.isOfType(o, h3d.scene.Skin) )
 			return "child";
 			return "child";
-		if( Api.is(o, h3d.parts.Particles) || Api.is(o,h3d.parts.GpuParticles) )
+		if( Api.isOfType(o, h3d.parts.Particles) || Api.isOfType(o,h3d.parts.GpuParticles) )
 			return "sun-o";
 			return "sun-o";
-		if( Api.is(o, h3d.scene.Mesh) )
+		if( Api.isOfType(o, h3d.scene.Mesh) )
 			return "cube";
 			return "cube";
-		if( Api.is(o, h3d.scene.CustomObject) )
+		if( Api.isOfType(o, h3d.scene.CustomObject) )
 			return "globe";
 			return "globe";
-		if( Api.is(o, h3d.scene.Scene) )
+		if( Api.isOfType(o, h3d.scene.Scene) )
 			return "picture-o";
 			return "picture-o";
-		if( Api.is(o, h3d.scene.Light) )
+		if( Api.isOfType(o, h3d.scene.Light) )
 			return "lightbulb-o";
 			return "lightbulb-o";
 		return null;
 		return null;
 	}
 	}

+ 6 - 6
hxd/inspect/SceneProps.hx

@@ -47,7 +47,7 @@ class SceneProps {
 			var m = Reflect.field(meta, f);
 			var m = Reflect.field(meta, f);
 			if( m != null && Reflect.hasField(m, "ignore") ) continue;
 			if( m != null && Reflect.hasField(m, "ignore") ) continue;
 			var v = Reflect.field(r, f);
 			var v = Reflect.field(r, f);
-			if( !Api.is(v, hxsl.Shader) && !Api.is(v, h3d.pass.ScreenFx) && !Api.is(v,Group) ) continue;
+			if( !Api.isOfType(v, hxsl.Shader) && !Api.isOfType(v, h3d.pass.ScreenFx) && !Api.isOfType(v,Group) ) continue;
 
 
 			if( prev != null && StringTools.startsWith(f, prev.name) ) {
 			if( prev != null && StringTools.startsWith(f, prev.name) ) {
 				prev.group.push({ name : f.substr(prev.name.length), v : v });
 				prev.group.push({ name : f.substr(prev.name.length), v : v });
@@ -121,7 +121,7 @@ class SceneProps {
 		case Core:
 		case Core:
 
 
 			var props = [];
 			var props = [];
-			addDynamicProps(props, r, function(v) return !Api.is(v,hxsl.Shader) && !Api.is(v,h3d.pass.ScreenFx) && !Api.is(v,Group));
+			addDynamicProps(props, r, function(v) return !Api.isOfType(v,hxsl.Shader) && !Api.isOfType(v,h3d.pass.ScreenFx) && !Api.isOfType(v,Group));
 			return props;
 			return props;
 
 
 		}
 		}
@@ -288,7 +288,7 @@ class SceneProps {
 	}
 	}
 
 
 	function getDynamicProps( v : Dynamic ) : Array<Property> {
 	function getDynamicProps( v : Dynamic ) : Array<Property> {
-		if( Api.is(v,h3d.pass.ScreenFx) || Api.is(v,Group) ) {
+		if( Api.isOfType(v,h3d.pass.ScreenFx) || Api.isOfType(v,Group) ) {
 			var props = [];
 			var props = [];
 			addDynamicProps(props, v);
 			addDynamicProps(props, v);
 			return props;
 			return props;
@@ -343,9 +343,9 @@ class SceneProps {
 				continue;
 				continue;
 
 
 			if( m != null && Reflect.hasField(m, "inspect") ) {
 			if( m != null && Reflect.hasField(m, "inspect") ) {
-				if( Api.is(v, Bool) )
+				if( Api.isOfType(v, Bool) )
 					props.unshift(PBool(f, function() return Reflect.getProperty(o, f), function(v) Reflect.setProperty(o, f, v)));
 					props.unshift(PBool(f, function() return Reflect.getProperty(o, f), function(v) Reflect.setProperty(o, f, v)));
-				else if( Api.is(v, Float) ) {
+				else if( Api.isOfType(v, Float) ) {
 					var range : Array<Dynamic> = m.range;
 					var range : Array<Dynamic> = m.range;
 					if( range != null )
 					if( range != null )
 						props.unshift(PRange(f, range[0], range[1], function() return Reflect.getProperty(o, f), function(v) Reflect.setProperty(o, f, v), range[2]));
 						props.unshift(PRange(f, range[0], range[1], function() return Reflect.getProperty(o, f), function(v) Reflect.setProperty(o, f, v), range[2]));
@@ -402,7 +402,7 @@ class SceneProps {
 		var props = null;
 		var props = null;
 		for( f in Reflect.fields(propsValues) ) {
 		for( f in Reflect.fields(propsValues) ) {
 			var v : Dynamic = Reflect.field(propsValues, f);
 			var v : Dynamic = Reflect.field(propsValues, f);
-			var isObj = Reflect.isObject(v) && !Api.is(v, String) && !Api.is(v, Array);
+			var isObj = Reflect.isObject(v) && !Api.isOfType(v, String) && !Api.isOfType(v, Array);
 			if( isObj ) {
 			if( isObj ) {
 				var n = node.getChildByName(f);
 				var n = node.getChildByName(f);
 				if( n != null ) {
 				if( n != null ) {

+ 8 - 8
hxd/res/DynamicText.hx

@@ -84,7 +84,7 @@ class DynamicText {
 			onMissing(path, "is missing");
 			onMissing(path, "is missing");
 			return null;
 			return null;
 		}
 		}
-		if( Api.is(old,Array) ) {
+		if( Api.isOfType(old,Array) ) {
 			onMissing(path,"should be a group");
 			onMissing(path,"should be a group");
 			return null;
 			return null;
 		}
 		}
@@ -155,23 +155,23 @@ class DynamicText {
 						path.pop();
 						path.pop();
 						continue;
 						continue;
 					}
 					}
-					if( Api.is(sub,String) ) {
+					if( Api.isOfType(sub,String) ) {
 						onMissing(path,"should be a text and not a group");
 						onMissing(path,"should be a text and not a group");
 						path.pop();
 						path.pop();
 						continue;
 						continue;
 					}
 					}
 					// build structure
 					// build structure
 					var ref = ref == null ? null : refIds.get(id);
 					var ref = ref == null ? null : refIds.get(id);
-					if( Api.is(sub,Array) ) {
+					if( Api.isOfType(sub,Array) ) {
 						var elements : Array<Dynamic> = sub;
 						var elements : Array<Dynamic> = sub;
 						var data = [for( e in x.elements ) e];
 						var data = [for( e in x.elements ) e];
 						var dataRef = ref == null ? null : [for( e in ref.elements ) e];
 						var dataRef = ref == null ? null : [for( e in ref.elements ) e];
 						for( i in 0...elements.length ) {
 						for( i in 0...elements.length ) {
 							var e = elements[i];
 							var e = elements[i];
 							path.push("[" + i + "]");
 							path.push("[" + i + "]");
-							if( Api.is(e, Array) ) {
+							if( Api.isOfType(e, Array) ) {
 								trace("TODO");
 								trace("TODO");
-							} else if( Api.is(e, String) ) {
+							} else if( Api.isOfType(e, String) ) {
 								var enew = applyText(path, e, data[i], dataRef == null ? null : dataRef[i], onMissing);
 								var enew = applyText(path, e, data[i], dataRef == null ? null : dataRef[i], onMissing);
 								if( enew != null )
 								if( enew != null )
 									elements[i] = enew;
 									elements[i] = enew;
@@ -211,12 +211,12 @@ class DynamicText {
 				for( e in x.elements ) {
 				for( e in x.elements ) {
 					var v : Dynamic = parseXmlData(e);
 					var v : Dynamic = parseXmlData(e);
 					if( isArray ) {
 					if( isArray ) {
-						if( !Api.is(v, Array) ) v = [v];
+						if( !Api.isOfType(v, Array) ) v = [v];
 					} else {
 					} else {
-						if( Api.is(v, Array) ) {
+						if( Api.isOfType(v, Array) ) {
 							for( i in 0...a.length ) {
 							for( i in 0...a.length ) {
 								var v = a[i];
 								var v = a[i];
-								if( !Api.is(v, Array) )
+								if( !Api.isOfType(v, Array) )
 									a[i] = [v];
 									a[i] = [v];
 							}
 							}
 							isArray = true;
 							isArray = true;

+ 2 - 2
hxd/snd/LoadingData.hx

@@ -11,7 +11,7 @@ class LoadingData extends Data {
 
 
 	override function decode(out:haxe.io.Bytes, outPos:Int, sampleStart:Int, sampleCount:Int):Void {
 	override function decode(out:haxe.io.Bytes, outPos:Int, sampleStart:Int, sampleCount:Int):Void {
 		var d = snd.getData();
 		var d = snd.getData();
-		if( hxd.impl.Api.is(d, LoadingData) )
+		if( hxd.impl.Api.isOfType(d, LoadingData) )
 			throw "Sound data is not yet available, use load() first";
 			throw "Sound data is not yet available, use load() first";
 		d.decode(out, outPos, sampleStart, sampleCount);
 		d.decode(out, outPos, sampleStart, sampleCount);
 	}
 	}
@@ -20,7 +20,7 @@ class LoadingData extends Data {
 		if( waitCount > 10 )
 		if( waitCount > 10 )
 			throw "Failed to load data";
 			throw "Failed to load data";
 		var d = snd.getData();
 		var d = snd.getData();
-		if( hxd.impl.Api.is(d, LoadingData) ) {
+		if( hxd.impl.Api.isOfType(d, LoadingData) ) {
 			waitCount++;
 			waitCount++;
 			haxe.Timer.delay(load.bind(onEnd), 100);
 			haxe.Timer.delay(load.bind(onEnd), 100);
 			return;
 			return;

+ 1 - 0
hxsl/GlslOut.hx

@@ -372,6 +372,7 @@ class GlslOut {
 			case OpIncrement: "++";
 			case OpIncrement: "++";
 			case OpDecrement: "--";
 			case OpDecrement: "--";
 			case OpNegBits: "~";
 			case OpNegBits: "~";
+			default: throw "assert"; // OpSpread for Haxe4.2+
 			});
 			});
 			addValue(e1, tabs);
 			addValue(e1, tabs);
 		case TVarDecl(v, init):
 		case TVarDecl(v, init):

+ 1 - 0
hxsl/HlslOut.hx

@@ -459,6 +459,7 @@ class HlslOut {
 			case OpIncrement: "++";
 			case OpIncrement: "++";
 			case OpDecrement: "--";
 			case OpDecrement: "--";
 			case OpNegBits: "~";
 			case OpNegBits: "~";
+			default: throw "assert"; // OpSpread for Haxe4.2+
 			});
 			});
 			addValue(e1, tabs);
 			addValue(e1, tabs);
 		case TVarDecl(v, init):
 		case TVarDecl(v, init):

+ 1 - 0
hxsl/Printer.hx

@@ -238,6 +238,7 @@ class Printer {
 			case OpNegBits:"~";
 			case OpNegBits:"~";
 			case OpIncrement:"++";
 			case OpIncrement:"++";
 			case OpDecrement:"--";
 			case OpDecrement:"--";
+			default: throw "assert"; // OpSpread for Haxe4.2+
 			});
 			});
 			addExpr(e, tabs);
 			addExpr(e, tabs);
 		case TBinop(op, e1, e2):
 		case TBinop(op, e1, e2):