Last Comment Bug 643368 - Need JSAPI to enumerate non-enumerable properties
: Need JSAPI to enumerate non-enumerable properties
Status: NEW
:
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: Trunk
: All All
: -- normal with 2 votes (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
: Jason Orendorff [:jorendorff]
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-03-20 23:20 PDT by Rob Arnold [:robarnold]
Modified: 2014-07-24 11:07 PDT (History)
6 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments

Description Rob Arnold [:robarnold] 2011-03-20 23:20:53 PDT
To implement v8::Object::Clone, I think we need to include the non-enumerable properties of an object. Currently there is no API to get us these. JS_NewPropertyIterator and JS_Enumerate claim to only show properties with the JSPROP_ENUMERATE bit.
Comment 1 Andreas Gal :gal 2011-03-20 23:22:05 PDT
I have a patch for that. Search for JS_Enumerate2 in the title.
Comment 2 Jeff Walden [:Waldo] (remove +bmo to email) 2011-03-21 01:36:49 PDT
(In reply to comment #0)
> Currently there is no API to get us these. JS_NewPropertyIterator and
> JS_Enumerate claim to only show properties with the JSPROP_ENUMERATE bit.

Lies!  Call JS_Enumerate with JSENUMERATE_INIT_ALL.

One caveat: enumeration hooks don't uniformly implement all the correct stuff for this to work fully.  Global objects in the browser are one case where things fall apart.  There might be others, but that's the biggest instance I'm aware of.

(...and not to say I'm opposed to JS_Enumerate2 or anything, just to say that it's not needed to serve the particular use case in this bug.)
Comment 3 Shawn Wilsher :sdwilsh 2011-03-21 08:57:15 PDT
(In reply to comment #2)
> Lies!  Call JS_Enumerate with JSENUMERATE_INIT_ALL.
Could someone possibly add some docs for that then, by chance?
Comment 4 Rob Arnold [:robarnold] 2011-03-21 10:16:52 PDT
(In reply to comment #2)
> (In reply to comment #0)
> > Currently there is no API to get us these. JS_NewPropertyIterator and
> > JS_Enumerate claim to only show properties with the JSPROP_ENUMERATE bit.
> 
> Lies!  Call JS_Enumerate with JSENUMERATE_INIT_ALL.

I still do not see how this is exposed via the API. JS_Enumerate takes a JSContext* and a JSObject* but not a JSIterateOp.
Comment 5 Brendan Eich [:brendan] 2011-03-21 10:31:14 PDT
Andreas is referring to bug 638347 in encouraging you to search for JS_Enumerate2.

/be
Comment 6 Jeff Walden [:Waldo] (remove +bmo to email) 2011-03-21 12:41:16 PDT
(In reply to comment #4)
> I still do not see how this is exposed via the API.

Hum, you're right.  Yes, we should fix that.  (And are, it seems.)

And what's this yolky-colored stuff on my face right now?
Comment 7 Andreas Gal :gal 2011-03-21 12:49:53 PDT
Waldo, feel free to steal 638347, in particular if you have a better idea for naming then JS_Enumerate2.

Note You need to log in before you can comment on or make changes to this bug.