Last Comment Bug 674775 - Implement js::IndexToString(cx, uint32_t)
: Implement js::IndexToString(cx, uint32_t)
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: unspecified
: All All
-- normal (vote)
: mozilla8
Assigned To: Jeff Walden [:Waldo] (remove +bmo to email)
: Jason Orendorff [:jorendorff]
Depends on:
Blocks: 586842
  Show dependency treegraph
Reported: 2011-07-27 17:03 PDT by Jeff Walden [:Waldo] (remove +bmo to email)
Modified: 2011-08-01 07:58 PDT (History)
3 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

Patch (3.50 KB, patch)
2011-07-27 17:03 PDT, Jeff Walden [:Waldo] (remove +bmo to email)
no flags Details | Diff | Splinter Review
h8 hg (5.07 KB, patch)
2011-07-27 17:10 PDT, Jeff Walden [:Waldo] (remove +bmo to email)
luke: review+
Details | Diff | Splinter Review

Description User image Jeff Walden [:Waldo] (remove +bmo to email) 2011-07-27 17:03:26 PDT
Created attachment 548976 [details] [diff] [review]

Upcoming work on using separate storage for element properties (property names which are the string versions of unsigned 32-bit integers) will need to be able to get a string for a given uint32_t, at least as long as jsid can't hold a full 32-bit-integer range of values.  Implement js::IndexToString to support this, and in the absence of users exactly right now, add a JSAPI test that uses private headers to test it.
Comment 1 User image Jeff Walden [:Waldo] (remove +bmo to email) 2011-07-27 17:10:18 PDT
Created attachment 548980 [details] [diff] [review]
h8 hg
Comment 2 User image Luke Wagner [:luke] 2011-07-28 13:26:56 PDT
Comment on attachment 548980 [details] [diff] [review]
h8 hg

Review of attachment 548980 [details] [diff] [review]:

::: js/src/vm/String-inl.h
@@ +206,5 @@
> +inline JSStaticAtom &
> +JSAtom::uintStatic(uint32 u)
> +{
> +    JS_ASSERT(hasUintStatic(u));
> +    return *reinterpret_cast<JSStaticAtom *>(const_cast<JSString::Data *>(intStaticTable[u]));

This casting shold match the casting in JSAtom::intStatic.  Personally, I find this a bit verbose and not terribly informative, but you pick.  I guess you already did :)
Comment 3 User image Jeff Walden [:Waldo] (remove +bmo to email) 2011-07-29 16:35:22 PDT
...or even better: just make the int32 version call the uint32 version.  (With some pre-validity-checking assertions still, of course.)  :-)

Landing shortly...
Comment 4 User image Jeff Walden [:Waldo] (remove +bmo to email) 2011-07-29 17:31:36 PDT
Comment 5 User image Marco Bonardo [::mak] 2011-08-01 07:58:58 PDT

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