Bug 1363555 - Make IS_TEAROFF_CLASS into a function. r=mrbkap draft
authorAndrew McCreight <continuation@gmail.com>
Tue, 09 May 2017 15:34:02 -0700
changeset 576384 2a509146c2481bfb01b2912554c7f698d3d0bf98
parent 574259 38f862749aed4e9a874182a9019e0671289088b0
child 576385 df5273354784a4e198f6e6c169f590a8056b00bb
push id58351
push userbmo:continuation@gmail.com
push dateThu, 11 May 2017 18:06:19 +0000
reviewersmrbkap
bugs1363555
milestone55.0a1
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
js/xpconnect/src/XPCCallContext.cpp
--- 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();
     }