Handle null toString in typed arrays

This commit is contained in:
Joshua Granick
2015-07-13 17:44:22 -07:00
parent 3b6b47d278
commit 66fc421472
10 changed files with 21 additions and 19 deletions

View File

@@ -241,7 +241,9 @@ class ArrayBufferView {
#if !no_typedarray_inline inline #end
function toString() {
if (this == null) return null;
var name =
switch(type) {
case Int8: 'Int8Array';

View File

@@ -53,7 +53,7 @@ package lime.utils;
#end
}
function toString() return 'Float32Array [byteLength:${this.byteLength}, length:${this.length}]';
function toString() return this != null ? 'Float32Array [byteLength:${this.byteLength}, length:${this.length}]' : null;
}
@@ -107,7 +107,7 @@ abstract Float32Array(ArrayBufferView) from ArrayBufferView to ArrayBufferView {
//Internal
function toString() return 'Float32Array [byteLength:${this.byteLength}, length:${this.length}]';
function toString() return this != null ? 'Float32Array [byteLength:${this.byteLength}, length:${this.length}]' : null;
inline function get_length() return this.length;

View File

@@ -53,7 +53,7 @@ package lime.utils;
#end
}
function toString() return 'Float64Array [byteLength:${this.byteLength}, length:${this.length}]';
function toString() return this != null ? 'Float64Array [byteLength:${this.byteLength}, length:${this.length}]' : null;
}
@@ -121,7 +121,7 @@ abstract Float64Array(ArrayBufferView) from ArrayBufferView to ArrayBufferView {
return ArrayBufferIO.setFloat64(this.buffer, this.byteOffset+(idx*BYTES_PER_ELEMENT), val);
}
function toString() return 'Float64Array [byteLength:${this.byteLength}, length:${this.length}]';
function toString() return this != null ? 'Float64Array [byteLength:${this.byteLength}, length:${this.length}]' : null;
}

View File

@@ -53,7 +53,7 @@ package lime.utils;
#end
}
function toString() return 'Int16Array [byteLength:${this.byteLength}, length:${this.length}]';
function toString() return this != null ? 'Int16Array [byteLength:${this.byteLength}, length:${this.length}]' : null;
}
@@ -121,7 +121,7 @@ abstract Int16Array(ArrayBufferView) from ArrayBufferView to ArrayBufferView {
return ArrayBufferIO.setInt16(this.buffer, this.byteOffset+(idx*BYTES_PER_ELEMENT), val);
}
function toString() return 'Int16Array [byteLength:${this.byteLength}, length:${this.length}]';
function toString() return this != null ? 'Int16Array [byteLength:${this.byteLength}, length:${this.length}]' : null;
}

View File

@@ -53,7 +53,7 @@ package lime.utils;
#end
}
function toString() return 'Int32Array [byteLength:${this.byteLength}, length:${this.length}]';
function toString() return this != null ? 'Int32Array [byteLength:${this.byteLength}, length:${this.length}]' : null;
}
@@ -121,7 +121,7 @@ abstract Int32Array(ArrayBufferView) from ArrayBufferView to ArrayBufferView {
return ArrayBufferIO.setInt32(this.buffer, this.byteOffset+(idx*BYTES_PER_ELEMENT), val);
}
function toString() return 'Int32Array [byteLength:${this.byteLength}, length:${this.length}]';
function toString() return this != null ? 'Int32Array [byteLength:${this.byteLength}, length:${this.length}]' : null;
}

View File

@@ -51,7 +51,7 @@ package lime.utils;
#end
}
function toString() return 'Int8Array [byteLength:${this.byteLength}, length:${this.length}]';
function toString() return this != null ? 'Int8Array [byteLength:${this.byteLength}, length:${this.length}]' : null;
}
@@ -121,7 +121,7 @@ abstract Int8Array(ArrayBufferView) from ArrayBufferView to ArrayBufferView {
return ArrayBufferIO.setInt8(this.buffer, this.byteOffset+idx, val);
}
function toString() return 'Int8Array [byteLength:${this.byteLength}, length:${this.length}]';
function toString() return this != null ? 'Int8Array [byteLength:${this.byteLength}, length:${this.length}]' : null;
}

View File

@@ -53,7 +53,7 @@ package lime.utils;
#end
}
function toString() return 'UInt16Array [byteLength:${this.byteLength}, length:${this.length}]';
function toString() return this != null ? 'UInt16Array [byteLength:${this.byteLength}, length:${this.length}]' : null;
}
@@ -121,7 +121,7 @@ abstract UInt16Array(ArrayBufferView) from ArrayBufferView to ArrayBufferView {
return ArrayBufferIO.setUint16(this.buffer, this.byteOffset+(idx*BYTES_PER_ELEMENT), val);
}
function toString() return 'UInt16Array [byteLength:${this.byteLength}, length:${this.length}]';
function toString() return this != null ? 'UInt16Array [byteLength:${this.byteLength}, length:${this.length}]' : null;
}

View File

@@ -53,7 +53,7 @@ package lime.utils;
#end
}
function toString() return 'UInt32Array [byteLength:${this.byteLength}, length:${this.length}]';
function toString() return this != null ? 'UInt32Array [byteLength:${this.byteLength}, length:${this.length}]' : null;
}
@@ -121,7 +121,7 @@ abstract UInt32Array(ArrayBufferView) from ArrayBufferView to ArrayBufferView {
return ArrayBufferIO.setUint32(this.buffer, this.byteOffset+(idx*BYTES_PER_ELEMENT), val);
}
function toString() return 'UInt32Array [byteLength:${this.byteLength}, length:${this.length}]';
function toString() return this != null ? 'UInt32Array [byteLength:${this.byteLength}, length:${this.length}]' : null;
}

View File

@@ -53,7 +53,7 @@ package lime.utils;
#end
}
function toString() return 'UInt8Array [byteLength:${this.byteLength}, length:${this.length}]';
function toString() return this != null ? 'UInt8Array [byteLength:${this.byteLength}, length:${this.length}]' : null;
}
@@ -106,7 +106,7 @@ abstract UInt8Array(ArrayBufferView) from ArrayBufferView to ArrayBufferView {
//Internal
function toString() return 'UInt8Array [byteLength:${this.byteLength}, length:${this.length}]';
function toString() return this != null ? 'UInt8Array [byteLength:${this.byteLength}, length:${this.length}]' : null;
inline function get_length() return this.length;

View File

@@ -53,7 +53,7 @@ package lime.utils;
#end
}
function toString() return 'UInt8ClampedArray [byteLength:${this.byteLength}, length:${this.length}]';
function toString() return this != null ? 'UInt8ClampedArray [byteLength:${this.byteLength}, length:${this.length}]' : null;
//internal
//clamp a Int to a 0-255 Uint8
@@ -129,7 +129,7 @@ abstract UInt8ClampedArray(ArrayBufferView) from ArrayBufferView to ArrayBufferV
return ArrayBufferIO.setUint8Clamped(this.buffer, this.byteOffset+idx, val);
}
function toString() return 'UInt8ClampedArray [byteLength:${this.byteLength}, length:${this.length}]';
function toString() return this != null ? 'UInt8ClampedArray [byteLength:${this.byteLength}, length:${this.length}]' : null;
}