Introduce jsmanaged_array

This commit is contained in:
Anthony Ramine 2016-12-06 12:40:46 -10:00
parent f20361179d
commit 535765907d
2 changed files with 17 additions and 10 deletions

View file

@ -303,15 +303,6 @@ macro_rules! make_nonzero_dimension_setter(
/// For use on non-jsmanaged types
/// Use #[derive(JSTraceable)] on JS managed types
macro_rules! unsafe_no_jsmanaged_fields(
([$ty:ident; $count:expr]) => (
#[allow(unsafe_code)]
unsafe impl $crate::dom::bindings::trace::JSTraceable for [$ty; $count] {
#[inline]
unsafe fn trace(&self, _: *mut ::js::jsapi::JSTracer) {
// Do nothing
}
}
);
($($ty:ident),+) => (
$(
#[allow(unsafe_code)]
@ -325,6 +316,22 @@ macro_rules! unsafe_no_jsmanaged_fields(
);
);
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]
unsafe fn trace(&self, tracer: *mut ::js::jsapi::JSTracer) {
for v in self.iter() {
v.trace(tracer);
}
}
}
);
);
/// These are used to generate a event handler which has no special case.
macro_rules! define_event_handler(
($handler: ident, $event_type: ident, $getter: ident, $setter: ident, $setter_fn: ident) => (