mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Make WebIDL static methods take a more specific global if possible
This commit is contained in:
parent
973f77c006
commit
ddfb8805dc
3 changed files with 12 additions and 11 deletions
|
@ -3378,12 +3378,13 @@ class CGAbstractStaticBindingMethod(CGAbstractMethod):
|
|||
Argument('*mut JSVal', 'vp'),
|
||||
]
|
||||
CGAbstractMethod.__init__(self, descriptor, name, "bool", args, extern=True)
|
||||
self.exposureSet = descriptor.interface.exposureSet
|
||||
|
||||
def definition_body(self):
|
||||
preamble = CGGeneric("""\
|
||||
let global = GlobalScope::from_object(JS_CALLEE(cx, vp).to_object());
|
||||
""")
|
||||
return CGList([preamble, self.generate_code()])
|
||||
preamble = "let global = GlobalScope::from_object(JS_CALLEE(cx, vp).to_object());\n"
|
||||
if len(self.exposureSet) == 1:
|
||||
preamble += "let global = Root::downcast::<dom::types::%s>(global).unwrap();\n" % list(self.exposureSet)[0]
|
||||
return CGList([CGGeneric(preamble), self.generate_code()])
|
||||
|
||||
def generate_code(self):
|
||||
raise NotImplementedError # Override me!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue