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

Unified Diff: src/js/array.js

Issue 2670833008: Expose more %ArrayPrototype% functions to the public API. (Closed)
Patch Set: Rebased patch Created 3 years, 10 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 | « src/contexts.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/array.js
diff --git a/src/js/array.js b/src/js/array.js
index 80051d5f8e69608e498e84c252f93400e76f4793..2cb2eda9552584a77f02f3f80ce128a4377d78c7 100644
--- a/src/js/array.js
+++ b/src/js/array.js
@@ -1527,7 +1527,14 @@ function getFunction(name, jsBuiltin, len) {
return f;
};
-var ArrayValues = getFunction("values", null, 0);
+// Array prototype functions that return iterators. They are exposed to the
+// public API via Template::SetIntrinsicDataProperty().
+var IteratorFunctions = {
+ "entries": getFunction("entries", null, 0),
+ "forEach": getFunction("forEach", ArrayForEach, 1),
+ "keys": getFunction("keys", null, 0),
+ "values": getFunction("values", null, 0)
+}
// Set up non-enumerable functions of the Array.prototype object and
// set their names.
@@ -1546,7 +1553,6 @@ utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
"splice", getFunction("splice", ArraySplice, 2),
"sort", getFunction("sort", ArraySort),
"filter", getFunction("filter", ArrayFilter, 1),
- "forEach", getFunction("forEach", ArrayForEach, 1),
"some", getFunction("some", ArraySome, 1),
"every", getFunction("every", ArrayEvery, 1),
"map", getFunction("map", ArrayMap, 1),
@@ -1559,14 +1565,18 @@ utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
"findIndex", getFunction("findIndex", ArrayFindIndex, 1),
"fill", getFunction("fill", ArrayFill, 1),
"includes", getFunction("includes", null, 1),
- "keys", getFunction("keys", null, 0),
- "entries", getFunction("entries", null, 0),
- iteratorSymbol, ArrayValues
+ "entries", IteratorFunctions.entries,
+ "forEach", IteratorFunctions.forEach,
+ "keys", IteratorFunctions.keys,
+ iteratorSymbol, IteratorFunctions.values
]);
utils.ForEachFunction = GlobalArray.prototype.forEach;
-%FunctionSetName(ArrayValues, "values");
+%FunctionSetName(IteratorFunctions.entries, "entries");
+%FunctionSetName(IteratorFunctions.forEach, "forEach");
+%FunctionSetName(IteratorFunctions.keys, "keys");
+%FunctionSetName(IteratorFunctions.values, "values");
%FinishArrayPrototypeSetup(GlobalArray.prototype);
@@ -1609,7 +1619,7 @@ utils.Export(function(to) {
to.ArrayJoin = ArrayJoin;
to.ArrayPush = ArrayPush;
to.ArrayToString = ArrayToString;
- to.ArrayValues = ArrayValues;
+ to.ArrayValues = IteratorFunctions.values,
to.InnerArrayEvery = InnerArrayEvery;
to.InnerArrayFill = InnerArrayFill;
to.InnerArrayFilter = InnerArrayFilter;
@@ -1627,13 +1637,16 @@ utils.Export(function(to) {
});
%InstallToContext([
+ "array_entries_iterator", IteratorFunctions.entries,
+ "array_for_each_iterator", IteratorFunctions.forEach,
+ "array_keys_iterator", IteratorFunctions.keys,
"array_pop", ArrayPop,
"array_push", ArrayPush,
"array_shift", ArrayShift,
"array_splice", ArraySplice,
"array_slice", ArraySlice,
"array_unshift", ArrayUnshift,
- "array_values_iterator", ArrayValues,
+ "array_values_iterator", IteratorFunctions.values,
]);
});
« no previous file with comments | « src/contexts.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698