Closed
Bug 915368
Opened 12 years ago
Closed 12 years ago
Give dictionaries a copy constructor and operator= when it's safe
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
FIXED
mozilla26
People
(Reporter: bzbarsky, Assigned: bzbarsky)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
5.77 KB,
patch
|
khuey
:
review+
|
Details | Diff | Splinter Review |
Specifically, if we contain only strings, enums, primitives, sequences containing safe stuff, dictionaries with only safe members, nullables around any of that.
![]() |
Assignee | |
Updated•12 years ago
|
Blocks: ParisBindings
Updated•12 years ago
|
No longer blocks: ParisBindings
![]() |
Assignee | |
Comment 1•12 years ago
|
||
So for this IDL:
dictionary ParentTest {
boolean haha;
};
dictionary MediaTrackConstraintSet : ParentTest {
VideoFacingModeEnum facingMode;
};
dictionary MediaStreamConstraintsInternal {
boolean fake = false;
MediaTrackConstraintsInternal audiom;
};
dictionary MediaTrackConstraintsInternal {
MediaTrackConstraintSet mandatory;
sequence<MediaTrackConstraintSet> _optional;
};
we get codegen like so in the header:
explicit inline ParentTest(const ParentTest& aOther)
{
*this = aOther;
}
void
operator=(const ParentTest& aOther);
and likewise for the other dictionaries, and like so in the .cpp:
void
ParentTest::operator=(const ParentTest& aOther)
{
if (aOther.mHaha.WasPassed()) {
mHaha.Construct();
mHaha.Value() = aOther.mHaha.Value();
} else {
mHaha.Reset();
}
}
void
MediaTrackConstraintSet::operator=(const MediaTrackConstraintSet& aOther)
{
ParentTest::operator=(aOther);
if (aOther.mFacingMode.WasPassed()) {
mFacingMode.Construct();
mFacingMode.Value() = aOther.mFacingMode.Value();
} else {
mFacingMode.Reset();
}
}
void
MediaTrackConstraintsInternal::operator=(const MediaTrackConstraintsInternal& aOther)
{
mMandatory = aOther.mMandatory;
if (aOther.mOptional.WasPassed()) {
mOptional.Construct();
mOptional.Value() = aOther.mOptional.Value();
} else {
mOptional.Reset();
}
}
void
MediaStreamConstraintsInternal::operator=(const MediaStreamConstraintsInternal& aOther)
{
mAudiom = aOther.mAudiom;
mFake = aOther.mFake;
}
Blocks: ParisBindings
![]() |
Assignee | |
Comment 2•12 years ago
|
||
Attachment #803270 -
Flags: review?(khuey)
Comment 3•12 years ago
|
||
Thanks for the patch! - What's the ETA on review? I'm hoping to land Bug 882145 for FF26 which uses it now. Let me know and I can back off and use a workaround if need be.
Thanks!
Comment 4•12 years ago
|
||
I should add that it works! :-)
Comment on attachment 803270 [details] [diff] [review]
Give dictionaries copy constructors and assignment operators when it's safe.
Review of attachment 803270 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/bindings/Codegen.py
@@ +8576,5 @@
>
> + @staticmethod
> + def isDictionaryCopyConstructible(dictionary):
> + def isTypeCopyConstructible(type):
> + # Nullable and sequnce stuff doesn't affect copy/constructibility
*sequence
Attachment #803270 -
Flags: review?(khuey) → review+
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla26
![]() |
Assignee | |
Updated•12 years ago
|
Flags: in-testsuite?
Whiteboard: [need review]
Updated•7 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•