ソースを参照

final fixes for IE8/9

Nicolas Cannasse 10 年 前
コミット
0c76e7961c

+ 4 - 2
std/js/html/compat/Float32Array.hx

@@ -26,7 +26,7 @@ class Float32Array {
 
 	static var BYTES_PER_ELEMENT = 4;
 
-	static function _new( ?arg1 : Dynamic, ?offset : Int, ?length : Int ) {
+	static function _new( ?arg1 : Dynamic, ?offset : Int, ?length : Int ) : Dynamic {
 		var arr : Array<Float>;
 		if( untyped __typeof__(arg1) == 'number' ) {
 			arr = new Array();
@@ -97,7 +97,9 @@ class Float32Array {
 
 	static function _subarray( start : Int, ?end : Int ) {
 		var t : Dynamic = untyped __js__("this");
-		return _new(t.slice(start,end));
+		var a = _new(t.slice(start,end));
+		a.byteOffset = start * 4;
+		return a;
 	}
 
 	static function __init__() untyped {

+ 4 - 2
std/js/html/compat/Uint8Array.hx

@@ -26,7 +26,7 @@ class Uint8Array {
 
 	static var BYTES_PER_ELEMENT = 1;
 
-	static function _new( ?arg1 : Dynamic, ?offset : Int, ?length : Int ) {
+	static function _new( ?arg1 : Dynamic, ?offset : Int, ?length : Int ) : Dynamic {
 		var arr;
 		if( untyped __typeof__(arg1) == 'number' ) {
 			arr = new Array();
@@ -88,7 +88,9 @@ class Uint8Array {
 
 	static function _subarray( start : Int, ?end : Int ) {
 		var t : Dynamic = untyped __js__("this");
-		return _new(t.slice(start,end));
+		var a = _new(t.slice(start,end));
+		a.byteOffset = start;
+		return a;
 	}
 
 	static function __init__() untyped {

+ 1 - 1
tests/unit/src/unitstd/haxe/io/Float32Array.unit.hx

@@ -52,7 +52,7 @@ b[4] == 5;
 
 b.view == b.view; // no alloc
 
-b.view.buffer == b2.view.buffer;
+if( !emulated ) b.view.buffer == b2.view.buffer;
 b.view.byteLength == 20;
 b.view.byteOffset == 0;
 b2.view.byteLength == 12;

+ 1 - 1
tests/unit/src/unitstd/haxe/io/Uint8Array.unit.hx

@@ -51,7 +51,7 @@ b[4] == 5;
 
 b.view == b.view; // no alloc
 
-b.view.buffer == b2.view.buffer;
+if( !emulated ) b.view.buffer == b2.view.buffer;
 b.view.byteLength == 5;
 b.view.byteOffset == 0;
 b2.view.byteLength == 3;