Auto merge of #23653 - Manishearth:nested, r=jdm

Improve support for nested dictionaries

Fixes https://github.com/servo/servo/issues/23640

Some IDLs need `= null`, that's something that needs to be updated upstream too.

After talking with @bzbarsky I realized that it was our IDLs which were incorrect, causing Options to appear where we don't want them to. In the media code we _do_ want Options. `= null` is the correct fix for that (and should be upstreamed).

r? @jdm

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23653)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-06-28 20:44:41 -04:00 committed by GitHub
commit 84786add22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 24 deletions

View file

@ -4611,7 +4611,8 @@ class IDLArgument(IDLObjectWithIdentifier):
if ((self.type.isDictionary() or if ((self.type.isDictionary() or
self.type.isUnion() and self.type.unroll().hasDictionaryType()) and self.type.isUnion() and self.type.unroll().hasDictionaryType()) and
self.optional and not self.defaultValue and not self.variadic): self.optional and not self.defaultValue and not self.variadic and
not self.dictionaryMember):
# Default optional non-variadic dictionary arguments to null, # Default optional non-variadic dictionary arguments to null,
# for simplicity, so the codegen doesn't have to special-case this. # for simplicity, so the codegen doesn't have to special-case this.
self.defaultValue = IDLNullValue(self.location) self.defaultValue = IDLNullValue(self.location)

View file

@ -1,12 +0,0 @@
--- WebIDL.py
+++ WebIDL.py
@@ -4570,8 +4570,7 @@ class IDLArgument(IDLObjectWithIdentifier):
if ((self.type.isDictionary() or
self.type.isUnion() and self.type.unroll().hasDictionaryType()) and
- self.optional and not self.defaultValue and not self.variadic and
- not self.dictionaryMember):
+ self.optional and not self.defaultValue and not self.variadic):
# Default optional non-variadic dictionary arguments to null,
# for simplicity, so the codegen doesn't have to special-case this.
self.defaultValue = IDLNullValue(self.location)

View file

@ -5,7 +5,6 @@ patch < pref-main-thread.patch
patch < callback-location.patch patch < callback-location.patch
patch < union-typedef.patch patch < union-typedef.patch
patch < inline.patch patch < inline.patch
patch < undo-dictionary-optional.patch
wget https://hg.mozilla.org/mozilla-central/archive/tip.tar.gz/dom/bindings/parser/tests/ -O tests.tar.gz wget https://hg.mozilla.org/mozilla-central/archive/tip.tar.gz/dom/bindings/parser/tests/ -O tests.tar.gz
rm -r tests rm -r tests

View file

@ -78,11 +78,11 @@ fn convert_constraints(js: &BooleanOrMediaTrackConstraints) -> Option<MediaTrack
BooleanOrMediaTrackConstraints::Boolean(true) => Some(Default::default()), BooleanOrMediaTrackConstraints::Boolean(true) => Some(Default::default()),
BooleanOrMediaTrackConstraints::MediaTrackConstraints(ref c) => { BooleanOrMediaTrackConstraints::MediaTrackConstraints(ref c) => {
Some(MediaTrackConstraintSet { Some(MediaTrackConstraintSet {
height: convert_culong(&c.parent.height), height: c.parent.height.as_ref().and_then(convert_culong),
width: convert_culong(&c.parent.width), width: c.parent.width.as_ref().and_then(convert_culong),
aspect: convert_cdouble(&c.parent.aspectRatio), aspect: c.parent.aspectRatio.as_ref().and_then(convert_cdouble),
frame_rate: convert_cdouble(&c.parent.frameRate), frame_rate: c.parent.frameRate.as_ref().and_then(convert_cdouble),
sample_rate: convert_culong(&c.parent.sampleRate), sample_rate: c.parent.sampleRate.as_ref().and_then(convert_culong),
}) })
}, },
} }

View file

@ -25,8 +25,8 @@ interface DOMQuad {
}; };
dictionary DOMQuadInit { dictionary DOMQuadInit {
DOMPointInit p1; DOMPointInit p1 = null;
DOMPointInit p2; DOMPointInit p2 = null;
DOMPointInit p3; DOMPointInit p3 = null;
DOMPointInit p4; DOMPointInit p4 = null;
}; };

View file

@ -32,7 +32,7 @@ dictionary TestDictionary {
Blob interfaceValue; Blob interfaceValue;
any anyValue; any anyValue;
object objectValue; object objectValue;
TestDictionaryDefaults dict; TestDictionaryDefaults dict = null;
sequence<TestDictionaryDefaults> seqDict; sequence<TestDictionaryDefaults> seqDict;
// Testing codegen to import Element correctly, ensure no other code references Element directly // Testing codegen to import Element correctly, ensure no other code references Element directly
sequence<Element> elementSequence; sequence<Element> elementSequence;