Bug 1329846 (part 2) - Remove NATIVE_HAS_FLAG. r=mccr8.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 11 Jan 2017 07:40:19 +1100
changeset 374219 18ff0b6063121d502dd610560512ff91f46c97e9
parent 374218 105d7762f4b06db69cef6fffd2129890dd9fbbb0
child 374220 b371ef382f1a65fc2699c741ca9b4833ce56b77d
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1329846
milestone53.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 1329846 (part 2) - Remove NATIVE_HAS_FLAG. r=mccr8. It's only used in three places, and it no longer makes the code more readable.
js/xpconnect/src/XPCWrapper.h
js/xpconnect/wrappers/WrapperFactory.cpp
js/xpconnect/wrappers/XrayWrapper.cpp
--- a/js/xpconnect/src/XPCWrapper.h
+++ b/js/xpconnect/src/XPCWrapper.h
@@ -6,24 +6,16 @@
 
 #ifndef XPC_WRAPPER_H
 #define XPC_WRAPPER_H 1
 
 #include "js/TypeDecls.h"
 
 namespace XPCNativeWrapper {
 
-// Given an XPCWrappedNative pointer and the name of a function on
-// nsIXPCScriptable corresponding with a flag, returns 'true' if the flag is
-// set.
-// XXX Convert to using GetFlags() and not a macro.
-#define NATIVE_HAS_FLAG(_wn, _flag)                                           \
-  ((_wn)->GetScriptable() &&                                                  \
-   (_wn)->GetScriptable()->_flag())
-
 bool
 AttachNewConstructorObject(JSContext* aCx, JS::HandleObject aGlobalObject);
 
 } // namespace XPCNativeWrapper
 
 // This namespace wraps some common functionality between the three existing
 // wrappers. Its main purpose is to allow XPCCrossOriginWrapper to act both
 // as an XPCSafeJSObjectWrapper and as an XPCNativeWrapper when required to
--- a/js/xpconnect/wrappers/WrapperFactory.cpp
+++ b/js/xpconnect/wrappers/WrapperFactory.cpp
@@ -198,17 +198,17 @@ WrapperFactory::PrepareForWrapping(JSCon
 
     XPCWrappedNative* wn = XPCWrappedNative::Get(obj);
 
     JSAutoCompartment ac(cx, obj);
     XPCCallContext ccx(cx, obj);
     RootedObject wrapScope(cx, scope);
 
     {
-        if (NATIVE_HAS_FLAG(&ccx, WantPreCreate)) {
+        if (ccx.GetScriptable() && ccx.GetScriptable()->WantPreCreate()) {
             // We have a precreate hook. This object might enforce that we only
             // ever create JS object for it.
 
             // Note: this penalizes objects that only have one wrapper, but are
             // being accessed across compartments. We would really prefer to
             // replace the above code with a test that says "do you only have one
             // wrapper?"
             nsresult rv = wn->GetScriptable()->
--- a/js/xpconnect/wrappers/XrayWrapper.cpp
+++ b/js/xpconnect/wrappers/XrayWrapper.cpp
@@ -1568,17 +1568,17 @@ XPCWrappedNativeXrayTraits::createHolder
 
 bool
 XPCWrappedNativeXrayTraits::call(JSContext* cx, HandleObject wrapper,
                                  const JS::CallArgs& args,
                                  const js::Wrapper& baseInstance)
 {
     // Run the call hook of the wrapped native.
     XPCWrappedNative* wn = getWN(wrapper);
-    if (NATIVE_HAS_FLAG(wn, WantCall)) {
+    if (wn->GetScriptable() && wn->GetScriptable()->WantCall()) {
         XPCCallContext ccx(cx, wrapper, nullptr, JSID_VOIDHANDLE, args.length(),
                            args.array(), args.rval().address());
         if (!ccx.IsValid())
             return false;
         bool ok = true;
         nsresult rv = wn->GetScriptable()->Call(wn, cx, wrapper, args, &ok);
         if (NS_FAILED(rv)) {
             if (ok)
@@ -1593,17 +1593,17 @@ XPCWrappedNativeXrayTraits::call(JSConte
 
 bool
 XPCWrappedNativeXrayTraits::construct(JSContext* cx, HandleObject wrapper,
                                       const JS::CallArgs& args,
                                       const js::Wrapper& baseInstance)
 {
     // Run the construct hook of the wrapped native.
     XPCWrappedNative* wn = getWN(wrapper);
-    if (NATIVE_HAS_FLAG(wn, WantConstruct)) {
+    if (wn->GetScriptable() && wn->GetScriptable()->WantConstruct()) {
         XPCCallContext ccx(cx, wrapper, nullptr, JSID_VOIDHANDLE, args.length(),
                            args.array(), args.rval().address());
         if (!ccx.IsValid())
             return false;
         bool ok = true;
         nsresult rv =
             wn->GetScriptable()->Construct(wn, cx, wrapper, args, &ok);
         if (NS_FAILED(rv)) {