diff --git a/modules/juce_audio_devices/juce_audio_devices.cpp b/modules/juce_audio_devices/juce_audio_devices.cpp index e5717830e6..e740a2e54d 100644 --- a/modules/juce_audio_devices/juce_audio_devices.cpp +++ b/modules/juce_audio_devices/juce_audio_devices.cpp @@ -58,7 +58,7 @@ //============================================================================== #elif JUCE_WINDOWS #if JUCE_WASAPI - #include + #include #endif #if JUCE_ASIO diff --git a/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp b/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp index d2b6422bea..708538f31f 100644 --- a/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp +++ b/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp @@ -96,11 +96,18 @@ bool check (HRESULT hr) } #if JUCE_MINGW + #define JUCE_COMCLASS(name, guid) \ struct name; \ template<> struct UUIDGetter { static CLSID get() { return uuidFromString (guid); } }; \ struct name + #ifdef __uuidof + #undef __uuidof + #endif + + #define __uuidof(cls) UUIDGetter::get() + struct PROPERTYKEY { GUID fmtid; diff --git a/modules/juce_core/native/juce_win32_ComSmartPtr.h b/modules/juce_core/native/juce_win32_ComSmartPtr.h index 380e9d8439..d8c96c2c22 100644 --- a/modules/juce_core/native/juce_win32_ComSmartPtr.h +++ b/modules/juce_core/native/juce_win32_ComSmartPtr.h @@ -29,9 +29,23 @@ #ifndef JUCE_WIN32_COMSMARTPTR_H_INCLUDED #define JUCE_WIN32_COMSMARTPTR_H_INCLUDED -#if ! (defined (_MSC_VER) || defined (__uuidof)) +#if JUCE_MINGW || (! (defined (_MSC_VER) || defined (__uuidof))) +#ifdef __uuidof + #undef __uuidof +#endif + template struct UUIDGetter { static CLSID get() { jassertfalse; return CLSID(); } }; #define __uuidof(x) UUIDGetter::get() + + template <> + struct UUIDGetter<::IUnknown> + { + static CLSID get() + { + GUID g = { 0, 0, 0, { 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 } }; + return g; + } + }; #endif inline GUID uuidFromString (const char* const s) noexcept @@ -135,7 +149,7 @@ protected: JUCE_COMRESULT QueryInterface (REFIID refId, void** result) { - if (refId == IID_IUnknown) + if (refId == __uuidof (IUnknown)) return castToType (result); *result = 0; diff --git a/modules/juce_core/native/juce_win32_SystemStats.cpp b/modules/juce_core/native/juce_win32_SystemStats.cpp index e07e6a09fc..beb8dcf43b 100644 --- a/modules/juce_core/native/juce_win32_SystemStats.cpp +++ b/modules/juce_core/native/juce_win32_SystemStats.cpp @@ -41,10 +41,28 @@ void Logger::outputDebugString (const String& text) #pragma intrinsic (__cpuid) #pragma intrinsic (__rdtsc) +#if JUCE_MINGW +static void callCPUID (int result[4], uint32 type) +{ + uint32 la = result[0], lb = result[1], lc = result[2], ld = result[3]; + + asm ("mov %%ebx, %%esi \n\t" + "cpuid \n\t" + "xchg %%esi, %%ebx" + : "=a" (la), "=S" (lb), "=c" (lc), "=d" (ld) : "a" (type) + #if JUCE_64BIT + , "b" (lb), "c" (lc), "d" (ld) + #endif + ); + + result[0] = la; result[1] = lb; result[2] = lc; result[3] = ld; +} +#else static void callCPUID (int result[4], int infoType) { __cpuid (result, infoType); } +#endif String SystemStats::getCpuVendor() { diff --git a/modules/juce_events/messages/juce_ApplicationBase.cpp b/modules/juce_events/messages/juce_ApplicationBase.cpp index 72657e02f5..5a2e3c3742 100644 --- a/modules/juce_events/messages/juce_ApplicationBase.cpp +++ b/modules/juce_events/messages/juce_ApplicationBase.cpp @@ -257,7 +257,7 @@ bool JUCEApplicationBase::initialiseApp() } #endif - #if JUCE_WINDOWS && JUCE_STANDALONE_APPLICATION && ! defined (_CONSOLE) + #if JUCE_WINDOWS && JUCE_STANDALONE_APPLICATION && (! defined (_CONSOLE)) && (! JUCE_MINGW) if (AttachConsole (ATTACH_PARENT_PROCESS) != 0) { // if we've launched a GUI app from cmd.exe or PowerShell, we need this to enable printf etc. diff --git a/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp b/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp index 190ef113f4..da8a0c0398 100644 --- a/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp +++ b/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp @@ -24,6 +24,24 @@ extern int64 getMouseEventTime(); +#if JUCE_MINGW + #define JUCE_COMCLASS(name, guid) \ + template<> struct UUIDGetter<::name> { static CLSID get() { return uuidFromString (guid); } }; + + #ifdef __uuidof + #undef __uuidof + #endif + + #define __uuidof(cls) UUIDGetter<::cls>::get() + +#else + #define JUCE_COMCLASS(name, guid) +#endif + +JUCE_COMCLASS (IOleObject, "00000112-0000-0000-C000-000000000046") +JUCE_COMCLASS (IOleWindow, "00000114-0000-0000-C000-000000000046") +JUCE_COMCLASS (IOleInPlaceSite, "00000119-0000-0000-C000-000000000046") + namespace ActiveXHelpers { //============================================================================== @@ -133,7 +151,7 @@ namespace ActiveXHelpers JUCE_COMRESULT QueryInterface (REFIID type, void** result) { - if (type == IID_IOleInPlaceSite) + if (type == __uuidof (IOleInPlaceSite)) { inplaceSite->AddRef(); *result = static_cast (inplaceSite); @@ -160,7 +178,7 @@ namespace ActiveXHelpers HWND getHWND (const ActiveXControlComponent* const component) { HWND hwnd = 0; - const IID iid = IID_IOleWindow; + const IID iid = __uuidof(IOleWindow); if (IOleWindow* const window = (IOleWindow*) component->queryInterface (&iid)) { @@ -340,7 +358,7 @@ bool ActiveXControlComponent::createControl (const void* controlIID) ScopedPointer newControl (new Pimpl (hwnd, *this)); HRESULT hr; - if ((hr = OleCreate (*(const IID*) controlIID, IID_IOleObject, 1 /*OLERENDER_DRAW*/, 0, + if ((hr = OleCreate (*(const IID*) controlIID, __uuidof (IOleObject), 1 /*OLERENDER_DRAW*/, 0, newControl->clientSite, newControl->storage, (void**) &(newControl->control))) == S_OK) { diff --git a/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp b/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp index 0b9ec01d38..96612094a3 100644 --- a/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp +++ b/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp @@ -22,6 +22,11 @@ ============================================================================== */ +JUCE_COMCLASS (DWebBrowserEvents2, "34A715A0-6587-11D0-924A-0020AFC7AC4D") +JUCE_COMCLASS (IConnectionPointContainer, "B196B284-BAB4-101A-B69C-00AA00341D07") +JUCE_COMCLASS (IWebBrowser2, "D30C1661-CDAF-11D0-8A3E-00C04FC9E26E") +JUCE_COMCLASS (WebBrowser, "8856F961-340A-11D0-A96B-00C04FD705A2") + class WebBrowserComponent::Pimpl : public ActiveXControlComponent { public: @@ -43,13 +48,18 @@ public: void createBrowser() { - createControl (&CLSID_WebBrowser); - browser = (IWebBrowser2*) queryInterface (&IID_IWebBrowser2); + CLSID webCLSID = __uuidof (WebBrowser); + createControl (&webCLSID); + + GUID iidWebBrowser2 = __uuidof (IWebBrowser2); + GUID iidConnectionPointContainer = __uuidof (IConnectionPointContainer); + + browser = (IWebBrowser2*) queryInterface (&iidWebBrowser2); if (IConnectionPointContainer* connectionPointContainer - = (IConnectionPointContainer*) queryInterface (&IID_IConnectionPointContainer)) + = (IConnectionPointContainer*) queryInterface (&iidConnectionPointContainer)) { - connectionPointContainer->FindConnectionPoint (DIID_DWebBrowserEvents2, &connectionPoint); + connectionPointContainer->FindConnectionPoint (__uuidof (DWebBrowserEvents2), &connectionPoint); if (connectionPoint != nullptr) { @@ -330,9 +340,12 @@ void WebBrowserComponent::visibilityChanged() void WebBrowserComponent::focusGained (FocusChangeType) { - if (IOleObject* oleObject = (IOleObject*) browser->queryInterface (&IID_IOleObject)) + GUID iidOleObject = __uuidof (IOleObject); + GUID iidOleWindow = __uuidof (IOleWindow); + + if (IOleObject* oleObject = (IOleObject*) browser->queryInterface (&iidOleObject)) { - if (IOleWindow* oleWindow = (IOleWindow*) browser->queryInterface (&IID_IOleWindow)) + if (IOleWindow* oleWindow = (IOleWindow*) browser->queryInterface (&iidOleWindow)) { IOleClientSite* oleClientSite = nullptr;