aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/macros.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-12-06 18:31:46 -0800
committerGitHub <noreply@github.com>2016-12-06 18:31:46 -0800
commit32c121b6ff4a3f9336e742ecf1a96b187986fde0 (patch)
tree678963322c292d39a286a78f299def638d6c2c17 /components/script/dom/macros.rs
parentb54cfc9f259e72ea26e68ec8a7b1d617cf0812d3 (diff)
parent535765907d667466636e0fcaa9a7c6a078cf397d (diff)
downloadservo-32c121b6ff4a3f9336e742ecf1a96b187986fde0.tar.gz
servo-32c121b6ff4a3f9336e742ecf1a96b187986fde0.zip
Auto merge of #14473 - nox:raf-safety, r=Ms2ger
Clean up JSTraceable and how we use it <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14473) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/macros.rs')
-rw-r--r--components/script/dom/macros.rs39
1 files changed, 16 insertions, 23 deletions
diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs
index 53c5bd20115..99b06bae39d 100644
--- a/components/script/dom/macros.rs
+++ b/components/script/dom/macros.rs
@@ -302,38 +302,31 @@ macro_rules! make_nonzero_dimension_setter(
/// For use on non-jsmanaged types
/// Use #[derive(JSTraceable)] on JS managed types
-macro_rules! no_jsmanaged_fields(
- ([$ty:ident; $count:expr]) => (
- impl $crate::dom::bindings::trace::JSTraceable for [$ty; $count] {
- #[inline]
- fn trace(&self, _: *mut ::js::jsapi::JSTracer) {
- // Do nothing
- }
- }
- );
+macro_rules! unsafe_no_jsmanaged_fields(
($($ty:ident),+) => (
$(
- impl $crate::dom::bindings::trace::JSTraceable for $ty {
+ #[allow(unsafe_code)]
+ unsafe impl $crate::dom::bindings::trace::JSTraceable for $ty {
#[inline]
- fn trace(&self, _: *mut ::js::jsapi::JSTracer) {
+ unsafe fn trace(&self, _: *mut ::js::jsapi::JSTracer) {
// Do nothing
}
}
)+
);
- ($ty:ident<$($gen:ident),+>) => (
- impl<$($gen),+> $crate::dom::bindings::trace::JSTraceable for $ty<$($gen),+> {
- #[inline]
- fn trace(&self, _: *mut ::js::jsapi::JSTracer) {
- // Do nothing
- }
- }
- );
- ($ty:ident<$($gen:ident: $bound:ident),+>) => (
- impl<$($gen: $bound),+> $crate::dom::bindings::trace::JSTraceable for $ty<$($gen),+> {
+);
+
+macro_rules! jsmanaged_array(
+ ($count:expr) => (
+ #[allow(unsafe_code)]
+ unsafe impl<T> $crate::dom::bindings::trace::JSTraceable for [T; $count]
+ where T: $crate::dom::bindings::trace::JSTraceable
+ {
#[inline]
- fn trace(&self, _: *mut ::js::jsapi::JSTracer) {
- // Do nothing
+ unsafe fn trace(&self, tracer: *mut ::js::jsapi::JSTracer) {
+ for v in self.iter() {
+ v.trace(tracer);
+ }
}
}
);