Introduce CallbackObject::new().

This commit is contained in:
Ms2ger 2017-01-06 16:23:57 +01:00
parent aa93260f1e
commit 11c21d3b1d

View file

@ -33,12 +33,20 @@ pub enum ExceptionHandling {
/// A common base class for representing IDL callback function and /// A common base class for representing IDL callback function and
/// callback interface types. /// callback interface types.
#[derive(JSTraceable)] #[derive(Default, JSTraceable)]
struct CallbackObject { struct CallbackObject {
/// The underlying `JSObject`. /// The underlying `JSObject`.
callback: Heap<*mut JSObject>, callback: Heap<*mut JSObject>,
} }
impl CallbackObject {
fn new() -> CallbackObject {
CallbackObject {
callback: Heap::default(),
}
}
}
impl PartialEq for CallbackObject { impl PartialEq for CallbackObject {
fn eq(&self, other: &CallbackObject) -> bool { fn eq(&self, other: &CallbackObject) -> bool {
self.callback.get() == other.callback.get() self.callback.get() == other.callback.get()
@ -66,9 +74,7 @@ impl CallbackFunction {
/// Create a new `CallbackFunction` for this object. /// Create a new `CallbackFunction` for this object.
pub fn new() -> CallbackFunction { pub fn new() -> CallbackFunction {
CallbackFunction { CallbackFunction {
object: CallbackObject { object: CallbackObject::new(),
callback: Heap::default(),
},
} }
} }
@ -95,9 +101,7 @@ impl CallbackInterface {
/// Create a new CallbackInterface object for the given `JSObject`. /// Create a new CallbackInterface object for the given `JSObject`.
pub fn new() -> CallbackInterface { pub fn new() -> CallbackInterface {
CallbackInterface { CallbackInterface {
object: CallbackObject { object: CallbackObject::new(),
callback: Heap::default(),
},
} }
} }