mirror of
https://github.com/servo/servo.git
synced 2025-06-13 02:44:29 +00:00
Auto merge of #9419 - psdh:includeTypedef, r=nox
generate typedefs in CodegenRust. fixes #9384 <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9419) <!-- Reviewable:end -->
This commit is contained in:
commit
a75f2cecda
2 changed files with 16 additions and 0 deletions
|
@ -5286,6 +5286,7 @@ class CGBindingRoot(CGThing):
|
|||
isCallback=True)
|
||||
|
||||
enums = config.getEnums(webIDLFile)
|
||||
typedefs = config.getTypedefs(webIDLFile)
|
||||
|
||||
if not (descriptors or dictionaries or mainCallbacks or callbackDescriptors or enums):
|
||||
self.root = None
|
||||
|
@ -5294,6 +5295,17 @@ class CGBindingRoot(CGThing):
|
|||
# Do codegen for all the enums.
|
||||
cgthings = [CGEnum(e) for e in enums]
|
||||
|
||||
# Do codegen for all the typdefs
|
||||
for t in typedefs:
|
||||
if t.innerType.isUnion():
|
||||
cgthings.extend([CGGeneric("\npub type %s = %s;\n\n" % (t.identifier.name,
|
||||
"UnionTypes::" + str(t.innerType)))])
|
||||
else:
|
||||
assert not typeNeedsRooting(t.innerType, config.getDescriptorProvider)
|
||||
cgthings.extend([CGGeneric("\npub type %s = " % (t.identifier.name)),
|
||||
getRetvalDeclarationForType(t.innerType, config.getDescriptorProvider()),
|
||||
CGGeneric(";\n\n")])
|
||||
|
||||
# Do codegen for all the dictionaries.
|
||||
cgthings.extend([CGDictionary(d, config.getDescriptorProvider())
|
||||
for d in dictionaries])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue