aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen/CodegenRust.py
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/bindings/codegen/CodegenRust.py')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py48
1 files changed, 38 insertions, 10 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 6ae07873dca..c969d3f04db 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -1779,10 +1779,10 @@ class CGDOMJSClass(CGThing):
}
if self.descriptor.isGlobal():
assert not self.descriptor.weakReferenceable
- args["enumerateHook"] = "Some(js::jsapi::JS_EnumerateStandardClasses)"
+ args["enumerateHook"] = "Some(enumerate_global)"
args["flags"] = "JSCLASS_IS_GLOBAL | JSCLASS_DOM_GLOBAL"
args["slots"] = "JSCLASS_GLOBAL_SLOT_COUNT + 1"
- args["resolveHook"] = "Some(js::jsapi::JS_ResolveStandardClass)"
+ args["resolveHook"] = "Some(resolve_global)"
args["traceHook"] = "js::jsapi::JS_GlobalObjectTraceHook"
elif self.descriptor.weakReferenceable:
args["slots"] = "2"
@@ -2280,11 +2280,8 @@ JS_SetPrototype(cx, obj.handle(), proto.handle());
%(copyUnforgeable)s
(*raw).init_reflector(obj.ptr);
-let ret = Root::from_ref(&*raw);
-
-RegisterBindings::Register(cx, obj.handle());
-
-ret""" % {'copyUnforgeable': unforgeable, 'createObject': create})
+Root::from_ref(&*raw)\
+""" % {'copyUnforgeable': unforgeable, 'createObject': create})
class CGIDLInterface(CGThing):
@@ -5447,12 +5444,12 @@ class CGBindingRoot(CGThing):
'dom::bindings::utils::{DOMClass, DOMJSClass}',
'dom::bindings::utils::{DOM_PROTO_UNFORGEABLE_HOLDER_SLOT, JSCLASS_DOM_GLOBAL}',
'dom::bindings::utils::{ProtoOrIfaceArray, create_dom_global}',
- 'dom::bindings::utils::{finalize_global, find_enum_string_index, generic_getter}',
- 'dom::bindings::utils::{generic_lenient_getter, generic_lenient_setter}',
+ 'dom::bindings::utils::{enumerate_global, finalize_global, find_enum_string_index}',
+ 'dom::bindings::utils::{generic_getter, generic_lenient_getter, generic_lenient_setter}',
'dom::bindings::utils::{generic_method, generic_setter, get_array_index_from_id}',
'dom::bindings::utils::{get_dictionary_property, get_property_on_prototype}',
'dom::bindings::utils::{get_proto_or_iface_array, has_property_on_prototype}',
- 'dom::bindings::utils::{is_platform_object, set_dictionary_property}',
+ 'dom::bindings::utils::{is_platform_object, resolve_global, set_dictionary_property}',
'dom::bindings::utils::{throwing_constructor, trace_global}',
'dom::bindings::trace::{JSTraceable, RootedTraceable}',
'dom::bindings::callback::{CallbackContainer,CallbackInterface,CallbackFunction}',
@@ -6096,6 +6093,37 @@ class GlobalGenRoots():
"""
@staticmethod
+ def InterfaceObjectMap(config):
+ mods = [
+ "dom::bindings::codegen",
+ "js::jsapi::{HandleObject, JSContext}",
+ "phf",
+ ]
+ imports = CGList([CGGeneric("use %s;" % mod) for mod in mods], "\n")
+
+ pairs = []
+ for d in config.getDescriptors(hasInterfaceObject=True):
+ binding = toBindingNamespace(d.name)
+ pairs.append((d.name, binding))
+ for ctor in d.interface.namedConstructors:
+ pairs.append((ctor.identifier.name, binding))
+ pairs.sort(key=operator.itemgetter(0))
+ mappings = [
+ CGGeneric('b"%s" => codegen::Bindings::%s::DefineDOMInterface as fn(_, _),' % pair)
+ for pair in pairs
+ ]
+ mapType = "phf::Map<&'static [u8], fn(*mut JSContext, HandleObject)>"
+ phf = CGWrapper(
+ CGIndenter(CGList(mappings, "\n")),
+ pre="pub static MAP: %s = phf_map! {\n" % mapType,
+ post="\n};\n")
+
+ return CGList([
+ CGGeneric(AUTOGENERATED_WARNING_COMMENT),
+ CGList([imports, phf], "\n\n")
+ ])
+
+ @staticmethod
def PrototypeList(config):
# Prototype ID enum.
interfaces = config.getDescriptors(isCallback=False)