HTML5 typed array fix

This commit is contained in:
Joshua Granick
2015-07-06 17:14:50 -07:00
parent 722f0d2701
commit ee08c8c37e
9 changed files with 65 additions and 47 deletions

View File

@@ -7,9 +7,9 @@ package lime.utils;
abstract Float32Array(js.html.Float32Array)
from js.html.Float32Array
to js.html.Float32Array {
public inline static var BYTES_PER_ELEMENT : Int = 4;
public inline static var BYTES_PER_ELEMENT : Int = 4;
@:generic
public inline function new<T>(
?elements:Int,
@@ -23,9 +23,11 @@ package lime.utils;
this = new js.html.Float32Array( untyped array );
} else if(view != null) {
this = new js.html.Float32Array( untyped view );
} else if(buffer != null) {
len = (len == null) ? untyped __js__('undefined') : len;
this = new js.html.Float32Array( buffer, byteoffset, len );
} else if (buffer != null) {
if (len == null)
this = new js.html.Float32Array( buffer, byteoffset );
else
this = new js.html.Float32Array( buffer, byteoffset, len );
} else {
this = null;
}

View File

@@ -7,9 +7,9 @@ package lime.utils;
abstract Float64Array(js.html.Float64Array)
from js.html.Float64Array
to js.html.Float64Array {
public inline static var BYTES_PER_ELEMENT : Int = 8;
public inline static var BYTES_PER_ELEMENT : Int = 8;
@:generic
public inline function new<T>(
?elements:Int,
@@ -23,9 +23,11 @@ package lime.utils;
this = new js.html.Float64Array( untyped array );
} else if(view != null) {
this = new js.html.Float64Array( untyped view );
} else if(buffer != null) {
len = (len == null) ? untyped __js__('undefined') : len;
this = new js.html.Float64Array( buffer, byteoffset, len );
} else if (buffer != null) {
if (len == null)
this = new js.html.Float64Array( buffer, byteoffset );
else
this = new js.html.Float64Array( buffer, byteoffset, len );
} else {
this = null;
}

View File

@@ -7,9 +7,9 @@ package lime.utils;
abstract Int16Array(js.html.Int16Array)
from js.html.Int16Array
to js.html.Int16Array {
public inline static var BYTES_PER_ELEMENT : Int = 2;
public inline static var BYTES_PER_ELEMENT : Int = 2;
@:generic
public inline function new<T>(
?elements:Int,
@@ -24,8 +24,10 @@ package lime.utils;
} else if(view != null) {
this = new js.html.Int16Array( untyped view );
} else if(buffer != null) {
len = (len == null) ? untyped __js__('undefined') : len;
this = new js.html.Int16Array( buffer, byteoffset, len );
if (len == null)
this = new js.html.Int16Array( buffer, byteoffset );
else
this = new js.html.Int16Array( buffer, byteoffset, len );
} else {
this = null;
}

View File

@@ -7,9 +7,9 @@ package lime.utils;
abstract Int32Array(js.html.Int32Array)
from js.html.Int32Array
to js.html.Int32Array {
public inline static var BYTES_PER_ELEMENT : Int = 4;
public inline static var BYTES_PER_ELEMENT : Int = 4;
@:generic
public inline function new<T>(
?elements:Int,
@@ -24,8 +24,10 @@ package lime.utils;
} else if(view != null) {
this = new js.html.Int32Array( untyped view );
} else if(buffer != null) {
len = (len == null) ? untyped __js__('undefined') : len;
this = new js.html.Int32Array( buffer, byteoffset, len );
if (len == null)
this = new js.html.Int32Array( buffer, byteoffset );
else
this = new js.html.Int32Array( buffer, byteoffset, len );
} else {
this = null;
}

View File

@@ -7,9 +7,9 @@ package lime.utils;
abstract Int8Array(js.html.Int8Array)
from js.html.Int8Array
to js.html.Int8Array {
public inline static var BYTES_PER_ELEMENT : Int = 1;
public inline static var BYTES_PER_ELEMENT : Int = 1;
@:generic
public inline function new<T>(
?elements:Int,
@@ -24,8 +24,10 @@ package lime.utils;
} else if(view != null) {
this = new js.html.Int8Array( untyped view );
} else if(buffer != null) {
len = (len == null) ? untyped __js__('undefined') : len;
this = new js.html.Int8Array( buffer, byteoffset, len );
if (len == null)
this = new js.html.Int8Array( buffer, byteoffset );
else
this = new js.html.Int8Array( buffer, byteoffset, len );
} else {
this = null;
}

View File

@@ -7,9 +7,9 @@ package lime.utils;
abstract UInt16Array(js.html.Uint16Array)
from js.html.Uint16Array
to js.html.Uint16Array {
public inline static var BYTES_PER_ELEMENT : Int = 2;
public inline static var BYTES_PER_ELEMENT : Int = 2;
@:generic
public inline function new<T>(
?elements:Int,
@@ -24,8 +24,10 @@ package lime.utils;
} else if(view != null) {
this = new js.html.Uint16Array( untyped view );
} else if(buffer != null) {
len = (len == null) ? untyped __js__('undefined') : len;
this = new js.html.Uint16Array( buffer, byteoffset, len );
if (len == null)
this = new js.html.Uint16Array( buffer, byteoffset );
else
this = new js.html.Uint16Array( buffer, byteoffset, len );
} else {
this = null;
}

View File

@@ -7,9 +7,9 @@ package lime.utils;
abstract UInt32Array(js.html.Uint32Array)
from js.html.Uint32Array
to js.html.Uint32Array {
public inline static var BYTES_PER_ELEMENT : Int = 4;
public inline static var BYTES_PER_ELEMENT : Int = 4;
@:generic
public inline function new<T>(
?elements:Int,
@@ -24,8 +24,10 @@ package lime.utils;
} else if(view != null) {
this = new js.html.Uint32Array( untyped view );
} else if(buffer != null) {
len = (len == null) ? untyped __js__('undefined') : len;
this = new js.html.Uint32Array( buffer, byteoffset, len );
if (len == null)
this = new js.html.Uint32Array( buffer, byteoffset );
else
this = new js.html.Uint32Array( buffer, byteoffset, len );
} else {
this = null;
}

View File

@@ -7,9 +7,9 @@ package lime.utils;
abstract UInt8Array(js.html.Uint8Array)
from js.html.Uint8Array
to js.html.Uint8Array {
public inline static var BYTES_PER_ELEMENT : Int = 1;
public inline static var BYTES_PER_ELEMENT : Int = 1;
@:generic
public inline function new<T>(
?elements:Int,
@@ -24,8 +24,10 @@ package lime.utils;
} else if(view != null) {
this = new js.html.Uint8Array( untyped view );
} else if(buffer != null) {
len = (len == null) ? untyped __js__('undefined') : len;
this = new js.html.Uint8Array( buffer, byteoffset, len );
if (len == null)
this = new js.html.Uint8Array( buffer, byteoffset );
else
this = new js.html.Uint8Array( buffer, byteoffset, len );
} else {
this = null;
}

View File

@@ -7,9 +7,9 @@ package lime.utils;
abstract UInt8ClampedArray(js.html.Uint8ClampedArray)
from js.html.Uint8ClampedArray
to js.html.Uint8ClampedArray {
public inline static var BYTES_PER_ELEMENT : Int = 1;
public inline static var BYTES_PER_ELEMENT : Int = 1;
@:generic
public inline function new<T>(
?elements:Int,
@@ -24,8 +24,10 @@ package lime.utils;
} else if(view != null) {
this = new js.html.Uint8ClampedArray( untyped view );
} else if(buffer != null) {
len = (len == null) ? untyped __js__('undefined') : len;
this = new js.html.Uint8ClampedArray( buffer, byteoffset, len );
if (len == null)
this = new js.html.Uint8ClampedArray( buffer, byteoffset );
else
this = new js.html.Uint8ClampedArray( buffer, byteoffset, len );
} else {
this = null;
}