From 1b5eef810c310ba40917323e825d8016bd4f21f3 Mon Sep 17 00:00:00 2001 From: shmyga Date: Tue, 1 Oct 2019 22:09:22 +0300 Subject: [PATCH] [client] render: fix empty brick render --- gulpfile.js | 2 - .../m/tankz/render/item/BitmapRenderItem.hx | 2 +- .../ru/m/tankz/render/item/BrickRenderItem.hx | 4 +- src/common/haxe/ru/m/tankz/engine/Ticker.hx | 4 +- src/fixes/haxe/lime/utils/Float32Array.hx | 164 ----------------- src/fixes/haxe/lime/utils/Float64Array.hx | 161 ----------------- src/fixes/haxe/lime/utils/Int16Array.hx | 161 ----------------- src/fixes/haxe/lime/utils/Int32Array.hx | 161 ----------------- src/fixes/haxe/lime/utils/Int8Array.hx | 161 ----------------- src/fixes/haxe/lime/utils/README.md | 8 - src/fixes/haxe/lime/utils/UInt16Array.hx | 161 ----------------- src/fixes/haxe/lime/utils/UInt32Array.hx | 161 ----------------- src/fixes/haxe/lime/utils/UInt8Array.hx | 159 ---------------- .../haxe/lime/utils/UInt8ClampedArray.hx | 171 ------------------ 14 files changed, 5 insertions(+), 1475 deletions(-) delete mode 100644 src/fixes/haxe/lime/utils/Float32Array.hx delete mode 100644 src/fixes/haxe/lime/utils/Float64Array.hx delete mode 100644 src/fixes/haxe/lime/utils/Int16Array.hx delete mode 100644 src/fixes/haxe/lime/utils/Int32Array.hx delete mode 100644 src/fixes/haxe/lime/utils/Int8Array.hx delete mode 100644 src/fixes/haxe/lime/utils/README.md delete mode 100644 src/fixes/haxe/lime/utils/UInt16Array.hx delete mode 100644 src/fixes/haxe/lime/utils/UInt32Array.hx delete mode 100644 src/fixes/haxe/lime/utils/UInt8Array.hx delete mode 100644 src/fixes/haxe/lime/utils/UInt8ClampedArray.hx diff --git a/gulpfile.js b/gulpfile.js index d8e2741..a1a62aa 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -70,7 +70,6 @@ const client = new Project( config.branch({ name: 'client', sources: [ - //'src/fixes/haxe', 'src/client/haxe', ], main: 'ru.m.tankz.Client', @@ -108,7 +107,6 @@ const editor = new Project( config.branch({ name: 'editor', sources: [ - //'src/fixes/haxe', 'src/client/haxe', 'src/editor/haxe', ], diff --git a/src/client/haxe/ru/m/tankz/render/item/BitmapRenderItem.hx b/src/client/haxe/ru/m/tankz/render/item/BitmapRenderItem.hx index af8d72d..a7347f2 100644 --- a/src/client/haxe/ru/m/tankz/render/item/BitmapRenderItem.hx +++ b/src/client/haxe/ru/m/tankz/render/item/BitmapRenderItem.hx @@ -13,7 +13,7 @@ class BitmapRenderItem extends RenderItem { public function new(rect:Rectangle) { super(rect); - this.bitmap = new Bitmap(null, PixelSnapping.AUTO, true); + this.bitmap = new Bitmap(null, PixelSnapping.NEVER, false); } override private function get_view():DisplayObject { diff --git a/src/client/haxe/ru/m/tankz/render/item/BrickRenderItem.hx b/src/client/haxe/ru/m/tankz/render/item/BrickRenderItem.hx index 959ad3f..c615d93 100644 --- a/src/client/haxe/ru/m/tankz/render/item/BrickRenderItem.hx +++ b/src/client/haxe/ru/m/tankz/render/item/BrickRenderItem.hx @@ -17,9 +17,9 @@ class BrickBitmapBundle { private function resolve(type:BrickType, cells:Array):BitmapData { return switch cells.length { case 0: - Assets.getBitmapData('resources/image/map/none.png'); + null; case 4: - Assets.getBitmapData('resources/image/map/${type}.png'); + type == "none" ? null : Assets.getBitmapData('resources/image/map/${type}.png'); case _: var image = Assets.getBitmapData('resources/image/map/${type}.png'); var result = new BitmapData(image.width, image.height, true, 0x00000000); diff --git a/src/common/haxe/ru/m/tankz/engine/Ticker.hx b/src/common/haxe/ru/m/tankz/engine/Ticker.hx index 9857a70..d9d9028 100644 --- a/src/common/haxe/ru/m/tankz/engine/Ticker.hx +++ b/src/common/haxe/ru/m/tankz/engine/Ticker.hx @@ -54,9 +54,9 @@ class Ticker implements ITicker { if (actions.length > 0) { runActions(); } - if (result > 45) { + /*if (result > 100) { L.w("Ticker", 'Long tick: ${result}'); - } + }*/ return result; } diff --git a/src/fixes/haxe/lime/utils/Float32Array.hx b/src/fixes/haxe/lime/utils/Float32Array.hx deleted file mode 100644 index 736d9c3..0000000 --- a/src/fixes/haxe/lime/utils/Float32Array.hx +++ /dev/null @@ -1,164 +0,0 @@ -package lime.utils; - -#if (js && !doc_gen) -#if haxe4 -import js.lib.Float32Array as JSFloat32Array; -import js.lib.Uint8Array as JSUInt8Array; -#else -import js.html.Float32Array as JSFloat32Array; -import js.html.Uint8Array as JSUInt8Array; -#end -@:forward -@:arrayAccess -abstract Float32Array(JSFloat32Array) from JSFloat32Array to JSFloat32Array/* to ArrayBufferView*/ -{ - public inline static var BYTES_PER_ELEMENT:Int = 4; - - @:generic - public inline function new(?elements:Int, ?array:Array, #if openfl ?vector:openfl.Vector, #end ?view:ArrayBufferView, ?buffer:ArrayBuffer, - ?byteoffset:Int = 0, ?len:Null) - { - if (elements != null) - { - this = new JSFloat32Array(elements); - } - else if (array != null) - { - this = new JSFloat32Array(untyped array); - #if (openfl && commonjs) - } - else if (vector != null) - { - this = new JSFloat32Array(untyped (vector)); - #elseif openfl - } - else if (vector != null) - { - this = new JSFloat32Array(untyped untyped (vector).__array); - #end - } - else if (view != null) - { - this = new JSFloat32Array(untyped view); - } - else if (buffer != null) - { - if (len == null) - { - this = new JSFloat32Array(buffer, byteoffset); - } - else - { - this = new JSFloat32Array(buffer, byteoffset, len); - } - } - else - { - this = null; - } - } - - @:arrayAccess @:extern inline function __set(idx:Int, val:Float):Float - return this[idx] = val; - - @:arrayAccess @:extern inline function __get(idx:Int):Float - return this[idx]; - - // non spec haxe conversions - inline public static function fromBytes(bytes:haxe.io.Bytes, ?byteOffset:Int = 0, ?len:Int):Float32Array - { - if (byteOffset == null) return new JSFloat32Array(cast bytes.getData()); - if (len == null) return new JSFloat32Array(cast bytes.getData(), byteOffset); - return new JSFloat32Array(cast bytes.getData(), byteOffset, len); - } - - inline public function toBytes():haxe.io.Bytes - { - return @:privateAccess new haxe.io.Bytes(cast new JSUInt8Array(this.buffer)); - } - - inline function toString() - return this != null ? 'Float32Array [byteLength:${this.byteLength}, length:${this.length}]' : null; -} -#else -import lime.utils.ArrayBuffer; -import lime.utils.ArrayBufferView; - -@:forward -abstract Float32Array(ArrayBufferView) from ArrayBufferView to ArrayBufferView -{ - public inline static var BYTES_PER_ELEMENT:Int = 4; - public static var hello:Int; - - public var length(get, never):Int; - - @:generic - public inline function new(?elements:Int, ?buffer:ArrayBuffer, ?array:Array, #if openfl ?vector:openfl.Vector, #end ?view:ArrayBufferView, - ?byteoffset:Int = 0, ?len:Null) - { - if (elements != null) - { - this = new ArrayBufferView(elements, Float32); - } - else if (array != null) - { - this = new ArrayBufferView(0, Float32).initArray(array); - #if openfl - } - else if (vector != null) - { - this = new ArrayBufferView(0, Float32).initArray(untyped (vector).__array); - #end - } - else if (view != null) - { - this = new ArrayBufferView(0, Float32).initTypedArray(view); - } - else if (buffer != null) - { - this = new ArrayBufferView(0, Float32).initBuffer(buffer, byteoffset, len); - } - else - { - throw "Invalid constructor arguments for Float32Array"; - } - } - - // Public API - public inline function subarray(begin:Int, end:Null = null):Float32Array - return this.subarray(begin, end); - - // non spec haxe conversions - inline public static function fromBytes(bytes:haxe.io.Bytes, ?byteOffset:Int = 0, ?len:Int):Float32Array - { - return new Float32Array(bytes, byteOffset, len); - } - - inline public function toBytes():haxe.io.Bytes - { - return this.buffer; - } - - // Internal - inline function toString() - return this != null ? 'Float32Array [byteLength:${this.byteLength}, length:${this.length}]' : null; - - @:extern inline function get_length() - return this.length; - - @:noCompletion - @:arrayAccess @:extern - public inline function __get(idx:Int):Float - { - return ArrayBufferIO.getFloat32(this.buffer, this.byteOffset + (idx * BYTES_PER_ELEMENT)); - } - - @:noCompletion - @:arrayAccess @:extern - public inline function __set(idx:Int, val:Float):Float - { - ArrayBufferIO.setFloat32(this.buffer, this.byteOffset + (idx * BYTES_PER_ELEMENT), val); - return val; - } -} -#end // !js diff --git a/src/fixes/haxe/lime/utils/Float64Array.hx b/src/fixes/haxe/lime/utils/Float64Array.hx deleted file mode 100644 index b546a33..0000000 --- a/src/fixes/haxe/lime/utils/Float64Array.hx +++ /dev/null @@ -1,161 +0,0 @@ -package lime.utils; - -#if (js && !doc_gen) -#if haxe4 -import js.lib.Float64Array as JSFloat64Array; -import js.lib.Uint8Array as JSUInt8Array; -#else -import js.html.Float64Array as JSFloat64Array; -import js.html.Uint8Array as JSUInt8Array; -#end -@:forward -abstract Float64Array(JSFloat64Array) from JSFloat64Array to JSFloat64Array/* to ArrayBufferView*/ -{ - public inline static var BYTES_PER_ELEMENT:Int = 8; - - @:generic - public inline function new(?elements:Int, ?array:Array, #if openfl ?vector:openfl.Vector, #end ?view:ArrayBufferView, ?buffer:ArrayBuffer, - ?byteoffset:Int = 0, ?len:Null) - { - if (elements != null) - { - this = new JSFloat64Array(elements); - } - else if (array != null) - { - this = new JSFloat64Array(untyped array); - #if (openfl && commonjs) - } - else if (vector != null) - { - this = new JSFloat64Array(untyped (vector)); - #elseif openfl - } - else if (vector != null) - { - this = new JSFloat64Array(untyped untyped (vector).__array); - #end - } - else if (view != null) - { - this = new JSFloat64Array(untyped view); - } - else if (buffer != null) - { - if (len == null) - { - this = new JSFloat64Array(buffer, byteoffset); - } - else - { - this = new JSFloat64Array(buffer, byteoffset, len); - } - } - else - { - this = null; - } - } - - @:arrayAccess @:extern inline function __set(idx:Int, val:Float):Float - return this[idx] = val; - - @:arrayAccess @:extern inline function __get(idx:Int):Float - return this[idx]; - - // non spec haxe conversions - inline public static function fromBytes(bytes:haxe.io.Bytes, ?byteOffset:Int = 0, ?len:Int):Float64Array - { - if (byteOffset == null) return new JSFloat64Array(cast bytes.getData()); - if (len == null) return new JSFloat64Array(cast bytes.getData(), byteOffset); - return new JSFloat64Array(cast bytes.getData(), byteOffset, len); - } - - inline public function toBytes():haxe.io.Bytes - { - return @:privateAccess new haxe.io.Bytes(cast new JSUInt8Array(this.buffer)); - } - - function toString() - return this != null ? 'Float64Array [byteLength:${this.byteLength}, length:${this.length}]' : null; -} -#else -import lime.utils.ArrayBufferView; - -@:forward -abstract Float64Array(ArrayBufferView) from ArrayBufferView to ArrayBufferView -{ - public inline static var BYTES_PER_ELEMENT:Int = 8; - - public var length(get, never):Int; - - @:generic - public inline function new(?elements:Int, ?buffer:ArrayBuffer, ?array:Array, #if openfl ?vector:openfl.Vector, #end ?view:ArrayBufferView, - ?byteoffset:Int = 0, ?len:Null) - { - if (elements != null) - { - this = new ArrayBufferView(elements, Float64); - } - else if (array != null) - { - this = new ArrayBufferView(0, Float64).initArray(array); - #if openfl - } - else if (vector != null) - { - this = new ArrayBufferView(0, Float64).initArray(untyped (vector).__array); - #end - } - else if (view != null) - { - this = new ArrayBufferView(0, Float64).initTypedArray(view); - } - else if (buffer != null) - { - this = new ArrayBufferView(0, Float64).initBuffer(buffer, byteoffset, len); - } - else - { - throw "Invalid constructor arguments for Float64Array"; - } - } - - // Public API - public inline function subarray(begin:Int, end:Null = null):Float64Array - return this.subarray(begin, end); - - // non spec haxe conversions - inline public static function fromBytes(bytes:haxe.io.Bytes, ?byteOffset:Int = 0, ?len:Int):Float64Array - { - return new Float64Array(bytes, byteOffset, len); - } - - inline public function toBytes():haxe.io.Bytes - { - return this.buffer; - } - - // Internal - inline function get_length() - return this.length; - - @:noCompletion - @:arrayAccess @:extern - public inline function __get(idx:Int):Float - { - return ArrayBufferIO.getFloat64(this.buffer, this.byteOffset + (idx * BYTES_PER_ELEMENT)); - } - - @:noCompletion - @:arrayAccess @:extern - public inline function __set(idx:Int, val:Float):Float - { - ArrayBufferIO.setFloat64(this.buffer, this.byteOffset + (idx * BYTES_PER_ELEMENT), val); - return val; - } - - inline function toString() - return this != null ? 'Float64Array [byteLength:${this.byteLength}, length:${this.length}]' : null; -} -#end // !js diff --git a/src/fixes/haxe/lime/utils/Int16Array.hx b/src/fixes/haxe/lime/utils/Int16Array.hx deleted file mode 100644 index 1cd5faf..0000000 --- a/src/fixes/haxe/lime/utils/Int16Array.hx +++ /dev/null @@ -1,161 +0,0 @@ -package lime.utils; - -#if (js && !doc_gen) -#if haxe4 -import js.lib.Int16Array as JSInt16Array; -import js.lib.Uint8Array as JSUInt8Array; -#else -import js.html.Int16Array as JSInt16Array; -import js.html.Uint8Array as JSUInt8Array; -#end -@:forward -abstract Int16Array(JSInt16Array) from JSInt16Array to JSInt16Array/* to ArrayBufferView*/ -{ - public inline static var BYTES_PER_ELEMENT:Int = 2; - - @:generic - public inline function new(?elements:Int, ?array:Array, #if openfl ?vector:openfl.Vector, #end ?view:ArrayBufferView, ?buffer:ArrayBuffer, - ?byteoffset:Int = 0, ?len:Null) - { - if (elements != null) - { - this = new JSInt16Array(elements); - } - else if (array != null) - { - this = new JSInt16Array(untyped array); - #if (openfl && commonjs) - } - else if (vector != null) - { - this = new JSInt16Array(untyped (vector)); - #elseif openfl - } - else if (vector != null) - { - this = new JSInt16Array(untyped untyped (vector).__array); - #end - } - else if (view != null) - { - this = new JSInt16Array(untyped view); - } - else if (buffer != null) - { - if (len == null) - { - this = new JSInt16Array(buffer, byteoffset); - } - else - { - this = new JSInt16Array(buffer, byteoffset, len); - } - } - else - { - this = null; - } - } - - @:arrayAccess @:extern inline function __set(idx:Int, val:Int):Int - return this[idx] = val; - - @:arrayAccess @:extern inline function __get(idx:Int):Int - return this[idx]; - - // non spec haxe conversions - inline public static function fromBytes(bytes:haxe.io.Bytes, ?byteOffset:Int = 0, ?len:Int):Int16Array - { - if (byteOffset == null) return new JSInt16Array(cast bytes.getData()); - if (len == null) return new JSInt16Array(cast bytes.getData(), byteOffset); - return new JSInt16Array(cast bytes.getData(), byteOffset, len); - } - - inline public function toBytes():haxe.io.Bytes - { - return @:privateAccess new haxe.io.Bytes(cast new JSUInt8Array(this.buffer)); - } - - inline function toString() - return this != null ? 'Int16Array [byteLength:${this.byteLength}, length:${this.length}]' : null; -} -#else -import lime.utils.ArrayBufferView; - -@:forward -abstract Int16Array(ArrayBufferView) from ArrayBufferView to ArrayBufferView -{ - public inline static var BYTES_PER_ELEMENT:Int = 2; - - public var length(get, never):Int; - - @:generic - public inline function new(?elements:Int, ?buffer:ArrayBuffer, ?array:Array, #if openfl ?vector:openfl.Vector, #end ?view:ArrayBufferView, - ?byteoffset:Int = 0, ?len:Null) - { - if (elements != null) - { - this = new ArrayBufferView(elements, Int16); - } - else if (array != null) - { - this = new ArrayBufferView(0, Int16).initArray(array); - #if openfl - } - else if (vector != null) - { - this = new ArrayBufferView(0, Int16).initArray(untyped (vector).__array); - #end - } - else if (view != null) - { - this = new ArrayBufferView(0, Int16).initTypedArray(view); - } - else if (buffer != null) - { - this = new ArrayBufferView(0, Int16).initBuffer(buffer, byteoffset, len); - } - else - { - throw "Invalid constructor arguments for Int16Array"; - } - } - - // Public API - public inline function subarray(begin:Int, end:Null = null):Int16Array - return this.subarray(begin, end); - - // non spec haxe conversions - inline public static function fromBytes(bytes:haxe.io.Bytes, ?byteOffset:Int = 0, ?len:Int):Int16Array - { - return new Int16Array(bytes, byteOffset, len); - } - - inline public function toBytes():haxe.io.Bytes - { - return this.buffer; - } - - // Internal - inline function get_length() - return this.length; - - @:noCompletion - @:arrayAccess @:extern - public inline function __get(idx:Int) - { - return ArrayBufferIO.getInt16(this.buffer, this.byteOffset + (idx * BYTES_PER_ELEMENT)); - } - - @:noCompletion - @:arrayAccess @:extern - public inline function __set(idx:Int, val:Int) - { - ArrayBufferIO.setInt16(this.buffer, this.byteOffset + (idx * BYTES_PER_ELEMENT), val); - return val; - } - - inline function toString() - return this != null ? 'Int16Array [byteLength:${this.byteLength}, length:${this.length}]' : null; -} -#end // !js diff --git a/src/fixes/haxe/lime/utils/Int32Array.hx b/src/fixes/haxe/lime/utils/Int32Array.hx deleted file mode 100644 index 21e417c..0000000 --- a/src/fixes/haxe/lime/utils/Int32Array.hx +++ /dev/null @@ -1,161 +0,0 @@ -package lime.utils; - -#if (js && !doc_gen) -#if haxe4 -import js.lib.Int32Array as JSInt32Array; -import js.lib.Uint8Array as JSUInt8Array; -#else -import js.html.Int32Array as JSInt32Array; -import js.html.Uint8Array as JSUInt8Array; -#end -@:forward -abstract Int32Array(JSInt32Array) from JSInt32Array to JSInt32Array/* to ArrayBufferView*/ -{ - public inline static var BYTES_PER_ELEMENT:Int = 4; - - @:generic - public inline function new(?elements:Int, ?array:Array, #if openfl ?vector:openfl.Vector, #end ?view:ArrayBufferView, ?buffer:ArrayBuffer, - ?byteoffset:Int = 0, ?len:Null) - { - if (elements != null) - { - this = new JSInt32Array(elements); - } - else if (array != null) - { - this = new JSInt32Array(untyped array); - #if (openfl && commonjs) - } - else if (vector != null) - { - this = new JSInt32Array(untyped (vector)); - #elseif openfl - } - else if (vector != null) - { - this = new JSInt32Array(untyped untyped (vector).__array); - #end - } - else if (view != null) - { - this = new JSInt32Array(untyped view); - } - else if (buffer != null) - { - if (len == null) - { - this = new JSInt32Array(buffer, byteoffset); - } - else - { - this = new JSInt32Array(buffer, byteoffset, len); - } - } - else - { - this = null; - } - } - - @:arrayAccess @:extern inline function __set(idx:Int, val:Int):Int - return this[idx] = val; - - @:arrayAccess @:extern inline function __get(idx:Int):Int - return this[idx]; - - // non spec haxe conversions - inline public static function fromBytes(bytes:haxe.io.Bytes, ?byteOffset:Int = 0, ?len:Int):Int32Array - { - if (byteOffset == null) return new JSInt32Array(cast bytes.getData()); - if (len == null) return new JSInt32Array(cast bytes.getData(), byteOffset); - return new JSInt32Array(cast bytes.getData(), byteOffset, len); - } - - inline public function toBytes():haxe.io.Bytes - { - return @:privateAccess new haxe.io.Bytes(cast new JSUInt8Array(this.buffer)); - } - - inline function toString() - return this != null ? 'Int32Array [byteLength:${this.byteLength}, length:${this.length}]' : null; -} -#else -import lime.utils.ArrayBufferView; - -@:forward -abstract Int32Array(ArrayBufferView) from ArrayBufferView to ArrayBufferView -{ - public inline static var BYTES_PER_ELEMENT:Int = 4; - - public var length(get, never):Int; - - @:generic - public inline function new(?elements:Int, ?buffer:ArrayBuffer, ?array:Array, #if openfl ?vector:openfl.Vector, #end ?view:ArrayBufferView, - ?byteoffset:Int = 0, ?len:Null) - { - if (elements != null) - { - this = new ArrayBufferView(elements, Int32); - } - else if (array != null) - { - this = new ArrayBufferView(0, Int32).initArray(array); - #if openfl - } - else if (vector != null) - { - this = new ArrayBufferView(0, Int32).initArray(untyped (vector).__array); - #end - } - else if (view != null) - { - this = new ArrayBufferView(0, Int32).initTypedArray(view); - } - else if (buffer != null) - { - this = new ArrayBufferView(0, Int32).initBuffer(buffer, byteoffset, len); - } - else - { - throw "Invalid constructor arguments for Int32Array"; - } - } - - // Public API - public inline function subarray(begin:Int, end:Null = null):Int32Array - return this.subarray(begin, end); - - // non spec haxe conversions - inline public static function fromBytes(bytes:haxe.io.Bytes, ?byteOffset:Int = 0, ?len:Int):Int32Array - { - return new Int32Array(bytes, byteOffset, len); - } - - inline public function toBytes():haxe.io.Bytes - { - return this.buffer; - } - - // Internal - inline function get_length() - return this.length; - - @:noCompletion - @:arrayAccess @:extern - public inline function __get(idx:Int) - { - return ArrayBufferIO.getInt32(this.buffer, this.byteOffset + (idx * BYTES_PER_ELEMENT)); - } - - @:noCompletion - @:arrayAccess @:extern - public inline function __set(idx:Int, val:Int) - { - ArrayBufferIO.setInt32(this.buffer, this.byteOffset + (idx * BYTES_PER_ELEMENT), val); - return val; - } - - inline function toString() - return this != null ? 'Int32Array [byteLength:${this.byteLength}, length:${this.length}]' : null; -} -#end // !js diff --git a/src/fixes/haxe/lime/utils/Int8Array.hx b/src/fixes/haxe/lime/utils/Int8Array.hx deleted file mode 100644 index 4485788..0000000 --- a/src/fixes/haxe/lime/utils/Int8Array.hx +++ /dev/null @@ -1,161 +0,0 @@ -package lime.utils; - -#if (js && !doc_gen) -#if haxe4 -import js.lib.Int8Array as JSInt8Array; -import js.lib.Uint8Array as JSUInt8Array; -#else -import js.html.Int8Array as JSInt8Array; -import js.html.Uint8Array as JSUInt8Array; -#end -@:forward -abstract Int8Array(JSInt8Array) from JSInt8Array to JSInt8Array/* to ArrayBufferView*/ -{ - public inline static var BYTES_PER_ELEMENT:Int = 1; - - @:generic - public inline function new(?elements:Int, ?array:Array, #if openfl ?vector:openfl.Vector, #end ?view:ArrayBufferView, ?buffer:ArrayBuffer, - ?byteoffset:Int = 0, ?len:Null) - { - if (elements != null) - { - this = new JSInt8Array(elements); - } - else if (array != null) - { - this = new JSInt8Array(untyped array); - #if (openfl && commonjs) - } - else if (vector != null) - { - this = new JSInt8Array(untyped (vector)); - #elseif openfl - } - else if (vector != null) - { - this = new JSInt8Array(untyped untyped (vector).__array); - #end - } - else if (view != null) - { - this = new JSInt8Array(untyped view); - } - else if (buffer != null) - { - if (len == null) - { - this = new JSInt8Array(buffer, byteoffset); - } - else - { - this = new JSInt8Array(buffer, byteoffset, len); - } - } - else - { - this = null; - } - } - - @:arrayAccess @:extern inline function __set(idx:Int, val:Int):Int - return this[idx] = val; - - @:arrayAccess @:extern inline function __get(idx:Int):Int - return this[idx]; - - // non spec haxe conversions - inline public static function fromBytes(bytes:haxe.io.Bytes, ?byteOffset:Int = 0, ?len:Int):Int8Array - { - return new JSInt8Array(cast bytes.getData(), byteOffset, len); - } - - inline public function toBytes():haxe.io.Bytes - { - return @:privateAccess new haxe.io.Bytes(cast new JSUInt8Array(this.buffer)); - } - - inline function toString() - return this != null ? 'Int8Array [byteLength:${this.byteLength}, length:${this.length}]' : null; -} -#else -import lime.utils.ArrayBufferView; - -@:forward -abstract Int8Array(ArrayBufferView) from ArrayBufferView to ArrayBufferView -{ - public inline static var BYTES_PER_ELEMENT:Int = 1; - - public var length(get, never):Int; - - @:generic - public inline function new(?elements:Int, ?buffer:ArrayBuffer, ?array:Array, #if openfl ?vector:openfl.Vector, #end ?view:ArrayBufferView, - ?byteoffset:Int = 0, ?len:Null) - { - if (elements != null) - { - this = new ArrayBufferView(elements, Int8); - } - else if (array != null) - { - this = new ArrayBufferView(0, Int8).initArray(array); - #if openfl - } - else if (vector != null) - { - this = new ArrayBufferView(0, Int8).initArray(untyped (vector).__array); - #end - } - else if (view != null) - { - this = new ArrayBufferView(0, Int8).initTypedArray(view); - } - else if (buffer != null) - { - this = new ArrayBufferView(0, Int8).initBuffer(buffer, byteoffset, len); - } - else - { - throw "Invalid constructor arguments for Int8Array"; - } - } - - // Public API - public inline function subarray(begin:Int, end:Null = null):Int8Array - return this.subarray(begin, end); - - // non spec haxe conversions - inline public static function fromBytes(bytes:haxe.io.Bytes, ?byteOffset:Int = 0, ?len:Int):Int8Array - { - if (byteOffset == null) return new Int8Array(null, null, cast bytes.getData()); - if (len == null) return new Int8Array(null, null, cast bytes.getData(), byteOffset); - return new Int8Array(null, null, cast bytes.getData(), byteOffset, len); - } - - inline public function toBytes():haxe.io.Bytes - { - return this.buffer; - } - - // Internal - inline function get_length() - return this.length; - - @:noCompletion - @:arrayAccess @:extern - public inline function __get(idx:Int) - { - return ArrayBufferIO.getInt8(this.buffer, this.byteOffset + idx); - } - - @:noCompletion - @:arrayAccess @:extern - public inline function __set(idx:Int, val:Int) - { - ArrayBufferIO.setInt8(this.buffer, this.byteOffset + idx, val); - return val; - } - - inline function toString() - return this != null ? 'Int8Array [byteLength:${this.byteLength}, length:${this.length}]' : null; -} -#end // !js diff --git a/src/fixes/haxe/lime/utils/README.md b/src/fixes/haxe/lime/utils/README.md deleted file mode 100644 index e829930..0000000 --- a/src/fixes/haxe/lime/utils/README.md +++ /dev/null @@ -1,8 +0,0 @@ -environment: -* lime 7.6.0 -* haxe 3.4.7 -* openfl build html5 - -code: ` to ArrayBufferView` - -error: You can only declare from/to with compatible types diff --git a/src/fixes/haxe/lime/utils/UInt16Array.hx b/src/fixes/haxe/lime/utils/UInt16Array.hx deleted file mode 100644 index 7e8ac16..0000000 --- a/src/fixes/haxe/lime/utils/UInt16Array.hx +++ /dev/null @@ -1,161 +0,0 @@ -package lime.utils; - -#if (js && !doc_gen) -#if haxe4 -import js.lib.Uint8Array as JSUInt8Array; -import js.lib.Uint16Array as JSUInt16Array; -#else -import js.html.Uint8Array as JSUInt8Array; -import js.html.Uint16Array as JSUInt16Array; -#end -@:forward -abstract UInt16Array(JSUInt16Array) from JSUInt16Array to JSUInt16Array/* to ArrayBufferView*/ -{ - public inline static var BYTES_PER_ELEMENT:Int = 2; - - @:generic - public inline function new(?elements:Int, ?array:Array, #if openfl ?vector:openfl.Vector, #end ?view:ArrayBufferView, ?buffer:ArrayBuffer, - ?byteoffset:Int = 0, ?len:Null) - { - if (elements != null) - { - this = new JSUInt16Array(elements); - } - else if (array != null) - { - this = new JSUInt16Array(untyped array); - #if (openfl && commonjs) - } - else if (vector != null) - { - this = new JSUInt16Array(untyped (vector)); - #elseif openfl - } - else if (vector != null) - { - this = new JSUInt16Array(untyped untyped (vector).__array); - #end - } - else if (view != null) - { - this = new JSUInt16Array(untyped view); - } - else if (buffer != null) - { - if (len == null) - { - this = new JSUInt16Array(buffer, byteoffset); - } - else - { - this = new JSUInt16Array(buffer, byteoffset, len); - } - } - else - { - this = null; - } - } - - @:arrayAccess @:extern inline function __set(idx:Int, val:UInt):UInt - return this[idx] = val; - - @:arrayAccess @:extern inline function __get(idx:Int):UInt - return this[idx]; - - // non spec haxe conversions - inline public static function fromBytes(bytes:haxe.io.Bytes, ?byteOffset:Int = 0, ?len:Int):UInt16Array - { - if (byteOffset == null) return new JSUInt16Array(cast bytes.getData()); - if (len == null) return new JSUInt16Array(cast bytes.getData(), byteOffset); - return new JSUInt16Array(cast bytes.getData(), byteOffset, len); - } - - inline public function toBytes():haxe.io.Bytes - { - return @:privateAccess new haxe.io.Bytes(cast new JSUInt8Array(this.buffer)); - } - - inline function toString() - return this != null ? 'UInt16Array [byteLength:${this.byteLength}, length:${this.length}]' : null; -} -#else -import lime.utils.ArrayBufferView; - -@:forward -abstract UInt16Array(ArrayBufferView) from ArrayBufferView to ArrayBufferView -{ - public inline static var BYTES_PER_ELEMENT:Int = 2; - - public var length(get, never):Int; - - @:generic - public inline function new(?elements:Int, ?buffer:ArrayBuffer, ?array:Array, #if openfl ?vector:openfl.Vector, #end ?view:ArrayBufferView, - ?byteoffset:Int = 0, ?len:Null) - { - if (elements != null) - { - this = new ArrayBufferView(elements, Uint16); - } - else if (array != null) - { - this = new ArrayBufferView(0, Uint16).initArray(array); - #if openfl - } - else if (vector != null) - { - this = new ArrayBufferView(0, Uint16).initArray(untyped (vector).__array); - #end - } - else if (view != null) - { - this = new ArrayBufferView(0, Uint16).initTypedArray(view); - } - else if (buffer != null) - { - this = new ArrayBufferView(0, Uint16).initBuffer(buffer, byteoffset, len); - } - else - { - throw "Invalid constructor arguments for UInt16Array"; - } - } - - // Public API - public inline function subarray(begin:Int, end:Null = null):UInt16Array - return this.subarray(begin, end); - - // non spec haxe conversions - inline public static function fromBytes(bytes:haxe.io.Bytes, ?byteOffset:Int = 0, ?len:Int):UInt16Array - { - return new UInt16Array(bytes, byteOffset, len); - } - - inline public function toBytes():haxe.io.Bytes - { - return this.buffer; - } - - // Internal - inline function get_length() - return this.length; - - @:noCompletion - @:arrayAccess @:extern - public inline function __get(idx:Int) - { - return ArrayBufferIO.getUint16(this.buffer, this.byteOffset + (idx * BYTES_PER_ELEMENT)); - } - - @:noCompletion - @:arrayAccess @:extern - public inline function __set(idx:Int, val:UInt) - { - ArrayBufferIO.setUint16(this.buffer, this.byteOffset + (idx * BYTES_PER_ELEMENT), val); - return val; - } - - inline function toString() - return this != null ? 'UInt16Array [byteLength:${this.byteLength}, length:${this.length}]' : null; -} -#end // !js diff --git a/src/fixes/haxe/lime/utils/UInt32Array.hx b/src/fixes/haxe/lime/utils/UInt32Array.hx deleted file mode 100644 index 2db3844..0000000 --- a/src/fixes/haxe/lime/utils/UInt32Array.hx +++ /dev/null @@ -1,161 +0,0 @@ -package lime.utils; - -#if (js && !doc_gen) -#if haxe4 -import js.lib.Uint8Array as JSUInt8Array; -import js.lib.Uint32Array as JSUInt32Array; -#else -import js.html.Uint8Array as JSUInt8Array; -import js.html.Uint32Array as JSUInt32Array; -#end -@:forward -abstract UInt32Array(JSUInt32Array) from JSUInt32Array to JSUInt32Array/* to ArrayBufferView*/ -{ - public inline static var BYTES_PER_ELEMENT:Int = 4; - - @:generic - public inline function new(?elements:Int, ?array:Array, #if openfl ?vector:openfl.Vector, #end ?view:ArrayBufferView, ?buffer:ArrayBuffer, - ?byteoffset:Int = 0, ?len:Null) - { - if (elements != null) - { - this = new JSUInt32Array(elements); - } - else if (array != null) - { - this = new JSUInt32Array(untyped array); - #if (openfl && commonjs) - } - else if (vector != null) - { - this = new JSUInt32Array(untyped (vector)); - #elseif openfl - } - else if (vector != null) - { - this = new JSUInt32Array(untyped untyped (vector).__array); - #end - } - else if (view != null) - { - this = new JSUInt32Array(untyped view); - } - else if (buffer != null) - { - if (len == null) - { - this = new JSUInt32Array(buffer, byteoffset); - } - else - { - this = new JSUInt32Array(buffer, byteoffset, len); - } - } - else - { - this = null; - } - } - - @:arrayAccess @:extern inline function __set(idx:Int, val:UInt):UInt - return this[idx] = val; - - @:arrayAccess @:extern inline function __get(idx:Int):UInt - return this[idx]; - - // non spec haxe conversions - inline public static function fromBytes(bytes:haxe.io.Bytes, ?byteOffset:Int = 0, ?len:Int):UInt32Array - { - if (byteOffset == null) return new JSUInt32Array(cast bytes.getData()); - if (len == null) return new JSUInt32Array(cast bytes.getData(), byteOffset); - return new JSUInt32Array(cast bytes.getData(), byteOffset, len); - } - - inline public function toBytes():haxe.io.Bytes - { - return @:privateAccess new haxe.io.Bytes(cast new JSUInt8Array(this.buffer)); - } - - inline function toString() - return this != null ? 'UInt32Array [byteLength:${this.byteLength}, length:${this.length}]' : null; -} -#else -import lime.utils.ArrayBufferView; - -@:forward -abstract UInt32Array(ArrayBufferView) from ArrayBufferView to ArrayBufferView -{ - public inline static var BYTES_PER_ELEMENT:Int = 4; - - public var length(get, never):Int; - - @:generic - public inline function new(?elements:Int, ?buffer:ArrayBuffer, ?array:Array, #if openfl ?vector:openfl.Vector, #end ?view:ArrayBufferView, - ?byteoffset:Int = 0, ?len:Null) - { - if (elements != null) - { - this = new ArrayBufferView(elements, Uint32); - } - else if (array != null) - { - this = new ArrayBufferView(0, Uint32).initArray(array); - #if openfl - } - else if (vector != null) - { - this = new ArrayBufferView(0, Uint32).initArray(untyped (vector).__array); - #end - } - else if (view != null) - { - this = new ArrayBufferView(0, Uint32).initTypedArray(view); - } - else if (buffer != null) - { - this = new ArrayBufferView(0, Uint32).initBuffer(buffer, byteoffset, len); - } - else - { - throw "Invalid constructor arguments for UInt32Array"; - } - } - - // Public API - public inline function subarray(begin:Int, end:Null = null):UInt32Array - return this.subarray(begin, end); - - // non spec haxe conversions - inline public static function fromBytes(bytes:haxe.io.Bytes, ?byteOffset:Int = 0, ?len:Int):UInt32Array - { - return new UInt32Array(bytes, byteOffset, len); - } - - inline public function toBytes():haxe.io.Bytes - { - return this.buffer; - } - - // Internal - inline function get_length() - return this.length; - - @:noCompletion - @:arrayAccess @:extern - public inline function __get(idx:Int) - { - return ArrayBufferIO.getUint32(this.buffer, this.byteOffset + (idx * BYTES_PER_ELEMENT)); - } - - @:noCompletion - @:arrayAccess @:extern - public inline function __set(idx:Int, val:UInt) - { - ArrayBufferIO.setUint32(this.buffer, this.byteOffset + (idx * BYTES_PER_ELEMENT), val); - return val; - } - - inline function toString() - return this != null ? 'UInt32Array [byteLength:${this.byteLength}, length:${this.length}]' : null; -} -#end // !js diff --git a/src/fixes/haxe/lime/utils/UInt8Array.hx b/src/fixes/haxe/lime/utils/UInt8Array.hx deleted file mode 100644 index 597dd96..0000000 --- a/src/fixes/haxe/lime/utils/UInt8Array.hx +++ /dev/null @@ -1,159 +0,0 @@ -package lime.utils; - -#if (js && !doc_gen) -#if haxe4 -import js.lib.Uint8Array as JSUInt8Array; -#else -import js.html.Uint8Array as JSUInt8Array; -#end -@:forward -abstract UInt8Array(JSUInt8Array) from JSUInt8Array to JSUInt8Array/* to ArrayBufferView*/ -{ - public inline static var BYTES_PER_ELEMENT:Int = 1; - - @:generic - public inline function new(?elements:Int, ?array:Array, #if openfl ?vector:openfl.Vector, #end ?view:ArrayBufferView, ?buffer:ArrayBuffer, - ?byteoffset:Int = 0, ?len:Null) - { - if (elements != null) - { - this = new JSUInt8Array(elements); - } - else if (array != null) - { - this = new JSUInt8Array(untyped array); - #if (openfl && commonjs) - } - else if (vector != null) - { - this = new JSUInt8Array(untyped (vector)); - #elseif openfl - } - else if (vector != null) - { - this = new JSUInt8Array(untyped untyped (vector).__array); - #end - } - else if (view != null) - { - this = new JSUInt8Array(untyped view); - } - else if (buffer != null) - { - if (len == null) - { - this = new JSUInt8Array(buffer, byteoffset); - } - else - { - this = new JSUInt8Array(buffer, byteoffset, len); - } - } - else - { - this = null; - } - } - - @:arrayAccess @:extern inline function __set(idx:Int, val:UInt):UInt - return this[idx] = val; - - @:arrayAccess @:extern inline function __get(idx:Int):UInt - return this[idx]; - - // non spec haxe conversions - inline public static function fromBytes(bytes:haxe.io.Bytes, ?byteOffset:Int, ?len:Int):UInt8Array - { - if (byteOffset == null) return new JSUInt8Array(cast bytes.getData()); - if (len == null) return new JSUInt8Array(cast bytes.getData(), byteOffset); - return new JSUInt8Array(cast bytes.getData(), byteOffset, len); - } - - inline public function toBytes():haxe.io.Bytes - { - return @:privateAccess new haxe.io.Bytes(cast new JSUInt8Array(this.buffer)); - } - - inline function toString() - return this != null ? 'UInt8Array [byteLength:${this.byteLength}, length:${this.length}]' : null; -} -#else -import lime.utils.ArrayBufferView; - -@:forward -abstract UInt8Array(ArrayBufferView) from ArrayBufferView to ArrayBufferView -{ - public inline static var BYTES_PER_ELEMENT:Int = 1; - - public var length(get, never):Int; - - @:generic - public inline function new(?elements:Int, ?buffer:ArrayBuffer, ?array:Array, #if openfl ?vector:openfl.Vector, #end ?view:ArrayBufferView, - ?byteoffset:Int = 0, ?len:Null) - { - if (elements != null) - { - this = new ArrayBufferView(elements, Uint8); - } - else if (array != null) - { - this = new ArrayBufferView(0, Uint8).initArray(array); - #if openfl - } - else if (vector != null) - { - this = new ArrayBufferView(0, Uint8).initArray(untyped (vector).__array); - #end - } - else if (view != null) - { - this = new ArrayBufferView(0, Uint8).initTypedArray(view); - } - else if (buffer != null) - { - this = new ArrayBufferView(0, Uint8).initBuffer(buffer, byteoffset, len); - } - else - { - throw "Invalid constructor arguments for UInt8Array"; - } - } - - // Public API - public inline function subarray(begin:Int, end:Null = null):UInt8Array - return this.subarray(begin, end); - - // non spec haxe conversions - inline public static function fromBytes(bytes:haxe.io.Bytes, ?byteOffset:Int = 0, ?len:Int):UInt8Array - { - return new UInt8Array(bytes, byteOffset, len); - } - - inline public function toBytes():haxe.io.Bytes - { - return this.buffer; - } - - // Internal - inline function toString() - return this != null ? 'UInt8Array [byteLength:${this.byteLength}, length:${this.length}]' : null; - - inline function get_length() - return this.length; - - @:noCompletion - @:arrayAccess @:extern - public inline function __get(idx:Int) - { - return ArrayBufferIO.getUint8(this.buffer, this.byteOffset + idx); - } - - @:noCompletion - @:arrayAccess @:extern - public inline function __set(idx:Int, val:UInt) - { - ArrayBufferIO.setUint8(this.buffer, this.byteOffset + idx, val); - return val; - } -} -#end // !js diff --git a/src/fixes/haxe/lime/utils/UInt8ClampedArray.hx b/src/fixes/haxe/lime/utils/UInt8ClampedArray.hx deleted file mode 100644 index f12f5ae..0000000 --- a/src/fixes/haxe/lime/utils/UInt8ClampedArray.hx +++ /dev/null @@ -1,171 +0,0 @@ -package lime.utils; - -#if (js && !doc_gen) -#if haxe4 -import js.lib.Uint8Array as JSUInt8Array; -import js.lib.Uint8ClampedArray as JSUInt8ClampedArray; -#else -import js.html.Uint8Array as JSUInt8Array; -import js.html.Uint8ClampedArray as JSUInt8ClampedArray; -#end -@:forward -abstract UInt8ClampedArray(JSUInt8ClampedArray) from JSUInt8ClampedArray to JSUInt8ClampedArray/* to ArrayBufferView*/ -{ - public inline static var BYTES_PER_ELEMENT:Int = 1; - - @:generic - public inline function new(?elements:Int, ?array:Array, #if openfl ?vector:openfl.Vector, #end ?view:ArrayBufferView, ?buffer:ArrayBuffer, - ?byteoffset:Int = 0, ?len:Null) - { - if (elements != null) - { - this = new JSUInt8ClampedArray(elements); - } - else if (array != null) - { - this = new JSUInt8ClampedArray(untyped array); - #if (openfl && commonjs) - } - else if (vector != null) - { - this = new JSUInt8ClampedArray(untyped (vector)); - #elseif openfl - } - else if (vector != null) - { - this = new JSUInt8ClampedArray(untyped untyped (vector).__array); - #end - } - else if (view != null) - { - this = new JSUInt8ClampedArray(untyped view); - } - else if (buffer != null) - { - if (len == null) - { - this = new JSUInt8ClampedArray(buffer, byteoffset); - } - else - { - this = new JSUInt8ClampedArray(buffer, byteoffset, len); - } - } - else - { - this = null; - } - } - - @:arrayAccess @:extern inline function __set(idx:Int, val:UInt):UInt - return this[idx] = _clamp(val); - - @:arrayAccess @:extern inline function __get(idx:Int):UInt - return this[idx]; - - // non spec haxe conversions - inline public static function fromBytes(bytes:haxe.io.Bytes, ?byteOffset:Int = 0, ?len:Int):UInt8ClampedArray - { - if (byteOffset == null) return new JSUInt8ClampedArray(cast bytes.getData()); - if (len == null) return new JSUInt8ClampedArray(cast bytes.getData(), byteOffset); - return new JSUInt8ClampedArray(cast bytes.getData(), byteOffset, len); - } - - inline public function toBytes():haxe.io.Bytes - { - return @:privateAccess new haxe.io.Bytes(cast new JSUInt8Array(this.buffer)); - } - - inline function toString() - return this != null ? 'UInt8ClampedArray [byteLength:${this.byteLength}, length:${this.length}]' : null; - - // internal - // clamp a Int to a 0-255 Uint8 - static function _clamp(_in:Float):Int - { - var _out = Std.int(_in); - _out = _out > 255 ? 255 : _out; - return _out < 0 ? 0 : _out; - } // _clamp -} -#else -import lime.utils.ArrayBufferView; - -@:forward -@:arrayAccess -abstract UInt8ClampedArray(ArrayBufferView) from ArrayBufferView to ArrayBufferView -{ - public inline static var BYTES_PER_ELEMENT:Int = 1; - - public var length(get, never):Int; - - @:generic - public inline function new(?elements:Int, ?buffer:ArrayBuffer, ?array:Array, #if openfl ?vector:openfl.Vector, #end ?view:ArrayBufferView, - ?byteoffset:Int = 0, ?len:Null) - { - if (elements != null) - { - this = new ArrayBufferView(elements, Uint8Clamped); - } - else if (array != null) - { - this = new ArrayBufferView(0, Uint8Clamped).initArray(array); - #if openfl - } - else if (vector != null) - { - this = new ArrayBufferView(0, Uint8Clamped).initArray(untyped (vector).__array); - #end - } - else if (view != null) - { - this = new ArrayBufferView(0, Uint8Clamped).initTypedArray(view); - } - else if (buffer != null) - { - this = new ArrayBufferView(0, Uint8Clamped).initBuffer(buffer, byteoffset, len); - } - else - { - throw "Invalid constructor arguments for UInt8ClampedArray"; - } - } - - // Public API - public inline function subarray(begin:Int, end:Null = null):UInt8ClampedArray - return this.subarray(begin, end); - - // non spec haxe conversions - inline public static function fromBytes(bytes:haxe.io.Bytes, ?byteOffset:Int = 0, ?len:Int):UInt8ClampedArray - { - return new UInt8ClampedArray(bytes, byteOffset, len); - } - - inline public function toBytes():haxe.io.Bytes - { - return this.buffer; - } - - // Internal - inline function get_length() - return this.length; - - @:noCompletion - @:arrayAccess @:extern - public inline function __get(idx:Int) - { - return ArrayBufferIO.getUint8(this.buffer, this.byteOffset + idx); - } - - @:noCompletion - @:arrayAccess @:extern - public inline function __set(idx:Int, val:UInt) - { - ArrayBufferIO.setUint8Clamped(this.buffer, this.byteOffset + idx, val); - return val; - } - - inline function toString() - return this != null ? 'UInt8ClampedArray [byteLength:${this.byteLength}, length:${this.length}]' : null; -} -#end // !js