Closed Bug 757699 Opened 12 years ago Closed 12 years ago

Simplify the code returning uint32_t to JS via IDL any in the WebGLContext a bit

Categories

(Core :: Graphics: CanvasWebGL, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla15

People

(Reporter: bzbarsky, Assigned: bzbarsky)

Details

Attachments

(1 file)

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.
Whiteboard: [need review]
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.
Attachment #626294 - Flags: review?(bjacob) → review+
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.
https://hg.mozilla.org/integration/mozilla-inbound/rev/a4240610972e
Flags: in-testsuite-
Whiteboard: [need review]
Target Milestone: --- → mozilla15
https://hg.mozilla.org/mozilla-central/rev/a4240610972e
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: