aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/bindings/codegen')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py10
-rw-r--r--components/script/dom/bindings/codegen/Configuration.py1
-rw-r--r--components/script/dom/bindings/codegen/run.py5
3 files changed, 10 insertions, 6 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 891f24f95ac..f9a7b2f5aaa 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -2167,7 +2167,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.
"""
@@ -2269,7 +2270,8 @@ class CGImports(CGWrapper):
parentName = descriptor.getParentName()
while parentName:
descriptor = descriptorProvider.getDescriptor(parentName)
- extras += [descriptor.path, descriptor.bindingPath]
+ if current_name != descriptor.ifaceName:
+ extras += [descriptor.path, descriptor.bindingPath]
parentName = descriptor.getParentName()
elif t.isType() and t.isRecord():
extras += ['crate::dom::bindings::record::Record']
@@ -6890,7 +6892,7 @@ class CGBindingRoot(CGThing):
DomRoot 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
@@ -6958,7 +6960,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::dom::bindings::import::base::*'], config=config)
+ imports=['crate::dom::bindings::import::base::*'], config=config, current_name=name)
# Add the auto-generated comment.
curr = CGWrapper(curr, pre=AUTOGENERATED_WARNING_COMMENT + ALLOWED_WARNINGS)
diff --git a/components/script/dom/bindings/codegen/Configuration.py b/components/script/dom/bindings/codegen/Configuration.py
index e49afb42b67..d96106a26dd 100644
--- a/components/script/dom/bindings/codegen/Configuration.py
+++ b/components/script/dom/bindings/codegen/Configuration.py
@@ -232,6 +232,7 @@ class Descriptor(DescriptorProvider):
self.register = desc.get('register', True)
self.path = desc.get('path', pathDefault)
self.inRealmMethods = [name for name in desc.get('inRealms', [])]
+ self.ifaceName = ifaceName
self.bindingPath = f"crate::dom::bindings::codegen::Bindings::{ifaceName}Binding::{ifaceName}_Binding"
self.outerObjectHook = desc.get('outerObjectHook', 'None')
self.proxy = False
diff --git a/components/script/dom/bindings/codegen/run.py b/components/script/dom/bindings/codegen/run.py
index a632abc1d9b..28e12989771 100644
--- a/components/script/dom/bindings/codegen/run.py
+++ b/components/script/dom/bindings/codegen/run.py
@@ -52,8 +52,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"))