Closed Bug 560412 Opened 14 years ago Closed 14 years ago

Publicly expose the value of LazilyConstructed<T> objects

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: mozilla+ben, Assigned: mozilla+ben)

References

Details

Attachments

(2 files, 1 obsolete file)

Currently LazilyConstructed<T> values can be constructed, but the constructed values can't be accessed outside the class.  I propose adding

  T *address();
  const T *address() const;

Also, it seems that the const empty() function has trouble calling the non-const constructed() method, which has presumably been ok until now because empty() was never called.  I can fix that too while I'm at it.
(In reply to comment #0)
>   const T *address() const;

This isn't really necessary, on second thought, because LazilyConstructed<T> objects will never be immutable.
Sounds good.  Incidentally, TM tip has a newer version of LazilyConstructed (silencing bloody GCC strict-aliasing warnings) which you probably want to work against.

Also, is there any chance we could get a return-by-reference member instead of or in addition to address()?  Also, the ever-popular AutoValueRooter calls their return-by-pointer addr(), so perhaps that abbreviation could be used for consistency?
I was torn between implementing empty() as

  return !static_cast<LazilyConstructed*>(this)->constructed();

or simply

  return !bytes[sizeof(T)];

I went with the latter for brevity, although it duplicates the converted() code.
Attachment #440101 - Flags: review?(lw)
These comments passed (without collision??) in mid-air.  I like your suggestions and will update momentarily.
This applies to mozilla-central.  I'll post a TM patch next.
Attachment #440101 - Attachment is obsolete: true
Attachment #440104 - Flags: review?(lw)
Attachment #440101 - Flags: review?(lw)
Attachment #440104 - Flags: review?(lw) → review+
As promised.
Attachment #440106 - Flags: review?(lw)
Comment on attachment 440106 [details] [diff] [review]
TM-relative patch.

Thank you, sir
Attachment #440106 - Flags: review?(lw) → review+
Does this need any more review before landing (either on TM or mozilla-central, or both)?
Nope, Luke's review is sufficient.
http://hg.mozilla.org/mozilla-central/rev/b22a8aee5311
Status: NEW → RESOLVED
Closed: 14 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: