aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/callback.rs
diff options
context:
space:
mode:
authorMs2ger <Ms2ger@gmail.com>2017-01-06 16:23:57 +0100
committerMs2ger <Ms2ger@gmail.com>2017-01-09 09:47:34 +0100
commit11c21d3b1d0f2f202d505c79cff20bf7c883d78e (patch)
tree4bc3cf51802a8a88b6346aca43a2252b9b41e1f4 /components/script/dom/bindings/callback.rs
parentaa93260f1e415d9e00acbcf07879004f110947b2 (diff)
downloadservo-11c21d3b1d0f2f202d505c79cff20bf7c883d78e.tar.gz
servo-11c21d3b1d0f2f202d505c79cff20bf7c883d78e.zip
Introduce CallbackObject::new().
Diffstat (limited to 'components/script/dom/bindings/callback.rs')
-rw-r--r--components/script/dom/bindings/callback.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/components/script/dom/bindings/callback.rs b/components/script/dom/bindings/callback.rs
index a9846477ac4..897cc3bd39f 100644
--- a/components/script/dom/bindings/callback.rs
+++ b/components/script/dom/bindings/callback.rs
@@ -33,12 +33,20 @@ pub enum ExceptionHandling {
/// A common base class for representing IDL callback function and
/// callback interface types.
-#[derive(JSTraceable)]
+#[derive(Default, JSTraceable)]
struct CallbackObject {
/// The underlying `JSObject`.
callback: Heap<*mut JSObject>,
}
+impl CallbackObject {
+ fn new() -> CallbackObject {
+ CallbackObject {
+ callback: Heap::default(),
+ }
+ }
+}
+
impl PartialEq for CallbackObject {
fn eq(&self, other: &CallbackObject) -> bool {
self.callback.get() == other.callback.get()
@@ -66,9 +74,7 @@ impl CallbackFunction {
/// Create a new `CallbackFunction` for this object.
pub fn new() -> CallbackFunction {
CallbackFunction {
- object: CallbackObject {
- callback: Heap::default(),
- },
+ object: CallbackObject::new(),
}
}
@@ -95,9 +101,7 @@ impl CallbackInterface {
/// Create a new CallbackInterface object for the given `JSObject`.
pub fn new() -> CallbackInterface {
CallbackInterface {
- object: CallbackObject {
- callback: Heap::default(),
- },
+ object: CallbackObject::new(),
}
}