Closed
Bug 506721
Opened 15 years ago
Closed 15 years ago
Convert JSVAL_TO_INT and INT_TO_JSVAL to functions
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: bzbarsky, Assigned: jorendorff)
References
Details
(Whiteboard: fixed-in-tracemonkey)
Attachments
(1 file)
(deleted),
patch
|
Waldo
:
review+
|
Details | Diff | Splinter Review |
We can't do it right now because we have static asserts that use them. But waldo says "C++0x constexpr might be able to save the day here, possibly"
Assignee | ||
Comment 1•15 years ago
|
||
Assignee: general → jorendorff
Attachment #393400 -
Flags: review?(jwalden+bmo)
Updated•15 years ago
|
Attachment #393400 -
Flags: review?(jwalden+bmo) → review+
Comment 2•15 years ago
|
||
Comment on attachment 393400 [details] [diff] [review]
v1
Better than nothing, I'm just worried we'll break JSAPI users doing this. I guess it's easy to fix, and they can not upgrade if necessary, but still...
Assignee | ||
Comment 3•15 years ago
|
||
http://hg.mozilla.org/tracemonkey/rev/d6f79987bf06
Cc-ing Brendan because of the concerns raised in comment 2. But we have already turned several other macros into functions. Type safety is worth the breakage.
Within SM we broke one thing, and it turned out to be a completely bogus call to INT_TO_JSVAL. See bug 509301.
Assignee | ||
Updated•15 years ago
|
Whiteboard: fixed-in-tracemonkey
Comment 4•15 years ago
|
||
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Comment 5•15 years ago
|
||
That broke me, big-time, in multiple places.
I use JSVAL_ZERO as the case label in switch statemnts. I can change those to stacked if..else blocks, I suppose. So I can live with that.
The REAL big breaker is that I have enums of jsvals, e.g.
typedef enum { jsve_uchar = INT_TO_JSVAL(inte_uchar}, ... } gffi_jsv_e;
I use this pattern in several places, where I need to expose constants to JavaScript and then act on which constant is chosen from C.
Often, the value of the constant isn't even relevant except as a conditional, so I never even wind up converting from jsval-space back into int-space; I can just use the jsvals directly.
Is there a way to fix the API to keep code like mine running, without losing the type safety benefit?
Comment 6•15 years ago
|
||
Recap of IRC conversation with jorendorff:
- INT_TO_JSVAL_CONSTEXPR() exists now and can take the place of old INT_TO_JSVAL() calls where macro is absolutely required
- JSVAL_ZERO and JSVAL_ONE should be changed to use INT_TO_JSVAL_CONSTEXPR() at some point, so that JSAPI users can use them in switch cases
You need to log in
before you can comment on or make changes to this bug.
Description
•