Index: src/harmony-typedarray.js |
diff --git a/src/harmony-typedarray.js b/src/harmony-typedarray.js |
index 3c4c4a40fedd69f97bc46813fd624edcf3f93f7b..3b7484a0b805a19b90749220e4ec9f1f85f54511 100644 |
--- a/src/harmony-typedarray.js |
+++ b/src/harmony-typedarray.js |
@@ -100,9 +100,31 @@ function TypedArrayOf() { |
return array; |
} |
+function ConstructTypedArray(constructor, array) { |
+ // TODO(dehrenberg): This is an approximation of the spec, which requires |
arv (Not doing code reviews)
2015/05/15 00:20:22
I thought you wanted littledan?
dehrenberg
2015/05/15 23:39:14
Done.
|
+ // that only real TypedArray classes should be accepted (22.2.2.1.1) |
+ if (!IS_SPEC_OBJECT(constructor) || constructor.prototype === undefined || |
arv (Not doing code reviews)
2015/05/15 00:20:22
Use IS_UNDEFINED since undefined can be redefined.
dehrenberg
2015/05/15 23:39:14
Done.
|
+ !%HasOwnProperty(constructor.prototype, "BYTES_PER_ELEMENT")) |
arv (Not doing code reviews)
2015/05/15 00:20:22
Use {}
dehrenberg
2015/05/15 23:39:14
Done.
|
+ throw MakeTypeError(kNotTypedArray); |
+ |
+ // TODO(dehrenberg): The spec requires that, rather than directly calling |
+ // the constructor, a TypedArray is created with the proper proto and |
+ // underlying size and element size, and elements are put in one by one. |
+ // By contrast, this would allow subclasses to make a radically different |
+ // constructor with different semantics. |
+ return new constructor(array); |
+} |
+ |
+function TypedArrayFrom(source, mapfn, thisArg) { |
+ var array = $arrayFrom.call(global.Array, source, mapfn, thisArg); |
arv (Not doing code reviews)
2015/05/15 00:20:22
Use %_CallFunction since Function.prototype.call c
arv (Not doing code reviews)
2015/05/15 00:20:22
Is global.Array correct here? Shouldn't Uint8Array
arv (Not doing code reviews)
2015/05/15 00:20:22
Please add
var GlobalArray = global.Array;
to t
dehrenberg
2015/05/15 23:39:14
Done.
dehrenberg
2015/05/15 23:39:14
Done.
dehrenberg
2015/05/15 23:39:14
I'm first making an array with the contents and th
|
+ return ConstructTypedArray(this, array); |
+} |
+%FunctionSetLength(TypedArrayFrom, 1); |
+ |
macro EXTEND_TYPED_ARRAY(NAME) |
// Set up non-enumerable functions on the object. |
$installFunctions(GlobalNAME, DONT_ENUM | DONT_DELETE | READ_ONLY, [ |
+ "from", TypedArrayFrom, |
arv (Not doing code reviews)
2015/05/15 00:20:22
This needs one more object in the [[Prototype]] ch
dehrenberg
2015/05/15 23:39:14
I have a bug open for this https://code.google.com
|
"of", TypedArrayOf |
]); |