1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-08 04:20:09 +00:00

Removed the (rather pointless) granularity value from the array objects. Converted a few macros into functions and other misc code clean-ups.

This commit is contained in:
Julian Storer 2010-01-13 18:58:40 +00:00
parent c368805559
commit 97035bb3a1
69 changed files with 218 additions and 369 deletions

View file

@ -193,7 +193,7 @@ inline void swapVariables (Type& variable1, Type& variable2)
variable2 = tempVal;
}
/** Handy macro for getting the number of elements in a simple const C array.
/** Handy function for getting the number of elements in a simple const C array.
E.g.
@code
@ -202,7 +202,8 @@ inline void swapVariables (Type& variable1, Type& variable2)
int numElements = numElementsInArray (myArray) // returns 3
@endcode
*/
#define numElementsInArray(a) ((int) (sizeof (a) / sizeof ((a)[0])))
template <typename Type>
inline int numElementsInArray (Type& array) { return (int) (sizeof (array) / sizeof (array[0])); }
//==============================================================================
// Some useful maths functions that aren't always present with all compilers and build settings.

View file

@ -200,15 +200,17 @@
//==============================================================================
/** Clears a block of memory. */
#define zeromem(memory, numBytes) memset (memory, 0, numBytes)
inline void zeromem (void* memory, int numBytes) { memset (memory, 0, numBytes); }
/** Clears a reference to a local structure. */
#define zerostruct(structure) memset (&structure, 0, sizeof (structure))
template <typename Type>
inline void zerostruct (Type& structure) { memset (&structure, 0, sizeof (structure)); }
/** A handy macro that calls delete on a pointer if it's non-zero, and
then sets the pointer to null.
/** A handy function that calls delete on a pointer if it's non-zero, and then sets
the pointer to null.
*/
#define deleteAndZero(pointer) { delete (pointer); (pointer) = 0; }
template <typename Type>
inline void deleteAndZero (Type& pointer) { delete pointer; pointer = 0; }

View file

@ -203,20 +203,12 @@
forcedinline void myfunction (int x)
@endcode
*/
#ifdef JUCE_DEBUG
#ifndef 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.
@ -230,14 +222,6 @@
#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__

View file

@ -60,6 +60,11 @@ void JUCE_PUBLIC_FUNCTION initialiseJuce_NonGUI()
#ifdef JUCE_DEBUG
{
char a1[7];
jassert (numElementsInArray(a1) == 7);
int a2[3];
jassert (numElementsInArray(a2) == 3);
// Some simple test code to keep an eye on things and make sure these functions
// work ok on all platforms. Let me know if any of these assertions fail!
int n = 1;

View file

@ -70,10 +70,10 @@
#ifdef _DEBUG
#define JUCE_DEBUG 1
#endif
#ifdef __MINGW32__
#define JUCE_MINGW 1
#endif
#ifdef __MINGW32__
#define JUCE_MINGW 1
#endif
/** If defined, this indicates that the processor is little-endian. */
#define JUCE_LITTLE_ENDIAN 1