mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Pass a &GlobalScope to WebIDL static methods and constructors
This commit is contained in:
parent
1fd470889d
commit
19108aa330
56 changed files with 198 additions and 245 deletions
|
@ -3438,7 +3438,7 @@ class CGStaticMethod(CGAbstractStaticBindingMethod):
|
|||
nativeName = CGSpecializedMethod.makeNativeName(self.descriptor,
|
||||
self.method)
|
||||
setupArgs = CGGeneric("let args = CallArgs::from_vp(vp, argc);\n")
|
||||
call = CGMethodCall(["global.r()"], nativeName, True, self.descriptor, self.method)
|
||||
call = CGMethodCall(["global.r().as_global_scope()"], nativeName, True, self.descriptor, self.method)
|
||||
return CGList([setupArgs, call])
|
||||
|
||||
|
||||
|
@ -3492,7 +3492,7 @@ class CGStaticGetter(CGAbstractStaticBindingMethod):
|
|||
nativeName = CGSpecializedGetter.makeNativeName(self.descriptor,
|
||||
self.attr)
|
||||
setupArgs = CGGeneric("let args = CallArgs::from_vp(vp, argc);\n")
|
||||
call = CGGetterCall(["global.r()"], self.attr.type, nativeName, self.descriptor,
|
||||
call = CGGetterCall(["global.r().as_global_scope()"], self.attr.type, nativeName, self.descriptor,
|
||||
self.attr)
|
||||
return CGList([setupArgs, call])
|
||||
|
||||
|
@ -3545,7 +3545,7 @@ class CGStaticSetter(CGAbstractStaticBindingMethod):
|
|||
" throw_type_error(cx, \"Not enough arguments to %s setter.\");\n"
|
||||
" return false;\n"
|
||||
"}" % self.attr.identifier.name)
|
||||
call = CGSetterCall(["global.r()"], self.attr.type, nativeName, self.descriptor,
|
||||
call = CGSetterCall(["global.r().as_global_scope()"], self.attr.type, nativeName, self.descriptor,
|
||||
self.attr)
|
||||
return CGList([checkForArg, call])
|
||||
|
||||
|
@ -5257,7 +5257,7 @@ let args = CallArgs::from_vp(vp, argc);
|
|||
""")
|
||||
name = self.constructor.identifier.name
|
||||
nativeName = MakeNativeName(self.descriptor.binaryNameFor(name))
|
||||
callGenerator = CGMethodCall(["global.r()"], nativeName, True,
|
||||
callGenerator = CGMethodCall(["global.r().as_global_scope()"], nativeName, True,
|
||||
self.descriptor, self.constructor)
|
||||
return CGList([preamble, callGenerator])
|
||||
|
||||
|
|
|
@ -43,8 +43,9 @@
|
|||
//! [`Fallible<T>`](error/type.Fallible.html).
|
||||
//! Methods that use certain WebIDL types like `any` or `object` will get a
|
||||
//! `*mut JSContext` argument prepended to the argument list. Static methods
|
||||
//! will be passed a [`GlobalRef`](global/enum.GlobalRef.html) for the relevant
|
||||
//! global. This argument comes before the `*mut JSContext` argument, if any.
|
||||
//! will be passed a [`&GlobalScope`](../globalscope/struct.GlobalScope.html)
|
||||
//! for the relevant global. This argument comes before the `*mut JSContext`
|
||||
//! argument, if any.
|
||||
//!
|
||||
//! Rust reflections of WebIDL operations (methods)
|
||||
//! -----------------------------------------------
|
||||
|
@ -79,7 +80,7 @@
|
|||
//!
|
||||
//! A WebIDL constructor is turned into a static class method named
|
||||
//! `Constructor`. The arguments of this method will be the arguments of the
|
||||
//! WebIDL constructor, with a `GlobalRef` for the relevant global prepended.
|
||||
//! WebIDL constructor, with a `&GlobalScope` for the relevant global prepended.
|
||||
//! The return value of the constructor for MyInterface is exactly the same as
|
||||
//! that of a method returning an instance of MyInterface. Constructors are
|
||||
//! always [allowed to throw](#throwing-exceptions).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue