Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up JSTraceable and how we use it #14473

Merged
merged 7 commits into from Dec 7, 2016
Prev

Introduce jsmanaged_array

  • Loading branch information
nox committed Dec 6, 2016
commit 535765907d667466636e0fcaa9a7c6a078cf397d
@@ -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) => (
@@ -26,7 +26,7 @@ pub enum TexParameterValue {
const MAX_LEVEL_COUNT: usize = 31;
const MAX_FACE_COUNT: usize = 6;

unsafe_no_jsmanaged_fields!([ImageInfo; MAX_LEVEL_COUNT * MAX_FACE_COUNT]);
jsmanaged_array!(MAX_LEVEL_COUNT * MAX_FACE_COUNT);

#[dom_struct]
pub struct WebGLTexture {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.