From be7c92688b59e97f8ec40a6c90f0e2de91c07828 Mon Sep 17 00:00:00 2001 From: Josh Tynjala Date: Fri, 10 Nov 2023 13:33:39 -0800 Subject: [PATCH] Haxe 4.3 compatibility --- away3d/containers/View3D.hx | 101 +++++++++++++++++++++------------- away3d/events/MouseEvent3D.hx | 2 +- away3d/events/Scene3DEvent.hx | 4 +- away3d/events/TouchEvent3D.hx | 4 +- away3d/textures/Anisotropy.hx | 2 +- 5 files changed, 70 insertions(+), 43 deletions(-) diff --git a/away3d/containers/View3D.hx b/away3d/containers/View3D.hx index a9f05c9f..83936ad7 100644 --- a/away3d/containers/View3D.hx +++ b/away3d/containers/View3D.hx @@ -479,11 +479,10 @@ class View3D extends Sprite /** * Not supported. Use filters3d instead. */ - @:getter(filters) #if (openfl < "8.0.0") - private #if (!flash && !display) override #end function get_filters():Array + @:getter(filters) private #if (!flash && !display) override #end function get_filters():Array #else - private #if !flash override #end function get_filters():Array + #if (flash && haxe_ver < 4.3) @:getter(filters) #else override #end private function get_filters():Array #end { throw new Error("filters is not supported in View3D. Use filters3d instead."); @@ -493,36 +492,35 @@ class View3D extends Sprite /** * Not supported. Use filters3d instead. */ - @:setter(filters) #if (openfl < "8.0.0") - private #if (!flash && !display) override #end function set_filters(value:Array) + @:setter(filters) private #if (!flash && !display) override #end function set_filters(value:Array) #else - private #if !flash override #end function set_filters(value:Array) + #if (flash && haxe_ver < 4.3) @:setter(filters) #else override #end private function set_filters(value:Array):#if (!flash || haxe_ver >= 4.3) Array #else Void #end #end { throw new Error("filters is not supported in View3D. Use filters3d instead."); - #if !flash return value; #end + #if (!flash || haxe_ver >= 4.3) + return value; + #end } /** * The width of the viewport. When software rendering is used, this is limited by the * platform to 2048 pixels. */ - @:getter(width) #if (openfl < "8.0.0") - private #if (!flash && !display) override #end function get_width():Float + @:getter(width) private #if (!flash && !display) override #end function get_width():Float #else - private #if !flash override #end function get_width():Float + #if (flash && haxe_ver < 4.3) @:getter(width) #else override #end private function get_width():Float #end { return _width; } - @:setter(width) #if (openfl < "8.0.0") - private #if (!flash && !display) override #end function set_width(value:Float) + @:setter(width) private #if (!flash && !display) override #end function set_width(value:Float) #else - private #if !flash override #end function set_width(value:Float) + #if (flash && haxe_ver < 4.3) @:setter(width) #else override #end private function set_width(value:Float):#if (!flash || haxe_ver >= 4.3) Float #else Void #end #end { // Backbuffer limitation in software mode. See comment in updateBackBuffer() @@ -530,7 +528,13 @@ class View3D extends Sprite value = 2048; if (_width == value) - #if flash return #else return value #end; + { + #if (!flash || haxe_ver >= 4.3) + return value; + #else + return; + #end + } _hitField.width = value; _width = value; @@ -552,28 +556,28 @@ class View3D extends Sprite _backBufferInvalid = true; _scissorRectDirty = true; - #if !flash return value; #end + #if (!flash || haxe_ver >= 4.3) + return value; + #end } /** * The height of the viewport. When software rendering is used, this is limited by the * platform to 2048 pixels. */ - @:getter(height) #if (openfl < "8.0.0") - private #if (!flash && !display) override #end function get_height():Float + @:getter(height) private #if (!flash && !display) override #end function get_height():Float #else - private #if !flash override #end function get_height():Float + #if (flash && haxe_ver < 4.3) @:getter(height) #else override #end private function get_height():Float #end { return _height; } - @:setter(height) #if (openfl < "8.0.0") - private #if (!flash && !display) override #end function set_height(value:Float) + @:setter(height) private #if (!flash && !display) override #end function set_height(value:Float) #else - private #if !flash override #end function set_height(value:Float) + #if (flash && haxe_ver < 4.3) @:setter(height) #else override #end private function set_height(value:Float):#if (!flash || haxe_ver >= 4.3) Float #else Void #end #end { // Backbuffer limitation in software mode. See comment in updateBackBuffer() @@ -581,7 +585,13 @@ class View3D extends Sprite value = 2048; if (_height == value) - #if flash return #else return value #end; + { + #if (!flash || haxe_ver >= 4.3) + return value; + #else + return; + #end + } _hitField.height = value; _height = value; @@ -603,18 +613,25 @@ class View3D extends Sprite _backBufferInvalid = true; _scissorRectDirty = true; - #if !flash return value; #end + #if (!flash || haxe_ver >= 4.3) + return value; + #end } - @:setter(x) #if (openfl < "8.0.0") - private #if (!flash && !display) override #end function set_x(value:Float) + @:setter(x) private #if (!flash && !display) override #end function set_x(value:Float) #else - private #if !flash override #end function set_x(value:Float) + #if (flash && haxe_ver < 4.3) @:setter(x) #else override #end private function set_x(value:Float):#if (!flash || haxe_ver >= 4.3) Float #else Void #end #end { if (x == value) - #if flash return #else return value #end; + { + #if (!flash || haxe_ver >= 4.3) + return value; + #else + return; + #end + } super.x = value; _localTLPos.x = value; @@ -622,18 +639,25 @@ class View3D extends Sprite _globalPos.x = parent != null ? parent.localToGlobal(_localTLPos).x : value; _globalPosDirty = true; - #if !flash return value; #end + #if (!flash || haxe_ver >= 4.3) + return value; + #end } - @:setter(y) #if (openfl < "8.0.0") - private #if (!flash && !display) override #end function set_y(value:Float) + @:setter(y) private #if (!flash && !display) override #end function set_y(value:Float) #else - private #if !flash override #end function set_y(value:Float) + #if (flash && haxe_ver < 4.3) @:setter(y) #else override #end private function set_y(value:Float):#if (!flash || haxe_ver >= 4.3) Float #else Void #end #end { if (y == value) - #if flash return #else return value #end; + { + #if (!flash || haxe_ver >= 4.3) + return value; + #else + return; + #end + } super.y = value; _localTLPos.y = value; @@ -641,14 +665,15 @@ class View3D extends Sprite _globalPos.y = parent != null ? parent.localToGlobal(_localTLPos).y : value; _globalPosDirty = true; - #if !flash return value; #end + #if (!flash || haxe_ver >= 4.3) + return value; + #end } - @:setter(visible) #if (openfl < "8.0.0") - private #if (!flash && !display) override #end function set_visible(value:Bool) + @:setter(visible) private #if (!flash && !display) override #end function set_visible(value:Bool) #else - private #if !flash override #end function set_visible(value:Bool) + #if (flash && haxe_ver < 4.3) @:setter(visible) #else override #end private function set_visible(value:Bool):#if (!flash || haxe_ver >= 4.3) Bool #else Void #end #end { super.visible = value; @@ -656,7 +681,9 @@ class View3D extends Sprite if (_stage3DProxy!=null && !_shareContext) _stage3DProxy.visible = value; - #if !flash return value; #end + #if (!flash || haxe_ver >= 4.3) + return value; + #end } /** diff --git a/away3d/events/MouseEvent3D.hx b/away3d/events/MouseEvent3D.hx index a32bd78e..06f62aa1 100644 --- a/away3d/events/MouseEvent3D.hx +++ b/away3d/events/MouseEvent3D.hx @@ -161,7 +161,7 @@ class MouseEvent3D extends Event * @inheritDoc */ #if flash - @:getter(bubbles) function get_bubbles():Bool + #if (haxe_ver < 4.3) @:getter(bubbles) #else override #end private function get_bubbles():Bool { var doesBubble:Bool = super.bubbles && _allowedToPropagate; _allowedToPropagate = true; diff --git a/away3d/events/Scene3DEvent.hx b/away3d/events/Scene3DEvent.hx index 29a60e7b..b52e3d30 100644 --- a/away3d/events/Scene3DEvent.hx +++ b/away3d/events/Scene3DEvent.hx @@ -3,6 +3,7 @@ package away3d.events; import away3d.containers.ObjectContainer3D; import openfl.events.Event; +import openfl.utils.Object; class Scene3DEvent extends Event { @@ -12,9 +13,8 @@ class Scene3DEvent extends Event public var objectContainer3D:ObjectContainer3D; - //@:getter(target) #if flash - private function get_target():Dynamic { + #if (haxe_ver < 4.3) @:getter(target) #else override #end private function get_target(): #if (openfl >= "9.2.0") Object #else Dynamic #end { return objectContainer3D; } #end diff --git a/away3d/events/TouchEvent3D.hx b/away3d/events/TouchEvent3D.hx index b46cd661..20ea7188 100644 --- a/away3d/events/TouchEvent3D.hx +++ b/away3d/events/TouchEvent3D.hx @@ -109,10 +109,10 @@ class TouchEvent3D extends Event * @inheritDoc */ #if flash - @:getter(bubbles) function get_bubbles():Bool + #if (haxe_ver < 4.3) @:getter(bubbles) #else override #end private function get_bubbles():Bool { // Don't bubble if propagation has been stopped. - return this.bubbles && _allowedToPropagate; + return super.bubbles && _allowedToPropagate; } #end diff --git a/away3d/textures/Anisotropy.hx b/away3d/textures/Anisotropy.hx index b60c1c90..3220d817 100644 --- a/away3d/textures/Anisotropy.hx +++ b/away3d/textures/Anisotropy.hx @@ -1,6 +1,6 @@ package away3d.textures; -@:enum abstract Anisotropy(Null) +#if (haxe_ver >= 4.0) enum #else @:enum #end abstract Anisotropy(Null) { public var NONE = 0; public var ANISOTROPIC2X = 1;