author | Daniel Holbert <dholbert@cs.stanford.edu> |
Thu, 01 Apr 2010 09:40:30 -0700 | |
changeset 40102 | df2717c37e7f70da06d2e1f46a288743b3414264 |
parent 40090 | fe801c8a20904bb40bd2a64fd8fb5a0bd463e104 |
child 40103 | 4bd4aee44c44542bbdcf469e6158f3285d6bdfd2 |
push id | unknown |
push user | unknown |
push date | unknown |
bugs | 551298 |
milestone | 1.9.3a4pre |
backs out | fe801c8a20904bb40bd2a64fd8fb5a0bd463e104 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
|
--- a/gfx/thebes/public/gfxTypes.h +++ b/gfx/thebes/public/gfxTypes.h @@ -93,17 +93,37 @@ 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) \ - NS_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: #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,45 +299,16 @@ 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,22 +103,20 @@ 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 -void +nsrefcnt ns_if_addref( T expr ) { - if (expr) { - expr->AddRef(); - } + return expr ? expr->AddRef() : 0; } } /* extern "C++" */ /** * Macro for adding a reference to an interface that checks for NULL. * @param _expr The interface pointer. */