Bug 551298, patch A: Move THEBES_INLINE_DECL_REFCOUNTING to xpcom (with s/THEBES/NS/). r=bsmedberg
☠☠ backed out by df2717c37e7f ☠ ☠
authorDaniel Holbert <dholbert@cs.stanford.edu>
Thu, 01 Apr 2010 08:07:23 -0700
changeset 40090 fe801c8a20904bb40bd2a64fd8fb5a0bd463e104
parent 40089 c4992956959a6af9352d5457a3953b8c2d5f5478
child 40091 e94819033c77aab855f2661b9fe3d61c41bfa381
child 40102 df2717c37e7f70da06d2e1f46a288743b3414264
push idunknown
push userunknown
push dateunknown
reviewersbsmedberg
bugs551298
milestone1.9.3a4pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
Bug 551298, patch A: Move THEBES_INLINE_DECL_REFCOUNTING to xpcom (with s/THEBES/NS/). r=bsmedberg
gfx/thebes/public/gfxTypes.h
xpcom/glue/nsISupportsImpl.h
xpcom/glue/nsISupportsUtils.h
--- a/gfx/thebes/public/gfxTypes.h
+++ b/gfx/thebes/public/gfxTypes.h
@@ -93,37 +93,17 @@ enum gfxBreakPriority {
 /**
  * Define refcounting for Thebes.  For now use the stuff from nsISupportsImpl
  * even though it forces the functions to be virtual...
  */
 #include "nsISupportsImpl.h"
 #include "nsAutoPtr.h"
 
 #define THEBES_INLINE_DECL_REFCOUNTING(_class)                                \
-public:                                                                       \
-    nsrefcnt AddRef(void) {                                                   \
-        NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt");             \
-        ++mRefCnt;                                                            \
-        NS_LOG_ADDREF(this, mRefCnt, #_class, sizeof(*this));                 \
-        return mRefCnt;                                                       \
-    }                                                                         \
-    nsrefcnt Release(void) {                                                  \
-        NS_PRECONDITION(0 != mRefCnt, "dup release");                         \
-        --mRefCnt;                                                            \
-        NS_LOG_RELEASE(this, mRefCnt, #_class);                               \
-        if (mRefCnt == 0) {                                                   \
-            mRefCnt = 1; /* stabilize */                                      \
-            NS_DELETEXPCOM(this);                                             \
-            return 0;                                                         \
-        }                                                                     \
-        return mRefCnt;                                                       \
-    }                                                                         \
-protected:                                                                    \
-    nsAutoRefCnt mRefCnt;                                                     \
-public:
+    NS_INLINE_DECL_REFCOUNTING(_class)
 
 #define THEBES_INLINE_DECL_THREADSAFE_REFCOUNTING(_class)                     \
 public:                                                                       \
     nsrefcnt AddRef(void) {                                                   \
         NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt");             \
         nsrefcnt count = PR_AtomicIncrement((PRInt32*)&mRefCnt);              \
         NS_LOG_ADDREF(this, count, #_class, sizeof(*this));                   \
         return count;                                                         \
--- a/xpcom/glue/nsISupportsImpl.h
+++ b/xpcom/glue/nsISupportsImpl.h
@@ -299,16 +299,45 @@ public:
 /**
  * Previously used to initialize the reference count, but no longer needed.
  *
  * DEPRECATED.
  */
 #define NS_INIT_ISUPPORTS() ((void)0)
 
 /**
+ * Use this macro to declare and implement the AddRef & Release methods for a
+ * given non-XPCOM <i>_class</i>.
+ *
+ * The implementations here should match NS_IMPL_ADDREF/NS_IMPL_RELEASE, minus
+ * the nsrefcnt return-value and the NS_ASSERT_OWNINGTHREAD() call.
+ *
+ * @param _class The name of the class implementing the method
+ */
+#define NS_INLINE_DECL_REFCOUNTING(_class)                                    \
+public:                                                                       \
+  void AddRef(void) {                                                         \
+    NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt");                 \
+    ++mRefCnt;                                                                \
+    NS_LOG_ADDREF(this, mRefCnt, #_class, sizeof(*this));                     \
+  }                                                                           \
+  void Release(void) {                                                        \
+    NS_PRECONDITION(0 != mRefCnt, "dup release");                             \
+    --mRefCnt;                                                                \
+    NS_LOG_RELEASE(this, mRefCnt, #_class);                                   \
+    if (mRefCnt == 0) {                                                       \
+      mRefCnt = 1; /* stabilize */                                            \
+      NS_DELETEXPCOM(this);                                                   \
+    }                                                                         \
+  }                                                                           \
+protected:                                                                    \
+  nsAutoRefCnt mRefCnt;                                                       \
+public:
+
+/**
  * Use this macro to implement the AddRef method for a given <i>_class</i>
  * @param _class The name of the class implementing the method
  */
 #define NS_IMPL_ADDREF(_class)                                                \
 NS_IMETHODIMP_(nsrefcnt) _class::AddRef(void)                                 \
 {                                                                             \
   NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt");                   \
   NS_ASSERT_OWNINGTHREAD(_class);                                             \
--- a/xpcom/glue/nsISupportsUtils.h
+++ b/xpcom/glue/nsISupportsUtils.h
@@ -103,20 +103,22 @@ extern "C++" {
 // ...because some one is accidentally including this file inside
 // an |extern "C"|
 
 
 // Making this a |inline| |template| allows |expr| to be evaluated only once,
 // yet still denies you the ability to |AddRef()| an |nsCOMPtr|.
 template <class T>
 inline
-nsrefcnt
+void
 ns_if_addref( T expr )
 {
-    return expr ? expr->AddRef() : 0;
+    if (expr) {
+        expr->AddRef();
+    }
 }
 
 } /* extern "C++" */
 
 /**
  * Macro for adding a reference to an interface that checks for NULL.
  * @param _expr The interface pointer.
  */