Bug 1330235 - Remove NS_STDCALL_FUNCPROTO and replace its usage with decltype. r?froydnj draft
authorXidorn Quan <me@upsuper.org>
Tue, 09 May 2017 23:00:37 +1000
changeset 574855 0dd187d2a5c3448301ab41103ff60c6c26ed55c3
parent 574854 161f4dbaa10b0a5fba71a07bf75cc6c65e3a3eed
child 627714 903a4ec3dc710420903c2d38a98bfb50717ac835
push id57832
push userxquan@mozilla.com
push dateTue, 09 May 2017 13:32:51 +0000
reviewersfroydnj
bugs1330235
milestone55.0a1
Bug 1330235 - Remove NS_STDCALL_FUNCPROTO and replace its usage with decltype. r?froydnj MozReview-Commit-ID: 5jrTqTfDzSk
dom/base/nsContentPolicy.h
layout/style/nsCSSRules.h
rdf/base/nsRDFContentSink.cpp
toolkit/components/places/nsNavHistoryQuery.cpp
widget/cocoa/nsMenuItemIconX.mm
xpcom/base/nscore.h
--- a/dom/base/nsContentPolicy.h
+++ b/dom/base/nsContentPolicy.h
@@ -30,29 +30,18 @@ class nsContentPolicy : public nsIConten
     //Array of policies
     nsCategoryCache<nsIContentPolicy> mPolicies;
     nsCategoryCache<nsISimpleContentPolicy> mSimplePolicies;
 
     nsCOMPtr<nsIContentPolicy> mMixedContentBlocker;
     nsCOMPtr<nsIContentPolicy> mCSPService;
 
     //Helper type for CheckPolicy
-    typedef
-    NS_STDCALL_FUNCPROTO(nsresult, CPMethod, nsIContentPolicy,
-                         ShouldProcess,
-                         (uint32_t, nsIURI*, nsIURI*, nsISupports*,
-                           const nsACString &, nsISupports*, nsIPrincipal*,
-                           int16_t*));
-
-    typedef
-    NS_STDCALL_FUNCPROTO(nsresult, SCPMethod, nsISimpleContentPolicy,
-                         ShouldProcess,
-                         (uint32_t, nsIURI*, nsIURI*, nsIDOMElement*, bool,
-                           const nsACString &, nsISupports*, nsIPrincipal*,
-                           int16_t*));
+    typedef decltype(&nsIContentPolicy::ShouldProcess) CPMethod;
+    typedef decltype(&nsISimpleContentPolicy::ShouldProcess) SCPMethod;
 
     //Helper method that applies policyMethod across all policies in mPolicies
     // with the given parameters
     nsresult CheckPolicy(CPMethod policyMethod, SCPMethod simplePolicyMethod,
                          nsContentPolicyType contentType,
                          nsIURI *aURI, nsIURI *origURI,
                          nsISupports *requestingContext,
                          const nsACString &mimeGuess, nsISupports *extra,
--- a/layout/style/nsCSSRules.h
+++ b/layout/style/nsCSSRules.h
@@ -562,18 +562,17 @@ public:
   void SetDesc(nsCSSCounterDesc aDescID, const nsCSSValue& aValue);
 
   virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aGivenProto) override;
 
 private:
-  typedef NS_STDCALL_FUNCPROTO(nsresult, Getter, nsCSSCounterStyleRule,
-                               GetSymbols, (nsAString&));
+  typedef decltype(&nsCSSCounterStyleRule::GetSymbols) Getter;
   static const Getter kGetters[];
 
   nsresult GetDescriptor(nsCSSCounterDesc aDescID, nsAString& aValue);
   nsresult SetDescriptor(nsCSSCounterDesc aDescID, const nsAString& aValue);
 
   nsCOMPtr<nsIAtom> mName;
   nsCSSValue mValues[eCSSCounterDesc_COUNT];
   uint32_t   mGeneration;
--- a/rdf/base/nsRDFContentSink.cpp
+++ b/rdf/base/nsRDFContentSink.cpp
@@ -80,27 +80,18 @@ enum RDFContentSinkState {
 
 enum RDFContentSinkParseMode {
     eRDFContentSinkParseMode_Resource,
     eRDFContentSinkParseMode_Literal,
     eRDFContentSinkParseMode_Int,
     eRDFContentSinkParseMode_Date
 };
 
-typedef
-NS_STDCALL_FUNCPROTO(nsresult,
-                     nsContainerTestFn,
-                     nsIRDFContainerUtils, IsAlt,
-                     (nsIRDFDataSource*, nsIRDFResource*, bool*));
-
-typedef
-NS_STDCALL_FUNCPROTO(nsresult,
-                     nsMakeContainerFn,
-                     nsIRDFContainerUtils, MakeAlt,
-                     (nsIRDFDataSource*, nsIRDFResource*, nsIRDFContainer**));
+typedef decltype(&nsIRDFContainerUtils::IsAlt) nsContainerTestFn;
+typedef decltype(&nsIRDFContainerUtils::MakeAlt) nsMakeContainerFn;
 
 class RDFContentSinkImpl : public nsIRDFContentSink,
                            public nsIExpatSink
 {
 public:
     RDFContentSinkImpl();
 
     // nsISupports
--- a/toolkit/components/places/nsNavHistoryQuery.cpp
+++ b/toolkit/components/places/nsNavHistoryQuery.cpp
@@ -51,59 +51,47 @@ public:
 };
 
 static nsresult TokenizeQueryString(const nsACString& aQuery,
                                     nsTArray<QueryKeyValuePair>* aTokens);
 static nsresult ParseQueryBooleanString(const nsCString& aString,
                                         bool* aValue);
 
 // query getters
-typedef NS_STDCALL_FUNCPROTO(nsresult, BoolQueryGetter, nsINavHistoryQuery,
-                             GetOnlyBookmarked, (bool*));
-typedef NS_STDCALL_FUNCPROTO(nsresult, Uint32QueryGetter, nsINavHistoryQuery,
-                             GetBeginTimeReference, (uint32_t*));
-typedef NS_STDCALL_FUNCPROTO(nsresult, Int64QueryGetter, nsINavHistoryQuery,
-                             GetBeginTime, (int64_t*));
+typedef decltype(&nsINavHistoryQuery::GetOnlyBookmarked) BoolQueryGetter;
+typedef decltype(&nsINavHistoryQuery::GetBeginTimeReference) Uint32QueryGetter;
+typedef decltype(&nsINavHistoryQuery::GetBeginTime) Int64QueryGetter;
 static void AppendBoolKeyValueIfTrue(nsACString& aString,
                                      const nsCString& aName,
                                      nsINavHistoryQuery* aQuery,
                                      BoolQueryGetter getter);
 static void AppendUint32KeyValueIfNonzero(nsACString& aString,
                                           const nsCString& aName,
                                           nsINavHistoryQuery* aQuery,
                                           Uint32QueryGetter getter);
 static void AppendInt64KeyValueIfNonzero(nsACString& aString,
                                          const nsCString& aName,
                                          nsINavHistoryQuery* aQuery,
                                          Int64QueryGetter getter);
 
 // query setters
-typedef NS_STDCALL_FUNCPROTO(nsresult, BoolQuerySetter, nsINavHistoryQuery,
-                             SetOnlyBookmarked, (bool));
-typedef NS_STDCALL_FUNCPROTO(nsresult, Uint32QuerySetter, nsINavHistoryQuery,
-                             SetBeginTimeReference, (uint32_t));
-typedef NS_STDCALL_FUNCPROTO(nsresult, Int64QuerySetter, nsINavHistoryQuery,
-                             SetBeginTime, (int64_t));
+typedef decltype(&nsINavHistoryQuery::SetOnlyBookmarked) BoolQuerySetter;
+typedef decltype(&nsINavHistoryQuery::SetBeginTimeReference) Uint32QuerySetter;
+typedef decltype(&nsINavHistoryQuery::SetBeginTime) Int64QuerySetter;
 static void SetQueryKeyBool(const nsCString& aValue, nsINavHistoryQuery* aQuery,
                             BoolQuerySetter setter);
 static void SetQueryKeyUint32(const nsCString& aValue, nsINavHistoryQuery* aQuery,
                               Uint32QuerySetter setter);
 static void SetQueryKeyInt64(const nsCString& aValue, nsINavHistoryQuery* aQuery,
                              Int64QuerySetter setter);
 
 // options setters
-typedef NS_STDCALL_FUNCPROTO(nsresult, BoolOptionsSetter,
-                             nsINavHistoryQueryOptions,
-                             SetExpandQueries, (bool));
-typedef NS_STDCALL_FUNCPROTO(nsresult, Uint32OptionsSetter,
-                             nsINavHistoryQueryOptions,
-                             SetMaxResults, (uint32_t));
-typedef NS_STDCALL_FUNCPROTO(nsresult, Uint16OptionsSetter,
-                             nsINavHistoryQueryOptions,
-                             SetResultType, (uint16_t));
+typedef decltype(&nsINavHistoryQueryOptions::SetExpandQueries) BoolOptionsSetter;
+typedef decltype(&nsINavHistoryQueryOptions::SetMaxResults) Uint32OptionsSetter;
+typedef decltype(&nsINavHistoryQueryOptions::SetResultType) Uint16OptionsSetter;
 static void SetOptionsKeyBool(const nsCString& aValue,
                               nsINavHistoryQueryOptions* aOptions,
                               BoolOptionsSetter setter);
 static void SetOptionsKeyUint16(const nsCString& aValue,
                                 nsINavHistoryQueryOptions* aOptions,
                                 Uint16OptionsSetter setter);
 static void SetOptionsKeyUint32(const nsCString& aValue,
                                 nsINavHistoryQueryOptions* aOptions,
--- a/widget/cocoa/nsMenuItemIconX.mm
+++ b/widget/cocoa/nsMenuItemIconX.mm
@@ -45,18 +45,17 @@
 #include "nsIContentPolicy.h"
 
 using mozilla::dom::Element;
 using mozilla::gfx::SourceSurface;
 
 static const uint32_t kIconWidth = 16;
 static const uint32_t kIconHeight = 16;
 
-typedef NS_STDCALL_FUNCPROTO(nsresult, GetRectSideMethod, nsIDOMRect,
-                             GetBottom, (nsIDOMCSSPrimitiveValue**));
+typedef decltype(&nsIDOMRect::GetBottom) GetRectSideMethod;
 
 NS_IMPL_ISUPPORTS(nsMenuItemIconX, imgINotificationObserver)
 
 nsMenuItemIconX::nsMenuItemIconX(nsMenuObjectX* aMenuItem,
                                  nsIContent*    aContent,
                                  NSMenuItem*    aNativeMenuItem)
 : mContent(aContent)
 , mLoadingPrincipal(aContent->NodePrincipal())
--- a/xpcom/base/nscore.h
+++ b/xpcom/base/nscore.h
@@ -129,43 +129,16 @@
 #define NS_FROZENCALL
 
 #endif
 
 #define NS_IMETHOD          NS_IMETHOD_(nsresult)
 #define NS_IMETHODIMP       NS_IMETHODIMP_(nsresult)
 
 /**
- * Macro for creating typedefs for pointer-to-member types which are
- * declared with stdcall.  It is important to use this for any type which is
- * declared as stdcall (i.e. NS_IMETHOD).  For example, instead of writing:
- *
- *  typedef nsresult (nsIFoo::*someType)(nsISupports* arg);
- *
- *  you should write:
- *
- *  typedef
- *  NS_STDCALL_FUNCPROTO(nsresult, someType, nsIFoo, typeFunc, (nsISupports*));
- *
- *  where nsIFoo::typeFunc is any method declared as
- *  NS_IMETHOD typeFunc(nsISupports*);
- *
- *  XXX this can be simplified to always use the non-typeof implementation
- *  when http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11893 is fixed.
- */
-
-#ifdef __GNUC__
-#define NS_STDCALL_FUNCPROTO(ret, name, class, func, args) \
-  typeof(&class::func) name
-#else
-#define NS_STDCALL_FUNCPROTO(ret, name, class, func, args) \
-  ret (NS_STDCALL class::*name) args
-#endif
-
-/**
  * Deprecated declarations.
  */
 #ifdef __GNUC__
 # define MOZ_DEPRECATED __attribute__((deprecated))
 #elif defined(_MSC_VER)
 # define MOZ_DEPRECATED __declspec(deprecated)
 #else
 # define MOZ_DEPRECATED