aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen/CodegenRust.py
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-04-25 02:45:29 -0700
committerbors-servo <lbergstrom+bors@mozilla.com>2016-04-25 02:45:29 -0700
commita92a6360cf2833c405ec668ee144db5de44c15cf (patch)
treecca9606df80b4a8b3bebdc03873c9392c08ada91 /components/script/dom/bindings/codegen/CodegenRust.py
parent59205323da10b5867d4386a50a290c3a7500c217 (diff)
parent4c2ca7a8c9244746ac168942651b0df6b6476626 (diff)
downloadservo-a92a6360cf2833c405ec668ee144db5de44c15cf.tar.gz
servo-a92a6360cf2833c405ec668ee144db5de44c15cf.zip
Auto merge of #10819 - nox:call-without-new, r=Ms2ger
Refactor the `call` hook on non-callback interface objects (fixes #10744) <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10819) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/bindings/codegen/CodegenRust.py')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 74dff1cce9f..1ef2e0a4eb9 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -1897,20 +1897,24 @@ class CGInterfaceObjectJSClass(CGThing):
def define(self):
if self.descriptor.interface.ctor():
- constructor = CONSTRUCT_HOOK_NAME
+ constructorBehavior = "InterfaceConstructorBehavior::call(%s)" % CONSTRUCT_HOOK_NAME
else:
- constructor = "throwing_constructor"
+ constructorBehavior = "InterfaceConstructorBehavior::throw()"
name = self.descriptor.interface.identifier.name
args = {
- "constructor": constructor,
+ "constructorBehavior": constructorBehavior,
"id": name,
"representation": str_to_const_array("function %s() {\\n [native code]\\n}" % name),
"depth": self.descriptor.prototypeDepth
}
return """\
-static InterfaceObjectClass: NonCallbackInterfaceObjectClass =
- NonCallbackInterfaceObjectClass::new(%(constructor)s, %(representation)s,
- PrototypeList::ID::%(id)s, %(depth)s);
+static InterfaceObjectClass: NonCallbackInterfaceObjectClass = unsafe {
+ NonCallbackInterfaceObjectClass::new(
+ %(constructorBehavior)s,
+ %(representation)s,
+ PrototypeList::ID::%(id)s,
+ %(depth)s)
+};
""" % args
@@ -2449,10 +2453,8 @@ if <*mut JSObject>::needs_post_barrier(prototype.ptr) {
if self.descriptor.interface.hasInterfaceObject():
properties["name"] = str_to_const_array(name)
if self.descriptor.interface.ctor():
- properties["constructor"] = CONSTRUCT_HOOK_NAME
properties["length"] = methodLength(self.descriptor.interface.ctor())
else:
- properties["constructor"] = "throwing_constructor"
properties["length"] = 0
if self.descriptor.interface.parent:
parentName = toBindingNamespace(self.descriptor.getParentName())
@@ -5400,9 +5402,9 @@ class CGBindingRoot(CGThing):
'js::rust::{GCMethods, define_methods, define_properties}',
'dom::bindings',
'dom::bindings::global::{GlobalRef, global_root_from_object, global_root_from_reflector}',
- 'dom::bindings::interface::{NonCallbackInterfaceObjectClass, create_callback_interface_object}',
- 'dom::bindings::interface::{create_interface_prototype_object, create_named_constructors}',
- 'dom::bindings::interface::{create_noncallback_interface_object}',
+ 'dom::bindings::interface::{InterfaceConstructorBehavior, NonCallbackInterfaceObjectClass}',
+ 'dom::bindings::interface::{create_callback_interface_object, create_interface_prototype_object}',
+ 'dom::bindings::interface::{create_named_constructors, create_noncallback_interface_object}',
'dom::bindings::interface::{ConstantSpec, NonNullJSNative}',
'dom::bindings::interface::ConstantVal::{IntVal, UintVal}',
'dom::bindings::js::{JS, Root, RootedReference}',
@@ -5416,8 +5418,7 @@ class CGBindingRoot(CGThing):
'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, resolve_global, set_dictionary_property}',
- 'dom::bindings::utils::{throwing_constructor, trace_global}',
+ 'dom::bindings::utils::{is_platform_object, resolve_global, set_dictionary_property, trace_global}',
'dom::bindings::trace::{JSTraceable, RootedTraceable}',
'dom::bindings::callback::{CallbackContainer,CallbackInterface,CallbackFunction}',
'dom::bindings::callback::{CallSetup,ExceptionHandling}',