From 6aceb165daa9e861c3d2f50cb1c5c348ca67939e Mon Sep 17 00:00:00 2001 From: jules Date: Fri, 18 Apr 2008 10:22:34 +0000 Subject: [PATCH] --- .../juce_win32_Threads.cpp | 2 +- .../audio/dsp/juce_AudioSampleBuffer.cpp | 1 + .../gui/components/controls/juce_Slider.cpp | 15 +- .../gui/components/controls/juce_Slider.h | 13 +- .../windows/juce_ResizableWindow.cpp | 12 +- src/juce_core/basics/juce_Logger.cpp | 2 +- src/juce_core/basics/juce_PlatformDefs.h | 718 +++++++++--------- src/juce_core/basics/juce_StandardHeader.h | 4 +- 8 files changed, 396 insertions(+), 371 deletions(-) diff --git a/build/win32/platform_specific_code/juce_win32_Threads.cpp b/build/win32/platform_specific_code/juce_win32_Threads.cpp index 51661c0f5a..529295e489 100644 --- a/build/win32/platform_specific_code/juce_win32_Threads.cpp +++ b/build/win32/platform_specific_code/juce_win32_Threads.cpp @@ -299,7 +299,7 @@ void Process::setPriority (ProcessPriority prior) } } -bool JUCE_CALLTYPE juce_isRunningUnderDebugger() throw() +bool JUCE_API JUCE_CALLTYPE juce_isRunningUnderDebugger() throw() { return IsDebuggerPresent() != FALSE; } diff --git a/src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.cpp b/src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.cpp index 8bc05d8420..41bf1fc3ee 100644 --- a/src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.cpp +++ b/src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.cpp @@ -530,6 +530,7 @@ void AudioSampleBuffer::readFromAudioReader (AudioFormatReader* reader, const bool useLeftChan, const bool useRightChan) throw() { + jassert (reader != 0); jassert (startSample >= 0 && startSample + numSamples <= size); if (numSamples > 0) diff --git a/src/juce_appframework/gui/components/controls/juce_Slider.cpp b/src/juce_appframework/gui/components/controls/juce_Slider.cpp index 2346435ba3..09a507a8fb 100644 --- a/src/juce_appframework/gui/components/controls/juce_Slider.cpp +++ b/src/juce_appframework/gui/components/controls/juce_Slider.cpp @@ -130,6 +130,7 @@ Slider::Slider (const String& name) menuEnabled (false), menuShown (false), scrollWheelEnabled (true), + snapsToMousePos (true), valueBox (0), incButton (0), decButton (0), @@ -315,6 +316,11 @@ void Slider::setChangeNotificationOnlyOnRelease (const bool onlyNotifyOnRelease) sendChangeOnlyOnRelease = onlyNotifyOnRelease; } +void Slider::setSliderSnapsToMousePosition (const bool shouldSnapToMouse) throw() +{ + snapsToMousePos = shouldSnapToMouse; +} + void Slider::setPopupDisplayEnabled (const bool enabled, Component* const parentComponentToUse) throw() { @@ -1200,10 +1206,15 @@ void Slider::mouseDrag (const MouseEvent& e) double scaledMousePos = (mousePos - sliderRegionStart) / (double) sliderRegionSize; - if (style == RotaryHorizontalDrag || style == RotaryVerticalDrag - || style == IncDecButtons) + if (style == RotaryHorizontalDrag + || style == RotaryVerticalDrag + || style == IncDecButtons + || ((style == LinearHorizontal || style == LinearVertical || style == LinearBar) + && ! snapsToMousePos)) { const int mouseDiff = (style == RotaryHorizontalDrag + || style == LinearHorizontal + || style == LinearBar || (style == IncDecButtons && incDecDragDirectionIsHorizontal())) ? e.getDistanceFromDragStartX() : -e.getDistanceFromDragStartY(); diff --git a/src/juce_appframework/gui/components/controls/juce_Slider.h b/src/juce_appframework/gui/components/controls/juce_Slider.h index fce29c762b..e3d37e6e88 100644 --- a/src/juce_appframework/gui/components/controls/juce_Slider.h +++ b/src/juce_appframework/gui/components/controls/juce_Slider.h @@ -457,6 +457,17 @@ public: */ void setChangeNotificationOnlyOnRelease (const bool onlyNotifyOnRelease) throw(); + /** This lets you change whether the slider thumb jumps to the mouse position + when you click. + + By default, this is true. If it's false, then the slider moves with relative + motion when you drag it. + + This only applies to linear bars, and won't affect two- or three- value + sliders. + */ + void setSliderSnapsToMousePosition (const bool shouldSnapToMouse) throw(); + /** If enabled, this gives the slider a pop-up bubble which appears while the slider is being dragged. @@ -697,7 +708,7 @@ private: bool isVelocityBased : 1, userKeyOverridesVelocity : 1, rotaryStop : 1; bool incDecButtonsSideBySide : 1, sendChangeOnlyOnRelease : 1, popupDisplayEnabled : 1; bool menuEnabled : 1, menuShown : 1, mouseWasHidden : 1, incDecDragged : 1; - bool scrollWheelEnabled : 1; + bool scrollWheelEnabled : 1, snapsToMousePos : 1; Font font; Label* valueBox; Button* incButton; diff --git a/src/juce_appframework/gui/components/windows/juce_ResizableWindow.cpp b/src/juce_appframework/gui/components/windows/juce_ResizableWindow.cpp index 9569e9bd2a..a33adc39f6 100644 --- a/src/juce_appframework/gui/components/windows/juce_ResizableWindow.cpp +++ b/src/juce_appframework/gui/components/windows/juce_ResizableWindow.cpp @@ -463,14 +463,18 @@ bool ResizableWindow::restoreWindowStateFromString (const String& s) if (tokens.size() != 4 + n) return false; - const Rectangle r (tokens[n].getIntValue(), - tokens[n + 1].getIntValue(), - tokens[n + 2].getIntValue(), - tokens[n + 3].getIntValue()); + Rectangle r (tokens[n].getIntValue(), + tokens[n + 1].getIntValue(), + tokens[n + 2].getIntValue(), + tokens[n + 3].getIntValue()); if (r.isEmpty()) return false; + const Rectangle screen (Desktop::getInstance().getMonitorAreaContaining (r.getX(), r.getY())); + + r = r.getIntersection (screen); + lastNonFullScreenPos = r; if (isOnDesktop()) diff --git a/src/juce_core/basics/juce_Logger.cpp b/src/juce_core/basics/juce_Logger.cpp index 9bd1b4f8d0..6a2ac3d318 100644 --- a/src/juce_core/basics/juce_Logger.cpp +++ b/src/juce_core/basics/juce_Logger.cpp @@ -67,7 +67,7 @@ void Logger::writeToLog (const String& message) } #if JUCE_LOG_ASSERTIONS -void juce_LogAssertion (const char* filename, const int lineNum) throw() +void JUCE_API juce_LogAssertion (const char* filename, const int lineNum) throw() { String m ("JUCE Assertion failure in "); m << filename << ", line " << lineNum; diff --git a/src/juce_core/basics/juce_PlatformDefs.h b/src/juce_core/basics/juce_PlatformDefs.h index 495dffd569..5162585305 100644 --- a/src/juce_core/basics/juce_PlatformDefs.h +++ b/src/juce_core/basics/juce_PlatformDefs.h @@ -1,361 +1,357 @@ -/* - ============================================================================== - - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-7 by Raw Material Software ltd. - - ------------------------------------------------------------------------------ - - JUCE can be redistributed and/or modified under the terms of the - GNU General Public License, as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later version. - - JUCE is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with JUCE; if not, visit www.gnu.org/licenses or write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - ------------------------------------------------------------------------------ - - If you'd like to release a closed-source product which uses JUCE, commercial - licenses are also available: visit www.rawmaterialsoftware.com/juce for - more information. - - ============================================================================== -*/ - -#ifndef __JUCE_PLATFORMDEFS_JUCEHEADER__ -#define __JUCE_PLATFORMDEFS_JUCEHEADER__ - -//============================================================================== -/* This file figures out which platform is being built, and defines some macros - that the rest of the code can use for OS-specific compilation. - - Macros that will be set here are: - - - One of JUCE_WIN32, JUCE_MAC or JUCE_LINUX. - - Either JUCE_32BIT or JUCE_64BIT, depending on the architecture. - - Either JUCE_LITTLE_ENDIAN or JUCE_BIG_ENDIAN. - - Either JUCE_INTEL or JUCE_PPC - - Either JUCE_GCC or JUCE_MSVC - - On the Mac, it also defines MACOS_10_2_OR_EARLIER if the build is targeting OSX10.2, - and MACOS_10_3_OR_EARLIER if it is targeting either 10.2 or 10.3 - - It also includes a set of macros for debug console output and assertions. - -*/ - -//============================================================================== -#if (defined (_WIN32) || defined (_WIN64)) - #define JUCE_WIN32 1 -#else - #ifdef LINUX - #define JUCE_LINUX 1 - #else - #define JUCE_MAC 1 - #endif -#endif - -//============================================================================== -#if JUCE_WIN32 - #ifdef _MSC_VER - #ifdef _WIN64 - #define JUCE_64BIT 1 - #else - #define JUCE_32BIT 1 - #endif - #endif - - #ifdef _DEBUG - #define JUCE_DEBUG 1 - #endif - - /** If defined, this indicates that the processor is little-endian. */ - #define JUCE_LITTLE_ENDIAN 1 - - #define JUCE_INTEL 1 -#endif - -//============================================================================== -#if JUCE_MAC - - #include - - #ifndef NDEBUG - #define JUCE_DEBUG 1 - #endif - - #ifdef __LITTLE_ENDIAN__ - #define JUCE_LITTLE_ENDIAN 1 - #else - #define JUCE_BIG_ENDIAN 1 - #endif - - #if defined (__ppc__) || defined (__ppc64__) - #define JUCE_PPC 1 - #else - #define JUCE_INTEL 1 - #endif - - #ifdef __LP64__ - #define JUCE_64BIT 1 - #else - #define JUCE_32BIT 1 - #endif - - #if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3) - #define MACOS_10_2_OR_EARLIER 1 - #endif - - #if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4) - #define MACOS_10_3_OR_EARLIER 1 - #endif -#endif - -//============================================================================== -#if JUCE_LINUX - - #ifdef _DEBUG - #define JUCE_DEBUG 1 - #endif - - // Allow override for big-endian Linux platforms - #ifndef JUCE_BIG_ENDIAN - #define JUCE_LITTLE_ENDIAN 1 - #endif - - #if defined (__LP64__) || defined (_LP64) - #define JUCE_64BIT 1 - #else - #define JUCE_32BIT 1 - #endif - - #define JUCE_INTEL 1 -#endif - - -//============================================================================== -// Compiler type macros. - -#ifdef __GNUC__ - #define JUCE_GCC 1 -#elif defined (_MSC_VER) - #define JUCE_MSVC 1 - - #if _MSC_VER >= 1400 - #define JUCE_USE_INTRINSICS 1 - #endif -#else - #error unknown compiler -#endif - -/** This macro defines the C calling convention used as the standard for Juce calls. */ -#if JUCE_MSVC - #define JUCE_CALLTYPE __stdcall -#else - #define JUCE_CALLTYPE -#endif - -//============================================================================== -// Debugging and assertion macros - -// (For info about JUCE_LOG_ASSERTIONS, have a look in juce_Config.h) -#if JUCE_LOG_ASSERTIONS - #define juce_LogCurrentAssertion juce_LogAssertion (__FILE__, __LINE__); -#elif defined (JUCE_DEBUG) - #define juce_LogCurrentAssertion fprintf (stderr, "JUCE Assertion failure in %s, line %d\n", __FILE__, __LINE__); -#else - #define juce_LogCurrentAssertion -#endif - -#ifdef JUCE_DEBUG - //============================================================================== - // If debugging is enabled.. - - /** Writes a string to the standard error stream. - - This is only compiled in a debug build. - - @see Logger::outputDebugString - */ - #define DBG(dbgtext) Logger::outputDebugString (dbgtext); - - /** Printf's a string to the standard error stream. - - This is only compiled in a debug build. - - @see Logger::outputDebugString - */ - #define DBG_PRINTF(dbgprintf) Logger::outputDebugPrintf dbgprintf; - - //============================================================================== - // Assertions.. - - BEGIN_JUCE_NAMESPACE - extern bool JUCE_CALLTYPE juce_isRunningUnderDebugger() throw(); - END_JUCE_NAMESPACE - - #if JUCE_WIN32 || DOXYGEN - - #if JUCE_USE_INTRINSICS - #pragma intrinsic (__debugbreak) - - /** This will try to break the debugger if one is currently hosting this app. - @see jassert() - */ - #define juce_breakDebugger __debugbreak(); - - #elif JUCE_GCC - /** This will try to break the debugger if one is currently hosting this app. - @see jassert() - */ - #define juce_breakDebugger asm("int $3"); - #else - /** This will try to break the debugger if one is currently hosting this app. - @see jassert() - */ - #define juce_breakDebugger { __asm int 3 } - #endif - #elif JUCE_MAC - #define juce_breakDebugger Debugger(); - #elif JUCE_LINUX - #define juce_breakDebugger kill (0, SIGTRAP); - #endif - - //============================================================================== - /** This will always cause an assertion failure. - - It is only compiled in a debug build, (unless JUCE_LOG_ASSERTIONS is enabled - in juce_Config.h). - - @see jassert() - */ - #define jassertfalse { juce_LogCurrentAssertion; if (JUCE_NAMESPACE::juce_isRunningUnderDebugger()) juce_breakDebugger; } - - //============================================================================== - /** Platform-independent assertion macro. - - This gets optimised out when not being built with debugging turned on. - - Be careful not to call any functions within its arguments that are vital to - the behaviour of the program, because these won't get called in the release - build. - - @see jassertfalse - */ - #define jassert(expression) { if (! (expression)) jassertfalse } - -#else - //============================================================================== - // If debugging is disabled, these dummy debug and assertion macros are used.. - - #define DBG(dbgtext) - #define DBG_PRINTF(dbgprintf) - - #define jassertfalse { juce_LogCurrentAssertion } - - #if JUCE_LOG_ASSERTIONS - #define jassert(expression) { if (! (expression)) jassertfalse } - #else - #define jassert(a) { } - #endif - -#endif - -//============================================================================== -#ifndef DOXYGEN - template struct JuceStaticAssert; - template <> struct JuceStaticAssert { static void dummy() {} }; -#endif - -/** A compile-time assertion macro. - - If the expression parameter is false, the macro will cause a compile error. -*/ -#define static_jassert(expression) JuceStaticAssert::dummy(); - - -//============================================================================== -#if JUCE_CATCH_UNHANDLED_EXCEPTIONS - - #define JUCE_TRY try - - /** Used in try-catch blocks, this macro will send exceptions to the JUCEApplication - object so they can be logged by the application if it wants to. - */ - #define JUCE_CATCH_EXCEPTION \ - catch (const std::exception& e) \ - { \ - JUCEApplication::sendUnhandledException (&e, __FILE__, __LINE__); \ - } \ - catch (...) \ - { \ - JUCEApplication::sendUnhandledException (0, __FILE__, __LINE__); \ - } - - #define JUCE_CATCH_ALL catch (...) {} - #define JUCE_CATCH_ALL_ASSERT catch (...) { jassertfalse } - -#else - - #define JUCE_TRY - #define JUCE_CATCH_EXCEPTION - #define JUCE_CATCH_ALL - #define JUCE_CATCH_ALL_ASSERT - -#endif - -//============================================================================== -// Macros for inlining. - -#if JUCE_MSVC - /** A platform-independent way of forcing an inline function. - - Use the syntax: @code - forcedinline void myfunction (int x) - @endcode - */ - #ifdef JUCE_DEBUG - #define forcedinline __forceinline - #else - #define forcedinline inline - #endif - - /** A platform-independent way of stopping the compiler inlining a function. - - Use the syntax: @code - juce_noinline void myfunction (int x) - @endcode - */ - #define juce_noinline - -#else - /** A platform-independent way of forcing an inline function. - - Use the syntax: @code - forcedinline void myfunction (int x) - @endcode - */ - #ifndef JUCE_DEBUG - #define forcedinline inline __attribute__((always_inline)) - #else - #define forcedinline inline - #endif - - /** A platform-independent way of stopping the compiler inlining a function. - - Use the syntax: @code - juce_noinline void myfunction (int x) - @endcode - */ - #define juce_noinline __attribute__((noinline)) - -#endif - -#endif // __JUCE_PLATFORMDEFS_JUCEHEADER__ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-7 by Raw Material Software ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the + GNU General Public License, as published by the Free Software Foundation; + either version 2 of the License, or (at your option) any later version. + + JUCE is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with JUCE; if not, visit www.gnu.org/licenses or write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + ------------------------------------------------------------------------------ + + If you'd like to release a closed-source product which uses JUCE, commercial + licenses are also available: visit www.rawmaterialsoftware.com/juce for + more information. + + ============================================================================== +*/ + +#ifndef __JUCE_PLATFORMDEFS_JUCEHEADER__ +#define __JUCE_PLATFORMDEFS_JUCEHEADER__ + +//============================================================================== +/* This file figures out which platform is being built, and defines some macros + that the rest of the code can use for OS-specific compilation. + + Macros that will be set here are: + + - One of JUCE_WIN32, JUCE_MAC or JUCE_LINUX. + - Either JUCE_32BIT or JUCE_64BIT, depending on the architecture. + - Either JUCE_LITTLE_ENDIAN or JUCE_BIG_ENDIAN. + - Either JUCE_INTEL or JUCE_PPC + - Either JUCE_GCC or JUCE_MSVC + + On the Mac, it also defines MACOS_10_2_OR_EARLIER if the build is targeting OSX10.2, + and MACOS_10_3_OR_EARLIER if it is targeting either 10.2 or 10.3 + + It also includes a set of macros for debug console output and assertions. + +*/ + +//============================================================================== +#if (defined (_WIN32) || defined (_WIN64)) + #define JUCE_WIN32 1 +#else + #ifdef LINUX + #define JUCE_LINUX 1 + #else + #define JUCE_MAC 1 + #endif +#endif + +//============================================================================== +#if JUCE_WIN32 + #ifdef _MSC_VER + #ifdef _WIN64 + #define JUCE_64BIT 1 + #else + #define JUCE_32BIT 1 + #endif + #endif + + #ifdef _DEBUG + #define JUCE_DEBUG 1 + #endif + + /** If defined, this indicates that the processor is little-endian. */ + #define JUCE_LITTLE_ENDIAN 1 + + #define JUCE_INTEL 1 +#endif + +//============================================================================== +#if JUCE_MAC + + #include + + #ifndef NDEBUG + #define JUCE_DEBUG 1 + #endif + + #ifdef __LITTLE_ENDIAN__ + #define JUCE_LITTLE_ENDIAN 1 + #else + #define JUCE_BIG_ENDIAN 1 + #endif + + #if defined (__ppc__) || defined (__ppc64__) + #define JUCE_PPC 1 + #else + #define JUCE_INTEL 1 + #endif + + #ifdef __LP64__ + #define JUCE_64BIT 1 + #else + #define JUCE_32BIT 1 + #endif + + #if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3) + #define MACOS_10_2_OR_EARLIER 1 + #endif + + #if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4) + #define MACOS_10_3_OR_EARLIER 1 + #endif +#endif + +//============================================================================== +#if JUCE_LINUX + + #ifdef _DEBUG + #define JUCE_DEBUG 1 + #endif + + // Allow override for big-endian Linux platforms + #ifndef JUCE_BIG_ENDIAN + #define JUCE_LITTLE_ENDIAN 1 + #endif + + #if defined (__LP64__) || defined (_LP64) + #define JUCE_64BIT 1 + #else + #define JUCE_32BIT 1 + #endif + + #define JUCE_INTEL 1 +#endif + + +//============================================================================== +// Compiler type macros. + +#ifdef __GNUC__ + #define JUCE_GCC 1 +#elif defined (_MSC_VER) + #define JUCE_MSVC 1 + + #if _MSC_VER >= 1400 + #define JUCE_USE_INTRINSICS 1 + #endif +#else + #error unknown compiler +#endif + +/** This macro defines the C calling convention used as the standard for Juce calls. */ +#if JUCE_MSVC + #define JUCE_CALLTYPE __stdcall +#else + #define JUCE_CALLTYPE +#endif + +//============================================================================== +// Debugging and assertion macros + +// (For info about JUCE_LOG_ASSERTIONS, have a look in juce_Config.h) +#if JUCE_LOG_ASSERTIONS + #define juce_LogCurrentAssertion juce_LogAssertion (__FILE__, __LINE__); +#elif defined (JUCE_DEBUG) + #define juce_LogCurrentAssertion fprintf (stderr, "JUCE Assertion failure in %s, line %d\n", __FILE__, __LINE__); +#else + #define juce_LogCurrentAssertion +#endif + +#ifdef JUCE_DEBUG + //============================================================================== + // If debugging is enabled.. + + /** Writes a string to the standard error stream. + + This is only compiled in a debug build. + + @see Logger::outputDebugString + */ + #define DBG(dbgtext) Logger::outputDebugString (dbgtext); + + /** Printf's a string to the standard error stream. + + This is only compiled in a debug build. + + @see Logger::outputDebugString + */ + #define DBG_PRINTF(dbgprintf) Logger::outputDebugPrintf dbgprintf; + + //============================================================================== + // Assertions.. + + #if JUCE_WIN32 || DOXYGEN + + #if JUCE_USE_INTRINSICS + #pragma intrinsic (__debugbreak) + + /** This will try to break the debugger if one is currently hosting this app. + @see jassert() + */ + #define juce_breakDebugger __debugbreak(); + + #elif JUCE_GCC + /** This will try to break the debugger if one is currently hosting this app. + @see jassert() + */ + #define juce_breakDebugger asm("int $3"); + #else + /** This will try to break the debugger if one is currently hosting this app. + @see jassert() + */ + #define juce_breakDebugger { __asm int 3 } + #endif + #elif JUCE_MAC + #define juce_breakDebugger Debugger(); + #elif JUCE_LINUX + #define juce_breakDebugger kill (0, SIGTRAP); + #endif + + //============================================================================== + /** This will always cause an assertion failure. + + It is only compiled in a debug build, (unless JUCE_LOG_ASSERTIONS is enabled + in juce_Config.h). + + @see jassert() + */ + #define jassertfalse { juce_LogCurrentAssertion; if (JUCE_NAMESPACE::juce_isRunningUnderDebugger()) juce_breakDebugger; } + + //============================================================================== + /** Platform-independent assertion macro. + + This gets optimised out when not being built with debugging turned on. + + Be careful not to call any functions within its arguments that are vital to + the behaviour of the program, because these won't get called in the release + build. + + @see jassertfalse + */ + #define jassert(expression) { if (! (expression)) jassertfalse } + +#else + //============================================================================== + // If debugging is disabled, these dummy debug and assertion macros are used.. + + #define DBG(dbgtext) + #define DBG_PRINTF(dbgprintf) + + #define jassertfalse { juce_LogCurrentAssertion } + + #if JUCE_LOG_ASSERTIONS + #define jassert(expression) { if (! (expression)) jassertfalse } + #else + #define jassert(a) { } + #endif + +#endif + +//============================================================================== +#ifndef DOXYGEN + template struct JuceStaticAssert; + template <> struct JuceStaticAssert { static void dummy() {} }; +#endif + +/** A compile-time assertion macro. + + If the expression parameter is false, the macro will cause a compile error. +*/ +#define static_jassert(expression) JuceStaticAssert::dummy(); + + +//============================================================================== +#if JUCE_CATCH_UNHANDLED_EXCEPTIONS + + #define JUCE_TRY try + + /** Used in try-catch blocks, this macro will send exceptions to the JUCEApplication + object so they can be logged by the application if it wants to. + */ + #define JUCE_CATCH_EXCEPTION \ + catch (const std::exception& e) \ + { \ + JUCEApplication::sendUnhandledException (&e, __FILE__, __LINE__); \ + } \ + catch (...) \ + { \ + JUCEApplication::sendUnhandledException (0, __FILE__, __LINE__); \ + } + + #define JUCE_CATCH_ALL catch (...) {} + #define JUCE_CATCH_ALL_ASSERT catch (...) { jassertfalse } + +#else + + #define JUCE_TRY + #define JUCE_CATCH_EXCEPTION + #define JUCE_CATCH_ALL + #define JUCE_CATCH_ALL_ASSERT + +#endif + +//============================================================================== +// Macros for inlining. + +#if JUCE_MSVC + /** A platform-independent way of forcing an inline function. + + Use the syntax: @code + forcedinline void myfunction (int x) + @endcode + */ + #ifdef JUCE_DEBUG + #define forcedinline __forceinline + #else + #define forcedinline inline + #endif + + /** A platform-independent way of stopping the compiler inlining a function. + + Use the syntax: @code + juce_noinline void myfunction (int x) + @endcode + */ + #define juce_noinline + +#else + /** A platform-independent way of forcing an inline function. + + Use the syntax: @code + forcedinline void myfunction (int x) + @endcode + */ + #ifndef JUCE_DEBUG + #define forcedinline inline __attribute__((always_inline)) + #else + #define forcedinline inline + #endif + + /** A platform-independent way of stopping the compiler inlining a function. + + Use the syntax: @code + juce_noinline void myfunction (int x) + @endcode + */ + #define juce_noinline __attribute__((noinline)) + +#endif + +#endif // __JUCE_PLATFORMDEFS_JUCEHEADER__ diff --git a/src/juce_core/basics/juce_StandardHeader.h b/src/juce_core/basics/juce_StandardHeader.h index 6e4e9bab7d..9a13128764 100644 --- a/src/juce_core/basics/juce_StandardHeader.h +++ b/src/juce_core/basics/juce_StandardHeader.h @@ -130,8 +130,10 @@ // Now include some basics that are needed by most of the Juce classes... BEGIN_JUCE_NAMESPACE +extern bool JUCE_API JUCE_CALLTYPE juce_isRunningUnderDebugger() throw(); + #if JUCE_LOG_ASSERTIONS - extern void juce_LogAssertion (const char* filename, const int lineNum) throw(); + extern void JUCE_API juce_LogAssertion (const char* filename, const int lineNum) throw(); #endif #include "juce_Memory.h"