aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen
diff options
context:
space:
mode:
authorTetsuharu OHZEKI <saneyuki.snyk@gmail.com>2015-01-25 02:06:25 +0900
committerTetsuharu OHZEKI <saneyuki.snyk@gmail.com>2015-02-01 01:54:37 +0900
commit80a4911f9c44aa544beb5d5ee6e45cbe7b166228 (patch)
tree8e1182129720ffd70a432dba0ef9c537dc0654ce /components/script/dom/bindings/codegen
parent6b1e2bd11ca73777283ad4953e8fc07a3323eca0 (diff)
downloadservo-80a4911f9c44aa544beb5d5ee6e45cbe7b166228.tar.gz
servo-80a4911f9c44aa544beb5d5ee6e45cbe7b166228.zip
Add BarCast::to_layout_js<T>().
Diffstat (limited to 'components/script/dom/bindings/codegen')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 795204466df..1983cbe41d5 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -5220,7 +5220,7 @@ class GlobalGenRoots():
descriptors = config.getDescriptors(register=True, isCallback=False)
allprotos = [CGGeneric("#![allow(unused_imports)]\n"),
CGGeneric("use dom::types::*;\n"),
- CGGeneric("use dom::bindings::js::{JS, JSRef, Temporary};\n"),
+ CGGeneric("use dom::bindings::js::{JS, JSRef, LayoutJS, Temporary};\n"),
CGGeneric("use dom::bindings::trace::JSTraceable;\n"),
CGGeneric("use dom::bindings::utils::Reflectable;\n"),
CGGeneric("use js::jsapi::JSTracer;\n\n"),
@@ -5280,6 +5280,17 @@ pub trait ${castTraitName} : Sized {
}
#[inline(always)]
+ #[allow(unrooted_must_root)]
+ fn to_layout_js<T: ${toBound}+Reflectable>(base: &LayoutJS<T>) -> Option<LayoutJS<Self>> {
+ unsafe {
+ match (*base.unsafe_get()).${checkFn}() {
+ true => Some(base.transmute_copy()),
+ false => None
+ }
+ }
+ }
+
+ #[inline(always)]
fn from_ref<'a, T: ${fromBound}+Reflectable>(derived: JSRef<'a, T>) -> JSRef<'a, Self> {
unsafe { derived.transmute() }
}