mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Generate DOM bindings imports for webidl typedefs
This commit is contained in:
parent
5fff90c73f
commit
354d94059b
1 changed files with 15 additions and 6 deletions
|
@ -1848,7 +1848,8 @@ class CGImports(CGWrapper):
|
|||
"""
|
||||
Generates the appropriate import/use statements.
|
||||
"""
|
||||
def __init__(self, child, descriptors, callbacks, dictionaries, enums, imports, config, ignored_warnings=None):
|
||||
def __init__(self, child, descriptors, callbacks, dictionaries, enums, typedefs, imports, config,
|
||||
ignored_warnings=None):
|
||||
"""
|
||||
Adds a set of imports.
|
||||
"""
|
||||
|
@ -1937,6 +1938,11 @@ class CGImports(CGWrapper):
|
|||
for d in dictionaries:
|
||||
types += componentTypes(d)
|
||||
|
||||
# Import the type names used in the typedefs that are being defined.
|
||||
for t in typedefs:
|
||||
if not t.innerType.isCallback():
|
||||
types += componentTypes(t.innerType)
|
||||
|
||||
# Normalize the types we've collected and remove any ones which can't be imported.
|
||||
types = removeWrapperAndNullableTypes(types)
|
||||
|
||||
|
@ -2292,6 +2298,7 @@ def UnionTypes(descriptors, dictionaries, callbacks, typedefs, config):
|
|||
callbacks=[],
|
||||
dictionaries=[],
|
||||
enums=[],
|
||||
typedefs=[],
|
||||
imports=imports,
|
||||
config=config,
|
||||
ignored_warnings=[])
|
||||
|
@ -5507,15 +5514,17 @@ class CGWeakReferenceableTrait(CGThing):
|
|||
return self.code
|
||||
|
||||
|
||||
def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries=None, enums=None):
|
||||
def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries=None, enums=None, typedefs=None):
|
||||
if not callbacks:
|
||||
callbacks = []
|
||||
if not dictionaries:
|
||||
dictionaries = []
|
||||
if not enums:
|
||||
enums = []
|
||||
if not typedefs:
|
||||
typedefs = []
|
||||
|
||||
return CGImports(cgthings, descriptors, callbacks, dictionaries, enums, [
|
||||
return CGImports(cgthings, descriptors, callbacks, dictionaries, enums, typedefs, [
|
||||
'core::nonzero::NonZero',
|
||||
'js',
|
||||
'js::JSCLASS_GLOBAL_SLOT_COUNT',
|
||||
|
@ -6220,7 +6229,7 @@ class CGBindingRoot(CGThing):
|
|||
# Do codegen for all the enums.
|
||||
cgthings = [CGEnum(e) for e in enums]
|
||||
|
||||
# Do codegen for all the typdefs
|
||||
# Do codegen for all the typedefs
|
||||
for t in typedefs:
|
||||
typeName = getRetvalDeclarationForType(t.innerType, config.getDescriptorProvider())
|
||||
substs = {
|
||||
|
@ -6258,7 +6267,7 @@ class CGBindingRoot(CGThing):
|
|||
|
||||
# Add imports
|
||||
curr = generate_imports(config, curr, callbackDescriptors, mainCallbacks,
|
||||
dictionaries, enums)
|
||||
dictionaries, enums, typedefs)
|
||||
|
||||
# Add the auto-generated comment.
|
||||
curr = CGWrapper(curr, pre=AUTOGENERATED_WARNING_COMMENT)
|
||||
|
@ -7060,7 +7069,7 @@ class GlobalGenRoots():
|
|||
CGRegisterProxyHandlers(config),
|
||||
], "\n")
|
||||
|
||||
return CGImports(code, descriptors=[], callbacks=[], dictionaries=[], enums=[], imports=[
|
||||
return CGImports(code, descriptors=[], callbacks=[], dictionaries=[], enums=[], typedefs=[], imports=[
|
||||
'dom::bindings::codegen::Bindings',
|
||||
'dom::bindings::codegen::PrototypeList::Proxies',
|
||||
'libc',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue