diff options
author | Kasey Carrothers <kaseyc.808@gmail.com> | 2014-10-11 16:02:59 -0700 |
---|---|---|
committer | Kasey Carrothers <kaseyc.808@gmail.com> | 2014-10-14 19:06:53 -0700 |
commit | 6d91e92c90caa61107ac3a4a6f11b92b3a363d18 (patch) | |
tree | abb21fba50a9bc8472412c8befed4f1414a8adce /components/script/dom/bindings/codegen | |
parent | 3eb6b17137964fc12779eca9597fa77930440138 (diff) | |
download | servo-6d91e92c90caa61107ac3a4a6f11b92b3a363d18.tar.gz servo-6d91e92c90caa61107ac3a4a6f11b92b3a363d18.zip |
Add a to_js method to the casting trait code in CodegenRust.py
Replace the manual checks and calls to transmute_copy in /layout/wrapper.rs with calls to to_js
Fixes #3616
Diffstat (limited to 'components/script/dom/bindings/codegen')
-rw-r--r-- | components/script/dom/bindings/codegen/CodegenRust.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 2981cbf341a..bca334de6ea 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -5481,6 +5481,17 @@ class GlobalGenRoots(): } #[inline(always)] + #[allow(unrooted_must_root)] + fn to_js<T: ${toBound}+Reflectable>(base: &JS<T>) -> Option<JS<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() } } |