Last Comment Bug 656810 - Implement js::NumberObject
: Implement js::NumberObject
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: unspecified
: All All
: -- minor (vote)
: mozilla9
Assigned To: Jeff Walden [:Waldo] (remove +bmo to email)
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-05-12 16:58 PDT by Jeff Walden [:Waldo] (remove +bmo to email)
Modified: 2011-09-27 03:51 PDT (History)
2 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Patch (8.50 KB, patch)
2011-05-12 16:58 PDT, Jeff Walden [:Waldo] (remove +bmo to email)
n.nethercote: review+
Details | Diff | Review

Description Jeff Walden [:Waldo] (remove +bmo to email) 2011-05-12 16:58:48 PDT
Created attachment 532079 [details] [diff] [review]
Patch

As object subclasses go it's on the low end of the importance scale, but we should have it to get away from the getPrimitiveThis/setPrimitiveThis punning.
Comment 1 Nicholas Nethercote [:njn] 2011-05-12 17:14:55 PDT
Comment on attachment 532079 [details] [diff] [review]
Patch

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

r=me

::: js/src/vm/NumberObject.h
@@ +69,5 @@
> +    }
> +
> +  private:
> +    inline void init(jsdouble d) {
> +        setSlot(PRIMITIVE_THIS_SLOT, NumberValue(d));

Is PRIMITIVE_THIS_SLOT the best name now?  Would something simpler like VALUE_SLOT be better?  And if you make that change, would setValue() be a better name than init()?

@@ +78,5 @@
> +    ::js_InitNumberClass(JSContext *cx, JSObject *global);
> +
> +  private:
> +    NumberObject();
> +    NumberObject &operator=(const NumberObject &so);

Add a comment here, please, explaining these are declared private so they can't be used.  (And maybe why you don't want them to be used.)
Comment 2 Luke Wagner [:luke] 2011-05-13 14:20:54 PDT
5 out 5 JS engineers just surveyed agree that private cctor/op= is a basic C++ idiom and not deserving of comment.
Comment 3 Jeff Walden [:Waldo] (remove +bmo to email) 2011-05-13 14:26:15 PDT
(In reply to comment #1)
> Is PRIMITIVE_THIS_SLOT the best name now?  Would something simpler
> like VALUE_SLOT be better?  And if you make that change, would
> setValue() be a better name than init()?

I had thought I was mimicking the name of the spec internal property, but that was actually [[PrimitiveValue]], so I renamed to PRIMITIVE_VALUE_SLOT and setPrimitiveValue.

> @@ +78,5 @@
> > +    ::js_InitNumberClass(JSContext *cx, JSObject *global);
> > +
> > +  private:
> > +    NumberObject();
> > +    NumberObject &operator=(const NumberObject &so);
> 
> Add a comment here, please, explaining these are declared private so
> they can't be used.  (And maybe why you don't want them to be used.)

A poll of the office says private constructor/operator= are idiomatic for "don't do that", so I'm leaving this as-is.  It doesn't seem important to clarify why, but anyone who's truly curious shouldn't have to think much past "this is GC-managed" to explain.

This is atop a bunch of other patches, so it'll be awhile before it lands, I think (but for 6, I believe).
Comment 4 Jeff Walden [:Waldo] (remove +bmo to email) 2011-09-26 11:51:22 PDT
...and four and a half months later, those other patches have made their way through reviews and such into the tree -- landed:

http://hg.mozilla.org/integration/mozilla-inbound/rev/66736ca9c8c3
Comment 5 Ed Morley [:emorley] 2011-09-27 03:51:43 PDT
https://hg.mozilla.org/mozilla-central/rev/66736ca9c8c3

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