Closed
Bug 393306
Opened 17 years ago
Closed 17 years ago
add JSClass hook for iteration
Categories
(Core :: JavaScript Engine, enhancement)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
People
(Reporter: jorendorff, Assigned: mrbkap)
References
Details
Attachments
(3 files)
5.64 KB,
patch
|
brendan
:
review+
brendan
:
approval1.9+
|
Details | Diff | Splinter Review |
3.45 KB,
patch
|
Details | Diff | Splinter Review | |
5.66 KB,
patch
|
Details | Diff | Splinter Review |
Implementing iteration in C is awkward. One way is to resolve the "__iterator__" property in NewResolve. See bug 390947, attachment 275918 [details] [diff] [review] for an example of code that tries to do this. A JSClass hook for iteration would make things more straightforward for the embedder (and in this case, the embedder is Mozilla).
Assignee | ||
Comment 1•17 years ago
|
||
I'm holding off on asking for review until I can test this (and convince hg to generate a diff -w).
Assignee: general → mrbkap
Status: NEW → ASSIGNED
Assignee | ||
Comment 2•17 years ago
|
||
These are the jsiter.c changes. I changed the indentation in one place, otherwise this is functionally equivalent.
Assignee | ||
Updated•17 years ago
|
Attachment #278227 -
Flags: review?(brendan)
Comment 3•17 years ago
|
||
Comment on attachment 278227 [details] [diff] [review] WIP >+ xclasp->iteratorObject(cx, obj, (flags & JSITER_FOREACH) == 0); . . . >+(* JS_DLL_CALLBACK JSIteratorOp)(JSContext *cx, JSObject *obj, JSBool foreach); So either the arg is notforeach, or you want != 0 in the call's third arg. /be
Assignee | ||
Comment 4•17 years ago
|
||
Oops, yeah.
Assignee | ||
Comment 5•17 years ago
|
||
Actually, I've done this instead: -(* JS_DLL_CALLBACK JSIteratorOp)(JSContext *cx, JSObject *obj, JSBool foreach); +(* JS_DLL_CALLBACK JSIteratorOp)(JSContext *cx, JSObject *obj, + JSBool keysonly); since it matches __iterator__'s sense.
Comment 6•17 years ago
|
||
Comment on attachment 278227 [details] [diff] [review] WIP Ok, with that keysonly, r+a=me. Still going to regret this when JS2 iterator support goes in and removes keysonly, but compatibility rules for now. /be
Attachment #278227 -
Flags: review?(brendan)
Attachment #278227 -
Flags: review+
Attachment #278227 -
Flags: approval1.9+
Assignee | ||
Comment 7•17 years ago
|
||
Assignee | ||
Comment 8•17 years ago
|
||
Fix checked into trunk.
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Updated•17 years ago
|
Flags: in-testsuite-
You need to log in
before you can comment on or make changes to this bug.
Description
•