mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Remove intrinsic Root::r()
This commit is contained in:
parent
51bcf516c8
commit
0b3ab875f4
55 changed files with 275 additions and 310 deletions
|
@ -3256,12 +3256,7 @@ class CGPerSignatureCall(CGThing):
|
|||
return "argc"
|
||||
|
||||
def getArguments(self):
|
||||
def process(arg, i):
|
||||
argVal = "arg" + str(i)
|
||||
if arg.type.isGeckoInterface() and not arg.type.unroll().inner.isCallback():
|
||||
argVal += ".r()"
|
||||
return argVal
|
||||
return [(a, process(a, i)) for (i, a) in enumerate(self.arguments)]
|
||||
return [(a, process_arg("arg" + str(i), a)) for (i, a) in enumerate(self.arguments)]
|
||||
|
||||
def isFallible(self):
|
||||
return 'infallible' not in self.extendedAttributes
|
||||
|
@ -4651,12 +4646,7 @@ class CGProxySpecialOperation(CGPerSignatureCall):
|
|||
self.cgRoot.prepend(CGGeneric("rooted!(in(cx) let value = desc.value);"))
|
||||
|
||||
def getArguments(self):
|
||||
def process(arg):
|
||||
argVal = arg.identifier.name
|
||||
if arg.type.isGeckoInterface() and not arg.type.unroll().inner.isCallback():
|
||||
argVal += ".r()"
|
||||
return argVal
|
||||
args = [(a, process(a)) for a in self.arguments]
|
||||
args = [(a, process_arg(a.identifier.name, a)) for a in self.arguments]
|
||||
return args
|
||||
|
||||
def wrap_return_value(self):
|
||||
|
@ -6775,6 +6765,15 @@ def camel_to_upper_snake(s):
|
|||
return "_".join(m.group(0).upper() for m in re.finditer("[A-Z][a-z]*", s))
|
||||
|
||||
|
||||
def process_arg(expr, arg):
|
||||
if arg.type.isGeckoInterface() and not arg.type.unroll().inner.isCallback():
|
||||
if arg.type.nullable() or arg.type.isSequence() or arg.optional:
|
||||
expr += ".r()"
|
||||
else:
|
||||
expr = "&" + expr
|
||||
return expr
|
||||
|
||||
|
||||
class GlobalGenRoots():
|
||||
"""
|
||||
Roots for global codegen.
|
||||
|
|
|
@ -473,7 +473,7 @@ impl<T: Reflectable> RootedReference<T> for Option<Rc<T>> {
|
|||
|
||||
impl<T: Reflectable> RootedReference<T> for Option<Root<T>> {
|
||||
fn r(&self) -> Option<&T> {
|
||||
self.as_ref().map(|root| root.r())
|
||||
self.as_ref().map(|root| &**root)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -615,12 +615,6 @@ impl<T: Reflectable> Root<T> {
|
|||
pub fn from_ref(unrooted: &T) -> Root<T> {
|
||||
Root::new(unsafe { NonZero::new(&*unrooted) })
|
||||
}
|
||||
|
||||
/// Obtain a safe reference to the wrapped JS owned-value that cannot
|
||||
/// outlive the lifetime of this root.
|
||||
pub fn r(&self) -> &T {
|
||||
&**self
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Reflectable> Deref for Root<T> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue