| @@ -682,7 +682,7 @@ private: | |||||
| if (iPhone) | if (iPhone) | ||||
| { | { | ||||
| s.addTokens ("UIKit Foundation CoreGraphics AudioToolbox QuartzCore OpenGLES", false); | |||||
| s.addTokens ("UIKit Foundation CoreGraphics CoreText AudioToolbox QuartzCore OpenGLES", false); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -9,6 +9,7 @@ | |||||
| 1DF18F6B9CCFF7BD07C36AC2 = { isa = PBXBuildFile; fileRef = CE3A43E4FB4D61350C000764; }; | 1DF18F6B9CCFF7BD07C36AC2 = { isa = PBXBuildFile; fileRef = CE3A43E4FB4D61350C000764; }; | ||||
| 3BE296F09A47C0ECE4D91CF5 = { isa = PBXBuildFile; fileRef = 90E63FC1333F952D526FF194; }; | 3BE296F09A47C0ECE4D91CF5 = { isa = PBXBuildFile; fileRef = 90E63FC1333F952D526FF194; }; | ||||
| 7938A4501BDD574C4121B988 = { isa = PBXBuildFile; fileRef = 0D376A9686DFA1EAF983841C; }; | 7938A4501BDD574C4121B988 = { isa = PBXBuildFile; fileRef = 0D376A9686DFA1EAF983841C; }; | ||||
| 8223C2805B1A9ECA27926EB5 = { isa = PBXBuildFile; fileRef = 1CFED196602026EF91937A0E; }; | |||||
| 36AEC0EAE7AB9D061AD9EFEF = { isa = PBXBuildFile; fileRef = 7B6D428682221857EAEA1C7D; }; | 36AEC0EAE7AB9D061AD9EFEF = { isa = PBXBuildFile; fileRef = 7B6D428682221857EAEA1C7D; }; | ||||
| F1BAE9DCD179C8784FF28F8D = { isa = PBXBuildFile; fileRef = 4A96850C150C1C6D87A0D21A; }; | F1BAE9DCD179C8784FF28F8D = { isa = PBXBuildFile; fileRef = 4A96850C150C1C6D87A0D21A; }; | ||||
| 268F2BF480CF9844E2F2B974 = { isa = PBXBuildFile; fileRef = B72353F9624D99DB6F93E400; }; | 268F2BF480CF9844E2F2B974 = { isa = PBXBuildFile; fileRef = B72353F9624D99DB6F93E400; }; | ||||
| @@ -42,6 +43,7 @@ | |||||
| CE3A43E4FB4D61350C000764 = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; | CE3A43E4FB4D61350C000764 = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; | ||||
| 90E63FC1333F952D526FF194 = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; | 90E63FC1333F952D526FF194 = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; | ||||
| 0D376A9686DFA1EAF983841C = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; | 0D376A9686DFA1EAF983841C = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; | ||||
| 1CFED196602026EF91937A0E = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; }; | |||||
| 7B6D428682221857EAEA1C7D = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; | 7B6D428682221857EAEA1C7D = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; | ||||
| 4A96850C150C1C6D87A0D21A = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; | 4A96850C150C1C6D87A0D21A = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; | ||||
| B72353F9624D99DB6F93E400 = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; | B72353F9624D99DB6F93E400 = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; | ||||
| @@ -149,6 +151,7 @@ | |||||
| CE3A43E4FB4D61350C000764, | CE3A43E4FB4D61350C000764, | ||||
| 90E63FC1333F952D526FF194, | 90E63FC1333F952D526FF194, | ||||
| 0D376A9686DFA1EAF983841C, | 0D376A9686DFA1EAF983841C, | ||||
| 1CFED196602026EF91937A0E, | |||||
| 7B6D428682221857EAEA1C7D, | 7B6D428682221857EAEA1C7D, | ||||
| 4A96850C150C1C6D87A0D21A, | 4A96850C150C1C6D87A0D21A, | ||||
| B72353F9624D99DB6F93E400 ); name = Frameworks; sourceTree = "<group>"; }; | B72353F9624D99DB6F93E400 ); name = Frameworks; sourceTree = "<group>"; }; | ||||
| @@ -266,6 +269,7 @@ | |||||
| 1DF18F6B9CCFF7BD07C36AC2, | 1DF18F6B9CCFF7BD07C36AC2, | ||||
| 3BE296F09A47C0ECE4D91CF5, | 3BE296F09A47C0ECE4D91CF5, | ||||
| 7938A4501BDD574C4121B988, | 7938A4501BDD574C4121B988, | ||||
| 8223C2805B1A9ECA27926EB5, | |||||
| 36AEC0EAE7AB9D061AD9EFEF, | 36AEC0EAE7AB9D061AD9EFEF, | ||||
| F1BAE9DCD179C8784FF28F8D, | F1BAE9DCD179C8784FF28F8D, | ||||
| 268F2BF480CF9844E2F2B974 ); runOnlyForDeploymentPostprocessing = 0; }; | 268F2BF480CF9844E2F2B974 ); runOnlyForDeploymentPostprocessing = 0; }; | ||||
| @@ -9,6 +9,7 @@ | |||||
| BAEB975FAD8A99FA884DC593 = { isa = PBXBuildFile; fileRef = 6B236CD90C0803738D7B5235; }; | BAEB975FAD8A99FA884DC593 = { isa = PBXBuildFile; fileRef = 6B236CD90C0803738D7B5235; }; | ||||
| D8DBAED4AB03622A655367C6 = { isa = PBXBuildFile; fileRef = 3DE047A554FB376BE3DA4C65; }; | D8DBAED4AB03622A655367C6 = { isa = PBXBuildFile; fileRef = 3DE047A554FB376BE3DA4C65; }; | ||||
| 1622BC343C98F98AC2AC0459 = { isa = PBXBuildFile; fileRef = AA21728A979A53287A0DEFED; }; | 1622BC343C98F98AC2AC0459 = { isa = PBXBuildFile; fileRef = AA21728A979A53287A0DEFED; }; | ||||
| 2F1CDA747BD63008A80CB986 = { isa = PBXBuildFile; fileRef = B9E8EA7A70EBC92D121DD5EF; }; | |||||
| D397D8CEF8663F449B4439C0 = { isa = PBXBuildFile; fileRef = 18665A7A93EDBA956B64774E; }; | D397D8CEF8663F449B4439C0 = { isa = PBXBuildFile; fileRef = 18665A7A93EDBA956B64774E; }; | ||||
| 9EA4F1C0E2356AB5C07CE95E = { isa = PBXBuildFile; fileRef = E6809DE026C8BEAB082B3DEB; }; | 9EA4F1C0E2356AB5C07CE95E = { isa = PBXBuildFile; fileRef = E6809DE026C8BEAB082B3DEB; }; | ||||
| C37934E8A18A3A82637C1445 = { isa = PBXBuildFile; fileRef = 541D7BED72093B09E01E3FD1; }; | C37934E8A18A3A82637C1445 = { isa = PBXBuildFile; fileRef = 541D7BED72093B09E01E3FD1; }; | ||||
| @@ -21,6 +22,7 @@ | |||||
| 6B236CD90C0803738D7B5235 = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; | 6B236CD90C0803738D7B5235 = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; | ||||
| 3DE047A554FB376BE3DA4C65 = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; | 3DE047A554FB376BE3DA4C65 = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; | ||||
| AA21728A979A53287A0DEFED = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; | AA21728A979A53287A0DEFED = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; | ||||
| B9E8EA7A70EBC92D121DD5EF = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; }; | |||||
| 18665A7A93EDBA956B64774E = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; | 18665A7A93EDBA956B64774E = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; | ||||
| E6809DE026C8BEAB082B3DEB = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; | E6809DE026C8BEAB082B3DEB = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; | ||||
| 541D7BED72093B09E01E3FD1 = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; | 541D7BED72093B09E01E3FD1 = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; | ||||
| @@ -52,6 +54,7 @@ | |||||
| 6B236CD90C0803738D7B5235, | 6B236CD90C0803738D7B5235, | ||||
| 3DE047A554FB376BE3DA4C65, | 3DE047A554FB376BE3DA4C65, | ||||
| AA21728A979A53287A0DEFED, | AA21728A979A53287A0DEFED, | ||||
| B9E8EA7A70EBC92D121DD5EF, | |||||
| 18665A7A93EDBA956B64774E, | 18665A7A93EDBA956B64774E, | ||||
| E6809DE026C8BEAB082B3DEB, | E6809DE026C8BEAB082B3DEB, | ||||
| 541D7BED72093B09E01E3FD1 ); name = Frameworks; sourceTree = "<group>"; }; | 541D7BED72093B09E01E3FD1 ); name = Frameworks; sourceTree = "<group>"; }; | ||||
| @@ -145,6 +148,7 @@ | |||||
| BAEB975FAD8A99FA884DC593, | BAEB975FAD8A99FA884DC593, | ||||
| D8DBAED4AB03622A655367C6, | D8DBAED4AB03622A655367C6, | ||||
| 1622BC343C98F98AC2AC0459, | 1622BC343C98F98AC2AC0459, | ||||
| 2F1CDA747BD63008A80CB986, | |||||
| D397D8CEF8663F449B4439C0, | D397D8CEF8663F449B4439C0, | ||||
| 9EA4F1C0E2356AB5C07CE95E, | 9EA4F1C0E2356AB5C07CE95E, | ||||
| C37934E8A18A3A82637C1445 ); runOnlyForDeploymentPostprocessing = 0; }; | C37934E8A18A3A82637C1445 ); runOnlyForDeploymentPostprocessing = 0; }; | ||||
| @@ -872,6 +872,7 @@ protected: | |||||
| #import <CoreData/CoreData.h> | #import <CoreData/CoreData.h> | ||||
| #import <MobileCoreServices/MobileCoreServices.h> | #import <MobileCoreServices/MobileCoreServices.h> | ||||
| #import <QuartzCore/QuartzCore.h> | #import <QuartzCore/QuartzCore.h> | ||||
| #import <CoreText/CoreText.h> | |||||
| #include <sys/fcntl.h> | #include <sys/fcntl.h> | ||||
| #if JUCE_OPENGL | #if JUCE_OPENGL | ||||
| #include <OpenGLES/ES1/gl.h> | #include <OpenGLES/ES1/gl.h> | ||||
| @@ -1406,6 +1407,12 @@ Random::Random (const int64 seedValue) noexcept | |||||
| { | { | ||||
| } | } | ||||
| Random::Random() | |||||
| : seed (1) | |||||
| { | |||||
| setSeedRandomly(); | |||||
| } | |||||
| Random::~Random() noexcept | Random::~Random() noexcept | ||||
| { | { | ||||
| } | } | ||||
| @@ -1429,6 +1436,12 @@ void Random::setSeedRandomly() | |||||
| combineSeed (Time::currentTimeMillis()); | combineSeed (Time::currentTimeMillis()); | ||||
| } | } | ||||
| Random& Random::getSystemRandom() noexcept | |||||
| { | |||||
| static Random sysRand; | |||||
| return sysRand; | |||||
| } | |||||
| int Random::nextInt() noexcept | int Random::nextInt() noexcept | ||||
| { | { | ||||
| seed = (seed * literal64bit (0x5deece66d) + 11) & literal64bit (0xffffffffffff); | seed = (seed * literal64bit (0x5deece66d) + 11) & literal64bit (0xffffffffffff); | ||||
| @@ -1496,12 +1509,6 @@ void Random::fillBitsRandomly (BigInteger& arrayToChange, int startBit, int numB | |||||
| arrayToChange.setBit (startBit + numBits, nextBool()); | arrayToChange.setBit (startBit + numBits, nextBool()); | ||||
| } | } | ||||
| Random& Random::getSystemRandom() noexcept | |||||
| { | |||||
| static Random sysRand (1); | |||||
| return sysRand; | |||||
| } | |||||
| END_JUCE_NAMESPACE | END_JUCE_NAMESPACE | ||||
| /*** End of inlined file: juce_Random.cpp ***/ | /*** End of inlined file: juce_Random.cpp ***/ | ||||
| @@ -1654,10 +1661,27 @@ END_JUCE_NAMESPACE | |||||
| /*** Start of inlined file: juce_SystemStats.cpp ***/ | /*** Start of inlined file: juce_SystemStats.cpp ***/ | ||||
| BEGIN_JUCE_NAMESPACE | BEGIN_JUCE_NAMESPACE | ||||
| SystemStats::CPUFlags SystemStats::cpuFlags; | |||||
| const SystemStats::CPUFlags& SystemStats::getCPUFlags() | |||||
| { | |||||
| static CPUFlags cpuFlags; | |||||
| return cpuFlags; | |||||
| } | |||||
| const String SystemStats::getJUCEVersion() | const String SystemStats::getJUCEVersion() | ||||
| { | { | ||||
| // Some basic tests, to keep an eye on things and make sure these types work ok | |||||
| // on all platforms. Let me know if any of these assertions fail on your system! | |||||
| static_jassert (sizeof (pointer_sized_int) == sizeof (void*)); | |||||
| static_jassert (sizeof (int8) == 1); | |||||
| static_jassert (sizeof (uint8) == 1); | |||||
| static_jassert (sizeof (int16) == 2); | |||||
| static_jassert (sizeof (uint16) == 2); | |||||
| static_jassert (sizeof (int32) == 4); | |||||
| static_jassert (sizeof (uint32) == 4); | |||||
| static_jassert (sizeof (int64) == 8); | |||||
| static_jassert (sizeof (uint64) == 8); | |||||
| // (these confusing macros convert numbers into a single string literal) | |||||
| #define JUCE_STRINGIFYVERSION2(a) #a | #define JUCE_STRINGIFYVERSION2(a) #a | ||||
| #define JUCE_STRINGIFYVERSION(a) JUCE_STRINGIFYVERSION2(a) | #define JUCE_STRINGIFYVERSION(a) JUCE_STRINGIFYVERSION2(a) | ||||
| @@ -2209,10 +2233,6 @@ BEGIN_JUCE_NAMESPACE | |||||
| #endif | #endif | ||||
| #if JUCE_DEBUG | |||||
| extern void juce_CheckForDanglingStreams(); // (in juce_OutputStream.cpp) | |||||
| #endif | |||||
| static bool juceInitialisedNonGUI = false; | static bool juceInitialisedNonGUI = false; | ||||
| JUCE_API void JUCE_CALLTYPE initialiseJuce_NonGUI() | JUCE_API void JUCE_CALLTYPE initialiseJuce_NonGUI() | ||||
| @@ -2221,34 +2241,8 @@ JUCE_API void JUCE_CALLTYPE initialiseJuce_NonGUI() | |||||
| { | { | ||||
| juceInitialisedNonGUI = true; | juceInitialisedNonGUI = true; | ||||
| JUCE_AUTORELEASEPOOL | |||||
| DBG (SystemStats::getJUCEVersion()); | DBG (SystemStats::getJUCEVersion()); | ||||
| SystemStats::initialiseStats(); | |||||
| Random::getSystemRandom().setSeedRandomly(); // (mustn't call this before initialiseStats() because it relies on the time being set up) | |||||
| } | } | ||||
| // Some basic tests, to keep an eye on things and make sure these types work ok | |||||
| // on all platforms. Let me know if any of these assertions fail on your system! | |||||
| static_jassert (sizeof (pointer_sized_int) == sizeof (void*)); | |||||
| static_jassert (sizeof (int8) == 1); | |||||
| static_jassert (sizeof (uint8) == 1); | |||||
| static_jassert (sizeof (int16) == 2); | |||||
| static_jassert (sizeof (uint16) == 2); | |||||
| static_jassert (sizeof (int32) == 4); | |||||
| static_jassert (sizeof (uint32) == 4); | |||||
| static_jassert (sizeof (int64) == 8); | |||||
| static_jassert (sizeof (uint64) == 8); | |||||
| #if JUCE_NATIVE_WCHAR_IS_UTF8 | |||||
| static_jassert (sizeof (wchar_t) == 1); | |||||
| #elif JUCE_NATIVE_WCHAR_IS_UTF16 | |||||
| static_jassert (sizeof (wchar_t) == 2); | |||||
| #elif JUCE_NATIVE_WCHAR_IS_UTF32 | |||||
| static_jassert (sizeof (wchar_t) == 4); | |||||
| #else | |||||
| #error "native wchar_t size is unknown" | |||||
| #endif | |||||
| } | } | ||||
| JUCE_API void JUCE_CALLTYPE shutdownJuce_NonGUI() | JUCE_API void JUCE_CALLTYPE shutdownJuce_NonGUI() | ||||
| @@ -2257,14 +2251,7 @@ JUCE_API void JUCE_CALLTYPE shutdownJuce_NonGUI() | |||||
| { | { | ||||
| juceInitialisedNonGUI = false; | juceInitialisedNonGUI = false; | ||||
| JUCE_AUTORELEASEPOOL | |||||
| LocalisedStrings::setCurrentMappings (nullptr); | |||||
| Thread::stopAllThreads (3000); | Thread::stopAllThreads (3000); | ||||
| #if JUCE_DEBUG | |||||
| juce_CheckForDanglingStreams(); | |||||
| #endif | |||||
| } | } | ||||
| } | } | ||||
| @@ -6720,7 +6707,7 @@ const BigInteger Primes::createProbablePrime (const int bitLength, | |||||
| { | { | ||||
| randomSeeds = defaultSeeds; | randomSeeds = defaultSeeds; | ||||
| numRandomSeeds = numElementsInArray (defaultSeeds); | numRandomSeeds = numElementsInArray (defaultSeeds); | ||||
| Random r (0); | |||||
| Random r; | |||||
| for (int j = 10; --j >= 0;) | for (int j = 10; --j >= 0;) | ||||
| { | { | ||||
| @@ -7123,32 +7110,40 @@ END_JUCE_NAMESPACE | |||||
| BEGIN_JUCE_NAMESPACE | BEGIN_JUCE_NAMESPACE | ||||
| #if JUCE_DEBUG | #if JUCE_DEBUG | ||||
| static Array<void*, CriticalSection> activeStreams; | |||||
| void juce_CheckForDanglingStreams() | |||||
| struct DanglingStreamChecker | |||||
| { | { | ||||
| /* | |||||
| It's always a bad idea to leak any object, but if you're leaking output | |||||
| streams, then there's a good chance that you're failing to flush a file | |||||
| to disk properly, which could result in corrupted data and other similar | |||||
| nastiness.. | |||||
| */ | |||||
| jassert (activeStreams.size() == 0); | |||||
| DanglingStreamChecker() {} | |||||
| ~DanglingStreamChecker() | |||||
| { | |||||
| /* | |||||
| It's always a bad idea to leak any object, but if you're leaking output | |||||
| streams, then there's a good chance that you're failing to flush a file | |||||
| to disk properly, which could result in corrupted data and other similar | |||||
| nastiness.. | |||||
| */ | |||||
| jassert (activeStreams.size() == 0); | |||||
| } | |||||
| Array<void*, CriticalSection> activeStreams; | |||||
| }; | }; | ||||
| static DanglingStreamChecker danglingStreamChecker; | |||||
| #endif | #endif | ||||
| OutputStream::OutputStream() | OutputStream::OutputStream() | ||||
| : newLineString (NewLine::getDefault()) | : newLineString (NewLine::getDefault()) | ||||
| { | { | ||||
| #if JUCE_DEBUG | #if JUCE_DEBUG | ||||
| activeStreams.add (this); | |||||
| danglingStreamChecker.activeStreams.add (this); | |||||
| #endif | #endif | ||||
| } | } | ||||
| OutputStream::~OutputStream() | OutputStream::~OutputStream() | ||||
| { | { | ||||
| #if JUCE_DEBUG | #if JUCE_DEBUG | ||||
| activeStreams.removeValue (this); | |||||
| danglingStreamChecker.activeStreams.removeValue (this); | |||||
| #endif | #endif | ||||
| } | } | ||||
| @@ -11418,6 +11413,23 @@ const String LocalisedStrings::translate (const String& text) const | |||||
| namespace | namespace | ||||
| { | { | ||||
| #if JUCE_CHECK_MEMORY_LEAKS | |||||
| // By using this object to force a LocalisedStrings object to be created | |||||
| // before the currentMappings object, we can force the static order-of-destruction to | |||||
| // delete the currentMappings object first, which avoids a bogus leak warning. | |||||
| // (Oddly, just creating a LocalisedStrings on the stack doesn't work in gcc, it | |||||
| // has to be created with 'new' for this to work..) | |||||
| struct LeakAvoidanceTrick | |||||
| { | |||||
| LeakAvoidanceTrick() | |||||
| { | |||||
| const ScopedPointer<LocalisedStrings> dummy (new LocalisedStrings (String())); | |||||
| } | |||||
| }; | |||||
| LeakAvoidanceTrick leakAvoidanceTrick; | |||||
| #endif | |||||
| SpinLock currentMappingsLock; | SpinLock currentMappingsLock; | ||||
| ScopedPointer<LocalisedStrings> currentMappings; | ScopedPointer<LocalisedStrings> currentMappings; | ||||
| @@ -11706,6 +11718,20 @@ private: | |||||
| return reinterpret_cast <StringHolder*> (reinterpret_cast <char*> (text.getAddress()) | return reinterpret_cast <StringHolder*> (reinterpret_cast <char*> (text.getAddress()) | ||||
| - (reinterpret_cast <size_t> (reinterpret_cast <StringHolder*> (1)->text) - 1)); | - (reinterpret_cast <size_t> (reinterpret_cast <StringHolder*> (1)->text) - 1)); | ||||
| } | } | ||||
| void compileTimeChecks() | |||||
| { | |||||
| // Let me know if any of these assertions fail on your system! | |||||
| #if JUCE_NATIVE_WCHAR_IS_UTF8 | |||||
| static_jassert (sizeof (wchar_t) == 1); | |||||
| #elif JUCE_NATIVE_WCHAR_IS_UTF16 | |||||
| static_jassert (sizeof (wchar_t) == 2); | |||||
| #elif JUCE_NATIVE_WCHAR_IS_UTF32 | |||||
| static_jassert (sizeof (wchar_t) == 4); | |||||
| #else | |||||
| #error "native wchar_t size is unknown" | |||||
| #endif | |||||
| } | |||||
| }; | }; | ||||
| StringHolder StringHolder::empty; | StringHolder StringHolder::empty; | ||||
| @@ -41089,6 +41115,8 @@ void Component::setAlwaysOnTop (const bool shouldStayOnTop) | |||||
| { | { | ||||
| if (shouldStayOnTop != flags.alwaysOnTopFlag) | if (shouldStayOnTop != flags.alwaysOnTopFlag) | ||||
| { | { | ||||
| BailOutChecker checker (this); | |||||
| flags.alwaysOnTopFlag = shouldStayOnTop; | flags.alwaysOnTopFlag = shouldStayOnTop; | ||||
| if (isOnDesktop()) | if (isOnDesktop()) | ||||
| @@ -41109,10 +41137,11 @@ void Component::setAlwaysOnTop (const bool shouldStayOnTop) | |||||
| } | } | ||||
| } | } | ||||
| if (shouldStayOnTop) | |||||
| if (shouldStayOnTop && ! checker.shouldBailOut()) | |||||
| toFront (false); | toFront (false); | ||||
| internalHierarchyChanged(); | |||||
| if (! checker.shouldBailOut()) | |||||
| internalHierarchyChanged(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -100215,7 +100244,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ | |||||
| #endif | #endif | ||||
| /* Diagnostic functions */ | /* Diagnostic functions */ | ||||
| #ifdef DEBUG | |||||
| #if 0 | |||||
| # include <stdio.h> | # include <stdio.h> | ||||
| extern int z_verbose; | extern int z_verbose; | ||||
| extern void z_error OF((const char *m)); | extern void z_error OF((const char *m)); | ||||
| @@ -100232,6 +100261,8 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ | |||||
| # define Tracevv(x) | # define Tracevv(x) | ||||
| # define Tracec(c,x) | # define Tracec(c,x) | ||||
| # define Tracecv(c,x) | # define Tracecv(c,x) | ||||
| # define z_error(x) | |||||
| # define z_verbose 0 | |||||
| #endif | #endif | ||||
| voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); | voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); | ||||
| @@ -106759,7 +106790,7 @@ uLong ZEXPORT zlibCompileFlags() | |||||
| return flags; | return flags; | ||||
| }*/ | }*/ | ||||
| #ifdef DEBUG | |||||
| #if 0 | |||||
| # ifndef verbose | # ifndef verbose | ||||
| # define verbose 0 | # define verbose 0 | ||||
| @@ -243208,9 +243239,6 @@ void Logger::outputDebugString (const String& text) | |||||
| OutputDebugString ((text + "\n").toWideCharPointer()); | OutputDebugString ((text + "\n").toWideCharPointer()); | ||||
| } | } | ||||
| static int64 hiResTicksPerSecond; | |||||
| static double hiResTicksScaleFactor; | |||||
| #if JUCE_USE_INTRINSICS || JUCE_64BIT | #if JUCE_USE_INTRINSICS || JUCE_64BIT | ||||
| // CPU info functions using intrinsics... | // CPU info functions using intrinsics... | ||||
| @@ -243275,38 +243303,33 @@ const String SystemStats::getCpuVendor() | |||||
| } | } | ||||
| #endif | #endif | ||||
| void SystemStats::initialiseStats() | |||||
| SystemStats::CPUFlags::CPUFlags() | |||||
| { | { | ||||
| cpuFlags.hasMMX = IsProcessorFeaturePresent (PF_MMX_INSTRUCTIONS_AVAILABLE) != 0; | |||||
| cpuFlags.hasSSE = IsProcessorFeaturePresent (PF_XMMI_INSTRUCTIONS_AVAILABLE) != 0; | |||||
| cpuFlags.hasSSE2 = IsProcessorFeaturePresent (PF_XMMI64_INSTRUCTIONS_AVAILABLE) != 0; | |||||
| hasMMX = IsProcessorFeaturePresent (PF_MMX_INSTRUCTIONS_AVAILABLE) != 0; | |||||
| hasSSE = IsProcessorFeaturePresent (PF_XMMI_INSTRUCTIONS_AVAILABLE) != 0; | |||||
| hasSSE2 = IsProcessorFeaturePresent (PF_XMMI64_INSTRUCTIONS_AVAILABLE) != 0; | |||||
| #ifdef PF_AMD3D_INSTRUCTIONS_AVAILABLE | #ifdef PF_AMD3D_INSTRUCTIONS_AVAILABLE | ||||
| cpuFlags.has3DNow = IsProcessorFeaturePresent (PF_AMD3D_INSTRUCTIONS_AVAILABLE) != 0; | |||||
| has3DNow = IsProcessorFeaturePresent (PF_AMD3D_INSTRUCTIONS_AVAILABLE) != 0; | |||||
| #else | #else | ||||
| cpuFlags.has3DNow = IsProcessorFeaturePresent (PF_3DNOW_INSTRUCTIONS_AVAILABLE) != 0; | |||||
| has3DNow = IsProcessorFeaturePresent (PF_3DNOW_INSTRUCTIONS_AVAILABLE) != 0; | |||||
| #endif | #endif | ||||
| SYSTEM_INFO systemInfo; | |||||
| GetSystemInfo (&systemInfo); | |||||
| numCpus = systemInfo.dwNumberOfProcessors; | |||||
| } | |||||
| #if JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS | |||||
| struct DebugFlagsInitialiser | |||||
| { | |||||
| DebugFlagsInitialiser() | |||||
| { | { | ||||
| SYSTEM_INFO systemInfo; | |||||
| GetSystemInfo (&systemInfo); | |||||
| cpuFlags.numCpus = systemInfo.dwNumberOfProcessors; | |||||
| _CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); | |||||
| } | } | ||||
| }; | |||||
| LARGE_INTEGER f; | |||||
| QueryPerformanceFrequency (&f); | |||||
| hiResTicksPerSecond = f.QuadPart; | |||||
| hiResTicksScaleFactor = 1000.0 / hiResTicksPerSecond; | |||||
| String s (SystemStats::getJUCEVersion()); | |||||
| const MMRESULT res = timeBeginPeriod (1); | |||||
| (void) res; | |||||
| jassert (res == TIMERR_NOERROR); | |||||
| #if JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS | |||||
| _CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); | |||||
| #endif | |||||
| } | |||||
| static DebugFlagsInitialiser debugFlagsInitialiser; | |||||
| #endif | |||||
| SystemStats::OperatingSystemType SystemStats::getOperatingSystemType() | SystemStats::OperatingSystemType SystemStats::getOperatingSystemType() | ||||
| { | { | ||||
| @@ -243379,34 +243402,54 @@ uint32 juce_millisecondsSinceStartup() noexcept | |||||
| return (uint32) timeGetTime(); | return (uint32) timeGetTime(); | ||||
| } | } | ||||
| int64 Time::getHighResolutionTicks() noexcept | |||||
| class HiResCounterHandler | |||||
| { | { | ||||
| LARGE_INTEGER ticks; | |||||
| QueryPerformanceCounter (&ticks); | |||||
| public: | |||||
| HiResCounterHandler() | |||||
| : hiResTicksOffset (0) | |||||
| { | |||||
| const MMRESULT res = timeBeginPeriod (1); | |||||
| (void) res; | |||||
| jassert (res == TIMERR_NOERROR); | |||||
| LARGE_INTEGER f; | |||||
| QueryPerformanceFrequency (&f); | |||||
| hiResTicksPerSecond = f.QuadPart; | |||||
| hiResTicksScaleFactor = 1000.0 / hiResTicksPerSecond; | |||||
| } | |||||
| const int64 mainCounterAsHiResTicks = (juce_millisecondsSinceStartup() * hiResTicksPerSecond) / 1000; | |||||
| const int64 newOffset = mainCounterAsHiResTicks - ticks.QuadPart; | |||||
| inline int64 getHighResolutionTicks() noexcept | |||||
| { | |||||
| LARGE_INTEGER ticks; | |||||
| QueryPerformanceCounter (&ticks); | |||||
| // fix for a very obscure PCI hardware bug that can make the counter | |||||
| // sometimes jump forwards by a few seconds.. | |||||
| static int64 hiResTicksOffset = 0; | |||||
| const int64 offsetDrift = abs64 (newOffset - hiResTicksOffset); | |||||
| const int64 mainCounterAsHiResTicks = (juce_millisecondsSinceStartup() * hiResTicksPerSecond) / 1000; | |||||
| const int64 newOffset = mainCounterAsHiResTicks - ticks.QuadPart; | |||||
| if (offsetDrift > (hiResTicksPerSecond >> 1)) | |||||
| hiResTicksOffset = newOffset; | |||||
| // fix for a very obscure PCI hardware bug that can make the counter | |||||
| // sometimes jump forwards by a few seconds.. | |||||
| const int64 offsetDrift = abs64 (newOffset - hiResTicksOffset); | |||||
| return ticks.QuadPart + hiResTicksOffset; | |||||
| } | |||||
| if (offsetDrift > (hiResTicksPerSecond >> 1)) | |||||
| hiResTicksOffset = newOffset; | |||||
| double Time::getMillisecondCounterHiRes() noexcept | |||||
| { | |||||
| return getHighResolutionTicks() * hiResTicksScaleFactor; | |||||
| } | |||||
| return ticks.QuadPart + hiResTicksOffset; | |||||
| } | |||||
| int64 Time::getHighResolutionTicksPerSecond() noexcept | |||||
| { | |||||
| return hiResTicksPerSecond; | |||||
| } | |||||
| inline double getMillisecondCounterHiRes() noexcept | |||||
| { | |||||
| return getHighResolutionTicks() * hiResTicksScaleFactor; | |||||
| } | |||||
| int64 hiResTicksPerSecond, hiResTicksOffset; | |||||
| double hiResTicksScaleFactor; | |||||
| }; | |||||
| static HiResCounterHandler hiResCounterHandler; | |||||
| int64 Time::getHighResolutionTicksPerSecond() noexcept { return hiResCounterHandler.hiResTicksPerSecond; } | |||||
| int64 Time::getHighResolutionTicks() noexcept { return hiResCounterHandler.getHighResolutionTicks(); } | |||||
| double Time::getMillisecondCounterHiRes() noexcept { return hiResCounterHandler.getMillisecondCounterHiRes(); } | |||||
| static int64 juce_getClockCycleCounter() noexcept | static int64 juce_getClockCycleCounter() noexcept | ||||
| { | { | ||||
| @@ -261378,15 +261421,15 @@ const String SystemStats::getComputerName() | |||||
| return String::empty; | return String::empty; | ||||
| } | } | ||||
| void SystemStats::initialiseStats() | |||||
| SystemStats::CPUFlags::CPUFlags() | |||||
| { | { | ||||
| const String flags (LinuxStatsHelpers::getCpuInfo ("flags")); | const String flags (LinuxStatsHelpers::getCpuInfo ("flags")); | ||||
| cpuFlags.hasMMX = flags.contains ("mmx"); | |||||
| cpuFlags.hasSSE = flags.contains ("sse"); | |||||
| cpuFlags.hasSSE2 = flags.contains ("sse2"); | |||||
| cpuFlags.has3DNow = flags.contains ("3dnow"); | |||||
| hasMMX = flags.contains ("mmx"); | |||||
| hasSSE = flags.contains ("sse"); | |||||
| hasSSE2 = flags.contains ("sse2"); | |||||
| has3DNow = flags.contains ("3dnow"); | |||||
| cpuFlags.numCpus = LinuxStatsHelpers::getCpuInfo ("processor").getIntValue() + 1; | |||||
| numCpus = LinuxStatsHelpers::getCpuInfo ("processor").getIntValue() + 1; | |||||
| } | } | ||||
| void PlatformUtilities::fpuReset() | void PlatformUtilities::fpuReset() | ||||
| @@ -268596,10 +268639,7 @@ const String SystemClipboard::getTextFromClipboard() | |||||
| namespace SystemStatsHelpers | namespace SystemStatsHelpers | ||||
| { | { | ||||
| static int64 highResTimerFrequency = 0; | |||||
| static double highResTimerToMillisecRatio = 0; | |||||
| #if JUCE_INTEL | |||||
| #if JUCE_INTEL | |||||
| void doCPUID (uint32& a, uint32& b, uint32& c, uint32& d, uint32 type) | void doCPUID (uint32& a, uint32& b, uint32& c, uint32& d, uint32 type) | ||||
| { | { | ||||
| uint32 la = a, lb = b, lc = c, ld = d; | uint32 la = a, lb = b, lc = c, ld = d; | ||||
| @@ -268615,56 +268655,50 @@ namespace SystemStatsHelpers | |||||
| a = la; b = lb; c = lc; d = ld; | a = la; b = lb; c = lc; d = ld; | ||||
| } | } | ||||
| #endif | |||||
| #endif | |||||
| } | } | ||||
| void SystemStats::initialiseStats() | |||||
| SystemStats::CPUFlags::CPUFlags() | |||||
| { | { | ||||
| using namespace SystemStatsHelpers; | |||||
| static bool initialised = false; | |||||
| if (! initialised) | |||||
| { | |||||
| initialised = true; | |||||
| #if JUCE_MAC | |||||
| [NSApplication sharedApplication]; | |||||
| #endif | |||||
| #if JUCE_INTEL | |||||
| uint32 familyModel = 0, extFeatures = 0, features = 0, dummy = 0; | |||||
| doCPUID (familyModel, extFeatures, dummy, features, 1); | |||||
| cpuFlags.hasMMX = ((features & (1 << 23)) != 0); | |||||
| cpuFlags.hasSSE = ((features & (1 << 25)) != 0); | |||||
| cpuFlags.hasSSE2 = ((features & (1 << 26)) != 0); | |||||
| cpuFlags.has3DNow = ((extFeatures & (1 << 31)) != 0); | |||||
| #else | |||||
| cpuFlags.hasMMX = false; | |||||
| cpuFlags.hasSSE = false; | |||||
| cpuFlags.hasSSE2 = false; | |||||
| cpuFlags.has3DNow = false; | |||||
| #endif | |||||
| #if JUCE_INTEL | |||||
| uint32 familyModel = 0, extFeatures = 0, features = 0, dummy = 0; | |||||
| SystemStatsHelpers::doCPUID (familyModel, extFeatures, dummy, features, 1); | |||||
| #if JUCE_IOS || (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5) | |||||
| cpuFlags.numCpus = (int) [[NSProcessInfo processInfo] activeProcessorCount]; | |||||
| #else | |||||
| cpuFlags.numCpus = (int) MPProcessors(); | |||||
| #endif | |||||
| hasMMX = (features & (1 << 23)) != 0; | |||||
| hasSSE = (features & (1 << 25)) != 0; | |||||
| hasSSE2 = (features & (1 << 26)) != 0; | |||||
| has3DNow = (extFeatures & (1 << 31)) != 0; | |||||
| #else | |||||
| hasMMX = false; | |||||
| hasSSE = false; | |||||
| hasSSE2 = false; | |||||
| has3DNow = false; | |||||
| #endif | |||||
| mach_timebase_info_data_t timebase; | |||||
| (void) mach_timebase_info (&timebase); | |||||
| highResTimerFrequency = (int64) (1.0e9 * timebase.denom / timebase.numer); | |||||
| highResTimerToMillisecRatio = timebase.numer / (1.0e6 * timebase.denom); | |||||
| #if JUCE_IOS || (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5) | |||||
| numCpus = (int) [[NSProcessInfo processInfo] activeProcessorCount]; | |||||
| #else | |||||
| numCpus = (int) MPProcessors(); | |||||
| #endif | |||||
| } | |||||
| String s (SystemStats::getJUCEVersion()); | |||||
| #if JUCE_MAC | |||||
| struct SharedAppInitialiser | |||||
| { | |||||
| SharedAppInitialiser() | |||||
| { | |||||
| JUCE_AUTORELEASEPOOL | |||||
| [NSApplication sharedApplication]; | |||||
| rlimit lim; | rlimit lim; | ||||
| getrlimit (RLIMIT_NOFILE, &lim); | getrlimit (RLIMIT_NOFILE, &lim); | ||||
| lim.rlim_cur = lim.rlim_max = RLIM_INFINITY; | lim.rlim_cur = lim.rlim_max = RLIM_INFINITY; | ||||
| setrlimit (RLIMIT_NOFILE, &lim); | setrlimit (RLIMIT_NOFILE, &lim); | ||||
| } | } | ||||
| } | |||||
| }; | |||||
| static SharedAppInitialiser sharedAppInitialiser; | |||||
| #endif | |||||
| SystemStats::OperatingSystemType SystemStats::getOperatingSystemType() | SystemStats::OperatingSystemType SystemStats::getOperatingSystemType() | ||||
| { | { | ||||
| @@ -268755,25 +268789,37 @@ const String SystemStats::getComputerName() | |||||
| return String::empty; | return String::empty; | ||||
| } | } | ||||
| uint32 juce_millisecondsSinceStartup() noexcept | |||||
| class HiResCounterHandler | |||||
| { | { | ||||
| return (uint32) (mach_absolute_time() * SystemStatsHelpers::highResTimerToMillisecRatio); | |||||
| } | |||||
| public: | |||||
| HiResCounterHandler() | |||||
| { | |||||
| mach_timebase_info_data_t timebase; | |||||
| (void) mach_timebase_info (&timebase); | |||||
| highResTimerFrequency = (int64) (1.0e9 * timebase.denom / timebase.numer); | |||||
| highResTimerToMillisecRatio = timebase.numer / (1.0e6 * timebase.denom); | |||||
| } | |||||
| double Time::getMillisecondCounterHiRes() noexcept | |||||
| { | |||||
| return mach_absolute_time() * SystemStatsHelpers::highResTimerToMillisecRatio; | |||||
| } | |||||
| inline uint32 millisecondsSinceStartup() const noexcept | |||||
| { | |||||
| return (uint32) (mach_absolute_time() * highResTimerToMillisecRatio); | |||||
| } | |||||
| int64 Time::getHighResolutionTicks() noexcept | |||||
| { | |||||
| return (int64) mach_absolute_time(); | |||||
| } | |||||
| inline double getMillisecondCounterHiRes() const noexcept | |||||
| { | |||||
| return mach_absolute_time() * highResTimerToMillisecRatio; | |||||
| } | |||||
| int64 Time::getHighResolutionTicksPerSecond() noexcept | |||||
| { | |||||
| return SystemStatsHelpers::highResTimerFrequency; | |||||
| } | |||||
| int64 highResTimerFrequency; | |||||
| double highResTimerToMillisecRatio; | |||||
| }; | |||||
| static HiResCounterHandler hiResCounterHandler; | |||||
| uint32 juce_millisecondsSinceStartup() noexcept { return hiResCounterHandler.millisecondsSinceStartup(); } | |||||
| double Time::getMillisecondCounterHiRes() noexcept { return hiResCounterHandler.getMillisecondCounterHiRes(); } | |||||
| int64 Time::getHighResolutionTicksPerSecond() noexcept { return hiResCounterHandler.highResTimerFrequency; } | |||||
| int64 Time::getHighResolutionTicks() noexcept { return (int64) mach_absolute_time(); } | |||||
| bool Time::setSystemTimeToThisTime() const | bool Time::setSystemTimeToThisTime() const | ||||
| { | { | ||||
| @@ -286270,15 +286316,15 @@ const String SystemStats::getComputerName() | |||||
| return String::empty; | return String::empty; | ||||
| } | } | ||||
| void SystemStats::initialiseStats() | |||||
| SystemStats::CPUFlags::CPUFlags() | |||||
| { | { | ||||
| // TODO | // TODO | ||||
| cpuFlags.hasMMX = false; | |||||
| cpuFlags.hasSSE = false; | |||||
| cpuFlags.hasSSE2 = false; | |||||
| cpuFlags.has3DNow = false; | |||||
| hasMMX = false; | |||||
| hasSSE = false; | |||||
| hasSSE2 = false; | |||||
| has3DNow = false; | |||||
| cpuFlags.numCpus = jmax (1, sysconf (_SC_NPROCESSORS_ONLN)); | |||||
| numCpus = jmax (1, sysconf (_SC_NPROCESSORS_ONLN)); | |||||
| } | } | ||||
| void PlatformUtilities::fpuReset() {} | void PlatformUtilities::fpuReset() {} | ||||
| @@ -73,7 +73,7 @@ namespace JuceDummyNamespace {} | |||||
| */ | */ | ||||
| #define JUCE_MAJOR_VERSION 1 | #define JUCE_MAJOR_VERSION 1 | ||||
| #define JUCE_MINOR_VERSION 53 | #define JUCE_MINOR_VERSION 53 | ||||
| #define JUCE_BUILDNUMBER 78 | |||||
| #define JUCE_BUILDNUMBER 79 | |||||
| /** Current Juce version number. | /** Current Juce version number. | ||||
| @@ -7073,7 +7073,7 @@ public: | |||||
| @param index the index of the element being requested (0 is the first element in the array) | @param index the index of the element being requested (0 is the first element in the array) | ||||
| @see getUnchecked, getFirst, getLast | @see getUnchecked, getFirst, getLast | ||||
| */ | */ | ||||
| inline ElementType operator[] (const int index) const | |||||
| const ElementType operator[] (const int index) const | |||||
| { | { | ||||
| const ScopedLockType lock (getLock()); | const ScopedLockType lock (getLock()); | ||||
| return isPositiveAndBelow (index, numUsed) ? data.elements [index] | return isPositiveAndBelow (index, numUsed) ? data.elements [index] | ||||
| @@ -18278,19 +18278,19 @@ public: | |||||
| static const String getCpuVendor(); | static const String getCpuVendor(); | ||||
| /** Checks whether Intel MMX instructions are available. */ | /** Checks whether Intel MMX instructions are available. */ | ||||
| static bool hasMMX() noexcept { return cpuFlags.hasMMX; } | |||||
| static bool hasMMX() noexcept { return getCPUFlags().hasMMX; } | |||||
| /** Checks whether Intel SSE instructions are available. */ | /** Checks whether Intel SSE instructions are available. */ | ||||
| static bool hasSSE() noexcept { return cpuFlags.hasSSE; } | |||||
| static bool hasSSE() noexcept { return getCPUFlags().hasSSE; } | |||||
| /** Checks whether Intel SSE2 instructions are available. */ | /** Checks whether Intel SSE2 instructions are available. */ | ||||
| static bool hasSSE2() noexcept { return cpuFlags.hasSSE2; } | |||||
| static bool hasSSE2() noexcept { return getCPUFlags().hasSSE2; } | |||||
| /** Checks whether AMD 3DNOW instructions are available. */ | /** Checks whether AMD 3DNOW instructions are available. */ | ||||
| static bool has3DNow() noexcept { return cpuFlags.has3DNow; } | |||||
| static bool has3DNow() noexcept { return getCPUFlags().has3DNow; } | |||||
| /** Returns the number of CPUs. */ | /** Returns the number of CPUs. */ | ||||
| static int getNumCpus() noexcept { return cpuFlags.numCpus; } | |||||
| static int getNumCpus() noexcept { return getCPUFlags().numCpus; } | |||||
| /** Finds out how much RAM is in the machine. | /** Finds out how much RAM is in the machine. | ||||
| @@ -18305,12 +18305,12 @@ public: | |||||
| */ | */ | ||||
| static int getPageSize(); | static int getPageSize(); | ||||
| // not-for-public-use platform-specific method gets called at startup to initialise things. | |||||
| static void initialiseStats(); | |||||
| private: | private: | ||||
| struct CPUFlags | struct CPUFlags | ||||
| { | { | ||||
| CPUFlags(); | |||||
| int numCpus; | int numCpus; | ||||
| bool hasMMX : 1; | bool hasMMX : 1; | ||||
| bool hasSSE : 1; | bool hasSSE : 1; | ||||
| @@ -18318,9 +18318,8 @@ private: | |||||
| bool has3DNow : 1; | bool has3DNow : 1; | ||||
| }; | }; | ||||
| static CPUFlags cpuFlags; | |||||
| SystemStats(); | SystemStats(); | ||||
| static const CPUFlags& getCPUFlags(); | |||||
| JUCE_DECLARE_NON_COPYABLE (SystemStats); | JUCE_DECLARE_NON_COPYABLE (SystemStats); | ||||
| }; | }; | ||||
| @@ -21372,6 +21371,11 @@ public: | |||||
| */ | */ | ||||
| explicit Random (int64 seedValue) noexcept; | explicit Random (int64 seedValue) noexcept; | ||||
| /** Creates a Random object using a random seed value. | |||||
| Internally, this calls setSeedRandomly() to randomise the seed. | |||||
| */ | |||||
| Random(); | |||||
| /** Destructor. */ | /** Destructor. */ | ||||
| ~Random() noexcept; | ~Random() noexcept; | ||||
| @@ -215,7 +215,7 @@ public: | |||||
| @param index the index of the element being requested (0 is the first element in the array) | @param index the index of the element being requested (0 is the first element in the array) | ||||
| @see getUnchecked, getFirst, getLast | @see getUnchecked, getFirst, getLast | ||||
| */ | */ | ||||
| inline ElementType operator[] (const int index) const | |||||
| const ElementType operator[] (const int index) const | |||||
| { | { | ||||
| const ScopedLockType lock (getLock()); | const ScopedLockType lock (getLock()); | ||||
| return isPositiveAndBelow (index, numUsed) ? data.elements [index] | return isPositiveAndBelow (index, numUsed) ? data.elements [index] | ||||
| @@ -28,7 +28,6 @@ | |||||
| BEGIN_JUCE_NAMESPACE | BEGIN_JUCE_NAMESPACE | ||||
| #include "../memory/juce_Atomic.h" | #include "../memory/juce_Atomic.h" | ||||
| #include "../maths/juce_Random.h" | |||||
| #include "juce_PlatformUtilities.h" | #include "juce_PlatformUtilities.h" | ||||
| #include "juce_SystemStats.h" | #include "juce_SystemStats.h" | ||||
| #include "../text/juce_LocalisedStrings.h" | #include "../text/juce_LocalisedStrings.h" | ||||
| @@ -42,11 +41,6 @@ BEGIN_JUCE_NAMESPACE | |||||
| #include "../gui/components/lookandfeel/juce_LookAndFeel.h" | #include "../gui/components/lookandfeel/juce_LookAndFeel.h" | ||||
| #endif | #endif | ||||
| #if JUCE_DEBUG | |||||
| extern void juce_CheckForDanglingStreams(); // (in juce_OutputStream.cpp) | |||||
| #endif | |||||
| //============================================================================== | //============================================================================== | ||||
| static bool juceInitialisedNonGUI = false; | static bool juceInitialisedNonGUI = false; | ||||
| @@ -56,34 +50,8 @@ JUCE_API void JUCE_CALLTYPE initialiseJuce_NonGUI() | |||||
| { | { | ||||
| juceInitialisedNonGUI = true; | juceInitialisedNonGUI = true; | ||||
| JUCE_AUTORELEASEPOOL | |||||
| DBG (SystemStats::getJUCEVersion()); | DBG (SystemStats::getJUCEVersion()); | ||||
| SystemStats::initialiseStats(); | |||||
| Random::getSystemRandom().setSeedRandomly(); // (mustn't call this before initialiseStats() because it relies on the time being set up) | |||||
| } | } | ||||
| // Some basic tests, to keep an eye on things and make sure these types work ok | |||||
| // on all platforms. Let me know if any of these assertions fail on your system! | |||||
| static_jassert (sizeof (pointer_sized_int) == sizeof (void*)); | |||||
| static_jassert (sizeof (int8) == 1); | |||||
| static_jassert (sizeof (uint8) == 1); | |||||
| static_jassert (sizeof (int16) == 2); | |||||
| static_jassert (sizeof (uint16) == 2); | |||||
| static_jassert (sizeof (int32) == 4); | |||||
| static_jassert (sizeof (uint32) == 4); | |||||
| static_jassert (sizeof (int64) == 8); | |||||
| static_jassert (sizeof (uint64) == 8); | |||||
| #if JUCE_NATIVE_WCHAR_IS_UTF8 | |||||
| static_jassert (sizeof (wchar_t) == 1); | |||||
| #elif JUCE_NATIVE_WCHAR_IS_UTF16 | |||||
| static_jassert (sizeof (wchar_t) == 2); | |||||
| #elif JUCE_NATIVE_WCHAR_IS_UTF32 | |||||
| static_jassert (sizeof (wchar_t) == 4); | |||||
| #else | |||||
| #error "native wchar_t size is unknown" | |||||
| #endif | |||||
| } | } | ||||
| JUCE_API void JUCE_CALLTYPE shutdownJuce_NonGUI() | JUCE_API void JUCE_CALLTYPE shutdownJuce_NonGUI() | ||||
| @@ -92,14 +60,7 @@ JUCE_API void JUCE_CALLTYPE shutdownJuce_NonGUI() | |||||
| { | { | ||||
| juceInitialisedNonGUI = false; | juceInitialisedNonGUI = false; | ||||
| JUCE_AUTORELEASEPOOL | |||||
| LocalisedStrings::setCurrentMappings (nullptr); | |||||
| Thread::stopAllThreads (3000); | Thread::stopAllThreads (3000); | ||||
| #if JUCE_DEBUG | |||||
| juce_CheckForDanglingStreams(); | |||||
| #endif | |||||
| } | } | ||||
| } | } | ||||
| @@ -33,7 +33,7 @@ | |||||
| */ | */ | ||||
| #define JUCE_MAJOR_VERSION 1 | #define JUCE_MAJOR_VERSION 1 | ||||
| #define JUCE_MINOR_VERSION 53 | #define JUCE_MINOR_VERSION 53 | ||||
| #define JUCE_BUILDNUMBER 78 | |||||
| #define JUCE_BUILDNUMBER 79 | |||||
| /** Current Juce version number. | /** Current Juce version number. | ||||
| @@ -34,10 +34,27 @@ BEGIN_JUCE_NAMESPACE | |||||
| //============================================================================== | //============================================================================== | ||||
| SystemStats::CPUFlags SystemStats::cpuFlags; | |||||
| const SystemStats::CPUFlags& SystemStats::getCPUFlags() | |||||
| { | |||||
| static CPUFlags cpuFlags; | |||||
| return cpuFlags; | |||||
| } | |||||
| const String SystemStats::getJUCEVersion() | const String SystemStats::getJUCEVersion() | ||||
| { | { | ||||
| // Some basic tests, to keep an eye on things and make sure these types work ok | |||||
| // on all platforms. Let me know if any of these assertions fail on your system! | |||||
| static_jassert (sizeof (pointer_sized_int) == sizeof (void*)); | |||||
| static_jassert (sizeof (int8) == 1); | |||||
| static_jassert (sizeof (uint8) == 1); | |||||
| static_jassert (sizeof (int16) == 2); | |||||
| static_jassert (sizeof (uint16) == 2); | |||||
| static_jassert (sizeof (int32) == 4); | |||||
| static_jassert (sizeof (uint32) == 4); | |||||
| static_jassert (sizeof (int64) == 8); | |||||
| static_jassert (sizeof (uint64) == 8); | |||||
| // (these confusing macros convert numbers into a single string literal) | |||||
| #define JUCE_STRINGIFYVERSION2(a) #a | #define JUCE_STRINGIFYVERSION2(a) #a | ||||
| #define JUCE_STRINGIFYVERSION(a) JUCE_STRINGIFYVERSION2(a) | #define JUCE_STRINGIFYVERSION(a) JUCE_STRINGIFYVERSION2(a) | ||||
| @@ -119,19 +119,19 @@ public: | |||||
| static const String getCpuVendor(); | static const String getCpuVendor(); | ||||
| /** Checks whether Intel MMX instructions are available. */ | /** Checks whether Intel MMX instructions are available. */ | ||||
| static bool hasMMX() noexcept { return cpuFlags.hasMMX; } | |||||
| static bool hasMMX() noexcept { return getCPUFlags().hasMMX; } | |||||
| /** Checks whether Intel SSE instructions are available. */ | /** Checks whether Intel SSE instructions are available. */ | ||||
| static bool hasSSE() noexcept { return cpuFlags.hasSSE; } | |||||
| static bool hasSSE() noexcept { return getCPUFlags().hasSSE; } | |||||
| /** Checks whether Intel SSE2 instructions are available. */ | /** Checks whether Intel SSE2 instructions are available. */ | ||||
| static bool hasSSE2() noexcept { return cpuFlags.hasSSE2; } | |||||
| static bool hasSSE2() noexcept { return getCPUFlags().hasSSE2; } | |||||
| /** Checks whether AMD 3DNOW instructions are available. */ | /** Checks whether AMD 3DNOW instructions are available. */ | ||||
| static bool has3DNow() noexcept { return cpuFlags.has3DNow; } | |||||
| static bool has3DNow() noexcept { return getCPUFlags().has3DNow; } | |||||
| /** Returns the number of CPUs. */ | /** Returns the number of CPUs. */ | ||||
| static int getNumCpus() noexcept { return cpuFlags.numCpus; } | |||||
| static int getNumCpus() noexcept { return getCPUFlags().numCpus; } | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Finds out how much RAM is in the machine. | /** Finds out how much RAM is in the machine. | ||||
| @@ -147,13 +147,13 @@ public: | |||||
| */ | */ | ||||
| static int getPageSize(); | static int getPageSize(); | ||||
| //============================================================================== | |||||
| // not-for-public-use platform-specific method gets called at startup to initialise things. | |||||
| static void initialiseStats(); | |||||
| private: | private: | ||||
| //============================================================================== | |||||
| struct CPUFlags | struct CPUFlags | ||||
| { | { | ||||
| CPUFlags(); | |||||
| int numCpus; | int numCpus; | ||||
| bool hasMMX : 1; | bool hasMMX : 1; | ||||
| bool hasSSE : 1; | bool hasSSE : 1; | ||||
| @@ -161,9 +161,8 @@ private: | |||||
| bool has3DNow : 1; | bool has3DNow : 1; | ||||
| }; | }; | ||||
| static CPUFlags cpuFlags; | |||||
| SystemStats(); | SystemStats(); | ||||
| static const CPUFlags& getCPUFlags(); | |||||
| JUCE_DECLARE_NON_COPYABLE (SystemStats); | JUCE_DECLARE_NON_COPYABLE (SystemStats); | ||||
| }; | }; | ||||
| @@ -171,7 +171,7 @@ const BigInteger Primes::createProbablePrime (const int bitLength, | |||||
| { | { | ||||
| randomSeeds = defaultSeeds; | randomSeeds = defaultSeeds; | ||||
| numRandomSeeds = numElementsInArray (defaultSeeds); | numRandomSeeds = numElementsInArray (defaultSeeds); | ||||
| Random r (0); | |||||
| Random r; | |||||
| for (int j = 10; --j >= 0;) | for (int j = 10; --j >= 0;) | ||||
| { | { | ||||
| @@ -874,6 +874,8 @@ void Component::setAlwaysOnTop (const bool shouldStayOnTop) | |||||
| { | { | ||||
| if (shouldStayOnTop != flags.alwaysOnTopFlag) | if (shouldStayOnTop != flags.alwaysOnTopFlag) | ||||
| { | { | ||||
| BailOutChecker checker (this); | |||||
| flags.alwaysOnTopFlag = shouldStayOnTop; | flags.alwaysOnTopFlag = shouldStayOnTop; | ||||
| if (isOnDesktop()) | if (isOnDesktop()) | ||||
| @@ -894,10 +896,11 @@ void Component::setAlwaysOnTop (const bool shouldStayOnTop) | |||||
| } | } | ||||
| } | } | ||||
| if (shouldStayOnTop) | |||||
| if (shouldStayOnTop && ! checker.shouldBailOut()) | |||||
| toFront (false); | toFront (false); | ||||
| internalHierarchyChanged(); | |||||
| if (! checker.shouldBailOut()) | |||||
| internalHierarchyChanged(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -35,18 +35,26 @@ BEGIN_JUCE_NAMESPACE | |||||
| //============================================================================== | //============================================================================== | ||||
| #if JUCE_DEBUG | #if JUCE_DEBUG | ||||
| static Array<void*, CriticalSection> activeStreams; | |||||
| void juce_CheckForDanglingStreams() | |||||
| struct DanglingStreamChecker | |||||
| { | { | ||||
| /* | |||||
| It's always a bad idea to leak any object, but if you're leaking output | |||||
| streams, then there's a good chance that you're failing to flush a file | |||||
| to disk properly, which could result in corrupted data and other similar | |||||
| nastiness.. | |||||
| */ | |||||
| jassert (activeStreams.size() == 0); | |||||
| DanglingStreamChecker() {} | |||||
| ~DanglingStreamChecker() | |||||
| { | |||||
| /* | |||||
| It's always a bad idea to leak any object, but if you're leaking output | |||||
| streams, then there's a good chance that you're failing to flush a file | |||||
| to disk properly, which could result in corrupted data and other similar | |||||
| nastiness.. | |||||
| */ | |||||
| jassert (activeStreams.size() == 0); | |||||
| } | |||||
| Array<void*, CriticalSection> activeStreams; | |||||
| }; | }; | ||||
| static DanglingStreamChecker danglingStreamChecker; | |||||
| #endif | #endif | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -54,14 +62,14 @@ OutputStream::OutputStream() | |||||
| : newLineString (NewLine::getDefault()) | : newLineString (NewLine::getDefault()) | ||||
| { | { | ||||
| #if JUCE_DEBUG | #if JUCE_DEBUG | ||||
| activeStreams.add (this); | |||||
| danglingStreamChecker.activeStreams.add (this); | |||||
| #endif | #endif | ||||
| } | } | ||||
| OutputStream::~OutputStream() | OutputStream::~OutputStream() | ||||
| { | { | ||||
| #if JUCE_DEBUG | #if JUCE_DEBUG | ||||
| activeStreams.removeValue (this); | |||||
| danglingStreamChecker.activeStreams.removeValue (this); | |||||
| #endif | #endif | ||||
| } | } | ||||
| @@ -112,7 +112,7 @@ uLong ZEXPORT zlibCompileFlags() | |||||
| return flags; | return flags; | ||||
| }*/ | }*/ | ||||
| #ifdef DEBUG | |||||
| #if 0 | |||||
| # ifndef verbose | # ifndef verbose | ||||
| # define verbose 0 | # define verbose 0 | ||||
| @@ -238,7 +238,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ | |||||
| #endif | #endif | ||||
| /* Diagnostic functions */ | /* Diagnostic functions */ | ||||
| #ifdef DEBUG | |||||
| #if 0 | |||||
| # include <stdio.h> | # include <stdio.h> | ||||
| extern int z_verbose; | extern int z_verbose; | ||||
| extern void z_error OF((const char *m)); | extern void z_error OF((const char *m)); | ||||
| @@ -255,6 +255,8 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ | |||||
| # define Tracevv(x) | # define Tracevv(x) | ||||
| # define Tracec(c,x) | # define Tracec(c,x) | ||||
| # define Tracecv(c,x) | # define Tracecv(c,x) | ||||
| # define z_error(x) | |||||
| # define z_verbose 0 | |||||
| #endif | #endif | ||||
| @@ -37,6 +37,12 @@ Random::Random (const int64 seedValue) noexcept | |||||
| { | { | ||||
| } | } | ||||
| Random::Random() | |||||
| : seed (1) | |||||
| { | |||||
| setSeedRandomly(); | |||||
| } | |||||
| Random::~Random() noexcept | Random::~Random() noexcept | ||||
| { | { | ||||
| } | } | ||||
| @@ -60,6 +66,12 @@ void Random::setSeedRandomly() | |||||
| combineSeed (Time::currentTimeMillis()); | combineSeed (Time::currentTimeMillis()); | ||||
| } | } | ||||
| Random& Random::getSystemRandom() noexcept | |||||
| { | |||||
| static Random sysRand; | |||||
| return sysRand; | |||||
| } | |||||
| //============================================================================== | //============================================================================== | ||||
| int Random::nextInt() noexcept | int Random::nextInt() noexcept | ||||
| { | { | ||||
| @@ -128,11 +140,4 @@ void Random::fillBitsRandomly (BigInteger& arrayToChange, int startBit, int numB | |||||
| arrayToChange.setBit (startBit + numBits, nextBool()); | arrayToChange.setBit (startBit + numBits, nextBool()); | ||||
| } | } | ||||
| //============================================================================== | |||||
| Random& Random::getSystemRandom() noexcept | |||||
| { | |||||
| static Random sysRand (1); | |||||
| return sysRand; | |||||
| } | |||||
| END_JUCE_NAMESPACE | END_JUCE_NAMESPACE | ||||
| @@ -52,6 +52,11 @@ public: | |||||
| */ | */ | ||||
| explicit Random (int64 seedValue) noexcept; | explicit Random (int64 seedValue) noexcept; | ||||
| /** Creates a Random object using a random seed value. | |||||
| Internally, this calls setSeedRandomly() to randomise the seed. | |||||
| */ | |||||
| Random(); | |||||
| /** Destructor. */ | /** Destructor. */ | ||||
| ~Random() noexcept; | ~Random() noexcept; | ||||
| @@ -115,15 +115,15 @@ const String SystemStats::getComputerName() | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| void SystemStats::initialiseStats() | |||||
| SystemStats::CPUFlags::CPUFlags() | |||||
| { | { | ||||
| // TODO | // TODO | ||||
| cpuFlags.hasMMX = false; | |||||
| cpuFlags.hasSSE = false; | |||||
| cpuFlags.hasSSE2 = false; | |||||
| cpuFlags.has3DNow = false; | |||||
| hasMMX = false; | |||||
| hasSSE = false; | |||||
| hasSSE2 = false; | |||||
| has3DNow = false; | |||||
| cpuFlags.numCpus = jmax (1, sysconf (_SC_NPROCESSORS_ONLN)); | |||||
| numCpus = jmax (1, sysconf (_SC_NPROCESSORS_ONLN)); | |||||
| } | } | ||||
| void PlatformUtilities::fpuReset() {} | void PlatformUtilities::fpuReset() {} | ||||
| @@ -126,15 +126,15 @@ const String SystemStats::getComputerName() | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| void SystemStats::initialiseStats() | |||||
| SystemStats::CPUFlags::CPUFlags() | |||||
| { | { | ||||
| const String flags (LinuxStatsHelpers::getCpuInfo ("flags")); | const String flags (LinuxStatsHelpers::getCpuInfo ("flags")); | ||||
| cpuFlags.hasMMX = flags.contains ("mmx"); | |||||
| cpuFlags.hasSSE = flags.contains ("sse"); | |||||
| cpuFlags.hasSSE2 = flags.contains ("sse2"); | |||||
| cpuFlags.has3DNow = flags.contains ("3dnow"); | |||||
| hasMMX = flags.contains ("mmx"); | |||||
| hasSSE = flags.contains ("sse"); | |||||
| hasSSE2 = flags.contains ("sse2"); | |||||
| has3DNow = flags.contains ("3dnow"); | |||||
| cpuFlags.numCpus = LinuxStatsHelpers::getCpuInfo ("processor").getIntValue() + 1; | |||||
| numCpus = LinuxStatsHelpers::getCpuInfo ("processor").getIntValue() + 1; | |||||
| } | } | ||||
| void PlatformUtilities::fpuReset() | void PlatformUtilities::fpuReset() | ||||
| @@ -36,6 +36,7 @@ | |||||
| #import <CoreData/CoreData.h> | #import <CoreData/CoreData.h> | ||||
| #import <MobileCoreServices/MobileCoreServices.h> | #import <MobileCoreServices/MobileCoreServices.h> | ||||
| #import <QuartzCore/QuartzCore.h> | #import <QuartzCore/QuartzCore.h> | ||||
| #import <CoreText/CoreText.h> | |||||
| #include <sys/fcntl.h> | #include <sys/fcntl.h> | ||||
| #if JUCE_OPENGL | #if JUCE_OPENGL | ||||
| #include <OpenGLES/ES1/gl.h> | #include <OpenGLES/ES1/gl.h> | ||||
| @@ -29,10 +29,7 @@ | |||||
| namespace SystemStatsHelpers | namespace SystemStatsHelpers | ||||
| { | { | ||||
| static int64 highResTimerFrequency = 0; | |||||
| static double highResTimerToMillisecRatio = 0; | |||||
| #if JUCE_INTEL | |||||
| #if JUCE_INTEL | |||||
| void doCPUID (uint32& a, uint32& b, uint32& c, uint32& d, uint32 type) | void doCPUID (uint32& a, uint32& b, uint32& c, uint32& d, uint32 type) | ||||
| { | { | ||||
| uint32 la = a, lb = b, lc = c, ld = d; | uint32 la = a, lb = b, lc = c, ld = d; | ||||
| @@ -48,57 +45,51 @@ namespace SystemStatsHelpers | |||||
| a = la; b = lb; c = lc; d = ld; | a = la; b = lb; c = lc; d = ld; | ||||
| } | } | ||||
| #endif | |||||
| #endif | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| void SystemStats::initialiseStats() | |||||
| SystemStats::CPUFlags::CPUFlags() | |||||
| { | { | ||||
| using namespace SystemStatsHelpers; | |||||
| static bool initialised = false; | |||||
| if (! initialised) | |||||
| { | |||||
| initialised = true; | |||||
| #if JUCE_INTEL | |||||
| uint32 familyModel = 0, extFeatures = 0, features = 0, dummy = 0; | |||||
| SystemStatsHelpers::doCPUID (familyModel, extFeatures, dummy, features, 1); | |||||
| #if JUCE_MAC | |||||
| [NSApplication sharedApplication]; | |||||
| #endif | |||||
| #if JUCE_INTEL | |||||
| uint32 familyModel = 0, extFeatures = 0, features = 0, dummy = 0; | |||||
| doCPUID (familyModel, extFeatures, dummy, features, 1); | |||||
| cpuFlags.hasMMX = ((features & (1 << 23)) != 0); | |||||
| cpuFlags.hasSSE = ((features & (1 << 25)) != 0); | |||||
| cpuFlags.hasSSE2 = ((features & (1 << 26)) != 0); | |||||
| cpuFlags.has3DNow = ((extFeatures & (1 << 31)) != 0); | |||||
| #else | |||||
| cpuFlags.hasMMX = false; | |||||
| cpuFlags.hasSSE = false; | |||||
| cpuFlags.hasSSE2 = false; | |||||
| cpuFlags.has3DNow = false; | |||||
| #endif | |||||
| #if JUCE_IOS || (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5) | |||||
| cpuFlags.numCpus = (int) [[NSProcessInfo processInfo] activeProcessorCount]; | |||||
| #else | |||||
| cpuFlags.numCpus = (int) MPProcessors(); | |||||
| #endif | |||||
| hasMMX = (features & (1 << 23)) != 0; | |||||
| hasSSE = (features & (1 << 25)) != 0; | |||||
| hasSSE2 = (features & (1 << 26)) != 0; | |||||
| has3DNow = (extFeatures & (1 << 31)) != 0; | |||||
| #else | |||||
| hasMMX = false; | |||||
| hasSSE = false; | |||||
| hasSSE2 = false; | |||||
| has3DNow = false; | |||||
| #endif | |||||
| mach_timebase_info_data_t timebase; | |||||
| (void) mach_timebase_info (&timebase); | |||||
| highResTimerFrequency = (int64) (1.0e9 * timebase.denom / timebase.numer); | |||||
| highResTimerToMillisecRatio = timebase.numer / (1.0e6 * timebase.denom); | |||||
| #if JUCE_IOS || (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5) | |||||
| numCpus = (int) [[NSProcessInfo processInfo] activeProcessorCount]; | |||||
| #else | |||||
| numCpus = (int) MPProcessors(); | |||||
| #endif | |||||
| } | |||||
| String s (SystemStats::getJUCEVersion()); | |||||
| #if JUCE_MAC | |||||
| struct SharedAppInitialiser | |||||
| { | |||||
| SharedAppInitialiser() | |||||
| { | |||||
| JUCE_AUTORELEASEPOOL | |||||
| [NSApplication sharedApplication]; | |||||
| rlimit lim; | rlimit lim; | ||||
| getrlimit (RLIMIT_NOFILE, &lim); | getrlimit (RLIMIT_NOFILE, &lim); | ||||
| lim.rlim_cur = lim.rlim_max = RLIM_INFINITY; | lim.rlim_cur = lim.rlim_max = RLIM_INFINITY; | ||||
| setrlimit (RLIMIT_NOFILE, &lim); | setrlimit (RLIMIT_NOFILE, &lim); | ||||
| } | } | ||||
| } | |||||
| }; | |||||
| static SharedAppInitialiser sharedAppInitialiser; | |||||
| #endif | |||||
| //============================================================================== | //============================================================================== | ||||
| SystemStats::OperatingSystemType SystemStats::getOperatingSystemType() | SystemStats::OperatingSystemType SystemStats::getOperatingSystemType() | ||||
| @@ -192,25 +183,37 @@ const String SystemStats::getComputerName() | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| uint32 juce_millisecondsSinceStartup() noexcept | |||||
| class HiResCounterHandler | |||||
| { | { | ||||
| return (uint32) (mach_absolute_time() * SystemStatsHelpers::highResTimerToMillisecRatio); | |||||
| } | |||||
| public: | |||||
| HiResCounterHandler() | |||||
| { | |||||
| mach_timebase_info_data_t timebase; | |||||
| (void) mach_timebase_info (&timebase); | |||||
| highResTimerFrequency = (int64) (1.0e9 * timebase.denom / timebase.numer); | |||||
| highResTimerToMillisecRatio = timebase.numer / (1.0e6 * timebase.denom); | |||||
| } | |||||
| double Time::getMillisecondCounterHiRes() noexcept | |||||
| { | |||||
| return mach_absolute_time() * SystemStatsHelpers::highResTimerToMillisecRatio; | |||||
| } | |||||
| inline uint32 millisecondsSinceStartup() const noexcept | |||||
| { | |||||
| return (uint32) (mach_absolute_time() * highResTimerToMillisecRatio); | |||||
| } | |||||
| int64 Time::getHighResolutionTicks() noexcept | |||||
| { | |||||
| return (int64) mach_absolute_time(); | |||||
| } | |||||
| inline double getMillisecondCounterHiRes() const noexcept | |||||
| { | |||||
| return mach_absolute_time() * highResTimerToMillisecRatio; | |||||
| } | |||||
| int64 Time::getHighResolutionTicksPerSecond() noexcept | |||||
| { | |||||
| return SystemStatsHelpers::highResTimerFrequency; | |||||
| } | |||||
| int64 highResTimerFrequency; | |||||
| double highResTimerToMillisecRatio; | |||||
| }; | |||||
| static HiResCounterHandler hiResCounterHandler; | |||||
| uint32 juce_millisecondsSinceStartup() noexcept { return hiResCounterHandler.millisecondsSinceStartup(); } | |||||
| double Time::getMillisecondCounterHiRes() noexcept { return hiResCounterHandler.getMillisecondCounterHiRes(); } | |||||
| int64 Time::getHighResolutionTicksPerSecond() noexcept { return hiResCounterHandler.highResTimerFrequency; } | |||||
| int64 Time::getHighResolutionTicks() noexcept { return (int64) mach_absolute_time(); } | |||||
| bool Time::setSystemTimeToThisTime() const | bool Time::setSystemTimeToThisTime() const | ||||
| { | { | ||||
| @@ -34,11 +34,6 @@ void Logger::outputDebugString (const String& text) | |||||
| OutputDebugString ((text + "\n").toWideCharPointer()); | OutputDebugString ((text + "\n").toWideCharPointer()); | ||||
| } | } | ||||
| //============================================================================== | |||||
| static int64 hiResTicksPerSecond; | |||||
| static double hiResTicksScaleFactor; | |||||
| //============================================================================== | //============================================================================== | ||||
| #if JUCE_USE_INTRINSICS || JUCE_64BIT | #if JUCE_USE_INTRINSICS || JUCE_64BIT | ||||
| @@ -107,38 +102,33 @@ const String SystemStats::getCpuVendor() | |||||
| //============================================================================== | //============================================================================== | ||||
| void SystemStats::initialiseStats() | |||||
| SystemStats::CPUFlags::CPUFlags() | |||||
| { | { | ||||
| cpuFlags.hasMMX = IsProcessorFeaturePresent (PF_MMX_INSTRUCTIONS_AVAILABLE) != 0; | |||||
| cpuFlags.hasSSE = IsProcessorFeaturePresent (PF_XMMI_INSTRUCTIONS_AVAILABLE) != 0; | |||||
| cpuFlags.hasSSE2 = IsProcessorFeaturePresent (PF_XMMI64_INSTRUCTIONS_AVAILABLE) != 0; | |||||
| hasMMX = IsProcessorFeaturePresent (PF_MMX_INSTRUCTIONS_AVAILABLE) != 0; | |||||
| hasSSE = IsProcessorFeaturePresent (PF_XMMI_INSTRUCTIONS_AVAILABLE) != 0; | |||||
| hasSSE2 = IsProcessorFeaturePresent (PF_XMMI64_INSTRUCTIONS_AVAILABLE) != 0; | |||||
| #ifdef PF_AMD3D_INSTRUCTIONS_AVAILABLE | #ifdef PF_AMD3D_INSTRUCTIONS_AVAILABLE | ||||
| cpuFlags.has3DNow = IsProcessorFeaturePresent (PF_AMD3D_INSTRUCTIONS_AVAILABLE) != 0; | |||||
| has3DNow = IsProcessorFeaturePresent (PF_AMD3D_INSTRUCTIONS_AVAILABLE) != 0; | |||||
| #else | #else | ||||
| cpuFlags.has3DNow = IsProcessorFeaturePresent (PF_3DNOW_INSTRUCTIONS_AVAILABLE) != 0; | |||||
| has3DNow = IsProcessorFeaturePresent (PF_3DNOW_INSTRUCTIONS_AVAILABLE) != 0; | |||||
| #endif | #endif | ||||
| SYSTEM_INFO systemInfo; | |||||
| GetSystemInfo (&systemInfo); | |||||
| numCpus = systemInfo.dwNumberOfProcessors; | |||||
| } | |||||
| #if JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS | |||||
| struct DebugFlagsInitialiser | |||||
| { | |||||
| DebugFlagsInitialiser() | |||||
| { | { | ||||
| SYSTEM_INFO systemInfo; | |||||
| GetSystemInfo (&systemInfo); | |||||
| cpuFlags.numCpus = systemInfo.dwNumberOfProcessors; | |||||
| _CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); | |||||
| } | } | ||||
| }; | |||||
| LARGE_INTEGER f; | |||||
| QueryPerformanceFrequency (&f); | |||||
| hiResTicksPerSecond = f.QuadPart; | |||||
| hiResTicksScaleFactor = 1000.0 / hiResTicksPerSecond; | |||||
| String s (SystemStats::getJUCEVersion()); | |||||
| const MMRESULT res = timeBeginPeriod (1); | |||||
| (void) res; | |||||
| jassert (res == TIMERR_NOERROR); | |||||
| #if JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS | |||||
| _CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); | |||||
| #endif | |||||
| } | |||||
| static DebugFlagsInitialiser debugFlagsInitialiser; | |||||
| #endif | |||||
| //============================================================================== | //============================================================================== | ||||
| SystemStats::OperatingSystemType SystemStats::getOperatingSystemType() | SystemStats::OperatingSystemType SystemStats::getOperatingSystemType() | ||||
| @@ -214,35 +204,57 @@ uint32 juce_millisecondsSinceStartup() noexcept | |||||
| return (uint32) timeGetTime(); | return (uint32) timeGetTime(); | ||||
| } | } | ||||
| int64 Time::getHighResolutionTicks() noexcept | |||||
| //============================================================================== | |||||
| class HiResCounterHandler | |||||
| { | { | ||||
| LARGE_INTEGER ticks; | |||||
| QueryPerformanceCounter (&ticks); | |||||
| public: | |||||
| HiResCounterHandler() | |||||
| : hiResTicksOffset (0) | |||||
| { | |||||
| const MMRESULT res = timeBeginPeriod (1); | |||||
| (void) res; | |||||
| jassert (res == TIMERR_NOERROR); | |||||
| LARGE_INTEGER f; | |||||
| QueryPerformanceFrequency (&f); | |||||
| hiResTicksPerSecond = f.QuadPart; | |||||
| hiResTicksScaleFactor = 1000.0 / hiResTicksPerSecond; | |||||
| } | |||||
| const int64 mainCounterAsHiResTicks = (juce_millisecondsSinceStartup() * hiResTicksPerSecond) / 1000; | |||||
| const int64 newOffset = mainCounterAsHiResTicks - ticks.QuadPart; | |||||
| inline int64 getHighResolutionTicks() noexcept | |||||
| { | |||||
| LARGE_INTEGER ticks; | |||||
| QueryPerformanceCounter (&ticks); | |||||
| // fix for a very obscure PCI hardware bug that can make the counter | |||||
| // sometimes jump forwards by a few seconds.. | |||||
| static int64 hiResTicksOffset = 0; | |||||
| const int64 offsetDrift = abs64 (newOffset - hiResTicksOffset); | |||||
| const int64 mainCounterAsHiResTicks = (juce_millisecondsSinceStartup() * hiResTicksPerSecond) / 1000; | |||||
| const int64 newOffset = mainCounterAsHiResTicks - ticks.QuadPart; | |||||
| if (offsetDrift > (hiResTicksPerSecond >> 1)) | |||||
| hiResTicksOffset = newOffset; | |||||
| // fix for a very obscure PCI hardware bug that can make the counter | |||||
| // sometimes jump forwards by a few seconds.. | |||||
| const int64 offsetDrift = abs64 (newOffset - hiResTicksOffset); | |||||
| return ticks.QuadPart + hiResTicksOffset; | |||||
| } | |||||
| if (offsetDrift > (hiResTicksPerSecond >> 1)) | |||||
| hiResTicksOffset = newOffset; | |||||
| double Time::getMillisecondCounterHiRes() noexcept | |||||
| { | |||||
| return getHighResolutionTicks() * hiResTicksScaleFactor; | |||||
| } | |||||
| return ticks.QuadPart + hiResTicksOffset; | |||||
| } | |||||
| int64 Time::getHighResolutionTicksPerSecond() noexcept | |||||
| { | |||||
| return hiResTicksPerSecond; | |||||
| } | |||||
| inline double getMillisecondCounterHiRes() noexcept | |||||
| { | |||||
| return getHighResolutionTicks() * hiResTicksScaleFactor; | |||||
| } | |||||
| int64 hiResTicksPerSecond, hiResTicksOffset; | |||||
| double hiResTicksScaleFactor; | |||||
| }; | |||||
| static HiResCounterHandler hiResCounterHandler; | |||||
| int64 Time::getHighResolutionTicksPerSecond() noexcept { return hiResCounterHandler.hiResTicksPerSecond; } | |||||
| int64 Time::getHighResolutionTicks() noexcept { return hiResCounterHandler.getHighResolutionTicks(); } | |||||
| double Time::getMillisecondCounterHiRes() noexcept { return hiResCounterHandler.getMillisecondCounterHiRes(); } | |||||
| //============================================================================== | |||||
| static int64 juce_getClockCycleCounter() noexcept | static int64 juce_getClockCycleCounter() noexcept | ||||
| { | { | ||||
| #if JUCE_USE_INTRINSICS | #if JUCE_USE_INTRINSICS | ||||
| @@ -54,6 +54,23 @@ const String LocalisedStrings::translate (const String& text) const | |||||
| namespace | namespace | ||||
| { | { | ||||
| #if JUCE_CHECK_MEMORY_LEAKS | |||||
| // By using this object to force a LocalisedStrings object to be created | |||||
| // before the currentMappings object, we can force the static order-of-destruction to | |||||
| // delete the currentMappings object first, which avoids a bogus leak warning. | |||||
| // (Oddly, just creating a LocalisedStrings on the stack doesn't work in gcc, it | |||||
| // has to be created with 'new' for this to work..) | |||||
| struct LeakAvoidanceTrick | |||||
| { | |||||
| LeakAvoidanceTrick() | |||||
| { | |||||
| const ScopedPointer<LocalisedStrings> dummy (new LocalisedStrings (String())); | |||||
| } | |||||
| }; | |||||
| LeakAvoidanceTrick leakAvoidanceTrick; | |||||
| #endif | |||||
| SpinLock currentMappingsLock; | SpinLock currentMappingsLock; | ||||
| ScopedPointer<LocalisedStrings> currentMappings; | ScopedPointer<LocalisedStrings> currentMappings; | ||||
| @@ -215,6 +215,20 @@ private: | |||||
| return reinterpret_cast <StringHolder*> (reinterpret_cast <char*> (text.getAddress()) | return reinterpret_cast <StringHolder*> (reinterpret_cast <char*> (text.getAddress()) | ||||
| - (reinterpret_cast <size_t> (reinterpret_cast <StringHolder*> (1)->text) - 1)); | - (reinterpret_cast <size_t> (reinterpret_cast <StringHolder*> (1)->text) - 1)); | ||||
| } | } | ||||
| void compileTimeChecks() | |||||
| { | |||||
| // Let me know if any of these assertions fail on your system! | |||||
| #if JUCE_NATIVE_WCHAR_IS_UTF8 | |||||
| static_jassert (sizeof (wchar_t) == 1); | |||||
| #elif JUCE_NATIVE_WCHAR_IS_UTF16 | |||||
| static_jassert (sizeof (wchar_t) == 2); | |||||
| #elif JUCE_NATIVE_WCHAR_IS_UTF32 | |||||
| static_jassert (sizeof (wchar_t) == 4); | |||||
| #else | |||||
| #error "native wchar_t size is unknown" | |||||
| #endif | |||||
| } | |||||
| }; | }; | ||||
| StringHolder StringHolder::empty; | StringHolder StringHolder::empty; | ||||