mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Introduce the NativePropertyHooks struct.
This will be required for the cross-origin wrapper work.
This commit is contained in:
parent
be538bcd23
commit
cadc84319a
2 changed files with 45 additions and 3 deletions
|
@ -131,6 +131,34 @@ class CGThing():
|
||||||
"""Produce code for a Rust file."""
|
"""Produce code for a Rust file."""
|
||||||
assert(False) # Override me!
|
assert(False) # Override me!
|
||||||
|
|
||||||
|
|
||||||
|
class CGNativePropertyHooks(CGThing):
|
||||||
|
"""
|
||||||
|
Generate a NativePropertyHooks for a given descriptor
|
||||||
|
"""
|
||||||
|
def __init__(self, descriptor, properties):
|
||||||
|
CGThing.__init__(self)
|
||||||
|
self.descriptor = descriptor
|
||||||
|
self.properties = properties
|
||||||
|
|
||||||
|
def define(self):
|
||||||
|
parent = self.descriptor.interface.parent
|
||||||
|
if parent:
|
||||||
|
parentHooks = "Some(&::dom::bindings::codegen::Bindings::%sBinding::sNativePropertyHooks)" % parent.identifier.name
|
||||||
|
else:
|
||||||
|
parentHooks = "None"
|
||||||
|
|
||||||
|
substitutions = {
|
||||||
|
"parentHooks": parentHooks
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Template(
|
||||||
|
"pub static sNativePropertyHooks: NativePropertyHooks = NativePropertyHooks {\n"
|
||||||
|
" native_properties: &sNativeProperties,\n"
|
||||||
|
" proto_hooks: ${parentHooks},\n"
|
||||||
|
"};\n").substitute(substitutions)
|
||||||
|
|
||||||
|
|
||||||
class CGMethodCall(CGThing):
|
class CGMethodCall(CGThing):
|
||||||
"""
|
"""
|
||||||
A class to generate selection of a method signature from a set of
|
A class to generate selection of a method signature from a set of
|
||||||
|
@ -1386,7 +1414,8 @@ def DOMClass(descriptor):
|
||||||
protoList.extend(['PrototypeList::id::IDCount'] * (descriptor.config.maxProtoChainLength - len(protoList)))
|
protoList.extend(['PrototypeList::id::IDCount'] * (descriptor.config.maxProtoChainLength - len(protoList)))
|
||||||
prototypeChainString = ', '.join(protoList)
|
prototypeChainString = ', '.join(protoList)
|
||||||
return """DOMClass {
|
return """DOMClass {
|
||||||
interface_chain: [ %s ]
|
interface_chain: [ %s ],
|
||||||
|
native_hooks: &sNativePropertyHooks,
|
||||||
}""" % prototypeChainString
|
}""" % prototypeChainString
|
||||||
|
|
||||||
class CGDOMJSClass(CGThing):
|
class CGDOMJSClass(CGThing):
|
||||||
|
@ -4119,6 +4148,7 @@ class CGDescriptor(CGThing):
|
||||||
properties = PropertyArrays(descriptor)
|
properties = PropertyArrays(descriptor)
|
||||||
cgThings.append(CGGeneric(str(properties)))
|
cgThings.append(CGGeneric(str(properties)))
|
||||||
cgThings.append(CGNativeProperties(descriptor, properties))
|
cgThings.append(CGNativeProperties(descriptor, properties))
|
||||||
|
cgThings.append(CGNativePropertyHooks(descriptor, properties))
|
||||||
cgThings.append(CGCreateInterfaceObjectsMethod(descriptor, properties))
|
cgThings.append(CGCreateInterfaceObjectsMethod(descriptor, properties))
|
||||||
|
|
||||||
cgThings.append(CGNamespace.build([descriptor.name + "Constants"],
|
cgThings.append(CGNamespace.build([descriptor.name + "Constants"],
|
||||||
|
@ -4499,7 +4529,7 @@ class CGBindingRoot(CGThing):
|
||||||
'dom::bindings::utils::{ThrowingConstructor, unwrap, unwrap_jsmanaged}',
|
'dom::bindings::utils::{ThrowingConstructor, unwrap, unwrap_jsmanaged}',
|
||||||
'dom::bindings::utils::VoidVal',
|
'dom::bindings::utils::VoidVal',
|
||||||
'dom::bindings::utils::get_dictionary_property',
|
'dom::bindings::utils::get_dictionary_property',
|
||||||
'dom::bindings::utils::NativeProperties',
|
'dom::bindings::utils::{NativeProperties, NativePropertyHooks}',
|
||||||
'dom::bindings::trace::JSTraceable',
|
'dom::bindings::trace::JSTraceable',
|
||||||
'dom::bindings::callback::{CallbackContainer,CallbackInterface,CallbackFunction}',
|
'dom::bindings::callback::{CallbackContainer,CallbackInterface,CallbackFunction}',
|
||||||
'dom::bindings::callback::{CallSetup,ExceptionHandling}',
|
'dom::bindings::callback::{CallSetup,ExceptionHandling}',
|
||||||
|
|
|
@ -222,11 +222,23 @@ pub struct ConstantSpec {
|
||||||
pub value: ConstantVal
|
pub value: ConstantVal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Helper structure for cross-origin wrappers for DOM binding objects.
|
||||||
|
pub struct NativePropertyHooks {
|
||||||
|
/// The property arrays for this interface.
|
||||||
|
pub native_properties: &'static NativeProperties,
|
||||||
|
|
||||||
|
/// The NativePropertyHooks instance for the parent interface, if any.
|
||||||
|
pub proto_hooks: Option<&'static NativePropertyHooks>,
|
||||||
|
}
|
||||||
|
|
||||||
/// The struct that holds inheritance information for DOM object reflectors.
|
/// The struct that holds inheritance information for DOM object reflectors.
|
||||||
pub struct DOMClass {
|
pub struct DOMClass {
|
||||||
/// A list of interfaces that this object implements, in order of decreasing
|
/// A list of interfaces that this object implements, in order of decreasing
|
||||||
/// derivedness.
|
/// derivedness.
|
||||||
pub interface_chain: [PrototypeList::id::ID, ..MAX_PROTO_CHAIN_LENGTH]
|
pub interface_chain: [PrototypeList::id::ID, ..MAX_PROTO_CHAIN_LENGTH],
|
||||||
|
|
||||||
|
/// The NativePropertyHooks for the interface associated with this class.
|
||||||
|
pub native_hooks: &'static NativePropertyHooks,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The JSClass used for DOM object reflectors.
|
/// The JSClass used for DOM object reflectors.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue