diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-09-09 18:45:56 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-09 18:45:56 -0500 |
commit | 1b3c7ed0ee8e968df01258ca8858295ead77dfa4 (patch) | |
tree | 923e5a6ddcf4c96351d2a3470ee1e40bc2e2fe26 /components/script/dom/bindings/codegen | |
parent | 142578f2e9dddadd530a4a436a74cfa411341cb5 (diff) | |
parent | 3976d974fc8cd79894fe876429d44fc3c88229f2 (diff) | |
download | servo-1b3c7ed0ee8e968df01258ca8858295ead77dfa4.tar.gz servo-1b3c7ed0ee8e968df01258ca8858295ead77dfa4.zip |
Auto merge of #13201 - KiChjang:codegen-typedefs, r=nox
Properly generate typedef identities in unions
Fixes #10605.
<!-- 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/13201)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/bindings/codegen')
-rw-r--r-- | components/script/dom/bindings/codegen/CodegenRust.py | 9 | ||||
-rw-r--r-- | components/script/dom/bindings/codegen/parser/WebIDL.py | 10 |
2 files changed, 15 insertions, 4 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 71331dfe503..717fc4a4cf2 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(): @@ -6914,6 +6916,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): |