Closed
Bug 505587
Opened 15 years ago
Closed 15 years ago
Implement ES5 Object.getOwnPropertyDescriptor
Categories
(Core :: JavaScript Engine, enhancement)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
People
(Reporter: Waldo, Assigned: Waldo)
References
Details
(Keywords: dev-doc-complete, Whiteboard: fixed-in-tracemonkey)
Attachments
(2 files)
(deleted),
patch
|
mrbkap
:
review+
|
Details | Diff | Splinter Review |
(deleted),
patch
|
Details | Diff | Splinter Review |
Needed for verifying correctness of Object.defineProperty...
Assignee | ||
Comment 1•15 years ago
|
||
Still needs tests, will start formally writing them shortly...
Attachment #397398 -
Flags: review?(mrbkap)
Assignee | ||
Comment 2•15 years ago
|
||
I also ran the patch against the ES5 tests at <http://es5conform.codeplex.com/>, and things seem to work perfectly fine.
This is currently limited to what's exposed by ES5 itself; bug 430133 and Object.defineProperty will allow access to the real corner cases that can't be examined in the current specified APIs.
Comment 3•15 years ago
|
||
Comment on attachment 397398 [details] [diff] [review]
Patch
>+static JSBool
>+obj_getOwnPropertyDescriptor(JSContext *cx, uintN argc, jsval *vp)
>+{
>+ if (argc == 0 || JSVAL_IS_PRIMITIVE(vp[2])) {
>+ JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
>+ JSMSG_NOT_NONNULL_OBJECT,
>+ js_getter_str);
>+ return JS_FALSE;
>+ }
>+ JSObject *obj = JSVAL_TO_OBJECT(vp[2]);
Nit: blank line after the }.
>+ JSScopeProperty *sprop = reinterpret_cast<JSScopeProperty *>(prop);
>+ if (!desc->defineProperty(cx, ATOM_TO_JSID(atomState.getAtom),
>+ ((attrs & JSPROP_GETTER) && OBJ_IS_NATIVE(obj))
>+ ? js_CastAsObjectJSVal(sprop->getter)
>+ : JSVAL_VOID,
>+ JS_PropertyStub, JS_PropertyStub,
>+ JSPROP_ENUMERATE, NULL) ||
>+ !desc->defineProperty(cx, ATOM_TO_JSID(atomState.setAtom),
>+ ((attrs & JSPROP_SETTER) && OBJ_IS_NATIVE(obj))
>+ ? js_CastAsObjectJSVal(sprop->setter)
>+ : JSVAL_VOID,
>+ JS_PropertyStub, JS_PropertyStub,
>+ JSPROP_ENUMERATE, NULL)) {
I'd prefer to move the OBJ_IS_NATIVE checks (and the cast to JSScopeProperty) into a common place.
Attachment #397398 -
Flags: review?(mrbkap) → review+
Assignee | ||
Comment 4•15 years ago
|
||
http://hg.mozilla.org/tracemonkey/rev/b7ee9263cf96
with the requested changes, also with the attached tests in the new ecma_5/Object/ directory.
Whiteboard: fixed-in-tracemonkey
Comment 5•15 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 6•15 years ago
|
||
http://hg.mozilla.org/tracemonkey/rev/87fcc6cb16af to update tests to use reportCompare once
Assignee | ||
Comment 7•15 years ago
|
||
I wrote up a little bit of documentation, but it needs to be made more visible than simply exposing it deep within the JS reference:
https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object/getOwnPropertyDescriptor
Keywords: dev-doc-needed
Updated•14 years ago
|
Keywords: dev-doc-needed → dev-doc-complete
You need to log in
before you can comment on or make changes to this bug.
Description
•