mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
generate typedefs in CodegenRust
This commit is contained in:
parent
525e77f64f
commit
d6df844ae5
2 changed files with 16 additions and 0 deletions
|
@ -5283,6 +5283,7 @@ class CGBindingRoot(CGThing):
|
||||||
isCallback=True)
|
isCallback=True)
|
||||||
|
|
||||||
enums = config.getEnums(webIDLFile)
|
enums = config.getEnums(webIDLFile)
|
||||||
|
typedefs = config.getTypedefs(webIDLFile)
|
||||||
|
|
||||||
if not (descriptors or dictionaries or mainCallbacks or callbackDescriptors or enums):
|
if not (descriptors or dictionaries or mainCallbacks or callbackDescriptors or enums):
|
||||||
self.root = None
|
self.root = None
|
||||||
|
@ -5291,6 +5292,17 @@ class CGBindingRoot(CGThing):
|
||||||
# Do codegen for all the enums.
|
# Do codegen for all the enums.
|
||||||
cgthings = [CGEnum(e) for e in 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.
|
# Do codegen for all the dictionaries.
|
||||||
cgthings.extend([CGDictionary(d, config.getDescriptorProvider())
|
cgthings.extend([CGDictionary(d, config.getDescriptorProvider())
|
||||||
for d in dictionaries])
|
for d in dictionaries])
|
||||||
|
|
|
@ -60,6 +60,7 @@ class Configuration:
|
||||||
descriptor.uniqueImplementation = len(otherDescriptors) == 1
|
descriptor.uniqueImplementation = len(otherDescriptors) == 1
|
||||||
|
|
||||||
self.enums = [e for e in parseData if e.isEnum()]
|
self.enums = [e for e in parseData if e.isEnum()]
|
||||||
|
self.typedefs = [e for e in parseData if e.isTypedef()]
|
||||||
self.dictionaries = [d for d in parseData if d.isDictionary()]
|
self.dictionaries = [d for d in parseData if d.isDictionary()]
|
||||||
self.callbacks = [c for c in parseData if
|
self.callbacks = [c for c in parseData if
|
||||||
c.isCallback() and not c.isInterface()]
|
c.isCallback() and not c.isInterface()]
|
||||||
|
@ -90,6 +91,9 @@ class Configuration:
|
||||||
def getEnums(self, webIDLFile):
|
def getEnums(self, webIDLFile):
|
||||||
return filter(lambda e: e.filename() == webIDLFile, self.enums)
|
return filter(lambda e: e.filename() == webIDLFile, self.enums)
|
||||||
|
|
||||||
|
def getTypedefs(self, webIDLFile):
|
||||||
|
return filter(lambda e: e.filename() == webIDLFile, self.typedefs)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _filterForFile(items, webIDLFile=""):
|
def _filterForFile(items, webIDLFile=""):
|
||||||
"""Gets the items that match the given filters."""
|
"""Gets the items that match the given filters."""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue