@@ -52,7 +52,7 @@ | |||||
#include "../LiveBuildEngine/UI/jucer_ComponentListComponent.h" | #include "../LiveBuildEngine/UI/jucer_ComponentListComponent.h" | ||||
#include "../LiveBuildEngine/jucer_CompileEngineServer.h" | #include "../LiveBuildEngine/jucer_CompileEngineServer.h" | ||||
juce_ImplementSingleton (CompileEngineDLL); | |||||
JUCE_IMPLEMENT_SINGLETON (CompileEngineDLL) | |||||
struct ProjucerAppClasses | struct ProjucerAppClasses | ||||
{ | { | ||||
@@ -29,7 +29,7 @@ | |||||
#include "jucer_LiveCodeBuilderDLL.h" | #include "jucer_LiveCodeBuilderDLL.h" | ||||
//============================================================================== | //============================================================================== | ||||
struct CompileEngineDLL : DeletedAtShutdown | |||||
struct CompileEngineDLL : private DeletedAtShutdown | |||||
{ | { | ||||
CompileEngineDLL() | CompileEngineDLL() | ||||
{ | { | ||||
@@ -39,6 +39,7 @@ struct CompileEngineDLL : DeletedAtShutdown | |||||
~CompileEngineDLL() | ~CompileEngineDLL() | ||||
{ | { | ||||
shutdown(); | shutdown(); | ||||
clearSingletonInstance(); | |||||
} | } | ||||
bool tryLoadDll() | bool tryLoadDll() | ||||
@@ -117,7 +118,7 @@ struct CompileEngineDLL : DeletedAtShutdown | |||||
return userAppData.getChildFile ("Projucer").getChildFile (String ("CompileEngine-") + ProjectInfo::versionString); | return userAppData.getChildFile ("Projucer").getChildFile (String ("CompileEngine-") + ProjectInfo::versionString); | ||||
} | } | ||||
juce_DeclareSingleton (CompileEngineDLL, false) | |||||
JUCE_DECLARE_SINGLETON (CompileEngineDLL, false) | |||||
private: | private: | ||||
DynamicLibrary dll; | DynamicLibrary dll; | ||||
@@ -62,6 +62,6 @@ void Analytics::setSuspended (bool shouldBeSuspended) | |||||
isSuspended = shouldBeSuspended; | isSuspended = shouldBeSuspended; | ||||
} | } | ||||
juce_ImplementSingleton (Analytics) | |||||
JUCE_IMPLEMENT_SINGLETON (Analytics) | |||||
} | } |
@@ -80,7 +80,7 @@ public: | |||||
void setSuspended (bool shouldBeSuspended); | void setSuspended (bool shouldBeSuspended); | ||||
#ifndef DOXYGEN | #ifndef DOXYGEN | ||||
juce_DeclareSingleton (Analytics, false) | |||||
JUCE_DECLARE_SINGLETON (Analytics, false) | |||||
#endif | #endif | ||||
private: | private: | ||||
@@ -1107,7 +1107,7 @@ public: | |||||
MidiServiceType* getService(); | MidiServiceType* getService(); | ||||
juce_DeclareSingleton (MidiService, false) | |||||
JUCE_DECLARE_SINGLETON (MidiService, false) | |||||
private: | private: | ||||
MidiService(); | MidiService(); | ||||
@@ -1115,7 +1115,7 @@ private: | |||||
ScopedPointer<MidiServiceType> internal; | ScopedPointer<MidiServiceType> internal; | ||||
}; | }; | ||||
juce_ImplementSingleton (MidiService) | |||||
JUCE_IMPLEMENT_SINGLETON (MidiService) | |||||
MidiService::~MidiService() | MidiService::~MidiService() | ||||
{ | { | ||||
@@ -189,12 +189,12 @@ struct SharedMessageThread : public Thread | |||||
{} | {} | ||||
} | } | ||||
juce_DeclareSingleton (SharedMessageThread, false) | |||||
JUCE_DECLARE_SINGLETON (SharedMessageThread, false) | |||||
bool initialised = false; | bool initialised = false; | ||||
}; | }; | ||||
juce_ImplementSingleton (SharedMessageThread) | |||||
JUCE_IMPLEMENT_SINGLETON (SharedMessageThread) | |||||
#endif | #endif | ||||
@@ -25,12 +25,115 @@ namespace juce | |||||
//============================================================================== | //============================================================================== | ||||
/** | /** | ||||
Macro to declare member variables and methods for a singleton class. | |||||
Used by the JUCE_DECLARE_SINGLETON macros to manage a static pointer | |||||
to a singleton instance. | |||||
You generally won't use this directly, but see the macros JUCE_DECLARE_SINGLETON, | |||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED, JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL, | |||||
and JUCE_IMPLEMENT_SINGLETON for how it is intended to be used. | |||||
*/ | |||||
template <typename Type, typename MutexType, bool onlyCreateOncePerRun> | |||||
struct SingletonHolder : private MutexType // (inherited so we can use the empty-base-class optimisation) | |||||
{ | |||||
SingletonHolder() noexcept {} | |||||
~SingletonHolder() | |||||
{ | |||||
/* The static singleton holder is being deleted before the object that it holds | |||||
has been deleted. This could mean that you've forgotten to call clearSingletonInstance() | |||||
in the class's destructor, or have failed to delete it before your app shuts down. | |||||
If you're having trouble cleaning up your singletons, perhaps consider using the | |||||
SharedResourcePointer class instead. | |||||
*/ | |||||
jassert (instance == nullptr); | |||||
} | |||||
/** Returns the current instance, or creates a new instance if there isn't one. */ | |||||
Type* get() | |||||
{ | |||||
if (instance == nullptr) | |||||
{ | |||||
typename MutexType::ScopedLockType sl (*this); | |||||
if (instance == nullptr) | |||||
{ | |||||
if (onlyCreateOncePerRun) | |||||
{ | |||||
static bool createdOnceAlready = false; | |||||
if (createdOnceAlready) | |||||
{ | |||||
// This means that the doNotRecreateAfterDeletion flag was set | |||||
// and you tried to create the singleton more than once. | |||||
jassertfalse; | |||||
return nullptr; | |||||
} | |||||
createdOnceAlready = true; | |||||
} | |||||
static bool alreadyInside = false; | |||||
if (alreadyInside) | |||||
{ | |||||
// This means that your object's constructor has done something which has | |||||
// ended up causing a recursive loop of singleton creation.. | |||||
jassertfalse; | |||||
} | |||||
else | |||||
{ | |||||
alreadyInside = true; | |||||
getWithoutChecking(); | |||||
alreadyInside = false; | |||||
} | |||||
} | |||||
} | |||||
return instance; | |||||
} | |||||
/** Returns the current instance, or creates a new instance if there isn't one, but doesn't do | |||||
any locking, or checking for recursion or error conditions. | |||||
*/ | |||||
Type* getWithoutChecking() | |||||
{ | |||||
if (instance == nullptr) | |||||
{ | |||||
auto newObject = new Type(); // (create into a local so that instance is still null during construction) | |||||
instance = newObject; | |||||
} | |||||
return instance; | |||||
} | |||||
/** Deletes and resets the current instance, if there is one. */ | |||||
void deleteInstance() | |||||
{ | |||||
typename MutexType::ScopedLockType sl (*this); | |||||
auto old = instance; | |||||
instance = nullptr; | |||||
delete old; | |||||
} | |||||
/** Called by the class's destructor to clear the pointer if it is currently set to the given object. */ | |||||
void clear (Type* expectedObject) noexcept | |||||
{ | |||||
if (instance == expectedObject) | |||||
instance = nullptr; | |||||
} | |||||
To use this, add the line juce_DeclareSingleton (MyClass, doNotRecreateAfterDeletion) | |||||
Type* instance = nullptr; | |||||
}; | |||||
//============================================================================== | |||||
/** | |||||
Macro to generate the appropriate methods and boilerplate for a singleton class. | |||||
To use this, add the line JUCE_DECLARE_SINGLETON(MyClass, doNotRecreateAfterDeletion) | |||||
to the class's definition. | to the class's definition. | ||||
Then put a macro juce_ImplementSingleton (MyClass) along with the class's | |||||
Then put a macro JUCE_IMPLEMENT_SINGLETON(MyClass) along with the class's | |||||
implementation code. | implementation code. | ||||
It's also a very good idea to also add the call clearSingletonInstance() in your class's | It's also a very good idea to also add the call clearSingletonInstance() in your class's | ||||
@@ -42,12 +145,9 @@ namespace juce | |||||
e.g. @code | e.g. @code | ||||
class MySingleton | |||||
struct MySingleton | |||||
{ | { | ||||
public: | |||||
MySingleton() | |||||
{ | |||||
} | |||||
MySingleton() {} | |||||
~MySingleton() | ~MySingleton() | ||||
{ | { | ||||
@@ -56,14 +156,15 @@ namespace juce | |||||
clearSingletonInstance(); | clearSingletonInstance(); | ||||
} | } | ||||
juce_DeclareSingleton (MySingleton, false) | |||||
JUCE_DECLARE_SINGLETON (MySingleton, false) | |||||
}; | }; | ||||
juce_ImplementSingleton (MySingleton) | |||||
// ..and this goes in a suitable .cpp file: | |||||
JUCE_IMPLEMENT_SINGLETON (MySingleton) | |||||
// example of usage: | // example of usage: | ||||
MySingleton* m = MySingleton::getInstance(); // creates the singleton if there isn't already one. | |||||
auto* m = MySingleton::getInstance(); // creates the singleton if there isn't already one. | |||||
... | ... | ||||
@@ -77,84 +178,38 @@ namespace juce | |||||
objects being accidentally re-created during your app's shutdown code. | objects being accidentally re-created during your app's shutdown code. | ||||
If you know that your object will only be created and deleted by a single thread, you | If you know that your object will only be created and deleted by a single thread, you | ||||
can use the slightly more efficient juce_DeclareSingleton_SingleThreaded() macro instead | |||||
can use the slightly more efficient JUCE_DECLARE_SINGLETON_SINGLETHREADED macro instead | |||||
of this one. | of this one. | ||||
@see juce_ImplementSingleton, juce_DeclareSingleton_SingleThreaded | |||||
@see JUCE_IMPLEMENT_SINGLETON, JUCE_DECLARE_SINGLETON_SINGLETHREADED | |||||
*/ | */ | ||||
#define juce_DeclareSingleton(classname, doNotRecreateAfterDeletion) \ | |||||
\ | |||||
static classname* _singletonInstance; \ | |||||
static juce::CriticalSection _singletonLock; \ | |||||
\ | |||||
static classname* JUCE_CALLTYPE getInstance() \ | |||||
{ \ | |||||
if (_singletonInstance == nullptr) \ | |||||
{\ | |||||
const juce::ScopedLock sl (_singletonLock); \ | |||||
\ | |||||
if (_singletonInstance == nullptr) \ | |||||
{ \ | |||||
static bool alreadyInside = false; \ | |||||
static bool createdOnceAlready = false; \ | |||||
\ | |||||
const bool problem = alreadyInside || ((doNotRecreateAfterDeletion) && createdOnceAlready); \ | |||||
jassert (! problem); \ | |||||
if (! problem) \ | |||||
{ \ | |||||
createdOnceAlready = true; \ | |||||
alreadyInside = true; \ | |||||
classname* newObject = new classname(); /* (use a stack variable to avoid setting the newObject value before the class has finished its constructor) */ \ | |||||
alreadyInside = false; \ | |||||
\ | |||||
_singletonInstance = newObject; \ | |||||
} \ | |||||
} \ | |||||
} \ | |||||
\ | |||||
return _singletonInstance; \ | |||||
} \ | |||||
#define JUCE_DECLARE_SINGLETON(Classname, doNotRecreateAfterDeletion) \ | |||||
\ | \ | ||||
static inline classname* JUCE_CALLTYPE getInstanceWithoutCreating() noexcept\ | |||||
{ \ | |||||
return _singletonInstance; \ | |||||
} \ | |||||
static juce::SingletonHolder<Classname, juce::CriticalSection, doNotRecreateAfterDeletion> singletonHolder; \ | |||||
friend decltype (singletonHolder); \ | |||||
\ | \ | ||||
static void JUCE_CALLTYPE deleteInstance() \ | |||||
{ \ | |||||
const juce::ScopedLock sl (_singletonLock); \ | |||||
if (_singletonInstance != nullptr) \ | |||||
{ \ | |||||
classname* const old = _singletonInstance; \ | |||||
_singletonInstance = nullptr; \ | |||||
delete old; \ | |||||
} \ | |||||
} \ | |||||
\ | |||||
void clearSingletonInstance() noexcept\ | |||||
{ \ | |||||
if (_singletonInstance == this) \ | |||||
_singletonInstance = nullptr; \ | |||||
} | |||||
static Classname* JUCE_CALLTYPE getInstance() { return singletonHolder.get(); } \ | |||||
static Classname* JUCE_CALLTYPE getInstanceWithoutCreating() noexcept { return singletonHolder.instance; } \ | |||||
static void JUCE_CALLTYPE deleteInstance() noexcept { singletonHolder.deleteInstance(); } \ | |||||
void clearSingletonInstance() noexcept { singletonHolder.clear (this); } | |||||
//============================================================================== | //============================================================================== | ||||
/** This is a counterpart to the juce_DeclareSingleton macro. | |||||
/** This is a counterpart to the JUCE_DECLARE_SINGLETON macros. | |||||
After adding the juce_DeclareSingleton to the class definition, this macro has | |||||
After adding the JUCE_DECLARE_SINGLETON to the class definition, this macro has | |||||
to be used in the cpp file. | to be used in the cpp file. | ||||
*/ | */ | ||||
#define juce_ImplementSingleton(classname) \ | |||||
#define JUCE_IMPLEMENT_SINGLETON(Classname) \ | |||||
\ | \ | ||||
classname* classname::_singletonInstance = nullptr; \ | |||||
juce::CriticalSection classname::_singletonLock; | |||||
decltype (Classname::singletonHolder) Classname::singletonHolder; | |||||
//============================================================================== | //============================================================================== | ||||
/** | /** | ||||
Macro to declare member variables and methods for a singleton class. | Macro to declare member variables and methods for a singleton class. | ||||
This is exactly the same as juce_DeclareSingleton, but doesn't use a critical | |||||
This is exactly the same as JUCE_DECLARE_SINGLETON, but doesn't use a critical | |||||
section to make access to it thread-safe. If you know that your object will | section to make access to it thread-safe. If you know that your object will | ||||
only ever be created or deleted by a single thread, then this is a | only ever be created or deleted by a single thread, then this is a | ||||
more efficient version to use. | more efficient version to use. | ||||
@@ -164,120 +219,61 @@ namespace juce | |||||
object, getInstance() will refuse to create another one. This can be useful to stop | object, getInstance() will refuse to create another one. This can be useful to stop | ||||
objects being accidentally re-created during your app's shutdown code. | objects being accidentally re-created during your app's shutdown code. | ||||
See the documentation for juce_DeclareSingleton for more information about | |||||
how to use it, the only difference being that you have to use | |||||
juce_ImplementSingleton_SingleThreaded instead of juce_ImplementSingleton. | |||||
See the documentation for JUCE_DECLARE_SINGLETON for more information about | |||||
how to use it. Just like JUCE_DECLARE_SINGLETON you need to also have a | |||||
corresponding JUCE_IMPLEMENT_SINGLETON statement somewhere in your code. | |||||
@see juce_ImplementSingleton_SingleThreaded, juce_DeclareSingleton, juce_DeclareSingleton_SingleThreaded_Minimal | |||||
@see JUCE_IMPLEMENT_SINGLETON, JUCE_DECLARE_SINGLETON, JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL | |||||
*/ | */ | ||||
#define juce_DeclareSingleton_SingleThreaded(classname, doNotRecreateAfterDeletion) \ | |||||
\ | |||||
static classname* _singletonInstance; \ | |||||
\ | |||||
static classname* getInstance() \ | |||||
{ \ | |||||
if (_singletonInstance == nullptr) \ | |||||
{ \ | |||||
static bool alreadyInside = false; \ | |||||
static bool createdOnceAlready = false; \ | |||||
\ | |||||
const bool problem = alreadyInside || ((doNotRecreateAfterDeletion) && createdOnceAlready); \ | |||||
jassert (! problem); \ | |||||
if (! problem) \ | |||||
{ \ | |||||
createdOnceAlready = true; \ | |||||
alreadyInside = true; \ | |||||
classname* newObject = new classname(); /* (use a stack variable to avoid setting the newObject value before the class has finished its constructor) */ \ | |||||
alreadyInside = false; \ | |||||
#define JUCE_DECLARE_SINGLETON_SINGLETHREADED(Classname, doNotRecreateAfterDeletion) \ | |||||
\ | \ | ||||
_singletonInstance = newObject; \ | |||||
} \ | |||||
} \ | |||||
static juce::SingletonHolder<Classname, juce::DummyCriticalSection, doNotRecreateAfterDeletion> singletonHolder; \ | |||||
friend decltype (singletonHolder); \ | |||||
\ | \ | ||||
return _singletonInstance; \ | |||||
} \ | |||||
\ | |||||
static inline classname* getInstanceWithoutCreating() noexcept\ | |||||
{ \ | |||||
return _singletonInstance; \ | |||||
} \ | |||||
\ | |||||
static void deleteInstance() \ | |||||
{ \ | |||||
if (_singletonInstance != nullptr) \ | |||||
{ \ | |||||
classname* const old = _singletonInstance; \ | |||||
_singletonInstance = nullptr; \ | |||||
delete old; \ | |||||
} \ | |||||
} \ | |||||
\ | |||||
void clearSingletonInstance() noexcept\ | |||||
{ \ | |||||
if (_singletonInstance == this) \ | |||||
_singletonInstance = nullptr; \ | |||||
} | |||||
static Classname* JUCE_CALLTYPE getInstance() { return singletonHolder.get(); } \ | |||||
static Classname* JUCE_CALLTYPE getInstanceWithoutCreating() noexcept { return singletonHolder.instance; } \ | |||||
static void JUCE_CALLTYPE deleteInstance() noexcept { singletonHolder.deleteInstance(); } \ | |||||
void clearSingletonInstance() noexcept { singletonHolder.clear (this); } | |||||
//============================================================================== | //============================================================================== | ||||
/** | /** | ||||
Macro to declare member variables and methods for a singleton class. | Macro to declare member variables and methods for a singleton class. | ||||
This is like juce_DeclareSingleton_SingleThreaded, but doesn't do any checking | |||||
This is like JUCE_DECLARE_SINGLETON_SINGLETHREADED, but doesn't do any checking | |||||
for recursion or repeated instantiation. It's intended for use as a lightweight | for recursion or repeated instantiation. It's intended for use as a lightweight | ||||
version of a singleton, where you're using it in very straightforward | version of a singleton, where you're using it in very straightforward | ||||
circumstances and don't need the extra checking. | circumstances and don't need the extra checking. | ||||
Just use the normal juce_ImplementSingleton_SingleThreaded as the counterpart | |||||
to this declaration, as you would with juce_DeclareSingleton_SingleThreaded. | |||||
Just use the normal JUCE_IMPLEMENT_SINGLETON_SINGLETHREADED as the counterpart | |||||
to this declaration, as you would with JUCE_DECLARE_SINGLETON_SINGLETHREADED. | |||||
See the documentation for juce_DeclareSingleton for more information about | |||||
See the documentation for JUCE_DECLARE_SINGLETON for more information about | |||||
how to use it, the only difference being that you have to use | how to use it, the only difference being that you have to use | ||||
juce_ImplementSingleton_SingleThreaded instead of juce_ImplementSingleton. | |||||
JUCE_IMPLEMENT_SINGLETON_SINGLETHREADED instead of JUCE_IMPLEMENT_SINGLETON. | |||||
@see juce_ImplementSingleton_SingleThreaded, juce_DeclareSingleton | |||||
@see JUCE_IMPLEMENT_SINGLETON_SINGLETHREADED, JUCE_DECLARE_SINGLETON | |||||
*/ | */ | ||||
#define juce_DeclareSingleton_SingleThreaded_Minimal(classname) \ | |||||
\ | |||||
static classname* _singletonInstance; \ | |||||
\ | |||||
static classname* getInstance() \ | |||||
{ \ | |||||
if (_singletonInstance == nullptr) \ | |||||
_singletonInstance = new classname(); \ | |||||
#define JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL(Classname) \ | |||||
\ | \ | ||||
return _singletonInstance; \ | |||||
} \ | |||||
static juce::SingletonHolder<Classname, juce::DummyCriticalSection, false> singletonHolder; \ | |||||
friend decltype (singletonHolder); \ | |||||
\ | \ | ||||
static inline classname* getInstanceWithoutCreating() noexcept\ | |||||
{ \ | |||||
return _singletonInstance; \ | |||||
} \ | |||||
\ | |||||
static void deleteInstance() \ | |||||
{ \ | |||||
if (_singletonInstance != nullptr) \ | |||||
{ \ | |||||
classname* const old = _singletonInstance; \ | |||||
_singletonInstance = nullptr; \ | |||||
delete old; \ | |||||
} \ | |||||
} \ | |||||
\ | |||||
void clearSingletonInstance() noexcept\ | |||||
{ \ | |||||
if (_singletonInstance == this) \ | |||||
_singletonInstance = nullptr; \ | |||||
} | |||||
static Classname* JUCE_CALLTYPE getInstance() { return singletonHolder.getWithoutChecking(); } \ | |||||
static Classname* JUCE_CALLTYPE getInstanceWithoutCreating() noexcept { return singletonHolder.instance; } \ | |||||
static void JUCE_CALLTYPE deleteInstance() noexcept { singletonHolder.deleteInstance(); } \ | |||||
void clearSingletonInstance() noexcept { singletonHolder.clear (this); } | |||||
//============================================================================== | //============================================================================== | ||||
/** This is a counterpart to the juce_DeclareSingleton_SingleThreaded macro. | |||||
After adding juce_DeclareSingleton_SingleThreaded or juce_DeclareSingleton_SingleThreaded_Minimal | |||||
to the class definition, this macro has to be used somewhere in the cpp file. | |||||
*/ | |||||
#define juce_ImplementSingleton_SingleThreaded(classname) \ | |||||
\ | |||||
classname* classname::_singletonInstance = nullptr; | |||||
#ifndef DOXYGEN | |||||
// These are ancient macros, and have now been updated with new names to match the JUCE style guide, | |||||
// so please update your code to use the newer versions! | |||||
#define juce_DeclareSingleton(Classname, doNotRecreate) JUCE_DECLARE_SINGLETON(Classname, doNotRecreate) | |||||
#define juce_DeclareSingleton_SingleThreaded(Classname, doNotRecreate) JUCE_DECLARE_SINGLETON_SINGLETHREADED(Classname, doNotRecreate) | |||||
#define juce_DeclareSingleton_SingleThreaded_Minimal(Classname) JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL(Classname) | |||||
#define juce_ImplementSingleton(Classname) JUCE_IMPLEMENT_SINGLETON(Classname) | |||||
#define juce_ImplementSingleton_SingleThreaded(Classname) JUCE_IMPLEMENT_SINGLETON(Classname) | |||||
#endif | |||||
} // namespace juce | } // namespace juce |
@@ -34,7 +34,7 @@ DECLARE_JNI_CLASS (JNIHandler, "android/os/Handler"); | |||||
//============================================================================== | //============================================================================== | ||||
namespace Android | namespace Android | ||||
{ | { | ||||
class Runnable : public juce::AndroidInterfaceImplementer | |||||
class Runnable : public juce::AndroidInterfaceImplementer | |||||
{ | { | ||||
public: | public: | ||||
virtual void run() = 0; | virtual void run() = 0; | ||||
@@ -58,7 +58,7 @@ namespace Android | |||||
struct Handler | struct Handler | ||||
{ | { | ||||
juce_DeclareSingleton (Handler, false) | |||||
JUCE_DECLARE_SINGLETON (Handler, false) | |||||
Handler() : nativeHandler (getEnv()->NewObject (JNIHandler, JNIHandler.constructor)) {} | Handler() : nativeHandler (getEnv()->NewObject (JNIHandler, JNIHandler.constructor)) {} | ||||
@@ -70,13 +70,13 @@ namespace Android | |||||
GlobalRef nativeHandler; | GlobalRef nativeHandler; | ||||
}; | }; | ||||
juce_ImplementSingleton (Handler); | |||||
JUCE_IMPLEMENT_SINGLETON (Handler) | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
struct AndroidMessageQueue : private Android::Runnable | struct AndroidMessageQueue : private Android::Runnable | ||||
{ | { | ||||
juce_DeclareSingleton_SingleThreaded (AndroidMessageQueue, true) | |||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED (AndroidMessageQueue, true) | |||||
AndroidMessageQueue() | AndroidMessageQueue() | ||||
: self (CreateJavaInterface (this, "java/lang/Runnable").get()) | : self (CreateJavaInterface (this, "java/lang/Runnable").get()) | ||||
@@ -118,7 +118,7 @@ private: | |||||
Android::Handler handler; | Android::Handler handler; | ||||
}; | }; | ||||
juce_ImplementSingleton_SingleThreaded (AndroidMessageQueue); | |||||
JUCE_IMPLEMENT_SINGLETON (AndroidMessageQueue) | |||||
//============================================================================== | //============================================================================== | ||||
void MessageManager::doPlatformSpecificInitialisation() { AndroidMessageQueue::getInstance(); } | void MessageManager::doPlatformSpecificInitialisation() { AndroidMessageQueue::getInstance(); } | ||||
@@ -132,7 +132,7 @@ public: | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
juce_DeclareSingleton_SingleThreaded_Minimal (InternalMessageQueue) | |||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (InternalMessageQueue) | |||||
private: | private: | ||||
CriticalSection lock; | CriticalSection lock; | ||||
@@ -165,7 +165,7 @@ private: | |||||
} | } | ||||
}; | }; | ||||
juce_ImplementSingleton_SingleThreaded (InternalMessageQueue) | |||||
JUCE_IMPLEMENT_SINGLETON (InternalMessageQueue) | |||||
//============================================================================== | //============================================================================== | ||||
@@ -22,5 +22,5 @@ | |||||
namespace juce | namespace juce | ||||
{ | { | ||||
juce_ImplementSingleton (WinRTWrapper) | |||||
JUCE_IMPLEMENT_SINGLETON (WinRTWrapper) | |||||
} | } |
@@ -26,7 +26,7 @@ namespace juce | |||||
class WinRTWrapper : public DeletedAtShutdown | class WinRTWrapper : public DeletedAtShutdown | ||||
{ | { | ||||
public: | public: | ||||
juce_DeclareSingleton (WinRTWrapper, true) | |||||
JUCE_DECLARE_SINGLETON (WinRTWrapper, true) | |||||
class ScopedHString | class ScopedHString | ||||
{ | { | ||||
@@ -60,7 +60,7 @@ public: | |||||
clearSingletonInstance(); | clearSingletonInstance(); | ||||
} | } | ||||
juce_DeclareSingleton (TypefaceCache, false) | |||||
JUCE_DECLARE_SINGLETON (TypefaceCache, false) | |||||
void setSize (const int numToCache) | void setSize (const int numToCache) | ||||
{ | { | ||||
@@ -157,7 +157,7 @@ private: | |||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TypefaceCache) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TypefaceCache) | ||||
}; | }; | ||||
juce_ImplementSingleton (TypefaceCache) | |||||
JUCE_IMPLEMENT_SINGLETON (TypefaceCache) | |||||
void Typeface::setTypefaceCacheSize (int numFontsToCache) | void Typeface::setTypefaceCacheSize (int numFontsToCache) | ||||
{ | { | ||||
@@ -33,7 +33,7 @@ struct ImageCache::Pimpl : private Timer, | |||||
Pimpl() {} | Pimpl() {} | ||||
~Pimpl() { clearSingletonInstance(); } | ~Pimpl() { clearSingletonInstance(); } | ||||
juce_DeclareSingleton_SingleThreaded_Minimal (ImageCache::Pimpl) | |||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (ImageCache::Pimpl) | |||||
Image getFromHashCode (const int64 hashCode) noexcept | Image getFromHashCode (const int64 hashCode) noexcept | ||||
{ | { | ||||
@@ -111,7 +111,7 @@ struct ImageCache::Pimpl : private Timer, | |||||
JUCE_DECLARE_NON_COPYABLE (Pimpl) | JUCE_DECLARE_NON_COPYABLE (Pimpl) | ||||
}; | }; | ||||
juce_ImplementSingleton_SingleThreaded (ImageCache::Pimpl) | |||||
JUCE_IMPLEMENT_SINGLETON (ImageCache::Pimpl) | |||||
//============================================================================== | //============================================================================== | ||||
@@ -229,7 +229,7 @@ public: | |||||
sansSerif.addIfNotAlreadyThere (faces.getUnchecked(i)->family); | sansSerif.addIfNotAlreadyThere (faces.getUnchecked(i)->family); | ||||
} | } | ||||
juce_DeclareSingleton_SingleThreaded_Minimal (FTTypefaceList) | |||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (FTTypefaceList) | |||||
private: | private: | ||||
FTLibWrapper::Ptr library; | FTLibWrapper::Ptr library; | ||||
@@ -288,7 +288,7 @@ private: | |||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FTTypefaceList) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FTTypefaceList) | ||||
}; | }; | ||||
juce_ImplementSingleton_SingleThreaded (FTTypefaceList) | |||||
JUCE_IMPLEMENT_SINGLETON (FTTypefaceList) | |||||
//============================================================================== | //============================================================================== | ||||
@@ -90,7 +90,7 @@ ModalComponentManager::~ModalComponentManager() | |||||
clearSingletonInstance(); | clearSingletonInstance(); | ||||
} | } | ||||
juce_ImplementSingleton_SingleThreaded (ModalComponentManager) | |||||
JUCE_IMPLEMENT_SINGLETON (ModalComponentManager) | |||||
//============================================================================== | //============================================================================== | ||||
@@ -75,7 +75,7 @@ public: | |||||
//============================================================================== | //============================================================================== | ||||
#ifndef DOXYGEN | #ifndef DOXYGEN | ||||
juce_DeclareSingleton_SingleThreaded_Minimal (ModalComponentManager) | |||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (ModalComponentManager) | |||||
#endif | #endif | ||||
//============================================================================== | //============================================================================== | ||||
@@ -148,7 +148,7 @@ private: | |||||
#endif | #endif | ||||
//============================================================================== | //============================================================================== | ||||
juce_ImplementSingleton (ContentSharer) | |||||
JUCE_IMPLEMENT_SINGLETON (ContentSharer) | |||||
ContentSharer::ContentSharer() {} | ContentSharer::ContentSharer() {} | ||||
ContentSharer::~ContentSharer() { clearSingletonInstance(); } | ContentSharer::~ContentSharer() { clearSingletonInstance(); } | ||||
@@ -36,7 +36,7 @@ namespace juce | |||||
class JUCE_API ContentSharer | class JUCE_API ContentSharer | ||||
{ | { | ||||
public: | public: | ||||
juce_DeclareSingleton (ContentSharer, false) | |||||
JUCE_DECLARE_SINGLETON (ContentSharer, false) | |||||
/** Shares the given files. Each URL should be either a full file path | /** Shares the given files. Each URL should be either a full file path | ||||
or it should point to a resource within the application bundle. For | or it should point to a resource within the application bundle. For | ||||
@@ -78,10 +78,10 @@ struct ReportingThreadContainer : public ChangeListener, | |||||
ScopedPointer<ReportingThread> reportingThread; | ScopedPointer<ReportingThread> reportingThread; | ||||
juce_DeclareSingleton_SingleThreaded_Minimal (ReportingThreadContainer) | |||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (ReportingThreadContainer) | |||||
}; | }; | ||||
juce_ImplementSingleton_SingleThreaded (ReportingThreadContainer) | |||||
JUCE_IMPLEMENT_SINGLETON (ReportingThreadContainer) | |||||
//============================================================================== | //============================================================================== | ||||
struct ReportingThread : public Thread, | struct ReportingThread : public Thread, | ||||
@@ -232,7 +232,7 @@ void XWindowSystem::destroyXDisplay() noexcept | |||||
LinuxEventLoop::removeWindowSystemFd(); | LinuxEventLoop::removeWindowSystemFd(); | ||||
} | } | ||||
juce_ImplementSingleton (XWindowSystem) | |||||
JUCE_IMPLEMENT_SINGLETON (XWindowSystem) | |||||
//============================================================================== | //============================================================================== | ||||
ScopedXDisplay::ScopedXDisplay() : display (XWindowSystem::getInstance()->displayRef()) | ScopedXDisplay::ScopedXDisplay() : display (XWindowSystem::getInstance()->displayRef()) | ||||
@@ -42,7 +42,7 @@ public: | |||||
XDisplay displayRef() noexcept; | XDisplay displayRef() noexcept; | ||||
XDisplay displayUnref() noexcept; | XDisplay displayUnref() noexcept; | ||||
juce_DeclareSingleton (XWindowSystem, false) | |||||
JUCE_DECLARE_SINGLETON (XWindowSystem, false) | |||||
private: | private: | ||||
XDisplay display = {}; | XDisplay display = {}; | ||||
@@ -56,10 +56,10 @@ struct JuceMainMenuBarHolder : private DeletedAtShutdown | |||||
NSMenu* mainMenuBar = nil; | NSMenu* mainMenuBar = nil; | ||||
juce_DeclareSingleton_SingleThreaded (JuceMainMenuBarHolder, true) | |||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED (JuceMainMenuBarHolder, true) | |||||
}; | }; | ||||
juce_ImplementSingleton_SingleThreaded (JuceMainMenuBarHolder) | |||||
JUCE_IMPLEMENT_SINGLETON (JuceMainMenuBarHolder) | |||||
//============================================================================== | //============================================================================== | ||||
class JuceMainMenuHandler : private MenuBarModel::Listener, | class JuceMainMenuHandler : private MenuBarModel::Listener, | ||||
@@ -442,12 +442,12 @@ struct DisplaySettingsChangeCallback : private DeletedAtShutdown | |||||
const_cast<Desktop::Displays&> (Desktop::getInstance().getDisplays()).refresh(); | const_cast<Desktop::Displays&> (Desktop::getInstance().getDisplays()).refresh(); | ||||
} | } | ||||
juce_DeclareSingleton_SingleThreaded_Minimal (DisplaySettingsChangeCallback) | |||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (DisplaySettingsChangeCallback) | |||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DisplaySettingsChangeCallback) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DisplaySettingsChangeCallback) | ||||
}; | }; | ||||
juce_ImplementSingleton_SingleThreaded (DisplaySettingsChangeCallback) | |||||
JUCE_IMPLEMENT_SINGLETON (DisplaySettingsChangeCallback) | |||||
static Rectangle<int> convertDisplayRect (NSRect r, CGFloat mainScreenBottom) | static Rectangle<int> convertDisplayRect (NSRect r, CGFloat mainScreenBottom) | ||||
{ | { | ||||
@@ -755,7 +755,7 @@ struct OnScreenKeyboard : public DeletedAtShutdown, | |||||
startTimer (10); | startTimer (10); | ||||
} | } | ||||
juce_DeclareSingleton_SingleThreaded (OnScreenKeyboard, true) | |||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED (OnScreenKeyboard, true) | |||||
private: | private: | ||||
OnScreenKeyboard() | OnScreenKeyboard() | ||||
@@ -803,7 +803,7 @@ private: | |||||
ComSmartPtr<ITipInvocation> tipInvocation; | ComSmartPtr<ITipInvocation> tipInvocation; | ||||
}; | }; | ||||
juce_ImplementSingleton_SingleThreaded (OnScreenKeyboard) | |||||
JUCE_IMPLEMENT_SINGLETON (OnScreenKeyboard) | |||||
//============================================================================== | //============================================================================== | ||||
struct HSTRING_PRIVATE; | struct HSTRING_PRIVATE; | ||||
@@ -1606,7 +1606,7 @@ private: | |||||
LPCTSTR getWindowClassName() const noexcept { return (LPCTSTR) (pointer_sized_uint) atom; } | LPCTSTR getWindowClassName() const noexcept { return (LPCTSTR) (pointer_sized_uint) atom; } | ||||
juce_DeclareSingleton_SingleThreaded_Minimal (WindowClassHolder) | |||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (WindowClassHolder) | |||||
private: | private: | ||||
ATOM atom; | ATOM atom; | ||||
@@ -3589,7 +3589,7 @@ JUCE_API ComponentPeer* createNonRepaintingEmbeddedWindowsPeer (Component& compo | |||||
} | } | ||||
juce_ImplementSingleton_SingleThreaded (HWNDComponentPeer::WindowClassHolder) | |||||
JUCE_IMPLEMENT_SINGLETON (HWNDComponentPeer::WindowClassHolder) | |||||
//============================================================================== | //============================================================================== | ||||
@@ -35,7 +35,7 @@ public: | |||||
TopLevelWindowManager() {} | TopLevelWindowManager() {} | ||||
~TopLevelWindowManager() { clearSingletonInstance(); } | ~TopLevelWindowManager() { clearSingletonInstance(); } | ||||
juce_DeclareSingleton_SingleThreaded_Minimal (TopLevelWindowManager) | |||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (TopLevelWindowManager) | |||||
void checkFocusAsync() | void checkFocusAsync() | ||||
{ | { | ||||
@@ -122,7 +122,7 @@ private: | |||||
JUCE_DECLARE_NON_COPYABLE (TopLevelWindowManager) | JUCE_DECLARE_NON_COPYABLE (TopLevelWindowManager) | ||||
}; | }; | ||||
juce_ImplementSingleton_SingleThreaded (TopLevelWindowManager) | |||||
JUCE_IMPLEMENT_SINGLETON (TopLevelWindowManager) | |||||
void juce_checkCurrentlyFocusedTopLevelWindow(); | void juce_checkCurrentlyFocusedTopLevelWindow(); | ||||
void juce_checkCurrentlyFocusedTopLevelWindow() | void juce_checkCurrentlyFocusedTopLevelWindow() | ||||
@@ -40,7 +40,7 @@ public: | |||||
AllComponentRepainter() {} | AllComponentRepainter() {} | ||||
~AllComponentRepainter() { clearSingletonInstance(); } | ~AllComponentRepainter() { clearSingletonInstance(); } | ||||
juce_DeclareSingleton (AllComponentRepainter, false) | |||||
JUCE_DECLARE_SINGLETON (AllComponentRepainter, false) | |||||
void trigger() | void trigger() | ||||
{ | { | ||||
@@ -89,8 +89,8 @@ private: | |||||
} | } | ||||
}; | }; | ||||
juce_ImplementSingleton (AllComponentRepainter) | |||||
juce_ImplementSingleton (ValueList) | |||||
JUCE_IMPLEMENT_SINGLETON (AllComponentRepainter) | |||||
JUCE_IMPLEMENT_SINGLETON (ValueList) | |||||
//============================================================================== | //============================================================================== | ||||
int64 parseInt (String s) | int64 parseInt (String s) | ||||
@@ -200,7 +200,7 @@ namespace LiveConstantEditor | |||||
ValueList(); | ValueList(); | ||||
~ValueList(); | ~ValueList(); | ||||
juce_DeclareSingleton (ValueList, false) | |||||
JUCE_DECLARE_SINGLETON (ValueList, false) | |||||
template <typename Type> | template <typename Type> | ||||
LiveValue<Type>& getValue (const char* file, int line, const Type& initialValue) | LiveValue<Type>& getValue (const char* file, int line, const Type& initialValue) | ||||
@@ -33,7 +33,7 @@ bool PushNotifications::Notification::isValid() const noexcept { return true; } | |||||
#endif | #endif | ||||
//============================================================================== | //============================================================================== | ||||
juce_ImplementSingleton (PushNotifications) | |||||
JUCE_IMPLEMENT_SINGLETON (PushNotifications) | |||||
PushNotifications::PushNotifications() | PushNotifications::PushNotifications() | ||||
#if JUCE_PUSH_NOTIFICATIONS | #if JUCE_PUSH_NOTIFICATIONS | ||||
@@ -45,7 +45,7 @@ class JUCE_API PushNotifications | |||||
{ | { | ||||
public: | public: | ||||
#ifndef DOXYGEN | #ifndef DOXYGEN | ||||
juce_DeclareSingleton (PushNotifications, false) | |||||
JUCE_DECLARE_SINGLETON (PushNotifications, false) | |||||
#endif | #endif | ||||
//========================================================================== | //========================================================================== | ||||
@@ -772,7 +772,7 @@ private: | |||||
bool isRegistered() const noexcept { return atom != 0; } | bool isRegistered() const noexcept { return atom != 0; } | ||||
LPCTSTR getWindowClassName() const noexcept { return (LPCTSTR) (pointer_sized_uint) MAKELONG (atom, 0); } | LPCTSTR getWindowClassName() const noexcept { return (LPCTSTR) (pointer_sized_uint) MAKELONG (atom, 0); } | ||||
juce_DeclareSingleton_SingleThreaded_Minimal (NativeWindowClass) | |||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (NativeWindowClass) | |||||
private: | private: | ||||
NativeWindowClass() | NativeWindowClass() | ||||
@@ -889,4 +889,4 @@ private: | |||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Pimpl) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Pimpl) | ||||
}; | }; | ||||
juce_ImplementSingleton_SingleThreaded (VideoComponent::Pimpl::DirectShowContext::NativeWindowClass) | |||||
JUCE_IMPLEMENT_SINGLETON (VideoComponent::Pimpl::DirectShowContext::NativeWindowClass) |