Last Comment Bug 757699 - Simplify the code returning uint32_t to JS via IDL any in the WebGLContext a bit
: Simplify the code returning uint32_t to JS via IDL any in the WebGLContext a bit
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: Canvas: WebGL (show other bugs)
: unspecified
: x86 Mac OS X
: -- normal (vote)
: mozilla15
Assigned To: Boris Zbarsky [:bz] (still a bit busy)
:
: Milan Sreckovic [:milan]
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-05-22 19:36 PDT by Boris Zbarsky [:bz] (still a bit busy)
Modified: 2012-05-24 10:46 PDT (History)
1 user (show)
bzbarsky: in‑testsuite-
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Use JS::NumberValue, not JS::DoubleValue, for returning uint32_t values to JS. (8.38 KB, patch)
2012-05-22 19:41 PDT, Boris Zbarsky [:bz] (still a bit busy)
jacob.benoit.1: review+
Details | Diff | Splinter Review

Description Boris Zbarsky [:bz] (still a bit busy) 2012-05-22 19:36:48 PDT
I'd missed that JS::NumberValue has a uint32_t overload that will automagically do the right thing in terms of picking double vs int.  We should use it here.
Comment 1 Boris Zbarsky [:bz] (still a bit busy) 2012-05-22 19:41:43 PDT
Created attachment 626294 [details] [diff] [review]
Use JS::NumberValue, not JS::DoubleValue, for returning uint32_t values to JS.
Comment 2 Benoit Jacob [:bjacob] (mostly away) 2012-05-22 19:54:07 PDT
Comment on attachment 626294 [details] [diff] [review]
Use JS::NumberValue, not JS::DoubleValue, for returning uint32_t values to JS.

Review of attachment 626294 [details] [diff] [review]:
-----------------------------------------------------------------

Isn't it unfortunate that you have to cast to uint32_t before passing to JS::NumberValue?

If the type of the argument really matters, I would templatize JS::NumberValue in the type of its argument, so that JS::NumberValue(x) would find its type by template-argument-deduction and could then automatically do the right thing.
Comment 3 Boris Zbarsky [:bz] (still a bit busy) 2012-05-22 20:08:27 PDT
JS::NumberValue is overloaded for various integer types.  For the ones that fit in a JS int, it just uses an int value; for uint32_t it has to decide whether to do an int value or a double value.

I'm not sure how using a template instead of just function overloads would help here...  And in particular, the desired behavior for passing in a uint32_t and an int32_t is different.
Comment 4 Boris Zbarsky [:bz] (still a bit busy) 2012-05-23 09:46:41 PDT
https://hg.mozilla.org/integration/mozilla-inbound/rev/a4240610972e
Comment 5 Ed Morley [:emorley] 2012-05-24 10:46:36 PDT
https://hg.mozilla.org/mozilla-central/rev/a4240610972e

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