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

Unified Diff: src/v8natives.js

Issue 201114: Implemented Object.keys. (Closed)
Patch Set: try-again Created 11 years, 3 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/runtime.cc ('k') | test/mjsunit/testcfg.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8natives.js
diff --git a/src/v8natives.js b/src/v8natives.js
index be92347768a71867c546785641dff8b6718ceb60..b63ce5f1082519d0543dd276f301631e74e25af7 100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -276,6 +276,13 @@ function ObjectLookupSetter(name) {
}
+function ObjectKeys(obj) {
+ if (!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj))
+ throw MakeTypeError('object_keys_non_object', [obj]);
+ return %LocalKeys(obj);
+}
+
+
%SetCode($Object, function(x) {
if (%_IsConstructCall()) {
if (x == null) return this;
@@ -304,6 +311,9 @@ function SetupObject() {
"__defineSetter__", ObjectDefineSetter,
"__lookupSetter__", ObjectLookupSetter
));
+ InstallFunctions($Object, DONT_ENUM, $Array(
+ "keys", ObjectKeys
+ ));
}
SetupObject();
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/testcfg.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698