diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2020-06-05 00:04:47 +0200 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2020-06-05 00:11:37 +0200 |
commit | 3367db6067a8d76061e7884e54cc61ce44012442 (patch) | |
tree | 48f73ecb97d509ee27529704264bc8199030384f /components/script/dom/bindings/codegen/CodegenRust.py | |
parent | 36920abfe86e6a3a2d8c989a3ba1f21a5cee54e5 (diff) | |
download | servo-3367db6067a8d76061e7884e54cc61ce44012442.tar.gz servo-3367db6067a8d76061e7884e54cc61ce44012442.zip |
Keep DOM proxy handlers as separate named items rather than in one array
Diffstat (limited to 'components/script/dom/bindings/codegen/CodegenRust.py')
-rw-r--r-- | components/script/dom/bindings/codegen/CodegenRust.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 0b1187a07fb..5440884ab16 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -2750,7 +2750,7 @@ class CGWrapMethod(CGAbstractMethod): unforgeable = CopyUnforgeablePropertiesToInstance(self.descriptor) if self.descriptor.proxy: create = """ -let handler = RegisterBindings::PROXY_HANDLERS[PrototypeList::Proxies::%(concreteType)s as usize]; +let handler = RegisterBindings::proxy_handlers::%(concreteType)s; rooted!(in(*cx) let obj = NewProxyObject( *cx, handler, @@ -6744,7 +6744,7 @@ class CGRegisterProxyHandlersMethod(CGAbstractMethod): def definition_body(self): return CGList([ - CGGeneric("PROXY_HANDLERS[Proxies::%s as usize] = Bindings::%s::DefineProxyHandler();" + CGGeneric("proxy_handlers::%s = Bindings::%s::DefineProxyHandler();" % (desc.name, '::'.join([desc.name + 'Binding'] * 2))) for desc in self.descriptors ], "\n") @@ -6753,10 +6753,17 @@ class CGRegisterProxyHandlersMethod(CGAbstractMethod): class CGRegisterProxyHandlers(CGThing): def __init__(self, config): descriptors = config.getDescriptors(proxy=True) - length = len(descriptors) self.root = CGList([ - CGGeneric("pub static mut PROXY_HANDLERS: [*const libc::c_void; %d] = [0 as *const libc::c_void; %d];" - % (length, length)), + CGGeneric( + "#[allow(non_upper_case_globals)]\n" + + "pub mod proxy_handlers {\n" + + "".join( + " pub static mut %s: *const libc::c_void = std::ptr::null();\n" + % desc.name + for desc in descriptors + ) + + "}\n" + ), CGRegisterProxyHandlersMethod(descriptors), ], "\n") @@ -7606,8 +7613,6 @@ class GlobalGenRoots(): for d in config.getDescriptors(hasInterfaceObject=True) if d.shouldHaveGetConstructorObjectMethod()]) - proxies = [d.name for d in config.getDescriptors(proxy=True)] - return CGList([ CGGeneric(AUTOGENERATED_WARNING_COMMENT), CGGeneric("pub const PROTO_OR_IFACE_LENGTH: usize = %d;\n" % (len(protos) + len(constructors))), @@ -7624,7 +7629,6 @@ class GlobalGenRoots(): " debug_assert!(proto_id < ID::Last as u16);\n" " INTERFACES[proto_id as usize]\n" "}\n\n"), - CGNonNamespacedEnum('Proxies', proxies, 0, deriving="PartialEq, Copy, Clone"), ]) @staticmethod @@ -7636,8 +7640,6 @@ class GlobalGenRoots(): return CGImports(code, descriptors=[], callbacks=[], dictionaries=[], enums=[], typedefs=[], imports=[ 'crate::dom::bindings::codegen::Bindings', - 'crate::dom::bindings::codegen::PrototypeList::Proxies', - 'libc', ], config=config, ignored_warnings=[]) @staticmethod |