[Webkit-unassigned] [Bug 77317] JSC::JSValue doesn't support UInt32 properly.

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Jan 31 00:20:52 PST 2012


https://bugs.webkit.org/show_bug.cgi?id=77317





--- Comment #3 from Gavin Barraclough <barraclough at apple.com>  2012-01-31 00:20:53 PST ---
(In reply to comment #2)
> When I input greater than equal 2^31(like 4294967295) to an argument, isUInt32() returns false. I think it have to return true. Am I wrong?

Ah, fair point, the isUint32() and asUint32() methods are currently rather poorly named – the names got shortened a while back for brevity, but they should probably be clearer.  These used to be called isFastUInt32() and asFastUInt32(), which was a little better.  The intention of these methods is not to definitively state whether the value is a number in the UInt32 range, rather, whether the value is in the UInt32 range and also is currently being represented as an integer (for example, the value 1 may be represented as the integer 1, or the double 1.0 – by design this method will return false if the value is stored at 1.0).  These methods exist only to implement optimized code paths – they may produce false negative results (the intention being that this would just result in slower handling).

We certainly could provide a method that would definitively return true for all integers in the range 0..0xFFFFFFFF regardless of whether they are current represented as an integer or double – but if we did, how would you use it? – Web IDL requires a ToNumber conversion to be performed, so a UInt32 result may be produced from a value that is non-numeric.  Is there a use for a more expensive, accurate isUInt32 here?

JSValue provides the ToNumber method required by step 1 of the Web IDL conversion to unsigned long:
    double toNumber(ExecState*) const;
And provides the ECMA-262 ToUInt32 conversion required by step 4, both as a method and as a convenient fee function:
    inline uint32_t toUInt32(double number)

This should be all you need to implement the Web IDL specified conversion, but you may also wish to use isUInt32/asUInt32 to provide a fast path.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list