Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(682)

Unified Diff: src/js/array-iterator.js

Issue 1780113002: Minor library function fixes for TypedArray spec compliance (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Improve comment Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/js/typedarray.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/array-iterator.js
diff --git a/src/js/array-iterator.js b/src/js/array-iterator.js
index 2ab6c8c1cb0b58a49e78857759b1409d2033a8c8..b3e25e9adbe77b5d350921aadfe26572ed09e0a1 100644
--- a/src/js/array-iterator.js
+++ b/src/js/array-iterator.js
@@ -109,6 +109,24 @@ function ArrayKeys() {
return CreateArrayIterator(this, ITERATOR_KIND_KEYS);
}
+// TODO(littledan): Check for detached TypedArray in these three methods
+function TypedArrayEntries() {
+ if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
+ return %_Call(ArrayEntries, this);
+}
+
+
+function TypedArrayValues() {
+ if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
+ return %_Call(ArrayValues, this);
+}
+
+
+function TypedArrayKeys() {
+ if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
+ return %_Call(ArrayKeys, this);
+}
+
%FunctionSetPrototype(ArrayIterator, {__proto__: IteratorPrototype});
%FunctionSetInstanceClassName(ArrayIterator, 'Array Iterator');
@@ -133,12 +151,13 @@ utils.SetFunctionName(ArrayValues, 'values');
%AddNamedProperty(GlobalArray.prototype, iteratorSymbol, ArrayValues,
DONT_ENUM);
+utils.InstallFunctions(GlobalTypedArray.prototype, DONT_ENUM, [
+ 'entries', TypedArrayEntries,
+ 'keys', TypedArrayKeys,
+ 'values', TypedArrayValues
+]);
%AddNamedProperty(GlobalTypedArray.prototype,
- 'entries', ArrayEntries, DONT_ENUM);
-%AddNamedProperty(GlobalTypedArray.prototype, 'values', ArrayValues, DONT_ENUM);
-%AddNamedProperty(GlobalTypedArray.prototype, 'keys', ArrayKeys, DONT_ENUM);
-%AddNamedProperty(GlobalTypedArray.prototype,
- iteratorSymbol, ArrayValues, DONT_ENUM);
+ iteratorSymbol, TypedArrayValues, DONT_ENUM);
// -------------------------------------------------------------------
// Exports
« no previous file with comments | « no previous file | src/js/typedarray.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698