mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Introduce jsmanaged_array
This commit is contained in:
parent
f20361179d
commit
535765907d
2 changed files with 17 additions and 10 deletions
|
@ -303,15 +303,6 @@ macro_rules! make_nonzero_dimension_setter(
|
||||||
/// For use on non-jsmanaged types
|
/// For use on non-jsmanaged types
|
||||||
/// Use #[derive(JSTraceable)] on JS managed types
|
/// Use #[derive(JSTraceable)] on JS managed types
|
||||||
macro_rules! unsafe_no_jsmanaged_fields(
|
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),+) => (
|
($($ty:ident),+) => (
|
||||||
$(
|
$(
|
||||||
#[allow(unsafe_code)]
|
#[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.
|
/// These are used to generate a event handler which has no special case.
|
||||||
macro_rules! define_event_handler(
|
macro_rules! define_event_handler(
|
||||||
($handler: ident, $event_type: ident, $getter: ident, $setter: ident, $setter_fn: ident) => (
|
($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_LEVEL_COUNT: usize = 31;
|
||||||
const MAX_FACE_COUNT: usize = 6;
|
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]
|
#[dom_struct]
|
||||||
pub struct WebGLTexture {
|
pub struct WebGLTexture {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue