Browse Source

more arraybuffer compat support

Nicolas Cannasse 10 years ago
parent
commit
a9907d7535
2 changed files with 8 additions and 3 deletions
  1. 7 2
      std/js/html/compat/ArrayBuffer.hx
  2. 1 1
      std/js/html/compat/Uint8Array.hx

+ 7 - 2
std/js/html/compat/ArrayBuffer.hx

@@ -31,8 +31,13 @@ class ArrayBuffer {
 		if( Std.is(a,Array) ) {
 		if( Std.is(a,Array) ) {
 			this.a = a;
 			this.a = a;
 			byteLength = a.length;
 			byteLength = a.length;
-		} else
-			throw "TODO";
+		} else {
+			var len : Int = a;
+			this.a = [];
+			for( i in 0...len )
+				this.a[i] = 0;
+			byteLength = len;
+		}
 	}
 	}
 	
 	
 	public function slice(begin,?end) {
 	public function slice(begin,?end) {

+ 1 - 1
std/js/html/compat/Uint8Array.hx

@@ -60,7 +60,7 @@ class Uint8Array {
 				arr.buffer = new ArrayBuffer(arr);
 				arr.buffer = new ArrayBuffer(arr);
 			}
 			}
 		} else
 		} else
-			throw "TODO";
+			throw "TODO "+arg1;
 		untyped {
 		untyped {
 			arr.subarray = _subarray;
 			arr.subarray = _subarray;
 			arr.set = _set;
 			arr.set = _set;