Bug 1363555 - Make IS_TEAROFF_CLASS into a function. r=mrbkap
Right now, it is a macro, which causes a warning with clang about
extraneous parentheses. Turning it into a function fixes that and is
also nicer.
MozReview-Commit-ID: KTPA9b6oeUu
--- a/js/xpconnect/src/XPCCallContext.cpp
+++ b/js/xpconnect/src/XPCCallContext.cpp
@@ -10,17 +10,20 @@
#include "jswrapper.h"
#include "jsfriendapi.h"
#include "nsContentUtils.h"
using namespace mozilla;
using namespace xpc;
using namespace JS;
-#define IS_TEAROFF_CLASS(clazz) ((clazz) == &XPC_WN_Tearoff_JSClass)
+static inline bool IsTearoffClass(const js::Class* clazz)
+{
+ return clazz == &XPC_WN_Tearoff_JSClass;
+}
XPCCallContext::XPCCallContext(JSContext* cx,
HandleObject obj /* = nullptr */,
HandleObject funobj /* = nullptr */,
HandleId name /* = JSID_VOID */,
unsigned argc /* = NO_ARGS */,
Value* argv /* = nullptr */,
Value* rval /* = nullptr */)
@@ -59,17 +62,17 @@ XPCCallContext::XPCCallContext(JSContext
if (!unwrapped) {
JS_ReportErrorASCII(mJSContext, "Permission denied to call method on |this|");
mState = INIT_FAILED;
return;
}
const js::Class* clasp = js::GetObjectClass(unwrapped);
if (IS_WN_CLASS(clasp)) {
mWrapper = XPCWrappedNative::Get(unwrapped);
- } else if (IS_TEAROFF_CLASS(clasp)) {
+ } else if (IsTearoffClass(clasp)) {
mTearOff = (XPCWrappedNativeTearOff*)js::GetObjectPrivate(unwrapped);
mWrapper = XPCWrappedNative::Get(
&js::GetReservedSlot(unwrapped,
XPC_WN_TEAROFF_FLAT_OBJECT_SLOT).toObject());
}
if (mWrapper && !mTearOff) {
mScriptable = mWrapper->GetScriptable();
}