Refactor #[jstraceable] to #[derive(JSTraceable)]

fixes #6524
This commit is contained in:
David Winslow 2015-07-01 16:31:07 -04:00
parent e958d92be6
commit 4cf46bff2d
51 changed files with 97 additions and 137 deletions

View file

@ -33,8 +33,7 @@ pub enum ExceptionHandling {
}
/// A common base class for representing IDL callback function types.
#[derive(PartialEq)]
#[jstraceable]
#[derive(JSTraceable, PartialEq)]
pub struct CallbackFunction {
object: CallbackObject
}
@ -57,8 +56,7 @@ impl CallbackFunction {
}
/// A common base class for representing IDL callback interface types.
#[derive(PartialEq)]
#[jstraceable]
#[derive(JSTraceable, PartialEq)]
pub struct CallbackInterface {
object: CallbackObject
}
@ -66,7 +64,7 @@ pub struct CallbackInterface {
/// A common base class for representing IDL callback function and
/// callback interface types.
#[allow(raw_pointer_derive)]
#[jstraceable]
#[derive(JSTraceable)]
struct CallbackObject {
/// The underlying `JSObject`.
callback: Heap<*mut JSObject>,

View file

@ -3189,8 +3189,7 @@ class CGEnum(CGThing):
decl = """\
#[repr(usize)]
#[derive(PartialEq, Copy, Clone)]
#[jstraceable]
#[derive(JSTraceable, PartialEq, Copy, Clone)]
pub enum %s {
%s
}
@ -5181,7 +5180,7 @@ class CGCallback(CGClass):
bases=[ClassBase(baseName)],
constructors=self.getConstructors(),
methods=realMethods+getters+setters,
decorators="#[derive(PartialEq)]#[jstraceable]")
decorators="#[derive(JSTraceable, PartialEq)]")
def getConstructors(self):
return [ClassConstructor(

View file

@ -46,7 +46,7 @@ pub enum GlobalRoot {
/// A traced reference to a global object, for use in fields of traced Rust
/// structures.
#[jstraceable]
#[derive(JSTraceable)]
#[must_root]
pub enum GlobalField {
/// A field for a `Window` object.

View file

@ -164,7 +164,7 @@ impl<T: Reflectable> HeapGCValue for JS<T> {
/// Must be used in place of traditional interior mutability to ensure proper
/// GC barriers are enforced.
#[must_root]
#[jstraceable]
#[derive(JSTraceable)]
pub struct MutHeapJSVal {
val: UnsafeCell<Heap<JSVal>>,
}
@ -196,7 +196,7 @@ impl MutHeapJSVal {
/// A holder that provides interior mutability for GC-managed values such as
/// `JS<T>`.
#[must_root]
#[jstraceable]
#[derive(JSTraceable)]
pub struct MutHeap<T: HeapGCValue+Copy> {
val: Cell<T>,
}
@ -225,7 +225,7 @@ impl<T: HeapGCValue+Copy> MutHeap<T> {
/// place of traditional internal mutability to ensure that the proper GC
/// barriers are enforced.
#[must_root]
#[jstraceable]
#[derive(JSTraceable)]
pub struct MutNullableHeap<T: HeapGCValue+Copy> {
ptr: Cell<Option<T>>
}

View file

@ -9,8 +9,7 @@ use num::Float;
use std::ops::Deref;
/// Encapsulates the IDL restricted float type.
#[derive(Clone,Eq,PartialEq)]
#[jstraceable]
#[derive(JSTraceable,Clone,Eq,PartialEq)]
pub struct Finite<T: Float>(T);
unsafe impl<T: Float> Zeroable for Finite<T> {}

View file

@ -12,8 +12,7 @@ use std::str;
use std::str::FromStr;
/// Encapsulates the IDL `ByteString` type.
#[derive(Clone,Eq,PartialEq)]
#[jstraceable]
#[derive(JSTraceable,Clone,Eq,PartialEq)]
pub struct ByteString(Vec<u8>);
impl ByteString {

View file

@ -12,7 +12,7 @@
//! phase. (This happens through `JSClass.trace` for non-proxy bindings, and
//! through `ProxyTraps.trace` otherwise.)
//! 2. `_trace` calls `Foo::trace()` (an implementation of `JSTraceable`).
//! This is typically derived via a `#[dom_struct]` (implies `#[jstraceable]`) annotation.
//! This is typically derived via a `#[dom_struct]` (implies `#[derive(JSTraceable)]`) annotation.
//! Non-JS-managed types have an empty inline `trace()` method,
//! achieved via `no_jsmanaged_fields!` or similar.
//! 3. For all fields, `Foo::trace()`
@ -410,7 +410,7 @@ impl RootedTraceableSet {
/// If you have GC things like *mut JSObject or JSVal, use jsapi::Rooted.
/// If you have an arbitrary number of Reflectables to root, use RootedVec<JS<T>>
/// If you know what you're doing, use this.
#[jstraceable]
#[derive(JSTraceable)]
pub struct RootedTraceable<'a, T: 'a + JSTraceable> {
ptr: &'a T
}
@ -434,7 +434,7 @@ impl<'a, T: JSTraceable> Drop for RootedTraceable<'a, T> {
/// Must be a reflectable
#[allow(unrooted_must_root)]
#[no_move]
#[jstraceable]
#[derive(JSTraceable)]
pub struct RootedVec<T: JSTraceable + Reflectable> {
v: Vec<T>
}

View file

@ -65,7 +65,7 @@ use string_cache::{Atom, Namespace};
pub struct WindowProxyHandler(pub *const libc::c_void);
#[allow(raw_pointer_derive)]
#[jstraceable]
#[derive(JSTraceable)]
/// Static data associated with a global object.
pub struct GlobalStaticData {
/// The WindowProxy proxy handler for this global.