Bug 1288870, part 1 - Add NS_INLINE_DECL_REFCOUNTING_WITH_DESTROY. r=froydnj

This is the same basic idea as NS_IMPL_RELEASE_WITH_DESTROY. I need
this because I am making XPCNativeInterface refcounted, and it uses
some weird placement new stuff requiring a special function to
deallocate the object. (It does this to store an array of arbitrary
length inline, presumably for some sort of time or space reason.)

MozReview-Commit-ID: 5I7BgY6YlLl
This commit is contained in:
Andrew McCreight 2016-08-18 15:20:48 -07:00
parent 94e75db5b5
commit f68a2b0443

View File

@ -492,9 +492,11 @@ public:
* given non-XPCOM <i>_class</i>.
*
* @param _class The name of the class implementing the method
* @param _destroy A statement that is executed when the object's
* refcount drops to zero.
* @param optional override Mark the AddRef & Release methods as overrides.
*/
#define NS_INLINE_DECL_REFCOUNTING(_class, ...) \
#define NS_INLINE_DECL_REFCOUNTING_WITH_DESTROY(_class, _destroy, ...) \
public: \
NS_METHOD_(MozExternalRefCountType) AddRef(void) __VA_ARGS__ { \
MOZ_ASSERT_TYPE_OK_FOR_REFCOUNTING(_class) \
@ -511,7 +513,7 @@ public: \
NS_LOG_RELEASE(this, mRefCnt, #_class); \
if (mRefCnt == 0) { \
mRefCnt = 1; /* stabilize */ \
delete this; \
_destroy; \
return 0; \
} \
return mRefCnt; \
@ -522,6 +524,16 @@ protected: \
NS_DECL_OWNINGTHREAD \
public:
/**
* Use this macro to declare and implement the AddRef & Release methods for a
* given non-XPCOM <i>_class</i>.
*
* @param _class The name of the class implementing the method
* @param optional override Mark the AddRef & Release methods as overrides.
*/
#define NS_INLINE_DECL_REFCOUNTING(_class, ...) \
NS_INLINE_DECL_REFCOUNTING_WITH_DESTROY(_class, delete(this), __VA_ARGS__)
#define NS_INLINE_DECL_THREADSAFE_REFCOUNTING_META(_class, _decl, ...) \
public: \
_decl(MozExternalRefCountType) AddRef(void) __VA_ARGS__ { \