mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Pass &JS<Window> to the Wrap functions in codegen.
This commit is contained in:
parent
23b7277b54
commit
787108deaf
5 changed files with 12 additions and 12 deletions
|
@ -2600,7 +2600,7 @@ class CGWrapMethod(CGAbstractMethod):
|
|||
def __init__(self, descriptor):
|
||||
assert descriptor.interface.hasInterfacePrototypeObject()
|
||||
if not descriptor.createGlobal:
|
||||
args = [Argument('*JSContext', 'aCx'), Argument('*JSObject', 'aScope'),
|
||||
args = [Argument('*JSContext', 'aCx'), Argument('&JS<Window>', 'aScope'),
|
||||
Argument(DOMObjectPointerArg(descriptor), 'aObject', mutable=True)]
|
||||
else:
|
||||
args = [Argument('*JSContext', 'aCx'),
|
||||
|
@ -2610,11 +2610,12 @@ class CGWrapMethod(CGAbstractMethod):
|
|||
def definition_body(self):
|
||||
if not self.descriptor.createGlobal:
|
||||
return """
|
||||
assert!(aScope.is_not_null());
|
||||
assert!(((*JS_GetClass(aScope)).flags & JSCLASS_IS_GLOBAL) != 0);
|
||||
let scope = aScope.reflector().get_jsobject();
|
||||
assert!(scope.is_not_null());
|
||||
assert!(((*JS_GetClass(scope)).flags & JSCLASS_IS_GLOBAL) != 0);
|
||||
|
||||
//JSAutoCompartment ac(aCx, aScope);
|
||||
let proto = GetProtoObject(aCx, aScope, aScope);
|
||||
//JSAutoCompartment ac(aCx, scope);
|
||||
let proto = GetProtoObject(aCx, scope, scope);
|
||||
if proto.is_null() {
|
||||
return ptr::null();
|
||||
}
|
||||
|
@ -2623,7 +2624,7 @@ class CGWrapMethod(CGAbstractMethod):
|
|||
|
||||
(*raw).mut_reflector().set_jsobject(obj);
|
||||
|
||||
return obj;""" % CreateBindingJSObject(self.descriptor, "aScope")
|
||||
return obj;""" % CreateBindingJSObject(self.descriptor, "scope")
|
||||
else:
|
||||
return """
|
||||
%s
|
||||
|
|
|
@ -32,11 +32,10 @@ impl <T> Clone for JS<T> {
|
|||
impl<T: Reflectable> JS<T> {
|
||||
pub fn new(mut obj: ~T,
|
||||
window: &JS<Window>,
|
||||
wrap_fn: extern "Rust" fn(*JSContext, *JSObject, ~T) -> *JSObject) -> JS<T> {
|
||||
wrap_fn: extern "Rust" fn(*JSContext, &JS<Window>, ~T) -> *JSObject) -> JS<T> {
|
||||
let cx = window.get().get_cx();
|
||||
let scope = window.get().reflector().get_jsobject();
|
||||
let raw: *mut T = &mut *obj;
|
||||
if wrap_fn(cx, scope, obj).is_null() {
|
||||
if wrap_fn(cx, window, obj).is_null() {
|
||||
fail!("Could not eagerly wrap object");
|
||||
}
|
||||
JS {
|
||||
|
|
|
@ -494,7 +494,7 @@ pub trait Reflectable {
|
|||
pub fn reflect_dom_object<T: Reflectable>
|
||||
(obj: ~T,
|
||||
window: &JS<window::Window>,
|
||||
wrap_fn: extern "Rust" fn(*JSContext, *JSObject, ~T) -> *JSObject)
|
||||
wrap_fn: extern "Rust" fn(*JSContext, &JS<window::Window>, ~T) -> *JSObject)
|
||||
-> JS<T> {
|
||||
JS::new(obj, window, wrap_fn)
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ impl Document {
|
|||
pub fn reflect_document<D: Reflectable+DocumentBase>
|
||||
(document: ~D,
|
||||
window: &JS<Window>,
|
||||
wrap_fn: extern "Rust" fn(*JSContext, *JSObject, ~D) -> *JSObject)
|
||||
wrap_fn: extern "Rust" fn(*JSContext, &JS<Window>, ~D) -> *JSObject)
|
||||
-> JS<D> {
|
||||
assert!(document.reflector().get_jsobject().is_null());
|
||||
let raw_doc = reflect_dom_object(document, window, wrap_fn);
|
||||
|
|
|
@ -754,7 +754,7 @@ impl Node {
|
|||
pub fn reflect_node<N: Reflectable+NodeBase>
|
||||
(node: ~N,
|
||||
document: &JS<Document>,
|
||||
wrap_fn: extern "Rust" fn(*JSContext, *JSObject, ~N) -> *JSObject)
|
||||
wrap_fn: extern "Rust" fn(*JSContext, &JS<Window>, ~N) -> *JSObject)
|
||||
-> JS<N> {
|
||||
assert!(node.reflector().get_jsobject().is_null());
|
||||
let node = reflect_dom_object(node, &document.get().window, wrap_fn);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue