From 9c94a7450d95285d85f4a15d025f3ea85e4deab9 Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Thu, 30 Jun 2011 17:53:15 +0100 Subject: [PATCH] Added some missing export markers. More internal re-organisation. --- Builds/Linux/Makefile | 6 - Builds/MacOSX/Juce.xcodeproj/project.pbxproj | 4 - Builds/VisualStudio2005/Juce.vcproj | 1 - Builds/VisualStudio2008/Juce.vcproj | 1 - Builds/VisualStudio2008_DLL/Juce.vcproj | 1 - Builds/VisualStudio2010/Juce.vcxproj | 1 - Builds/VisualStudio2010/Juce.vcxproj.filters | 3 - Builds/iOS/Juce.xcodeproj/project.pbxproj | 4 - Juce.jucer | 2 - amalgamation/juce_amalgamated_template.cpp | 1 - extras/binarybuilder/BinaryBuilder.jucer | 4 +- juce_amalgamated.cpp | 509 ++++++++---------- juce_amalgamated.h | 13 +- src/core/juce_Initialisation.cpp | 36 -- src/core/juce_Result.h | 2 +- src/core/juce_StandardHeader.h | 2 +- src/events/juce_MessageManager.cpp | 20 +- src/events/juce_MessageManager.h | 7 +- .../android/juce_android_NativeCode.cpp | 1 - src/native/common/juce_MidiDataConcatenator.h | 4 - src/native/linux/juce_linux_Threads.cpp | 40 +- src/native/mac/juce_mac_NativeCode.mm | 10 +- src/native/windows/juce_win32_Messaging.cpp | 3 - src/native/windows/juce_win32_Misc.cpp | 6 +- src/native/windows/juce_win32_NativeCode.cpp | 2 +- src/native/windows/juce_win32_Registry.cpp | 12 +- src/native/windows/juce_win32_Threads.cpp | 11 +- src/threads/juce_DynamicLibrary.h | 2 +- src/threads/juce_Thread.cpp | 106 ++++ 29 files changed, 410 insertions(+), 404 deletions(-) diff --git a/Builds/Linux/Makefile b/Builds/Linux/Makefile index b8df7a1949..8355f15bb9 100644 --- a/Builds/Linux/Makefile +++ b/Builds/Linux/Makefile @@ -103,7 +103,6 @@ OBJECTS := \ $(OBJDIR)/juce_ValueTree_f822be84.o \ $(OBJDIR)/juce_Variant_4f31c35a.o \ $(OBJDIR)/juce_FileLogger_7858478e.o \ - $(OBJDIR)/juce_Initialisation_fec765a9.o \ $(OBJDIR)/juce_Logger_4f4f7f72.o \ $(OBJDIR)/juce_PerformanceCounter_6422080e.o \ $(OBJDIR)/juce_RelativeTime_bc5ef35b.o \ @@ -708,11 +707,6 @@ $(OBJDIR)/juce_FileLogger_7858478e.o: ../../src/core/juce_FileLogger.cpp @echo "Compiling juce_FileLogger.cpp" @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" -$(OBJDIR)/juce_Initialisation_fec765a9.o: ../../src/core/juce_Initialisation.cpp - -@mkdir -p $(OBJDIR) - @echo "Compiling juce_Initialisation.cpp" - @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" - $(OBJDIR)/juce_Logger_4f4f7f72.o: ../../src/core/juce_Logger.cpp -@mkdir -p $(OBJDIR) @echo "Compiling juce_Logger.cpp" diff --git a/Builds/MacOSX/Juce.xcodeproj/project.pbxproj b/Builds/MacOSX/Juce.xcodeproj/project.pbxproj index f55ee1b46b..1397872c3d 100644 --- a/Builds/MacOSX/Juce.xcodeproj/project.pbxproj +++ b/Builds/MacOSX/Juce.xcodeproj/project.pbxproj @@ -72,7 +72,6 @@ A230949FF8848D5E923F9083 = { isa = PBXBuildFile; fileRef = 5D27EE211D9BFF6A58C4DC42; }; 11162E9812CFB0E738A7E2E6 = { isa = PBXBuildFile; fileRef = 4DF9D333038A442870668D31; }; C682BEA7DB70FDC7C6BA2D6E = { isa = PBXBuildFile; fileRef = D66C00E06B06EAD3B5257DD6; }; - 77104E86801B6CAD01F963F4 = { isa = PBXBuildFile; fileRef = 5B789AAC295BA4BB6D5AD4A3; }; 6A53DA58B55E2DE7241BF2C8 = { isa = PBXBuildFile; fileRef = 4555F03DBD059EEDECEF9F85; }; 0FF71870483AC46D5B7AC5B0 = { isa = PBXBuildFile; fileRef = DF6CAC67C0F2D379BDA03062; }; FA01B3EABA192AE041D4FE4D = { isa = PBXBuildFile; fileRef = CFAECB6551F48A1695DEC243; }; @@ -536,7 +535,6 @@ A81B4FC81A75E21E5B96E506 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_Variant.h"; path = "../../src/containers/juce_Variant.h"; sourceTree = "SOURCE_ROOT"; }; D66C00E06B06EAD3B5257DD6 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_FileLogger.cpp"; path = "../../src/core/juce_FileLogger.cpp"; sourceTree = "SOURCE_ROOT"; }; C8441B7B3E4CCD4A257B4BFE = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_FileLogger.h"; path = "../../src/core/juce_FileLogger.h"; sourceTree = "SOURCE_ROOT"; }; - 5B789AAC295BA4BB6D5AD4A3 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_Initialisation.cpp"; path = "../../src/core/juce_Initialisation.cpp"; sourceTree = "SOURCE_ROOT"; }; 92ACFFCCCD1C85A0F8C6F80F = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_Initialisation.h"; path = "../../src/core/juce_Initialisation.h"; sourceTree = "SOURCE_ROOT"; }; 4555F03DBD059EEDECEF9F85 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_Logger.cpp"; path = "../../src/core/juce_Logger.cpp"; sourceTree = "SOURCE_ROOT"; }; 63F44EC0485FCA050814967E = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_Logger.h"; path = "../../src/core/juce_Logger.h"; sourceTree = "SOURCE_ROOT"; }; @@ -1317,7 +1315,6 @@ 1AF37A533ABDD889670F9349 = { isa = PBXGroup; children = ( D66C00E06B06EAD3B5257DD6, C8441B7B3E4CCD4A257B4BFE, - 5B789AAC295BA4BB6D5AD4A3, 92ACFFCCCD1C85A0F8C6F80F, 4555F03DBD059EEDECEF9F85, 63F44EC0485FCA050814967E, @@ -2135,7 +2132,6 @@ A230949FF8848D5E923F9083, 11162E9812CFB0E738A7E2E6, C682BEA7DB70FDC7C6BA2D6E, - 77104E86801B6CAD01F963F4, 6A53DA58B55E2DE7241BF2C8, 0FF71870483AC46D5B7AC5B0, FA01B3EABA192AE041D4FE4D, diff --git a/Builds/VisualStudio2005/Juce.vcproj b/Builds/VisualStudio2005/Juce.vcproj index d80a877a9f..3819f4a975 100644 --- a/Builds/VisualStudio2005/Juce.vcproj +++ b/Builds/VisualStudio2005/Juce.vcproj @@ -366,7 +366,6 @@ - diff --git a/Builds/VisualStudio2008/Juce.vcproj b/Builds/VisualStudio2008/Juce.vcproj index 62c41280ba..88bc194796 100644 --- a/Builds/VisualStudio2008/Juce.vcproj +++ b/Builds/VisualStudio2008/Juce.vcproj @@ -366,7 +366,6 @@ - diff --git a/Builds/VisualStudio2008_DLL/Juce.vcproj b/Builds/VisualStudio2008_DLL/Juce.vcproj index 2beb19c93e..5bdbc15482 100644 --- a/Builds/VisualStudio2008_DLL/Juce.vcproj +++ b/Builds/VisualStudio2008_DLL/Juce.vcproj @@ -368,7 +368,6 @@ - diff --git a/Builds/VisualStudio2010/Juce.vcxproj b/Builds/VisualStudio2010/Juce.vcxproj index 3d3ced0910..599bc46a5b 100644 --- a/Builds/VisualStudio2010/Juce.vcxproj +++ b/Builds/VisualStudio2010/Juce.vcxproj @@ -186,7 +186,6 @@ - diff --git a/Builds/VisualStudio2010/Juce.vcxproj.filters b/Builds/VisualStudio2010/Juce.vcxproj.filters index 33b7b7adb5..abff23afd5 100644 --- a/Builds/VisualStudio2010/Juce.vcxproj.filters +++ b/Builds/VisualStudio2010/Juce.vcxproj.filters @@ -415,9 +415,6 @@ Juce\Source\core - - Juce\Source\core - Juce\Source\core diff --git a/Builds/iOS/Juce.xcodeproj/project.pbxproj b/Builds/iOS/Juce.xcodeproj/project.pbxproj index 195bb2d6f7..165f589f45 100644 --- a/Builds/iOS/Juce.xcodeproj/project.pbxproj +++ b/Builds/iOS/Juce.xcodeproj/project.pbxproj @@ -72,7 +72,6 @@ A230949FF8848D5E923F9083 = { isa = PBXBuildFile; fileRef = 5D27EE211D9BFF6A58C4DC42; }; 11162E9812CFB0E738A7E2E6 = { isa = PBXBuildFile; fileRef = 4DF9D333038A442870668D31; }; C682BEA7DB70FDC7C6BA2D6E = { isa = PBXBuildFile; fileRef = D66C00E06B06EAD3B5257DD6; }; - 77104E86801B6CAD01F963F4 = { isa = PBXBuildFile; fileRef = 5B789AAC295BA4BB6D5AD4A3; }; 6A53DA58B55E2DE7241BF2C8 = { isa = PBXBuildFile; fileRef = 4555F03DBD059EEDECEF9F85; }; 0FF71870483AC46D5B7AC5B0 = { isa = PBXBuildFile; fileRef = DF6CAC67C0F2D379BDA03062; }; FA01B3EABA192AE041D4FE4D = { isa = PBXBuildFile; fileRef = CFAECB6551F48A1695DEC243; }; @@ -536,7 +535,6 @@ A81B4FC81A75E21E5B96E506 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_Variant.h"; path = "../../src/containers/juce_Variant.h"; sourceTree = "SOURCE_ROOT"; }; D66C00E06B06EAD3B5257DD6 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_FileLogger.cpp"; path = "../../src/core/juce_FileLogger.cpp"; sourceTree = "SOURCE_ROOT"; }; C8441B7B3E4CCD4A257B4BFE = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_FileLogger.h"; path = "../../src/core/juce_FileLogger.h"; sourceTree = "SOURCE_ROOT"; }; - 5B789AAC295BA4BB6D5AD4A3 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_Initialisation.cpp"; path = "../../src/core/juce_Initialisation.cpp"; sourceTree = "SOURCE_ROOT"; }; 92ACFFCCCD1C85A0F8C6F80F = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_Initialisation.h"; path = "../../src/core/juce_Initialisation.h"; sourceTree = "SOURCE_ROOT"; }; 4555F03DBD059EEDECEF9F85 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_Logger.cpp"; path = "../../src/core/juce_Logger.cpp"; sourceTree = "SOURCE_ROOT"; }; 63F44EC0485FCA050814967E = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_Logger.h"; path = "../../src/core/juce_Logger.h"; sourceTree = "SOURCE_ROOT"; }; @@ -1317,7 +1315,6 @@ 1AF37A533ABDD889670F9349 = { isa = PBXGroup; children = ( D66C00E06B06EAD3B5257DD6, C8441B7B3E4CCD4A257B4BFE, - 5B789AAC295BA4BB6D5AD4A3, 92ACFFCCCD1C85A0F8C6F80F, 4555F03DBD059EEDECEF9F85, 63F44EC0485FCA050814967E, @@ -2139,7 +2136,6 @@ A230949FF8848D5E923F9083, 11162E9812CFB0E738A7E2E6, C682BEA7DB70FDC7C6BA2D6E, - 77104E86801B6CAD01F963F4, 6A53DA58B55E2DE7241BF2C8, 0FF71870483AC46D5B7AC5B0, FA01B3EABA192AE041D4FE4D, diff --git a/Juce.jucer b/Juce.jucer index 6520e2f1c3..f94bfcdfdd 100644 --- a/Juce.jucer +++ b/Juce.jucer @@ -404,8 +404,6 @@ file="src/core/juce_FileLogger.cpp"/> - + rtasFolder="c:\SDKs\PT_80_SDK" juceFolder="../../../juce" libraryType="1"/> + rtasFolder="c:\SDKs\PT_80_SDK" juceFolder="../../../juce" libraryType="1"/> diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index a98a06bf7e..45f75b9cb8 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -2301,151 +2301,6 @@ END_JUCE_NAMESPACE /*** End of inlined file: juce_Time.cpp ***/ -/*** Start of inlined file: juce_Initialisation.cpp ***/ -BEGIN_JUCE_NAMESPACE - -#if ! JUCE_ONLY_BUILD_CORE_LIBRARY - -#endif - -#if ! JUCE_ONLY_BUILD_CORE_LIBRARY - -static bool juceInitialisedGUI = false; - -JUCE_API void JUCE_CALLTYPE initialiseJuce_GUI() -{ - if (! juceInitialisedGUI) - { - juceInitialisedGUI = true; - - JUCE_AUTORELEASEPOOL - MessageManager::getInstance(); - } -} - -JUCE_API void JUCE_CALLTYPE shutdownJuce_GUI() -{ - if (juceInitialisedGUI) - { - juceInitialisedGUI = false; - - JUCE_AUTORELEASEPOOL - DeletedAtShutdown::deleteAll(); - delete MessageManager::getInstance(); - } -} - -#endif - -#if JUCE_UNIT_TESTS - -class AtomicTests : public UnitTest -{ -public: - AtomicTests() : UnitTest ("Atomics") {} - - void runTest() - { - beginTest ("Misc"); - - char a1[7]; - expect (numElementsInArray(a1) == 7); - int a2[3]; - expect (numElementsInArray(a2) == 3); - - expect (ByteOrder::swap ((uint16) 0x1122) == 0x2211); - expect (ByteOrder::swap ((uint32) 0x11223344) == 0x44332211); - expect (ByteOrder::swap ((uint64) literal64bit (0x1122334455667788)) == literal64bit (0x8877665544332211)); - - beginTest ("Atomic int"); - AtomicTester ::testInteger (*this); - beginTest ("Atomic unsigned int"); - AtomicTester ::testInteger (*this); - beginTest ("Atomic int32"); - AtomicTester ::testInteger (*this); - beginTest ("Atomic uint32"); - AtomicTester ::testInteger (*this); - beginTest ("Atomic long"); - AtomicTester ::testInteger (*this); - beginTest ("Atomic void*"); - AtomicTester ::testInteger (*this); - beginTest ("Atomic int*"); - AtomicTester ::testInteger (*this); - beginTest ("Atomic float"); - AtomicTester ::testFloat (*this); - #if ! JUCE_64BIT_ATOMICS_UNAVAILABLE // 64-bit intrinsics aren't available on some old platforms - beginTest ("Atomic int64"); - AtomicTester ::testInteger (*this); - beginTest ("Atomic uint64"); - AtomicTester ::testInteger (*this); - beginTest ("Atomic double"); - AtomicTester ::testFloat (*this); - #endif - } - - template - class AtomicTester - { - public: - AtomicTester() {} - - static void testInteger (UnitTest& test) - { - Atomic a, b; - a.set ((Type) 10); - test.expect (a.value == (Type) 10); - test.expect (a.get() == (Type) 10); - a += (Type) 15; - test.expect (a.get() == (Type) 25); - a.memoryBarrier(); - a -= (Type) 5; - test.expect (a.get() == (Type) 20); - test.expect (++a == (Type) 21); - ++a; - test.expect (--a == (Type) 21); - test.expect (a.get() == (Type) 21); - a.memoryBarrier(); - - testFloat (test); - } - - static void testFloat (UnitTest& test) - { - Atomic a, b; - a = (Type) 21; - a.memoryBarrier(); - - /* These are some simple test cases to check the atomics - let me know - if any of these assertions fail on your system! - */ - test.expect (a.get() == (Type) 21); - test.expect (a.compareAndSetValue ((Type) 100, (Type) 50) == (Type) 21); - test.expect (a.get() == (Type) 21); - test.expect (a.compareAndSetValue ((Type) 101, a.get()) == (Type) 21); - test.expect (a.get() == (Type) 101); - test.expect (! a.compareAndSetBool ((Type) 300, (Type) 200)); - test.expect (a.get() == (Type) 101); - test.expect (a.compareAndSetBool ((Type) 200, a.get())); - test.expect (a.get() == (Type) 200); - - test.expect (a.exchange ((Type) 300) == (Type) 200); - test.expect (a.get() == (Type) 300); - - b = a; - test.expect (b.get() == a.get()); - } - }; -}; - -static AtomicTests atomicUnitTests; - -#endif - -END_JUCE_NAMESPACE - -/*** End of inlined file: juce_Initialisation.cpp ***/ - - /*** Start of inlined file: juce_AbstractFifo.cpp ***/ BEGIN_JUCE_NAMESPACE @@ -17528,6 +17383,110 @@ void SpinLock::enter() const noexcept } } +#if JUCE_UNIT_TESTS + +class AtomicTests : public UnitTest +{ +public: + AtomicTests() : UnitTest ("Atomics") {} + + void runTest() + { + beginTest ("Misc"); + + char a1[7]; + expect (numElementsInArray(a1) == 7); + int a2[3]; + expect (numElementsInArray(a2) == 3); + + expect (ByteOrder::swap ((uint16) 0x1122) == 0x2211); + expect (ByteOrder::swap ((uint32) 0x11223344) == 0x44332211); + expect (ByteOrder::swap ((uint64) literal64bit (0x1122334455667788)) == literal64bit (0x8877665544332211)); + + beginTest ("Atomic int"); + AtomicTester ::testInteger (*this); + beginTest ("Atomic unsigned int"); + AtomicTester ::testInteger (*this); + beginTest ("Atomic int32"); + AtomicTester ::testInteger (*this); + beginTest ("Atomic uint32"); + AtomicTester ::testInteger (*this); + beginTest ("Atomic long"); + AtomicTester ::testInteger (*this); + beginTest ("Atomic void*"); + AtomicTester ::testInteger (*this); + beginTest ("Atomic int*"); + AtomicTester ::testInteger (*this); + beginTest ("Atomic float"); + AtomicTester ::testFloat (*this); + #if ! JUCE_64BIT_ATOMICS_UNAVAILABLE // 64-bit intrinsics aren't available on some old platforms + beginTest ("Atomic int64"); + AtomicTester ::testInteger (*this); + beginTest ("Atomic uint64"); + AtomicTester ::testInteger (*this); + beginTest ("Atomic double"); + AtomicTester ::testFloat (*this); + #endif + } + + template + class AtomicTester + { + public: + AtomicTester() {} + + static void testInteger (UnitTest& test) + { + Atomic a, b; + a.set ((Type) 10); + test.expect (a.value == (Type) 10); + test.expect (a.get() == (Type) 10); + a += (Type) 15; + test.expect (a.get() == (Type) 25); + a.memoryBarrier(); + a -= (Type) 5; + test.expect (a.get() == (Type) 20); + test.expect (++a == (Type) 21); + ++a; + test.expect (--a == (Type) 21); + test.expect (a.get() == (Type) 21); + a.memoryBarrier(); + + testFloat (test); + } + + static void testFloat (UnitTest& test) + { + Atomic a, b; + a = (Type) 21; + a.memoryBarrier(); + + /* These are some simple test cases to check the atomics - let me know + if any of these assertions fail on your system! + */ + test.expect (a.get() == (Type) 21); + test.expect (a.compareAndSetValue ((Type) 100, (Type) 50) == (Type) 21); + test.expect (a.get() == (Type) 21); + test.expect (a.compareAndSetValue ((Type) 101, a.get()) == (Type) 21); + test.expect (a.get() == (Type) 101); + test.expect (! a.compareAndSetBool ((Type) 300, (Type) 200)); + test.expect (a.get() == (Type) 101); + test.expect (a.compareAndSetBool ((Type) 200, a.get())); + test.expect (a.get() == (Type) 200); + + test.expect (a.exchange ((Type) 300) == (Type) 200); + test.expect (a.get() == (Type) 300); + + b = a; + test.expect (b.get() == a.get()); + } + }; +}; + +static AtomicTests atomicUnitTests; + +#endif + END_JUCE_NAMESPACE /*** End of inlined file: juce_Thread.cpp ***/ @@ -40581,7 +40540,7 @@ MessageManager::~MessageManager() noexcept instance = nullptr; // do this last in case this instance is still needed by doPlatformSpecificShutdown() } -MessageManager* MessageManager::getInstance() noexcept +MessageManager* MessageManager::getInstance() { if (instance == nullptr) { @@ -40592,6 +40551,11 @@ MessageManager* MessageManager::getInstance() noexcept return instance; } +void MessageManager::deleteInstance() +{ + deleteAndZero (instance); +} + void MessageManager::postMessageToQueue (Message* const message) { if (quitMessagePosted || ! postMessageToSystemQueue (message)) @@ -40825,6 +40789,19 @@ MessageManagerLock::~MessageManagerLock() noexcept } } +JUCE_API void JUCE_CALLTYPE initialiseJuce_GUI() +{ + JUCE_AUTORELEASEPOOL + MessageManager::getInstance(); +} + +JUCE_API void JUCE_CALLTYPE shutdownJuce_GUI() +{ + JUCE_AUTORELEASEPOOL + DeletedAtShutdown::deleteAll(); + MessageManager::deleteInstance(); +} + END_JUCE_NAMESPACE /*** End of inlined file: juce_MessageManager.cpp ***/ @@ -244468,8 +244445,6 @@ END_JUCE_NAMESPACE #ifndef __JUCE_MIDIDATACONCATENATOR_JUCEHEADER__ #define __JUCE_MIDIDATACONCATENATOR_JUCEHEADER__ -#if ! JUCE_ONLY_BUILD_CORE_LIBRARY - /** Helper class that takes chunks of incoming midi bytes, packages them into messages, and dispatches them to a midi callback. @@ -244582,8 +244557,6 @@ private: JUCE_DECLARE_NON_COPYABLE (MidiDataConcatenator); }; -#endif - #endif // __JUCE_MIDIDATACONCATENATOR_JUCEHEADER__ /*** End of inlined file: juce_MidiDataConcatenator.h ***/ @@ -244963,9 +244936,7 @@ String SystemStats::getComputerName() // compiled on its own). #if JUCE_INCLUDED_FILE -#if ! JUCE_ONLY_BUILD_CORE_LIBRARY - extern HWND juce_messageWindowHandle; -#endif +HWND juce_messageWindowHandle = 0; // (this is used by other parts of the codebase) #if ! JUCE_USE_INTRINSICS // In newer compilers, the inline versions of these are used (in juce_Atomic.h), but in @@ -245050,10 +245021,9 @@ void JUCE_API juce_threadEntryPoint (void*); static unsigned int __stdcall threadEntryProc (void* userData) { - #if ! JUCE_ONLY_BUILD_CORE_LIBRARY - AttachThreadInput (GetWindowThreadProcessId (juce_messageWindowHandle, 0), - GetCurrentThreadId(), TRUE); - #endif + if (juce_messageWindowHandle != 0) + AttachThreadInput (GetWindowThreadProcessId (juce_messageWindowHandle, 0), + GetCurrentThreadId(), TRUE); juce_threadEntryPoint (userData); @@ -246734,7 +246704,7 @@ bool Process::openEmailWithAttachments (const String& targetEmailAddress, // compiled on its own). #if JUCE_INCLUDED_FILE -namespace +namespace RegistryHelpers { HKEY findKeyForPath (String name, const bool createForWriting, String& valueName) { @@ -246775,7 +246745,7 @@ namespace String WindowsRegistry::getValue (const String& regValuePath, const String& defaultValue) { String valueName, result (defaultValue); - HKEY k = findKeyForPath (regValuePath, false, valueName); + HKEY k = RegistryHelpers::findKeyForPath (regValuePath, false, valueName); if (k != 0) { @@ -246800,7 +246770,7 @@ String WindowsRegistry::getValue (const String& regValuePath, const String& defa void WindowsRegistry::setValue (const String& regValuePath, const String& value) { String valueName; - HKEY k = findKeyForPath (regValuePath, true, valueName); + HKEY k = RegistryHelpers::findKeyForPath (regValuePath, true, valueName); if (k != 0) { @@ -246816,7 +246786,7 @@ bool WindowsRegistry::valueExists (const String& regValuePath) { bool exists = false; String valueName; - HKEY k = findKeyForPath (regValuePath, false, valueName); + HKEY k = RegistryHelpers::findKeyForPath (regValuePath, false, valueName); if (k != 0) { @@ -246836,7 +246806,7 @@ bool WindowsRegistry::valueExists (const String& regValuePath) void WindowsRegistry::deleteValue (const String& regValuePath) { String valueName; - HKEY k = findKeyForPath (regValuePath, true, valueName); + HKEY k = RegistryHelpers::findKeyForPath (regValuePath, true, valueName); if (k != 0) { @@ -246848,7 +246818,7 @@ void WindowsRegistry::deleteValue (const String& regValuePath) void WindowsRegistry::deleteKey (const String& regKeyPath) { String valueName; - HKEY k = findKeyForPath (regKeyPath, true, valueName); + HKEY k = RegistryHelpers::findKeyForPath (regKeyPath, true, valueName); if (k != 0) { @@ -246926,8 +246896,6 @@ private: LPCTSTR getClassNameFromAtom() noexcept { return (LPCTSTR) MAKELONG (atom, 0); } }; -HWND juce_messageWindowHandle = 0; // (this is referred to by other parts of the codebase) - class JuceWindowIdentifier { public: @@ -252099,9 +252067,9 @@ bool juce_IsRunningInWine() String JUCE_CALLTYPE Process::getCurrentCommandLineParams() { - return String (CharacterFunctions::findEndOfToken (CharPointer_UTF16 (GetCommandLineW()), - CharPointer_UTF16 (L" "), - CharPointer_UTF16 (L"\""))).trimStart(); + return CharacterFunctions::findEndOfToken (CharPointer_UTF16 (GetCommandLineW()), + CharPointer_UTF16 (L" "), + CharPointer_UTF16 (L"\"")).findEndOfWhitespace(); } static void* currentModuleHandle = nullptr; @@ -263934,30 +263902,22 @@ bool Time::setSystemTimeToThisTime() const live in juce_posix_SharedCode.h! */ -// sets the process to 0=low priority, 1=normal, 2=high, 3=realtime -void Process::setPriority (ProcessPriority prior) +void Process::setPriority (const ProcessPriority prior) { - struct sched_param param; - int policy, maxp, minp; - - const int p = (int) prior; - - if (p <= 1) - policy = SCHED_OTHER; - else - policy = SCHED_RR; + const int policy = (prior <= NormalPriority) ? SCHED_OTHER : SCHED_RR; + const int minp = sched_get_priority_min (policy); + const int maxp = sched_get_priority_max (policy); - minp = sched_get_priority_min (policy); - maxp = sched_get_priority_max (policy); + struct sched_param param; - if (p < 2) - param.sched_priority = 0; - else if (p == 2 ) - // Set to middle of lower realtime priority range - param.sched_priority = minp + (maxp - minp) / 4; - else - // Set to middle of higher realtime priority range - param.sched_priority = minp + (3 * (maxp - minp) / 4); + switch (prior) + { + case LowPriority: + case NormalPriority: param.sched_priority = 0; break; + case HighPriority: param.sched_priority = minp + (maxp - minp) / 4; break; + case RealtimePriority: param.sched_priority = minp + (3 * (maxp - minp) / 4); break; + default: jassertfalse; break; + } pthread_setschedparam (pthread_self(), policy, ¶m); } @@ -263992,8 +263952,7 @@ JUCE_API bool JUCE_CALLTYPE Process::isRunningUnderDebugger() void Process::raisePrivilege() { - // If running suid root, change effective user - // to root + // If running suid root, change effective user to root if (geteuid() != 0 && getuid() == 0) { setreuid (geteuid(), getuid()); @@ -264003,8 +263962,7 @@ void Process::raisePrivilege() void Process::lowerPrivilege() { - // If runing suid root, change effective user - // back to real user + // If runing suid root, change effective user back to real user if (geteuid() == 0 && getuid() != 0) { setreuid (geteuid(), getuid()); @@ -270837,7 +270795,10 @@ BEGIN_JUCE_NAMESPACE #undef Point -#if ! JUCE_ONLY_BUILD_CORE_LIBRARY +#define JUCE_INCLUDED_FILE 1 + +// Now include the actual code files.. + /*** Start of inlined file: juce_osx_ObjCHelpers.h ***/ #ifndef __JUCE_OSX_OBJCHELPERS_JUCEHEADER__ @@ -270893,89 +270854,6 @@ ScopedAutoReleasePool::~ScopedAutoReleasePool() /*** End of inlined file: juce_osx_ObjCHelpers.h ***/ - -/*** Start of inlined file: juce_osx_MessageQueue.h ***/ -#ifndef __JUCE_OSX_MESSAGEQUEUE_JUCEHEADER__ -#define __JUCE_OSX_MESSAGEQUEUE_JUCEHEADER__ - -/* An internal message pump class used in OSX and iOS. */ -class MessageQueue -{ -public: - MessageQueue() - { - #if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 && ! JUCE_IOS - runLoop = CFRunLoopGetMain(); - #else - runLoop = CFRunLoopGetCurrent(); - #endif - - CFRunLoopSourceContext sourceContext = { 0 }; - sourceContext.info = this; - sourceContext.perform = runLoopSourceCallback; - runLoopSource = CFRunLoopSourceCreate (kCFAllocatorDefault, 1, &sourceContext); - CFRunLoopAddSource (runLoop, runLoopSource, kCFRunLoopCommonModes); - } - - ~MessageQueue() - { - CFRunLoopRemoveSource (runLoop, runLoopSource, kCFRunLoopCommonModes); - CFRunLoopSourceInvalidate (runLoopSource); - CFRelease (runLoopSource); - } - - void post (Message* const message) - { - messages.add (message); - CFRunLoopSourceSignal (runLoopSource); - CFRunLoopWakeUp (runLoop); - } - -private: - ReferenceCountedArray messages; - CriticalSection lock; - CFRunLoopRef runLoop; - CFRunLoopSourceRef runLoopSource; - - bool deliverNextMessage() - { - const Message::Ptr nextMessage (messages.removeAndReturn (0)); - - if (nextMessage == nullptr) - return false; - - JUCE_AUTORELEASEPOOL - MessageManager::getInstance()->deliverMessage (nextMessage); - return true; - } - - void runLoopCallback() - { - for (int i = 4; --i >= 0;) - if (! deliverNextMessage()) - return; - - CFRunLoopSourceSignal (runLoopSource); - CFRunLoopWakeUp (runLoop); - } - - static void runLoopSourceCallback (void* info) - { - static_cast (info)->runLoopCallback(); - } -}; - -#endif // __JUCE_OSX_MESSAGEQUEUE_JUCEHEADER__ - -/*** End of inlined file: juce_osx_MessageQueue.h ***/ - -#endif - -#define JUCE_INCLUDED_FILE 1 - -// Now include the actual code files.. - - /*** Start of inlined file: juce_mac_ObjCSuffix.h ***/ /** This suffix is used for naming all Obj-C classes that are used inside juce. @@ -273350,6 +273228,83 @@ JUCE_API bool JUCE_CALLTYPE Process::isRunningUnderDebugger() /*** End of inlined file: juce_mac_Debugging.mm ***/ #if ! JUCE_ONLY_BUILD_CORE_LIBRARY + +/*** Start of inlined file: juce_osx_MessageQueue.h ***/ +#ifndef __JUCE_OSX_MESSAGEQUEUE_JUCEHEADER__ +#define __JUCE_OSX_MESSAGEQUEUE_JUCEHEADER__ + +/* An internal message pump class used in OSX and iOS. */ +class MessageQueue +{ +public: + MessageQueue() + { + #if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 && ! JUCE_IOS + runLoop = CFRunLoopGetMain(); + #else + runLoop = CFRunLoopGetCurrent(); + #endif + + CFRunLoopSourceContext sourceContext = { 0 }; + sourceContext.info = this; + sourceContext.perform = runLoopSourceCallback; + runLoopSource = CFRunLoopSourceCreate (kCFAllocatorDefault, 1, &sourceContext); + CFRunLoopAddSource (runLoop, runLoopSource, kCFRunLoopCommonModes); + } + + ~MessageQueue() + { + CFRunLoopRemoveSource (runLoop, runLoopSource, kCFRunLoopCommonModes); + CFRunLoopSourceInvalidate (runLoopSource); + CFRelease (runLoopSource); + } + + void post (Message* const message) + { + messages.add (message); + CFRunLoopSourceSignal (runLoopSource); + CFRunLoopWakeUp (runLoop); + } + +private: + ReferenceCountedArray messages; + CriticalSection lock; + CFRunLoopRef runLoop; + CFRunLoopSourceRef runLoopSource; + + bool deliverNextMessage() + { + const Message::Ptr nextMessage (messages.removeAndReturn (0)); + + if (nextMessage == nullptr) + return false; + + JUCE_AUTORELEASEPOOL + MessageManager::getInstance()->deliverMessage (nextMessage); + return true; + } + + void runLoopCallback() + { + for (int i = 4; --i >= 0;) + if (! deliverNextMessage()) + return; + + CFRunLoopSourceSignal (runLoopSource); + CFRunLoopWakeUp (runLoop); + } + + static void runLoopSourceCallback (void* info) + { + static_cast (info)->runLoopCallback(); + } +}; + +#endif // __JUCE_OSX_MESSAGEQUEUE_JUCEHEADER__ + +/*** End of inlined file: juce_osx_MessageQueue.h ***/ + + #if JUCE_IOS /*** Start of inlined file: juce_mac_Fonts.mm ***/ diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 793a9c999c..c8319e2705 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -73,7 +73,7 @@ namespace JuceDummyNamespace {} */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 54 -#define JUCE_BUILDNUMBER 9 +#define JUCE_BUILDNUMBER 10 /** Current Juce version number. @@ -12175,7 +12175,7 @@ private: } @endcode */ -class Result +class JUCE_API Result { public: @@ -22176,7 +22176,7 @@ private: Since the DLL is freed when this object is deleted, it's handy for managing library lifetimes using RAII. */ -class DynamicLibrary +class JUCE_API DynamicLibrary { public: /** Creates an unopened DynamicLibrary object. @@ -48225,7 +48225,12 @@ class JUCE_API MessageManager public: /** Returns the global instance of the MessageManager. */ - static MessageManager* getInstance() noexcept; + static MessageManager* getInstance(); + + /** Deletes the global MessageManager instance. + Does nothing if no instance had been created. + */ + static void deleteInstance(); /** Runs the event dispatch loop until a stop message is posted. diff --git a/src/core/juce_Initialisation.cpp b/src/core/juce_Initialisation.cpp index c899e4f12e..f9b904c4ff 100644 --- a/src/core/juce_Initialisation.cpp +++ b/src/core/juce_Initialisation.cpp @@ -27,42 +27,6 @@ BEGIN_JUCE_NAMESPACE -#include "../utilities/juce_DeletedAtShutdown.h" - -#if ! JUCE_ONLY_BUILD_CORE_LIBRARY - #include "../events/juce_MessageManager.h" -#endif - -//============================================================================== -#if ! JUCE_ONLY_BUILD_CORE_LIBRARY - -static bool juceInitialisedGUI = false; - -JUCE_API void JUCE_CALLTYPE initialiseJuce_GUI() -{ - if (! juceInitialisedGUI) - { - juceInitialisedGUI = true; - - JUCE_AUTORELEASEPOOL - MessageManager::getInstance(); - } -} - -JUCE_API void JUCE_CALLTYPE shutdownJuce_GUI() -{ - if (juceInitialisedGUI) - { - juceInitialisedGUI = false; - - JUCE_AUTORELEASEPOOL - DeletedAtShutdown::deleteAll(); - delete MessageManager::getInstance(); - } -} - -#endif - //============================================================================== #if JUCE_UNIT_TESTS diff --git a/src/core/juce_Result.h b/src/core/juce_Result.h index b9d1a1b792..70e68f7ea7 100644 --- a/src/core/juce_Result.h +++ b/src/core/juce_Result.h @@ -57,7 +57,7 @@ } @endcode */ -class Result +class JUCE_API Result { public: //============================================================================== diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index 8fa603b203..e581c9c2d9 100644 --- a/src/core/juce_StandardHeader.h +++ b/src/core/juce_StandardHeader.h @@ -33,7 +33,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 54 -#define JUCE_BUILDNUMBER 9 +#define JUCE_BUILDNUMBER 10 /** Current Juce version number. diff --git a/src/events/juce_MessageManager.cpp b/src/events/juce_MessageManager.cpp index 99cac80ecb..982378192c 100644 --- a/src/events/juce_MessageManager.cpp +++ b/src/events/juce_MessageManager.cpp @@ -63,7 +63,7 @@ MessageManager::~MessageManager() noexcept instance = nullptr; // do this last in case this instance is still needed by doPlatformSpecificShutdown() } -MessageManager* MessageManager::getInstance() noexcept +MessageManager* MessageManager::getInstance() { if (instance == nullptr) { @@ -74,6 +74,11 @@ MessageManager* MessageManager::getInstance() noexcept return instance; } +void MessageManager::deleteInstance() +{ + deleteAndZero (instance); +} + void MessageManager::postMessageToQueue (Message* const message) { if (quitMessagePosted || ! postMessageToSystemQueue (message)) @@ -315,5 +320,18 @@ MessageManagerLock::~MessageManagerLock() noexcept } } +//============================================================================== +JUCE_API void JUCE_CALLTYPE initialiseJuce_GUI() +{ + JUCE_AUTORELEASEPOOL + MessageManager::getInstance(); +} + +JUCE_API void JUCE_CALLTYPE shutdownJuce_GUI() +{ + JUCE_AUTORELEASEPOOL + DeletedAtShutdown::deleteAll(); + MessageManager::deleteInstance(); +} END_JUCE_NAMESPACE diff --git a/src/events/juce_MessageManager.h b/src/events/juce_MessageManager.h index e920786e00..a2a47468be 100644 --- a/src/events/juce_MessageManager.h +++ b/src/events/juce_MessageManager.h @@ -53,7 +53,12 @@ class JUCE_API MessageManager public: //============================================================================== /** Returns the global instance of the MessageManager. */ - static MessageManager* getInstance() noexcept; + static MessageManager* getInstance(); + + /** Deletes the global MessageManager instance. + Does nothing if no instance had been created. + */ + static void deleteInstance(); //============================================================================== /** Runs the event dispatch loop until a stop message is posted. diff --git a/src/native/android/juce_android_NativeCode.cpp b/src/native/android/juce_android_NativeCode.cpp index 3cda7f92f8..0fe58e4d91 100644 --- a/src/native/android/juce_android_NativeCode.cpp +++ b/src/native/android/juce_android_NativeCode.cpp @@ -89,7 +89,6 @@ BEGIN_JUCE_NAMESPACE #include "../../audio/midi/juce_MidiOutput.h" #include "../../audio/midi/juce_MidiInput.h" #include "../../containers/juce_ScopedValueSetter.h" -#include "../common/juce_MidiDataConcatenator.h" #define USE_ANDROID_CANVAS 0 diff --git a/src/native/common/juce_MidiDataConcatenator.h b/src/native/common/juce_MidiDataConcatenator.h index f6733664be..f39cbe4dc8 100644 --- a/src/native/common/juce_MidiDataConcatenator.h +++ b/src/native/common/juce_MidiDataConcatenator.h @@ -26,8 +26,6 @@ #ifndef __JUCE_MIDIDATACONCATENATOR_JUCEHEADER__ #define __JUCE_MIDIDATACONCATENATOR_JUCEHEADER__ -#if ! JUCE_ONLY_BUILD_CORE_LIBRARY - //============================================================================== /** Helper class that takes chunks of incoming midi bytes, packages them into @@ -141,6 +139,4 @@ private: JUCE_DECLARE_NON_COPYABLE (MidiDataConcatenator); }; -#endif - #endif // __JUCE_MIDIDATACONCATENATOR_JUCEHEADER__ diff --git a/src/native/linux/juce_linux_Threads.cpp b/src/native/linux/juce_linux_Threads.cpp index 202de742eb..34d423d7aa 100644 --- a/src/native/linux/juce_linux_Threads.cpp +++ b/src/native/linux/juce_linux_Threads.cpp @@ -33,30 +33,22 @@ */ //============================================================================== -// sets the process to 0=low priority, 1=normal, 2=high, 3=realtime -void Process::setPriority (ProcessPriority prior) +void Process::setPriority (const ProcessPriority prior) { - struct sched_param param; - int policy, maxp, minp; - - const int p = (int) prior; - - if (p <= 1) - policy = SCHED_OTHER; - else - policy = SCHED_RR; + const int policy = (prior <= NormalPriority) ? SCHED_OTHER : SCHED_RR; + const int minp = sched_get_priority_min (policy); + const int maxp = sched_get_priority_max (policy); - minp = sched_get_priority_min (policy); - maxp = sched_get_priority_max (policy); + struct sched_param param; - if (p < 2) - param.sched_priority = 0; - else if (p == 2 ) - // Set to middle of lower realtime priority range - param.sched_priority = minp + (maxp - minp) / 4; - else - // Set to middle of higher realtime priority range - param.sched_priority = minp + (3 * (maxp - minp) / 4); + switch (prior) + { + case LowPriority: + case NormalPriority: param.sched_priority = 0; break; + case HighPriority: param.sched_priority = minp + (maxp - minp) / 4; break; + case RealtimePriority: param.sched_priority = minp + (3 * (maxp - minp) / 4); break; + default: jassertfalse; break; + } pthread_setschedparam (pthread_self(), policy, ¶m); } @@ -91,8 +83,7 @@ JUCE_API bool JUCE_CALLTYPE Process::isRunningUnderDebugger() void Process::raisePrivilege() { - // If running suid root, change effective user - // to root + // If running suid root, change effective user to root if (geteuid() != 0 && getuid() == 0) { setreuid (geteuid(), getuid()); @@ -102,8 +93,7 @@ void Process::raisePrivilege() void Process::lowerPrivilege() { - // If runing suid root, change effective user - // back to real user + // If runing suid root, change effective user back to real user if (geteuid() == 0 && getuid() != 0) { setreuid (geteuid(), getuid()); diff --git a/src/native/mac/juce_mac_NativeCode.mm b/src/native/mac/juce_mac_NativeCode.mm index c0a90b6d82..288954e1a6 100644 --- a/src/native/mac/juce_mac_NativeCode.mm +++ b/src/native/mac/juce_mac_NativeCode.mm @@ -97,19 +97,14 @@ BEGIN_JUCE_NAMESPACE #include "../../audio/midi/juce_MidiInput.h" #include "../../containers/juce_ScopedValueSetter.h" #include "../../events/juce_AppleRemote.h" -#include "../common/juce_MidiDataConcatenator.h" #undef Point -#if ! JUCE_ONLY_BUILD_CORE_LIBRARY - #include "juce_osx_ObjCHelpers.h" - #include "juce_osx_MessageQueue.h" -#endif - //============================================================================== #define JUCE_INCLUDED_FILE 1 // Now include the actual code files.. +#include "juce_osx_ObjCHelpers.h" #include "juce_mac_ObjCSuffix.h" #include "juce_mac_Strings.mm" #include "juce_mac_SystemStats.mm" @@ -121,6 +116,9 @@ BEGIN_JUCE_NAMESPACE #include "juce_mac_Debugging.mm" #if ! JUCE_ONLY_BUILD_CORE_LIBRARY + #include "juce_osx_MessageQueue.h" + #include "../common/juce_MidiDataConcatenator.h" + #if JUCE_IOS #include "juce_mac_Fonts.mm" #include "juce_mac_CoreGraphicsContext.mm" diff --git a/src/native/windows/juce_win32_Messaging.cpp b/src/native/windows/juce_win32_Messaging.cpp index 30644414cc..c3b23bec0d 100644 --- a/src/native/windows/juce_win32_Messaging.cpp +++ b/src/native/windows/juce_win32_Messaging.cpp @@ -70,9 +70,6 @@ private: }; -//============================================================================== -HWND juce_messageWindowHandle = 0; // (this is referred to by other parts of the codebase) - //============================================================================== class JuceWindowIdentifier { diff --git a/src/native/windows/juce_win32_Misc.cpp b/src/native/windows/juce_win32_Misc.cpp index 2911ec2c57..5b0e6b5f05 100644 --- a/src/native/windows/juce_win32_Misc.cpp +++ b/src/native/windows/juce_win32_Misc.cpp @@ -38,9 +38,9 @@ bool juce_IsRunningInWine() //============================================================================== String JUCE_CALLTYPE Process::getCurrentCommandLineParams() { - return String (CharacterFunctions::findEndOfToken (CharPointer_UTF16 (GetCommandLineW()), - CharPointer_UTF16 (L" "), - CharPointer_UTF16 (L"\""))).trimStart(); + return CharacterFunctions::findEndOfToken (CharPointer_UTF16 (GetCommandLineW()), + CharPointer_UTF16 (L" "), + CharPointer_UTF16 (L"\"")).findEndOfWhitespace(); } //============================================================================== diff --git a/src/native/windows/juce_win32_NativeCode.cpp b/src/native/windows/juce_win32_NativeCode.cpp index 7463e06890..69d2c9ec4b 100644 --- a/src/native/windows/juce_win32_NativeCode.cpp +++ b/src/native/windows/juce_win32_NativeCode.cpp @@ -94,7 +94,6 @@ BEGIN_JUCE_NAMESPACE #include "../../audio/midi/juce_MidiInput.h" #include "../../containers/juce_ScopedValueSetter.h" #include "../../utilities/juce_WindowsRegistry.h" -#include "../common/juce_MidiDataConcatenator.h" //============================================================================== #define JUCE_INCLUDED_FILE 1 @@ -119,6 +118,7 @@ BEGIN_JUCE_NAMESPACE #include "juce_win32_WebBrowserComponent.cpp" #include "juce_win32_OpenGLComponent.cpp" #include "juce_win32_AudioCDReader.cpp" + #include "../common/juce_MidiDataConcatenator.h" #include "juce_win32_Midi.cpp" #include "juce_win32_ASIO.cpp" #include "juce_win32_DirectSound.cpp" diff --git a/src/native/windows/juce_win32_Registry.cpp b/src/native/windows/juce_win32_Registry.cpp index 8863cd205d..adf175a9bc 100644 --- a/src/native/windows/juce_win32_Registry.cpp +++ b/src/native/windows/juce_win32_Registry.cpp @@ -29,7 +29,7 @@ //============================================================================== -namespace +namespace RegistryHelpers { HKEY findKeyForPath (String name, const bool createForWriting, String& valueName) { @@ -70,7 +70,7 @@ namespace String WindowsRegistry::getValue (const String& regValuePath, const String& defaultValue) { String valueName, result (defaultValue); - HKEY k = findKeyForPath (regValuePath, false, valueName); + HKEY k = RegistryHelpers::findKeyForPath (regValuePath, false, valueName); if (k != 0) { @@ -95,7 +95,7 @@ String WindowsRegistry::getValue (const String& regValuePath, const String& defa void WindowsRegistry::setValue (const String& regValuePath, const String& value) { String valueName; - HKEY k = findKeyForPath (regValuePath, true, valueName); + HKEY k = RegistryHelpers::findKeyForPath (regValuePath, true, valueName); if (k != 0) { @@ -111,7 +111,7 @@ bool WindowsRegistry::valueExists (const String& regValuePath) { bool exists = false; String valueName; - HKEY k = findKeyForPath (regValuePath, false, valueName); + HKEY k = RegistryHelpers::findKeyForPath (regValuePath, false, valueName); if (k != 0) { @@ -131,7 +131,7 @@ bool WindowsRegistry::valueExists (const String& regValuePath) void WindowsRegistry::deleteValue (const String& regValuePath) { String valueName; - HKEY k = findKeyForPath (regValuePath, true, valueName); + HKEY k = RegistryHelpers::findKeyForPath (regValuePath, true, valueName); if (k != 0) { @@ -143,7 +143,7 @@ void WindowsRegistry::deleteValue (const String& regValuePath) void WindowsRegistry::deleteKey (const String& regKeyPath) { String valueName; - HKEY k = findKeyForPath (regKeyPath, true, valueName); + HKEY k = RegistryHelpers::findKeyForPath (regKeyPath, true, valueName); if (k != 0) { diff --git a/src/native/windows/juce_win32_Threads.cpp b/src/native/windows/juce_win32_Threads.cpp index 89cd60214c..7ddd2138f5 100644 --- a/src/native/windows/juce_win32_Threads.cpp +++ b/src/native/windows/juce_win32_Threads.cpp @@ -27,9 +27,7 @@ // compiled on its own). #if JUCE_INCLUDED_FILE -#if ! JUCE_ONLY_BUILD_CORE_LIBRARY - extern HWND juce_messageWindowHandle; -#endif +HWND juce_messageWindowHandle = 0; // (this is used by other parts of the codebase) //============================================================================== #if ! JUCE_USE_INTRINSICS @@ -118,10 +116,9 @@ void JUCE_API juce_threadEntryPoint (void*); static unsigned int __stdcall threadEntryProc (void* userData) { - #if ! JUCE_ONLY_BUILD_CORE_LIBRARY - AttachThreadInput (GetWindowThreadProcessId (juce_messageWindowHandle, 0), - GetCurrentThreadId(), TRUE); - #endif + if (juce_messageWindowHandle != 0) + AttachThreadInput (GetWindowThreadProcessId (juce_messageWindowHandle, 0), + GetCurrentThreadId(), TRUE); juce_threadEntryPoint (userData); diff --git a/src/threads/juce_DynamicLibrary.h b/src/threads/juce_DynamicLibrary.h index 3c4627284c..1b81f496c2 100644 --- a/src/threads/juce_DynamicLibrary.h +++ b/src/threads/juce_DynamicLibrary.h @@ -33,7 +33,7 @@ Since the DLL is freed when this object is deleted, it's handy for managing library lifetimes using RAII. */ -class DynamicLibrary +class JUCE_API DynamicLibrary { public: /** Creates an unopened DynamicLibrary object. diff --git a/src/threads/juce_Thread.cpp b/src/threads/juce_Thread.cpp index 69e5e75764..f9fcdebba2 100644 --- a/src/threads/juce_Thread.cpp +++ b/src/threads/juce_Thread.cpp @@ -338,5 +338,111 @@ void SpinLock::enter() const noexcept } } +//============================================================================== +#if JUCE_UNIT_TESTS + +#include "../utilities/juce_UnitTest.h" + +class AtomicTests : public UnitTest +{ +public: + AtomicTests() : UnitTest ("Atomics") {} + + void runTest() + { + beginTest ("Misc"); + + char a1[7]; + expect (numElementsInArray(a1) == 7); + int a2[3]; + expect (numElementsInArray(a2) == 3); + + expect (ByteOrder::swap ((uint16) 0x1122) == 0x2211); + expect (ByteOrder::swap ((uint32) 0x11223344) == 0x44332211); + expect (ByteOrder::swap ((uint64) literal64bit (0x1122334455667788)) == literal64bit (0x8877665544332211)); + + beginTest ("Atomic int"); + AtomicTester ::testInteger (*this); + beginTest ("Atomic unsigned int"); + AtomicTester ::testInteger (*this); + beginTest ("Atomic int32"); + AtomicTester ::testInteger (*this); + beginTest ("Atomic uint32"); + AtomicTester ::testInteger (*this); + beginTest ("Atomic long"); + AtomicTester ::testInteger (*this); + beginTest ("Atomic void*"); + AtomicTester ::testInteger (*this); + beginTest ("Atomic int*"); + AtomicTester ::testInteger (*this); + beginTest ("Atomic float"); + AtomicTester ::testFloat (*this); + #if ! JUCE_64BIT_ATOMICS_UNAVAILABLE // 64-bit intrinsics aren't available on some old platforms + beginTest ("Atomic int64"); + AtomicTester ::testInteger (*this); + beginTest ("Atomic uint64"); + AtomicTester ::testInteger (*this); + beginTest ("Atomic double"); + AtomicTester ::testFloat (*this); + #endif + } + + template + class AtomicTester + { + public: + AtomicTester() {} + + static void testInteger (UnitTest& test) + { + Atomic a, b; + a.set ((Type) 10); + test.expect (a.value == (Type) 10); + test.expect (a.get() == (Type) 10); + a += (Type) 15; + test.expect (a.get() == (Type) 25); + a.memoryBarrier(); + a -= (Type) 5; + test.expect (a.get() == (Type) 20); + test.expect (++a == (Type) 21); + ++a; + test.expect (--a == (Type) 21); + test.expect (a.get() == (Type) 21); + a.memoryBarrier(); + + testFloat (test); + } + + static void testFloat (UnitTest& test) + { + Atomic a, b; + a = (Type) 21; + a.memoryBarrier(); + + /* These are some simple test cases to check the atomics - let me know + if any of these assertions fail on your system! + */ + test.expect (a.get() == (Type) 21); + test.expect (a.compareAndSetValue ((Type) 100, (Type) 50) == (Type) 21); + test.expect (a.get() == (Type) 21); + test.expect (a.compareAndSetValue ((Type) 101, a.get()) == (Type) 21); + test.expect (a.get() == (Type) 101); + test.expect (! a.compareAndSetBool ((Type) 300, (Type) 200)); + test.expect (a.get() == (Type) 101); + test.expect (a.compareAndSetBool ((Type) 200, a.get())); + test.expect (a.get() == (Type) 200); + + test.expect (a.exchange ((Type) 300) == (Type) 200); + test.expect (a.get() == (Type) 300); + + b = a; + test.expect (b.get() == a.get()); + } + }; +}; + +static AtomicTests atomicUnitTests; + +#endif END_JUCE_NAMESPACE