Navigation Menu

Skip to content

Commit

Permalink
Don't use RootedReference for Option<T> in codegen anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
nox committed Mar 10, 2019
1 parent 5fe5e5d commit 1744a42
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
6 changes: 4 additions & 2 deletions components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -7250,9 +7250,11 @@ def camel_to_upper_snake(s):

def process_arg(expr, arg):
if arg.type.isGeckoInterface() and not arg.type.unroll().inner.isCallback():
if arg.variadic or arg.type.isSequence() or arg.type.nullable() and arg.optional:
if arg.variadic or arg.type.isSequence():
expr += ".r()"
elif arg.type.nullable() or arg.optional:
elif arg.type.nullable() and arg.optional and not arg.defaultValue:
expr += ".as_ref().map(Option::deref)"
elif arg.type.nullable() or arg.optional and not arg.defaultValue:
expr += ".deref()"
else:
expr = "&" + expr
Expand Down
14 changes: 0 additions & 14 deletions components/script/dom/bindings/root.rs
Expand Up @@ -264,27 +264,13 @@ pub trait RootedReference<'root> {
fn r(&'root self) -> Self::Ref;
}

impl<'root, T: DomObject + 'root> RootedReference<'root> for DomRoot<T> {
type Ref = &'root T;
fn r(&'root self) -> &'root T {
self
}
}

impl<'root, T: JSTraceable + DomObject + 'root> RootedReference<'root> for [Dom<T>] {
type Ref = &'root [&'root T];
fn r(&'root self) -> &'root [&'root T] {
unsafe { mem::transmute(self) }
}
}

impl<'root, T: RootedReference<'root> + 'root> RootedReference<'root> for Option<T> {
type Ref = Option<T::Ref>;
fn r(&'root self) -> Option<T::Ref> {
self.as_ref().map(RootedReference::r)
}
}

/// A traced reference to a DOM object
///
/// This type is critical to making garbage collection work with the DOM,
Expand Down

0 comments on commit 1744a42

Please sign in to comment.