Closed
Bug 1112774
Opened 10 years ago
Closed 10 years ago
Move a bunch of conversion methods over into js/public/Conversions.h
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla38
People
(Reporter: Waldo, Assigned: Waldo)
References
Details
(Keywords: dev-doc-complete)
Attachments
(2 files, 1 obsolete file)
14.33 KB,
patch
|
jorendorff
:
review+
|
Details | Diff | Splinter Review |
3.62 KB,
patch
|
jorendorff
:
review+
|
Details | Diff | Splinter Review |
The non-exposure of the ES5 ToObject algorithm is a criminal lapse in the JSAPI. Rectify this with a new js/Conversions.h header that also includes js/NumericConversions.h (but leaves that separate so that including it can be a lighter-weight thing).
I expect we'll add other conversion operations (JS::ToString, for example) to Conversions.h over time. But this is all I need right now, so I'm stopping here.
Assignee | ||
Comment 1•10 years ago
|
||
Attachment #8538082 -
Flags: review?(jorendorff)
Updated•10 years ago
|
Attachment #8538082 -
Flags: review?(jorendorff) → review+
Comment 2•10 years ago
|
||
Note that the review in bug 1112769 comment 2 requires either renaming the existing header to Conversions.h or renaming the functions --- here it looks like you chose to rename the functions, which is a bit of a surprise given our conversation yesterday.
Assignee | ||
Comment 3•10 years ago
|
||
I went back and moved a whole bunch more methods into Conversions.h to make things consistent. No renames of anything, just API moves.
I'm not sure how you read the prior patch here to rename any functions -- this was pure moving as far as I can tell.
Attachment #8544887 -
Flags: review?(jorendorff)
Assignee | ||
Updated•10 years ago
|
Attachment #8538082 -
Attachment is obsolete: true
Assignee | ||
Comment 4•10 years ago
|
||
More small consolidation. I see no reason to have these given the other methods exist now, with the names from the ES6 standard that people would expect.
Attachment #8545273 -
Flags: review?(jorendorff)
Updated•10 years ago
|
Keywords: dev-doc-needed
Comment 5•10 years ago
|
||
(In reply to Jeff Walden [:Waldo] (remove +bmo to email) from comment #3)
> I'm not sure how you read the prior patch here to rename any functions --
> this was pure moving as far as I can tell.
What I meant is, you did not choose to renaming the existing header to Conversions.h. Therefore I guess you chose renaming the functions? I don't know, Waldo, you tell me. What's going on here?
Assignee | ||
Comment 6•10 years ago
|
||
Oh, you mean having *both* NumericConversions.h and Conversions.h, I guess. The idea was that narrower uses that didn't need the full contents of the header, could be a little simpler by referring only to the finer-grained header. Perhaps this was *too* fine a splitting.
Assignee | ||
Updated•10 years ago
|
Summary: Add js/public/Conversions.h, including NumericConversions.h and adding JS::ToObject as well → Move a bunch of conversion methods over into js/public/Conversions.h
Comment 7•10 years ago
|
||
(In reply to Jeff Walden [:Waldo] (remove +bmo to email) from comment #6)
> Oh, you mean having *both* NumericConversions.h and Conversions.h, I guess.
> The idea was that narrower uses that didn't need the full contents of the
> header, could be a little simpler by referring only to the finer-grained
> header. Perhaps this was *too* fine a splitting.
Oh --- to clarify, the reason I asked for both signatures to be declared in the same header was so that it would be impossible to include one signature without the other.
Otherwise, it's possible for a cast (or call to a function template) that works in a non-unified build, because only one signature is visible, to break in a unified build, where all signatures have been magically included.
Assignee | ||
Comment 8•10 years ago
|
||
Yeah, it made sense once you pointed it out. And we continue to wish for some sort of encapsulating module system for C++...
Comment 9•10 years ago
|
||
Comment on attachment 8544887 [details] [diff] [review]
Add a raft of other conversion methods to js/public/Conversions.h past just JS::ToObject
Review of attachment 8544887 [details] [diff] [review]:
-----------------------------------------------------------------
Thanks.
::: js/public/Conversions.h
@@ +23,5 @@
> +struct JSContext;
> +
> +namespace js {
> +
> +/* DO NOT CALL THIS. Use JS::ToBoolean. */
It'd be nice to move this stuff into JS::detail instead of using comments, someday.
::: js/src/jsobj.cpp
@@ +3625,4 @@
> * Callers must handle the already-object case.
> */
> JSObject *
> +js::ToObjectSlow(JSContext *cx, JS::HandleValue val, bool reportScanStack)
Huh. Why was this necessary? Seems like HandleValue is used unqualified all over in jsobj.cpp.
Attachment #8544887 -
Flags: review?(jorendorff) → review+
Updated•10 years ago
|
Attachment #8545273 -
Flags: review?(jorendorff) → review+
Assignee | ||
Comment 10•10 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/9df7385ff114
https://hg.mozilla.org/mozilla-central/rev/e87f763fc29a
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
Comment 12•10 years ago
|
||
:Waldo, the following docs got updated to say that JS::To{Ui,I}nt32 are obsolete starting with SpiderMonkey 38. Can you review, and mark this as dev-doc-complete if that is all we need docs-wise here? Thanks!
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_DoubleToInt32
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference#Numbers
Flags: needinfo?(jwalden+bmo)
Comment 13•9 years ago
|
||
No answer -> dev-doc-complete.
Flags: needinfo?(jwalden+bmo)
Keywords: dev-doc-needed → dev-doc-complete
You need to log in
before you can comment on or make changes to this bug.
Description
•