Skip to content

Commit

Permalink
Keep DOM proxy handlers as separate named items rather than in one array
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin committed Jun 4, 2020
1 parent 36920ab commit 3367db6
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -2750,7 +2750,7 @@ def definition_body(self):
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,
Expand Down Expand Up @@ -6744,7 +6744,7 @@ def __init__(self, descriptors):

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")
Expand All @@ -6753,10 +6753,17 @@ def definition_body(self):
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")

Expand Down Expand Up @@ -7606,8 +7613,6 @@ def PrototypeList(config):
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))),
Expand All @@ -7624,7 +7629,6 @@ def PrototypeList(config):
" 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
Expand All @@ -7636,8 +7640,6 @@ def RegisterBindings(config):

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
Expand Down

0 comments on commit 3367db6

Please sign in to comment.