aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCameron McCormack <cam@mcc.id.au>2016-08-12 17:00:36 +0800
committerCameron McCormack <cam@mcc.id.au>2016-09-22 15:29:15 +0800
commitbd23790c093765a5bde6d2113a18334f7bb105d7 (patch)
treeacd0a045d180a71bfd3f5d29311a5dbdfa1ce628
parent614e9ca840baacfa427ec78db99258a83b75e135 (diff)
downloadservo-bd23790c093765a5bde6d2113a18334f7bb105d7.tar.gz
servo-bd23790c093765a5bde6d2113a18334f7bb105d7.zip
Rename GeckoArc macro so it sounds like it's useful for already-threadsafely-refcounted objects.
-rw-r--r--ports/geckolib/gecko_bindings/ptr.rs25
1 files changed, 14 insertions, 11 deletions
diff --git a/ports/geckolib/gecko_bindings/ptr.rs b/ports/geckolib/gecko_bindings/ptr.rs
index 9cdabee818b..f17762247b4 100644
--- a/ports/geckolib/gecko_bindings/ptr.rs
+++ b/ports/geckolib/gecko_bindings/ptr.rs
@@ -7,17 +7,20 @@ use heapsize::HeapSizeOf;
use std::fmt::{self, Debug};
// Defines an Arc-like type that manages a refcounted Gecko object stored
-// in a ThreadSafeFooHolder smart pointer. Used in tandem with the
-// NS_DECL_HOLDER_FFI_REFCOUNTING-defined types and functions in Gecko.
-macro_rules! define_holder_arc {
- ($arc_type:ident, $name:ident, $holder_type:ident, $addref: ident, $release: ident) => (
+// in a ThreadSafeFooHolder smart pointer (for those Gecko classes that
+// do not have thread-safe refcounting support) or as raw pointers (for
+// those that do have thread-safe refcounting support). Used in tandem
+// with the NS_DECL_(HOLDER|THREADSAFE)_FFI_REFCOUNTING-defined types and
+// functions in Gecko.
+macro_rules! define_arc {
+ ($arc_type:ident, $name:ident, $gecko_type:ident, $addref: ident, $release: ident) => (
#[derive(PartialEq)]
pub struct $arc_type {
- ptr: *mut $holder_type,
+ ptr: *mut $gecko_type,
}
impl $arc_type {
- pub fn new(data: *mut $holder_type) -> $arc_type {
+ pub fn new(data: *mut $gecko_type) -> $arc_type {
debug_assert!(!data.is_null());
unsafe { $addref(data); }
$arc_type {
@@ -25,7 +28,7 @@ macro_rules! define_holder_arc {
}
}
- pub fn as_raw(&self) -> *mut $holder_type { self.ptr }
+ pub fn as_raw(&self) -> *mut $gecko_type { self.ptr }
}
unsafe impl Send for $arc_type {}
@@ -55,7 +58,7 @@ macro_rules! define_holder_arc {
)
}
-define_holder_arc!(GeckoArcPrincipal, Principal, ThreadSafePrincipalHolder,
- Gecko_AddRefPrincipalArbitraryThread, Gecko_ReleasePrincipalArbitraryThread);
-define_holder_arc!(GeckoArcURI, URI, ThreadSafeURIHolder,
- Gecko_AddRefURIArbitraryThread, Gecko_ReleaseURIArbitraryThread);
+define_arc!(GeckoArcPrincipal, Principal, ThreadSafePrincipalHolder,
+ Gecko_AddRefPrincipalArbitraryThread, Gecko_ReleasePrincipalArbitraryThread);
+define_arc!(GeckoArcURI, URI, ThreadSafeURIHolder,
+ Gecko_AddRefURIArbitraryThread, Gecko_ReleaseURIArbitraryThread);