mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Fix generation of static JS methods
They now take a global argument.
This commit is contained in:
parent
a3dafe4999
commit
7e7b421db9
2 changed files with 12 additions and 8 deletions
|
@ -2616,7 +2616,11 @@ class CGAbstractStaticBindingMethod(CGAbstractMethod):
|
||||||
CGAbstractMethod.__init__(self, descriptor, name, "JSBool", args, extern=True)
|
CGAbstractMethod.__init__(self, descriptor, name, "JSBool", args, extern=True)
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
return self.generate_code()
|
preamble = CGGeneric("""\
|
||||||
|
let global = global_object_for_js_object(JS_CALLEE(cx, vp).to_object());
|
||||||
|
let global = global.root();
|
||||||
|
""")
|
||||||
|
return CGList([preamble, self.generate_code()])
|
||||||
|
|
||||||
def generate_code(self):
|
def generate_code(self):
|
||||||
assert False # Override me
|
assert False # Override me
|
||||||
|
@ -2674,7 +2678,7 @@ class CGStaticMethod(CGAbstractStaticBindingMethod):
|
||||||
def generate_code(self):
|
def generate_code(self):
|
||||||
nativeName = CGSpecializedMethod.makeNativeName(self.descriptor,
|
nativeName = CGSpecializedMethod.makeNativeName(self.descriptor,
|
||||||
self.method)
|
self.method)
|
||||||
return CGMethodCall([], nativeName, True, self.descriptor, self.method)
|
return CGMethodCall(["global.r()"], nativeName, True, self.descriptor, self.method)
|
||||||
|
|
||||||
|
|
||||||
class CGGenericGetter(CGAbstractBindingMethod):
|
class CGGenericGetter(CGAbstractBindingMethod):
|
||||||
|
@ -2748,7 +2752,7 @@ class CGStaticGetter(CGAbstractStaticBindingMethod):
|
||||||
def generate_code(self):
|
def generate_code(self):
|
||||||
nativeName = CGSpecializedGetter.makeNativeName(self.descriptor,
|
nativeName = CGSpecializedGetter.makeNativeName(self.descriptor,
|
||||||
self.attr)
|
self.attr)
|
||||||
return CGGetterCall([], self.attr.type, nativeName, self.descriptor,
|
return CGGetterCall(["global.r()"], self.attr.type, nativeName, self.descriptor,
|
||||||
self.attr)
|
self.attr)
|
||||||
|
|
||||||
|
|
||||||
|
@ -2827,7 +2831,7 @@ class CGStaticSetter(CGAbstractStaticBindingMethod):
|
||||||
" throw_type_error(cx, \"Not enough arguments to %s setter.\");\n"
|
" throw_type_error(cx, \"Not enough arguments to %s setter.\");\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}" % self.attr.identifier.name)
|
"}" % self.attr.identifier.name)
|
||||||
call = CGSetterCall([], self.attr.type, nativeName, self.descriptor,
|
call = CGSetterCall(["global.r()"], self.attr.type, nativeName, self.descriptor,
|
||||||
self.attr)
|
self.attr)
|
||||||
return CGList([checkForArg, call])
|
return CGList([checkForArg, call])
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ use dom::bindings::codegen::UnionTypes::EventOrString;
|
||||||
use dom::bindings::codegen::UnionTypes::EventOrString::eString;
|
use dom::bindings::codegen::UnionTypes::EventOrString::eString;
|
||||||
use dom::bindings::codegen::UnionTypes::HTMLElementOrLong;
|
use dom::bindings::codegen::UnionTypes::HTMLElementOrLong;
|
||||||
use dom::bindings::codegen::UnionTypes::HTMLElementOrLong::eLong;
|
use dom::bindings::codegen::UnionTypes::HTMLElementOrLong::eLong;
|
||||||
use dom::bindings::global::GlobalField;
|
use dom::bindings::global::{GlobalField, GlobalRef};
|
||||||
use dom::bindings::js::{JSRef, Temporary};
|
use dom::bindings::js::{JSRef, Temporary};
|
||||||
use dom::bindings::num::Finite;
|
use dom::bindings::num::Finite;
|
||||||
use dom::bindings::str::{ByteString, USVString};
|
use dom::bindings::str::{ByteString, USVString};
|
||||||
|
@ -361,8 +361,8 @@ impl<'a> TestBindingMethods for JSRef<'a, TestBinding> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestBinding {
|
impl TestBinding {
|
||||||
pub fn BooleanAttributeStatic() -> bool { false }
|
pub fn BooleanAttributeStatic(_: GlobalRef) -> bool { false }
|
||||||
pub fn SetBooleanAttributeStatic(_: bool) {}
|
pub fn SetBooleanAttributeStatic(_: GlobalRef, _: bool) {}
|
||||||
pub fn ReceiveVoidStatic() {}
|
pub fn ReceiveVoidStatic(_: GlobalRef) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue