Bug 1273406 - Ugly macros transform into beautiful constexpr goodness - r?cpearce draft
authorGerald Squelart <gsquelart@mozilla.com>
Tue, 17 May 2016 19:32:31 +1000
changeset 367808 4a0683c7deedd3a4d53858d201bc9025e6e6798d
parent 367709 378ed392a625565318279a38739e34eb8764b230
child 521104 2e9f72094d0e8abf901223b86fd1117da52d8ed1
push id18350
push usergsquelart@mozilla.com
push dateTue, 17 May 2016 10:38:28 +0000
reviewerscpearce
bugs1273406
milestone49.0a1
Bug 1273406 - Ugly macros transform into beautiful constexpr goodness - r?cpearce MozReview-Commit-ID: K5cyEbvPWhQ
dom/media/platforms/wmf/WMFVideoMFTManager.cpp
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
@@ -148,38 +148,39 @@ WMFVideoMFTManager::GetMediaSubtypeGUID(
     case VP8: return MFVideoFormat_VP80;
     case VP9: return MFVideoFormat_VP90;
     default: return GUID_NULL;
   };
 }
 
 struct BlacklistedD3D11DLL
 {
+  constexpr
+  BlacklistedD3D11DLL(LPCWSTR aName, DWORD a, DWORD b, DWORD c, DWORD d)
+    : name(aName), ms((a << 16) | b), ls((c << 16) | d)
+  {}
   LPCWSTR name;
   DWORD ms;
   DWORD ls;
 };
-#define DLLVER(a, b, c, d) \
-        ((DWORD(a) << 16) | DWORD(b)),  ((DWORD(c) << 16) | DWORD(d))
-static const BlacklistedD3D11DLL sBlacklistedD3D11DLL[] =
+static constexpr BlacklistedD3D11DLL sBlacklistedD3D11DLL[] =
 {
   // Keep same DLL names together.
-  { L"igd10umd32.dll", DLLVER(9,17,10,2857) },
-  { L"isonyvideoprocessor.dll", DLLVER(4,1,2247,8090) },
-  { L"isonyvideoprocessor.dll", DLLVER(4,1,2153,6200) },
-  { L"tosqep.dll", DLLVER(1,2,15,526) },
-  { L"tosqep.dll", DLLVER(1,1,12,201) },
-  { L"tosqep.dll", DLLVER(1,0,11,318) },
-  { L"tosqep.dll", DLLVER(1,0,11,215) },
-  { L"tosqep64.dll", DLLVER(1,1,12,201) },
-  { L"tosqep64.dll", DLLVER(1,0,11,215) },
+  BlacklistedD3D11DLL(L"igd10umd32.dll", 9,17,10,2857),
+  BlacklistedD3D11DLL(L"isonyvideoprocessor.dll", 4,1,2247,8090),
+  BlacklistedD3D11DLL(L"isonyvideoprocessor.dll", 4,1,2153,6200),
+  BlacklistedD3D11DLL(L"tosqep.dll", 1,2,15,526),
+  BlacklistedD3D11DLL(L"tosqep.dll", 1,1,12,201),
+  BlacklistedD3D11DLL(L"tosqep.dll", 1,0,11,318),
+  BlacklistedD3D11DLL(L"tosqep.dll", 1,0,11,215),
+  BlacklistedD3D11DLL(L"tosqep64.dll", 1,1,12,201),
+  BlacklistedD3D11DLL(L"tosqep64.dll", 1,0,11,215),
   // Keep this last.
-  { nullptr, 0u, 0u }
+  BlacklistedD3D11DLL(nullptr, 0,0,0,0)
 };
-#undef DLLVER
 
 // If a blacklisted DLL is found, return its information, otherwise nullptr.
 static const BlacklistedD3D11DLL*
 IsD3D11DLLBlacklisted()
 {
   NS_ASSERTION(NS_IsMainThread(), "Must be on main thread.");
   // Cache the result, so we only check DLLs once per browser run.
   static const BlacklistedD3D11DLL* sAlreadySearched = nullptr;