mirror of
https://github.com/servo/servo.git
synced 2025-06-06 00:25:37 +00:00
Fix duplicate import generation
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
This commit is contained in:
parent
7f0cebd442
commit
9d9fdd2f79
3 changed files with 10 additions and 6 deletions
|
@ -2138,7 +2138,8 @@ class CGImports(CGWrapper):
|
|||
"""
|
||||
Generates the appropriate import/use statements.
|
||||
"""
|
||||
def __init__(self, child, descriptors, callbacks, dictionaries, enums, typedefs, imports, config):
|
||||
def __init__(self, child, descriptors, callbacks, dictionaries, enums, typedefs, imports, config,
|
||||
current_name=None):
|
||||
"""
|
||||
Adds a set of imports.
|
||||
"""
|
||||
|
@ -2249,7 +2250,8 @@ class CGImports(CGWrapper):
|
|||
parentName = descriptor.getParentName()
|
||||
while parentName:
|
||||
descriptor = descriptorProvider.getDescriptor(parentName)
|
||||
extras += [descriptor.bindingPath]
|
||||
if current_name != descriptor.ifaceName:
|
||||
extras += [descriptor.path, descriptor.bindingPath]
|
||||
parentName = descriptor.getParentName()
|
||||
elif t.isType() and t.isRecord():
|
||||
extras += ['crate::record::Record']
|
||||
|
@ -7644,7 +7646,7 @@ class CGBindingRoot(CGThing):
|
|||
Root codegen class for binding generation. Instantiate the class, and call
|
||||
declare or define to generate header or cpp code (respectively).
|
||||
"""
|
||||
def __init__(self, config, prefix, webIDLFile):
|
||||
def __init__(self, config, prefix, webIDLFile, name):
|
||||
descriptors = config.getDescriptors(webIDLFile=webIDLFile,
|
||||
hasInterfaceObject=True)
|
||||
# We also want descriptors that have an interface prototype object
|
||||
|
@ -7712,7 +7714,7 @@ class CGBindingRoot(CGThing):
|
|||
# These are the global imports (outside of the generated module)
|
||||
curr = CGImports(curr, descriptors=callbackDescriptors, callbacks=mainCallbacks,
|
||||
dictionaries=dictionaries, enums=enums, typedefs=typedefs,
|
||||
imports=['crate::import::base::*'], config=config)
|
||||
imports=['crate::import::base::*'], config=config, current_name=name)
|
||||
|
||||
# Add the auto-generated comment.
|
||||
curr = CGWrapper(curr, pre=f"{AUTOGENERATED_WARNING_COMMENT}{ALLOWED_WARNINGS}")
|
||||
|
|
|
@ -248,6 +248,7 @@ class Descriptor(DescriptorProvider):
|
|||
self.inRealmMethods = [name for name in desc.get('inRealms', [])]
|
||||
self.canGcMethods = [name for name in desc.get('canGc', [])]
|
||||
self.additionalTraits = [name for name in desc.get('additionalTraits', [])]
|
||||
self.ifaceName = ifaceName
|
||||
self.bindingPath = f"{getModuleFromObject(self.interface)}::{ifaceName}_Binding"
|
||||
self.outerObjectHook = desc.get('outerObjectHook', 'None')
|
||||
self.proxy = False
|
||||
|
|
|
@ -72,8 +72,9 @@ def main():
|
|||
|
||||
for webidl in webidls:
|
||||
filename = os.path.join(webidls_dir, webidl)
|
||||
prefix = "Bindings/%sBinding" % webidl[:-len(".webidl")]
|
||||
module = CGBindingRoot(config, prefix, filename).define()
|
||||
name = webidl[:-len(".webidl")]
|
||||
prefix = "Bindings/%sBinding" % name
|
||||
module = CGBindingRoot(config, prefix, filename, name).define()
|
||||
if module:
|
||||
with open(os.path.join(out_dir, prefix + ".rs"), "wb") as f:
|
||||
f.write(module.encode("utf-8"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue