The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

387 lines
14KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. The code included in this file is provided under the terms of the ISC license
  8. http://www.isc.org/downloads/software-support-policy/isc-license. Permission
  9. To use, copy, modify, and/or distribute this software for any purpose with or
  10. without fee is hereby granted provided that the above copyright notice and
  11. this permission notice appear in all copies.
  12. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  13. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  14. DISCLAIMED.
  15. ==============================================================================
  16. */
  17. /*******************************************************************************
  18. The block below describes the properties of this module, and is read by
  19. the Projucer to automatically generate project code that uses it.
  20. For details about the syntax and how to create or use a module, see the
  21. JUCE Module Format.txt file.
  22. BEGIN_JUCE_MODULE_DECLARATION
  23. ID: juce_core
  24. vendor: juce
  25. version: 5.4.3
  26. name: JUCE core classes
  27. description: The essential set of basic JUCE classes, as required by all the other JUCE modules. Includes text, container, memory, threading and i/o functionality.
  28. website: http://www.juce.com/juce
  29. license: ISC
  30. dependencies:
  31. OSXFrameworks: Cocoa IOKit
  32. iOSFrameworks: Foundation
  33. linuxLibs: rt dl pthread
  34. mingwLibs: uuid wsock32 wininet version ole32 ws2_32 oleaut32 imm32 comdlg32 shlwapi rpcrt4 winmm
  35. END_JUCE_MODULE_DECLARATION
  36. *******************************************************************************/
  37. #pragma once
  38. #define JUCE_CORE_H_INCLUDED
  39. //==============================================================================
  40. #ifdef _MSC_VER
  41. #pragma warning (push)
  42. // Disable warnings for long class names, padding, and undefined preprocessor definitions.
  43. #pragma warning (disable: 4251 4786 4668 4820)
  44. #ifdef __INTEL_COMPILER
  45. #pragma warning (disable: 1125)
  46. #endif
  47. #endif
  48. #include "system/juce_TargetPlatform.h"
  49. //==============================================================================
  50. /** Config: JUCE_FORCE_DEBUG
  51. Normally, JUCE_DEBUG is set to 1 or 0 based on compiler and project settings,
  52. but if you define this value, you can override this to force it to be true or false.
  53. */
  54. #ifndef JUCE_FORCE_DEBUG
  55. //#define JUCE_FORCE_DEBUG 0
  56. #endif
  57. //==============================================================================
  58. /** Config: JUCE_LOG_ASSERTIONS
  59. If this flag is enabled, the jassert and jassertfalse macros will always use Logger::writeToLog()
  60. to write a message when an assertion happens.
  61. Enabling it will also leave this turned on in release builds. When it's disabled,
  62. however, the jassert and jassertfalse macros will not be compiled in a
  63. release build.
  64. @see jassert, jassertfalse, Logger
  65. */
  66. #ifndef JUCE_LOG_ASSERTIONS
  67. #if JUCE_ANDROID
  68. #define JUCE_LOG_ASSERTIONS 1
  69. #else
  70. #define JUCE_LOG_ASSERTIONS 0
  71. #endif
  72. #endif
  73. //==============================================================================
  74. /** Config: JUCE_CHECK_MEMORY_LEAKS
  75. Enables a memory-leak check for certain objects when the app terminates. See the LeakedObjectDetector
  76. class and the JUCE_LEAK_DETECTOR macro for more details about enabling leak checking for specific classes.
  77. */
  78. #if JUCE_DEBUG && ! defined (JUCE_CHECK_MEMORY_LEAKS)
  79. #define JUCE_CHECK_MEMORY_LEAKS 1
  80. #endif
  81. //==============================================================================
  82. /** Config: JUCE_DONT_AUTOLINK_TO_WIN32_LIBRARIES
  83. In a Visual C++ build, this can be used to stop the required system libs being
  84. automatically added to the link stage.
  85. */
  86. #ifndef JUCE_DONT_AUTOLINK_TO_WIN32_LIBRARIES
  87. #define JUCE_DONT_AUTOLINK_TO_WIN32_LIBRARIES 0
  88. #endif
  89. /** Config: JUCE_INCLUDE_ZLIB_CODE
  90. This can be used to disable Juce's embedded 3rd-party zlib code.
  91. You might need to tweak this if you're linking to an external zlib library in your app,
  92. but for normal apps, this option should be left alone.
  93. If you disable this, you might also want to set a value for JUCE_ZLIB_INCLUDE_PATH, to
  94. specify the path where your zlib headers live.
  95. */
  96. #ifndef JUCE_INCLUDE_ZLIB_CODE
  97. #define JUCE_INCLUDE_ZLIB_CODE 1
  98. #endif
  99. #ifndef JUCE_ZLIB_INCLUDE_PATH
  100. #define JUCE_ZLIB_INCLUDE_PATH <zlib.h>
  101. #endif
  102. /** Config: JUCE_USE_CURL
  103. Enables http/https support via libcurl (Linux only). Enabling this will add an additional
  104. run-time dynamic dependency to libcurl.
  105. If you disable this then https/ssl support will not be available on linux.
  106. */
  107. #ifndef JUCE_USE_CURL
  108. #if JUCE_LINUX
  109. #define JUCE_USE_CURL 1
  110. #else
  111. #define JUCE_USE_CURL 0
  112. #endif
  113. #endif
  114. /** Config: JUCE_LOAD_CURL_SYMBOLS_LAZILY
  115. If enabled, JUCE will load libcurl lazily when required (for example, when WebInputStream
  116. is used). Enabling this flag may also help with library dependency erros as linking
  117. libcurl at compile-time may instruct the linker to hard depend on a specific version
  118. of libcurl. It's also useful if you want to limit the amount of JUCE dependencies and
  119. you are not using WebInputStream or the URL classes.
  120. */
  121. #ifndef JUCE_LOAD_CURL_SYMBOLS_LAZILY
  122. #define JUCE_LOAD_CURL_SYMBOLS_LAZILY 0
  123. #endif
  124. /** Config: JUCE_CATCH_UNHANDLED_EXCEPTIONS
  125. If enabled, this will add some exception-catching code to forward unhandled exceptions
  126. to your JUCEApplicationBase::unhandledException() callback.
  127. */
  128. #ifndef JUCE_CATCH_UNHANDLED_EXCEPTIONS
  129. //#define JUCE_CATCH_UNHANDLED_EXCEPTIONS 1
  130. #endif
  131. /** Config: JUCE_ALLOW_STATIC_NULL_VARIABLES
  132. If disabled, this will turn off dangerous static globals like String::empty, var::null, etc
  133. which can cause nasty order-of-initialisation problems if they are referenced during static
  134. constructor code.
  135. */
  136. #ifndef JUCE_ALLOW_STATIC_NULL_VARIABLES
  137. #define JUCE_ALLOW_STATIC_NULL_VARIABLES 0
  138. #endif
  139. /** Config: JUCE_STRICT_REFCOUNTEDPOINTER
  140. If enabled, this will make the ReferenceCountedObjectPtr class stricter about allowing
  141. itself to be cast directly to a raw pointer. By default this is disabled, for compatibility
  142. with old code, but if possible, you should always enable it to improve code safety!
  143. */
  144. #ifndef JUCE_STRICT_REFCOUNTEDPOINTER
  145. #define JUCE_STRICT_REFCOUNTEDPOINTER 0
  146. #endif
  147. #ifndef JUCE_STRING_UTF_TYPE
  148. #define JUCE_STRING_UTF_TYPE 8
  149. #endif
  150. //==============================================================================
  151. //==============================================================================
  152. #if JUCE_CORE_INCLUDE_NATIVE_HEADERS
  153. #include "native/juce_BasicNativeHeaders.h"
  154. #endif
  155. #if JUCE_WINDOWS
  156. #undef small
  157. #endif
  158. #include "system/juce_StandardHeader.h"
  159. namespace juce
  160. {
  161. class StringRef;
  162. class MemoryBlock;
  163. class File;
  164. class InputStream;
  165. class OutputStream;
  166. class DynamicObject;
  167. class FileInputStream;
  168. class FileOutputStream;
  169. class XmlElement;
  170. extern JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger() noexcept;
  171. extern JUCE_API void JUCE_CALLTYPE logAssertion (const char* file, int line) noexcept;
  172. }
  173. #include "memory/juce_Memory.h"
  174. #include "maths/juce_MathsFunctions.h"
  175. #include "memory/juce_ByteOrder.h"
  176. #include "memory/juce_Atomic.h"
  177. #include "text/juce_CharacterFunctions.h"
  178. #if JUCE_MSVC
  179. #pragma warning (push)
  180. #pragma warning (disable: 4514 4996)
  181. #endif
  182. #include "text/juce_CharPointer_UTF8.h"
  183. #include "text/juce_CharPointer_UTF16.h"
  184. #include "text/juce_CharPointer_UTF32.h"
  185. #include "text/juce_CharPointer_ASCII.h"
  186. #if JUCE_MSVC
  187. #pragma warning (pop)
  188. #endif
  189. #include "text/juce_String.h"
  190. #include "text/juce_StringRef.h"
  191. #include "logging/juce_Logger.h"
  192. #include "memory/juce_LeakedObjectDetector.h"
  193. #include "memory/juce_ContainerDeletePolicy.h"
  194. #include "memory/juce_HeapBlock.h"
  195. #include "memory/juce_MemoryBlock.h"
  196. #include "memory/juce_ReferenceCountedObject.h"
  197. #include "memory/juce_ScopedPointer.h"
  198. #include "memory/juce_OptionalScopedPointer.h"
  199. #include "memory/juce_Singleton.h"
  200. #include "memory/juce_WeakReference.h"
  201. #include "threads/juce_ScopedLock.h"
  202. #include "threads/juce_CriticalSection.h"
  203. #include "maths/juce_Range.h"
  204. #include "maths/juce_NormalisableRange.h"
  205. #include "maths/juce_StatisticsAccumulator.h"
  206. #include "containers/juce_ElementComparator.h"
  207. #include "containers/juce_ArrayAllocationBase.h"
  208. #include "containers/juce_ArrayBase.h"
  209. #include "containers/juce_Array.h"
  210. #include "containers/juce_LinkedListPointer.h"
  211. #include "containers/juce_ListenerList.h"
  212. #include "containers/juce_OwnedArray.h"
  213. #include "containers/juce_ReferenceCountedArray.h"
  214. #include "containers/juce_ScopedValueSetter.h"
  215. #include "containers/juce_SortedSet.h"
  216. #include "containers/juce_SparseSet.h"
  217. #include "containers/juce_AbstractFifo.h"
  218. #include "text/juce_NewLine.h"
  219. #include "text/juce_StringPool.h"
  220. #include "text/juce_Identifier.h"
  221. #include "text/juce_StringArray.h"
  222. #include "system/juce_SystemStats.h"
  223. #include "memory/juce_HeavyweightLeakedObjectDetector.h"
  224. #include "text/juce_StringPairArray.h"
  225. #include "text/juce_TextDiff.h"
  226. #include "text/juce_LocalisedStrings.h"
  227. #include "text/juce_Base64.h"
  228. #include "misc/juce_Result.h"
  229. #include "misc/juce_Uuid.h"
  230. #include "misc/juce_ConsoleApplication.h"
  231. #include "containers/juce_Variant.h"
  232. #include "containers/juce_NamedValueSet.h"
  233. #include "containers/juce_DynamicObject.h"
  234. #include "containers/juce_HashMap.h"
  235. #include "time/juce_RelativeTime.h"
  236. #include "time/juce_Time.h"
  237. #include "streams/juce_InputStream.h"
  238. #include "streams/juce_OutputStream.h"
  239. #include "streams/juce_BufferedInputStream.h"
  240. #include "streams/juce_MemoryInputStream.h"
  241. #include "streams/juce_MemoryOutputStream.h"
  242. #include "streams/juce_SubregionStream.h"
  243. #include "streams/juce_InputSource.h"
  244. #include "files/juce_File.h"
  245. #include "files/juce_DirectoryIterator.h"
  246. #include "files/juce_FileInputStream.h"
  247. #include "files/juce_FileOutputStream.h"
  248. #include "files/juce_FileSearchPath.h"
  249. #include "files/juce_MemoryMappedFile.h"
  250. #include "files/juce_TemporaryFile.h"
  251. #include "files/juce_FileFilter.h"
  252. #include "files/juce_WildcardFileFilter.h"
  253. #include "streams/juce_FileInputSource.h"
  254. #include "logging/juce_FileLogger.h"
  255. #include "javascript/juce_JSON.h"
  256. #include "javascript/juce_Javascript.h"
  257. #include "maths/juce_BigInteger.h"
  258. #include "maths/juce_Expression.h"
  259. #include "maths/juce_Random.h"
  260. #include "misc/juce_RuntimePermissions.h"
  261. #include "misc/juce_WindowsRegistry.h"
  262. #include "threads/juce_ChildProcess.h"
  263. #include "threads/juce_DynamicLibrary.h"
  264. #include "threads/juce_HighResolutionTimer.h"
  265. #include "threads/juce_InterProcessLock.h"
  266. #include "threads/juce_Process.h"
  267. #include "threads/juce_SpinLock.h"
  268. #include "threads/juce_WaitableEvent.h"
  269. #include "threads/juce_Thread.h"
  270. #include "threads/juce_ThreadLocalValue.h"
  271. #include "threads/juce_ThreadPool.h"
  272. #include "threads/juce_TimeSliceThread.h"
  273. #include "threads/juce_ReadWriteLock.h"
  274. #include "threads/juce_ScopedReadLock.h"
  275. #include "threads/juce_ScopedWriteLock.h"
  276. #include "network/juce_IPAddress.h"
  277. #include "network/juce_MACAddress.h"
  278. #include "network/juce_NamedPipe.h"
  279. #include "network/juce_Socket.h"
  280. #include "network/juce_URL.h"
  281. #include "network/juce_WebInputStream.h"
  282. #include "streams/juce_URLInputSource.h"
  283. #include "time/juce_PerformanceCounter.h"
  284. #include "unit_tests/juce_UnitTest.h"
  285. #include "xml/juce_XmlDocument.h"
  286. #include "xml/juce_XmlElement.h"
  287. #include "zip/juce_GZIPCompressorOutputStream.h"
  288. #include "zip/juce_GZIPDecompressorInputStream.h"
  289. #include "zip/juce_ZipFile.h"
  290. #include "containers/juce_PropertySet.h"
  291. #include "memory/juce_SharedResourcePointer.h"
  292. #if JUCE_CORE_INCLUDE_OBJC_HELPERS && (JUCE_MAC || JUCE_IOS)
  293. #include "native/juce_osx_ObjCHelpers.h"
  294. #endif
  295. #if JUCE_CORE_INCLUDE_COM_SMART_PTR && JUCE_WINDOWS
  296. #include "native/juce_win32_ComSmartPtr.h"
  297. #endif
  298. #if JUCE_CORE_INCLUDE_JNI_HELPERS && JUCE_ANDROID
  299. #include <jni.h>
  300. #include "native/juce_android_JNIHelpers.h"
  301. #endif
  302. #ifndef DOXYGEN
  303. namespace juce
  304. {
  305. /*
  306. As the very long class names here try to explain, the purpose of this code is to cause
  307. a linker error if not all of your compile units are consistent in the options that they
  308. enable before including JUCE headers. The reason this is important is that if you have
  309. two cpp files, and one includes the juce headers with debug enabled, and another does so
  310. without that, then each will be generating code with different class layouts, and you'll
  311. get subtle and hard-to-track-down memory corruption!
  312. */
  313. #if JUCE_DEBUG
  314. struct JUCE_API this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_debug_mode
  315. { this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_debug_mode() noexcept; };
  316. static this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_debug_mode compileUnitMismatchSentinel;
  317. #else
  318. struct JUCE_API this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_release_mode
  319. { this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_release_mode() noexcept; };
  320. static this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_release_mode compileUnitMismatchSentinel;
  321. #endif
  322. }
  323. #endif
  324. #if JUCE_MSVC
  325. #pragma warning (pop)
  326. // In DLL builds, need to disable this warnings for other modules
  327. #if defined (JUCE_DLL_BUILD) || defined (JUCE_DLL)
  328. #pragma warning (disable: 4251)
  329. #endif
  330. #endif