Bug 1363555 - Make IS_TEAROFF_CLASS into a function. r=mrbkap
authorAndrew McCreight <continuation@gmail.com>
Tue, 09 May 2017 15:34:02 -0700
changeset 358499 2dc612bec44b88be0bf484a0e0b3901ada89481e
parent 358498 424daa127a04c8295dee7ca320417ad8f79dfcbc
child 358500 1b51aa9afd06b56998da103ae853db5cac04ad8f
push id42726
push useramccreight@mozilla.com
push dateTue, 16 May 2017 00:52:00 +0000
treeherderautoland@2dc612bec44b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs1363555
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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();
     }