aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/bindings/codegen/CodegenRust.py
diff options
context:
space:
mode:
authorbors-servo <release+servo@mozilla.com>2014-04-21 09:40:27 -0400
committerbors-servo <release+servo@mozilla.com>2014-04-21 09:40:27 -0400
commit77b5c1f4f63c59ee88ad26363420fef6e2468ce1 (patch)
tree45e694c952855f9c342c0467bd0949f04f6ac3f7 /src/components/script/dom/bindings/codegen/CodegenRust.py
parentbb8a037cb249ee0bc17c16b7ce7b7df0222ee66e (diff)
parent4f9e119334cbd68a33874402d31c0bf8b629b038 (diff)
downloadservo-77b5c1f4f63c59ee88ad26363420fef6e2468ce1.tar.gz
servo-77b5c1f4f63c59ee88ad26363420fef6e2468ce1.zip
auto merge of #2198 : Ms2ger/servo/js_compartment, r=jdm
A js::rust::Compartment is little more than a glorified pointer to the reflector of a window, so there's no good reason to use it. Instead, this commit passes a JS<Window> directly when it's necessary. This also means that we now have to use JS_DefineFunctions rather than Compartment::define_functions; I believe the former is clearer to the reader than the extra indirection involved in the latter calling through three reopsitories. This commit also simplifies ScriptTask::load to reuse the 'cx' local that is in scope already, rather than refetching it through js_info.
Diffstat (limited to 'src/components/script/dom/bindings/codegen/CodegenRust.py')
-rw-r--r--src/components/script/dom/bindings/codegen/CodegenRust.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py
index 1e30647a3d6..22523568719 100644
--- a/src/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/src/components/script/dom/bindings/codegen/CodegenRust.py
@@ -2118,7 +2118,10 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
a given interface.
"""
def __init__(self, descriptor):
- args = [Argument('&mut JSPageInfo', 'js_info')]
+ args = [
+ Argument('&JS<Window>', 'window'),
+ Argument('&mut JSPageInfo', 'js_info'),
+ ]
CGAbstractMethod.__init__(self, descriptor, 'DefineDOMInterface', 'void', args, pub=True)
def define(self):
@@ -2173,10 +2176,10 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
('Some(%s)' % TRACE_HOOK_NAME),
self.descriptor.name)
- return (body + """ let cx = (*js_info.js_context).deref().ptr;
- let receiver = js_info.js_compartment.global_obj;
- let global: *JSObject = JS_GetGlobalForObject(cx, receiver);
- assert!(%s(cx, global, receiver).is_not_null());""" % (getter))
+ return (body + """ let cx = (**js_info.js_context).ptr;
+ let global = window.reflector().get_jsobject();
+ assert!(global.is_not_null());
+ assert!(%s(cx, global, global).is_not_null());""" % (getter))
def needCx(returnType, arguments, extendedAttributes, considerTypes):
return (considerTypes and
@@ -4305,13 +4308,16 @@ class CGDictionary(CGThing):
class CGRegisterProtos(CGAbstractMethod):
def __init__(self, config):
- CGAbstractMethod.__init__(self, None, 'Register', 'void',
- [Argument('&mut JSPageInfo', 'js_info')],
+ arguments = [
+ Argument('&JS<Window>', 'window'),
+ Argument('&mut JSPageInfo', 'js_info'),
+ ]
+ CGAbstractMethod.__init__(self, None, 'Register', 'void', arguments,
unsafe=False, pub=True)
self.config = config
def _registerProtos(self):
- lines = [" codegen::%sBinding::DefineDOMInterface(js_info);" % desc.name
+ lines = [" codegen::%sBinding::DefineDOMInterface(window, js_info);" % desc.name
for desc in self.config.getDescriptors(hasInterfaceObject=True,
register=True)]
return '\n'.join(lines) + '\n'
@@ -5349,6 +5355,8 @@ class GlobalGenRoots():
# TODO - Generate the methods we want
return CGImports(CGRegisterProtos(config), [
'dom::bindings::codegen',
+ 'dom::bindings::js::JS',
+ 'dom::window::Window',
'script_task::JSPageInfo',
])