diff options
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/bindings/codegen/CodegenRust.py | 9 | ||||
-rw-r--r-- | components/script/dom/bindings/codegen/parser/WebIDL.py | 10 | ||||
-rw-r--r-- | components/script/dom/testbinding.rs | 7 | ||||
-rw-r--r-- | components/script/dom/webidls/TestBinding.webidl | 3 |
4 files changed, 23 insertions, 6 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index cb7e796c627..bc6b3469a6f 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -2134,7 +2134,7 @@ class CGCallbackTempRoot(CGGeneric): CGGeneric.__init__(self, "%s::new(${val}.get().to_object())" % name) -def getAllTypes(descriptors, dictionaries, callbacks): +def getAllTypes(descriptors, dictionaries, callbacks, typedefs): """ Generate all the types we're dealing with. For each type, a tuple containing type, descriptor, dictionary is yielded. The @@ -2150,9 +2150,11 @@ def getAllTypes(descriptors, dictionaries, callbacks): for callback in callbacks: for t in getTypesFromCallback(callback): yield (t, None, None) + for typedef in typedefs: + yield (typedef.innerType, None, None) -def UnionTypes(descriptors, dictionaries, callbacks, config): +def UnionTypes(descriptors, dictionaries, callbacks, typedefs, config): """ Returns a CGList containing CGUnionStructs for every union. """ @@ -2181,7 +2183,7 @@ def UnionTypes(descriptors, dictionaries, callbacks, config): # Now find all the things we'll need as arguments and return values because # we need to wrap or unwrap them. unionStructs = dict() - for (t, descriptor, dictionary) in getAllTypes(descriptors, dictionaries, callbacks): + for (t, descriptor, dictionary) in getAllTypes(descriptors, dictionaries, callbacks, typedefs): assert not descriptor or not dictionary t = t.unroll() if not t.isUnion(): @@ -6913,6 +6915,7 @@ impl %(base)s { curr = UnionTypes(config.getDescriptors(), config.getDictionaries(), config.getCallbacks(), + config.typedefs, config) # Add the auto-generated comment. diff --git a/components/script/dom/bindings/codegen/parser/WebIDL.py b/components/script/dom/bindings/codegen/parser/WebIDL.py index 21af299303e..878c221f01c 100644 --- a/components/script/dom/bindings/codegen/parser/WebIDL.py +++ b/components/script/dom/bindings/codegen/parser/WebIDL.py @@ -2491,10 +2491,18 @@ class IDLUnionType(IDLType): return type.name for (i, type) in enumerate(self.memberTypes): - if not type.isComplete(): + # Exclude typedefs because if given "typedef (B or C) test", + # we want AOrTest, not AOrBOrC + if not type.isComplete() and not isinstance(type, IDLTypedefType): self.memberTypes[i] = type.complete(scope) self.name = "Or".join(typeName(type) for type in self.memberTypes) + + # We do this again to complete the typedef types + for (i, type) in enumerate(self.memberTypes): + if not type.isComplete(): + self.memberTypes[i] = type.complete(scope) + self.flatMemberTypes = list(self.memberTypes) i = 0 while i < len(self.flatMemberTypes): diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index 21439c0b19a..b9e34ebe0a7 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -12,8 +12,9 @@ use dom::bindings::codegen::Bindings::TestBindingBinding::{TestBindingMethods, T use dom::bindings::codegen::Bindings::TestBindingBinding::{TestDictionaryDefaults, TestEnum}; use dom::bindings::codegen::UnionTypes::{BlobOrBoolean, BlobOrBlobSequence, LongOrLongSequenceSequence}; use dom::bindings::codegen::UnionTypes::{BlobOrString, BlobOrUnsignedLong, EventOrString}; -use dom::bindings::codegen::UnionTypes::{ByteStringOrLong, ByteStringSequenceOrLongOrString, ByteStringSequenceOrLong}; -use dom::bindings::codegen::UnionTypes::{EventOrUSVString, HTMLElementOrLong}; +use dom::bindings::codegen::UnionTypes::{ByteStringOrLong, ByteStringSequenceOrLongOrString}; +use dom::bindings::codegen::UnionTypes::{ByteStringSequenceOrLong, DocumentOrTestTypedef}; +use dom::bindings::codegen::UnionTypes::{EventOrUSVString, HTMLElementOrLong, LongSequenceOrTestTypedef}; use dom::bindings::codegen::UnionTypes::{HTMLElementOrUnsignedLongOrStringOrBoolean, LongSequenceOrBoolean}; use dom::bindings::codegen::UnionTypes::{StringOrLongSequence, StringOrStringSequence, StringSequenceOrUnsignedLong}; use dom::bindings::codegen::UnionTypes::{StringOrUnsignedLong, StringOrBoolean, UnsignedLongOrBoolean}; @@ -421,6 +422,8 @@ impl TestBindingMethods for TestBinding { fn PassUnion6(&self, _: UnsignedLongOrBoolean) {} fn PassUnion7(&self, _: StringSequenceOrUnsignedLong) {} fn PassUnion8(&self, _: ByteStringSequenceOrLong) {} + fn PassUnionWithTypedef(&self, _: DocumentOrTestTypedef) {} + fn PassUnionWithTypedef2(&self, _: LongSequenceOrTestTypedef) {} fn PassAny(&self, _: *mut JSContext, _: HandleValue) {} fn PassObject(&self, _: *mut JSContext, _: *mut JSObject) {} fn PassCallbackFunction(&self, _: Rc<Function>) {} diff --git a/components/script/dom/webidls/TestBinding.webidl b/components/script/dom/webidls/TestBinding.webidl index 392aee5963b..d98b9428031 100644 --- a/components/script/dom/webidls/TestBinding.webidl +++ b/components/script/dom/webidls/TestBinding.webidl @@ -6,6 +6,7 @@ // web pages. enum TestEnum { "", "foo", "bar" }; +typedef (DOMString or URL or Blob) TestTypedef; dictionary TestDictionary { required boolean requiredValue; @@ -241,6 +242,8 @@ interface TestBinding { void passUnion6((unsigned long or boolean) bool); void passUnion7((sequence<DOMString> or unsigned long) arg); void passUnion8((sequence<ByteString> or long) arg); + void passUnionWithTypedef((Document or TestTypedef) arg); + void passUnionWithTypedef2((sequence<long> or TestTypedef) arg); void passAny(any arg); void passObject(object arg); void passCallbackFunction(Function fun); |