| @@ -61,7 +61,7 @@ ifeq ($(MACOS),true) | |||||
| # No C++11 support; force 32bit per default | # No C++11 support; force 32bit per default | ||||
| BUILD_C_FLAGS = $(BASE_FLAGS) $(32BIT_FLAGS) -std=gnu99 $(CFLAGS) | BUILD_C_FLAGS = $(BASE_FLAGS) $(32BIT_FLAGS) -std=gnu99 $(CFLAGS) | ||||
| BUILD_CXX_FLAGS = $(BASE_FLAGS) $(32BIT_FLAGS) $(CXXFLAGS) | BUILD_CXX_FLAGS = $(BASE_FLAGS) $(32BIT_FLAGS) $(CXXFLAGS) | ||||
| LINK_FLAGS = $(LDFLAGS) | |||||
| LINK_FLAGS = $(32BIT_FLAGS) $(LDFLAGS) | |||||
| endif | endif | ||||
| # -------------------------------------------------------------- | # -------------------------------------------------------------- | ||||
| @@ -37,6 +37,10 @@ POSIX_32BIT_FLAGS = $(32BIT_FLAGS) -L/usr/lib32 -L/usr/lib/i386-linux-gnu | |||||
| POSIX_64BIT_FLAGS = $(64BIT_FLAGS) -L/usr/lib64 -L/usr/lib/x86_64-linux-gnu | POSIX_64BIT_FLAGS = $(64BIT_FLAGS) -L/usr/lib64 -L/usr/lib/x86_64-linux-gnu | ||||
| POSIX_LINK_FLAGS = $(LINK_FLAGS) $(EXTRA_LIBS) -ldl -lpthread | POSIX_LINK_FLAGS = $(LINK_FLAGS) $(EXTRA_LIBS) -ldl -lpthread | ||||
| ifeq ($(MACOS),true) | |||||
| POSIX_LINK_FLAGS += -framework Cocoa -framework IOKit | |||||
| endif | |||||
| WIN_BUILD_FLAGS = $(BUILD_CXX_FLAGS) | WIN_BUILD_FLAGS = $(BUILD_CXX_FLAGS) | ||||
| WIN_32BIT_FLAGS = $(32BIT_FLAGS) | WIN_32BIT_FLAGS = $(32BIT_FLAGS) | ||||
| WIN_64BIT_FLAGS = $(64BIT_FLAGS) | WIN_64BIT_FLAGS = $(64BIT_FLAGS) | ||||
| @@ -71,9 +71,9 @@ public: | |||||
| { | { | ||||
| public: | public: | ||||
| template <class SampleFormatType> static inline float getAsFloat (SampleFormatType& s) noexcept { return s.getAsFloatBE(); } | template <class SampleFormatType> static inline float getAsFloat (SampleFormatType& s) noexcept { return s.getAsFloatBE(); } | ||||
| template <class SampleFormatType> static inline void setAsFloat (SampleFormatType& s, float newValue) noexcept { s.setAsFloatBE (newValue); } | |||||
| template <class SampleFormatType> static inline void setAsFloat (SampleFormatType& s, float newValue) noexcept { s.setAsFloatBE (newValue); } | |||||
| template <class SampleFormatType> static inline int32 getAsInt32 (SampleFormatType& s) noexcept { return s.getAsInt32BE(); } | template <class SampleFormatType> static inline int32 getAsInt32 (SampleFormatType& s) noexcept { return s.getAsInt32BE(); } | ||||
| template <class SampleFormatType> static inline void setAsInt32 (SampleFormatType& s, int32 newValue) noexcept { s.setAsInt32BE (newValue); } | |||||
| template <class SampleFormatType> static inline void setAsInt32 (SampleFormatType& s, int32 newValue) noexcept { s.setAsInt32BE (newValue); } | |||||
| template <class SourceType, class DestType> static inline void copyFrom (DestType& dest, SourceType& source) noexcept { dest.copyFromBE (source); } | template <class SourceType, class DestType> static inline void copyFrom (DestType& dest, SourceType& source) noexcept { dest.copyFromBE (source); } | ||||
| enum { isBigEndian = 1 }; | enum { isBigEndian = 1 }; | ||||
| }; | }; | ||||
| @@ -82,9 +82,9 @@ public: | |||||
| { | { | ||||
| public: | public: | ||||
| template <class SampleFormatType> static inline float getAsFloat (SampleFormatType& s) noexcept { return s.getAsFloatLE(); } | template <class SampleFormatType> static inline float getAsFloat (SampleFormatType& s) noexcept { return s.getAsFloatLE(); } | ||||
| template <class SampleFormatType> static inline void setAsFloat (SampleFormatType& s, float newValue) noexcept { s.setAsFloatLE (newValue); } | |||||
| template <class SampleFormatType> static inline void setAsFloat (SampleFormatType& s, float newValue) noexcept { s.setAsFloatLE (newValue); } | |||||
| template <class SampleFormatType> static inline int32 getAsInt32 (SampleFormatType& s) noexcept { return s.getAsInt32LE(); } | template <class SampleFormatType> static inline int32 getAsInt32 (SampleFormatType& s) noexcept { return s.getAsInt32LE(); } | ||||
| template <class SampleFormatType> static inline void setAsInt32 (SampleFormatType& s, int32 newValue) noexcept { s.setAsInt32LE (newValue); } | |||||
| template <class SampleFormatType> static inline void setAsInt32 (SampleFormatType& s, int32 newValue) noexcept { s.setAsInt32LE (newValue); } | |||||
| template <class SourceType, class DestType> static inline void copyFrom (DestType& dest, SourceType& source) noexcept { dest.copyFromLE (source); } | template <class SourceType, class DestType> static inline void copyFrom (DestType& dest, SourceType& source) noexcept { dest.copyFromLE (source); } | ||||
| enum { isBigEndian = 0 }; | enum { isBigEndian = 0 }; | ||||
| }; | }; | ||||
| @@ -205,11 +205,11 @@ public: | |||||
| inline void skip (int numSamples) noexcept { data += numSamples; } | inline void skip (int numSamples) noexcept { data += numSamples; } | ||||
| inline float getAsFloatLE() const noexcept { return (float) ((1.0 / (1.0 + maxValue)) * (int32) ByteOrder::swapIfBigEndian (*data)); } | inline float getAsFloatLE() const noexcept { return (float) ((1.0 / (1.0 + maxValue)) * (int32) ByteOrder::swapIfBigEndian (*data)); } | ||||
| inline float getAsFloatBE() const noexcept { return (float) ((1.0 / (1.0 + maxValue)) * (int32) ByteOrder::swapIfLittleEndian (*data)); } | inline float getAsFloatBE() const noexcept { return (float) ((1.0 / (1.0 + maxValue)) * (int32) ByteOrder::swapIfLittleEndian (*data)); } | ||||
| inline void setAsFloatLE (float newValue) noexcept { *data = ByteOrder::swapIfBigEndian ((uint32) (maxValue * jlimit (-1.0, 1.0, (double) newValue))); } | |||||
| inline void setAsFloatLE (float newValue) noexcept { *data = ByteOrder::swapIfBigEndian ((uint32) (maxValue * jlimit (-1.0, 1.0, (double) newValue))); } | |||||
| inline void setAsFloatBE (float newValue) noexcept { *data = ByteOrder::swapIfLittleEndian ((uint32) (maxValue * jlimit (-1.0, 1.0, (double) newValue))); } | inline void setAsFloatBE (float newValue) noexcept { *data = ByteOrder::swapIfLittleEndian ((uint32) (maxValue * jlimit (-1.0, 1.0, (double) newValue))); } | ||||
| inline int32 getAsInt32LE() const noexcept { return (int32) ByteOrder::swapIfBigEndian (*data); } | |||||
| inline int32 getAsInt32LE() const noexcept { return (int32) ByteOrder::swapIfBigEndian (*data); } | |||||
| inline int32 getAsInt32BE() const noexcept { return (int32) ByteOrder::swapIfLittleEndian (*data); } | inline int32 getAsInt32BE() const noexcept { return (int32) ByteOrder::swapIfLittleEndian (*data); } | ||||
| inline void setAsInt32LE (int32 newValue) noexcept { *data = ByteOrder::swapIfBigEndian ((uint32) newValue); } | |||||
| inline void setAsInt32LE (int32 newValue) noexcept { *data = ByteOrder::swapIfBigEndian ((uint32) newValue); } | |||||
| inline void setAsInt32BE (int32 newValue) noexcept { *data = ByteOrder::swapIfLittleEndian ((uint32) newValue); } | inline void setAsInt32BE (int32 newValue) noexcept { *data = ByteOrder::swapIfLittleEndian ((uint32) newValue); } | ||||
| inline void clear() noexcept { *data = 0; } | inline void clear() noexcept { *data = 0; } | ||||
| inline void clearMultiple (int num) noexcept { zeromem (data, (size_t) (num * bytesPerSample)) ;} | inline void clearMultiple (int num) noexcept { zeromem (data, (size_t) (num * bytesPerSample)) ;} | ||||
| @@ -221,6 +221,27 @@ public: | |||||
| enum { bytesPerSample = 4, maxValue = 0x7fffffff, resolution = 1, isFloat = 0 }; | enum { bytesPerSample = 4, maxValue = 0x7fffffff, resolution = 1, isFloat = 0 }; | ||||
| }; | }; | ||||
| /** A 32-bit integer type, of which only the bottom 24 bits are used. */ | |||||
| class Int24in32 : public Int32 | |||||
| { | |||||
| public: | |||||
| inline Int24in32 (void* d) noexcept : Int32 (d) {} | |||||
| inline float getAsFloatLE() const noexcept { return (float) ((1.0 / (1.0 + maxValue)) * (int32) ByteOrder::swapIfBigEndian (*data)); } | |||||
| inline float getAsFloatBE() const noexcept { return (float) ((1.0 / (1.0 + maxValue)) * (int32) ByteOrder::swapIfLittleEndian (*data)); } | |||||
| inline void setAsFloatLE (float newValue) noexcept { *data = ByteOrder::swapIfBigEndian ((uint32) (maxValue * jlimit (-1.0, 1.0, (double) newValue))); } | |||||
| inline void setAsFloatBE (float newValue) noexcept { *data = ByteOrder::swapIfLittleEndian ((uint32) (maxValue * jlimit (-1.0, 1.0, (double) newValue))); } | |||||
| inline int32 getAsInt32LE() const noexcept { return (int32) ByteOrder::swapIfBigEndian (*data) << 8; } | |||||
| inline int32 getAsInt32BE() const noexcept { return (int32) ByteOrder::swapIfLittleEndian (*data) << 8; } | |||||
| inline void setAsInt32LE (int32 newValue) noexcept { *data = ByteOrder::swapIfBigEndian ((uint32) newValue >> 8); } | |||||
| inline void setAsInt32BE (int32 newValue) noexcept { *data = ByteOrder::swapIfLittleEndian ((uint32) newValue >> 8); } | |||||
| template <class SourceType> inline void copyFromLE (SourceType& source) noexcept { setAsInt32LE (source.getAsInt32()); } | |||||
| template <class SourceType> inline void copyFromBE (SourceType& source) noexcept { setAsInt32BE (source.getAsInt32()); } | |||||
| inline void copyFromSameType (Int24in32& source) noexcept { *data = *source.data; } | |||||
| enum { bytesPerSample = 4, maxValue = 0x7fffff, resolution = (1 << 8), isFloat = 0 }; | |||||
| }; | |||||
| class Float32 | class Float32 | ||||
| { | { | ||||
| public: | public: | ||||
| @@ -591,9 +612,7 @@ public: | |||||
| : sourceChannels (numSourceChannels), destChannels (numDestChannels) | : sourceChannels (numSourceChannels), destChannels (numDestChannels) | ||||
| {} | {} | ||||
| ~ConverterInstance() {} | |||||
| void convertSamples (void* dest, const void* source, int numSamples) const | |||||
| void convertSamples (void* dest, const void* source, int numSamples) const override | |||||
| { | { | ||||
| SourceSampleType s (source, sourceChannels); | SourceSampleType s (source, sourceChannels); | ||||
| DestSampleType d (dest, destChannels); | DestSampleType d (dest, destChannels); | ||||
| @@ -601,7 +620,7 @@ public: | |||||
| } | } | ||||
| void convertSamples (void* dest, int destSubChannel, | void convertSamples (void* dest, int destSubChannel, | ||||
| const void* source, int sourceSubChannel, int numSamples) const | |||||
| const void* source, int sourceSubChannel, int numSamples) const override | |||||
| { | { | ||||
| jassert (destSubChannel < destChannels && sourceSubChannel < sourceChannels); | jassert (destSubChannel < destChannels && sourceSubChannel < sourceChannels); | ||||
| @@ -158,8 +158,8 @@ void AudioSampleBuffer::setSize (const int newNumChannels, | |||||
| if (newNumSamples != size || newNumChannels != numChannels) | if (newNumSamples != size || newNumChannels != numChannels) | ||||
| { | { | ||||
| const size_t allocatedSamplesPerChannel = (newNumSamples + 3) & ~3; | |||||
| const size_t channelListSize = ((sizeof (float*) * (size_t) (newNumChannels + 1)) + 15) & ~15; | |||||
| const size_t allocatedSamplesPerChannel = ((size_t) newNumSamples + 3) & ~3u; | |||||
| const size_t channelListSize = ((sizeof (float*) * (size_t) (newNumChannels + 1)) + 15) & ~15u; | |||||
| const size_t newTotalBytes = ((size_t) newNumChannels * (size_t) allocatedSamplesPerChannel * sizeof (float)) | const size_t newTotalBytes = ((size_t) newNumChannels * (size_t) allocatedSamplesPerChannel * sizeof (float)) | ||||
| + channelListSize + 32; | + channelListSize + 32; | ||||
| @@ -168,7 +168,7 @@ void AudioSampleBuffer::setSize (const int newNumChannels, | |||||
| HeapBlock <char, true> newData; | HeapBlock <char, true> newData; | ||||
| newData.allocate (newTotalBytes, clearExtraSpace); | newData.allocate (newTotalBytes, clearExtraSpace); | ||||
| const size_t numSamplesToCopy = jmin (newNumSamples, size); | |||||
| const size_t numSamplesToCopy = (size_t) jmin (newNumSamples, size); | |||||
| float** const newChannels = reinterpret_cast <float**> (newData.getData()); | float** const newChannels = reinterpret_cast <float**> (newData.getData()); | ||||
| float* newChan = reinterpret_cast <float*> (newData + channelListSize); | float* newChan = reinterpret_cast <float*> (newData + channelListSize); | ||||
| @@ -162,7 +162,7 @@ namespace FloatVectorHelpers | |||||
| void JUCE_CALLTYPE FloatVectorOperations::clear (float* dest, int num) noexcept | void JUCE_CALLTYPE FloatVectorOperations::clear (float* dest, int num) noexcept | ||||
| { | { | ||||
| #if JUCE_USE_VDSP_FRAMEWORK | #if JUCE_USE_VDSP_FRAMEWORK | ||||
| vDSP_vclr (dest, 1, num); | |||||
| vDSP_vclr (dest, 1, (size_t) num); | |||||
| #else | #else | ||||
| zeromem (dest, num * sizeof (float)); | zeromem (dest, num * sizeof (float)); | ||||
| #endif | #endif | ||||
| @@ -171,7 +171,7 @@ void JUCE_CALLTYPE FloatVectorOperations::clear (float* dest, int num) noexcept | |||||
| void JUCE_CALLTYPE FloatVectorOperations::fill (float* dest, float valueToFill, int num) noexcept | void JUCE_CALLTYPE FloatVectorOperations::fill (float* dest, float valueToFill, int num) noexcept | ||||
| { | { | ||||
| #if JUCE_USE_VDSP_FRAMEWORK | #if JUCE_USE_VDSP_FRAMEWORK | ||||
| vDSP_vfill (&valueToFill, dest, 1, num); | |||||
| vDSP_vfill (&valueToFill, dest, 1, (size_t) num); | |||||
| #else | #else | ||||
| #if JUCE_USE_SSE_INTRINSICS | #if JUCE_USE_SSE_INTRINSICS | ||||
| const __m128 val = _mm_load1_ps (&valueToFill); | const __m128 val = _mm_load1_ps (&valueToFill); | ||||
| @@ -183,7 +183,7 @@ void JUCE_CALLTYPE FloatVectorOperations::fill (float* dest, float valueToFill, | |||||
| void JUCE_CALLTYPE FloatVectorOperations::copy (float* dest, const float* src, int num) noexcept | void JUCE_CALLTYPE FloatVectorOperations::copy (float* dest, const float* src, int num) noexcept | ||||
| { | { | ||||
| memcpy (dest, src, num * sizeof (float)); | |||||
| memcpy (dest, src, (size_t) num * sizeof (float)); | |||||
| } | } | ||||
| void JUCE_CALLTYPE FloatVectorOperations::copyWithMultiply (float* dest, const float* src, float multiplier, int num) noexcept | void JUCE_CALLTYPE FloatVectorOperations::copyWithMultiply (float* dest, const float* src, float multiplier, int num) noexcept | ||||
| @@ -25,6 +25,7 @@ | |||||
| #ifndef JUCE_DECIBELS_H_INCLUDED | #ifndef JUCE_DECIBELS_H_INCLUDED | ||||
| #define JUCE_DECIBELS_H_INCLUDED | #define JUCE_DECIBELS_H_INCLUDED | ||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| This class contains some helpful static methods for dealing with decibel values. | This class contains some helpful static methods for dealing with decibel values. | ||||
| @@ -31,19 +31,19 @@ | |||||
| //============================================================================== | //============================================================================== | ||||
| IIRCoefficients::IIRCoefficients() noexcept | IIRCoefficients::IIRCoefficients() noexcept | ||||
| { | { | ||||
| zeromem (c, sizeof (c)); | |||||
| zeromem (coefficients, sizeof (coefficients)); | |||||
| } | } | ||||
| IIRCoefficients::~IIRCoefficients() noexcept {} | IIRCoefficients::~IIRCoefficients() noexcept {} | ||||
| IIRCoefficients::IIRCoefficients (const IIRCoefficients& other) noexcept | IIRCoefficients::IIRCoefficients (const IIRCoefficients& other) noexcept | ||||
| { | { | ||||
| memcpy (c, other.c, sizeof (c)); | |||||
| memcpy (coefficients, other.coefficients, sizeof (coefficients)); | |||||
| } | } | ||||
| IIRCoefficients& IIRCoefficients::operator= (const IIRCoefficients& other) noexcept | IIRCoefficients& IIRCoefficients::operator= (const IIRCoefficients& other) noexcept | ||||
| { | { | ||||
| memcpy (c, other.c, sizeof (c)); | |||||
| memcpy (coefficients, other.coefficients, sizeof (coefficients)); | |||||
| return *this; | return *this; | ||||
| } | } | ||||
| @@ -52,11 +52,11 @@ IIRCoefficients::IIRCoefficients (double c1, double c2, double c3, | |||||
| { | { | ||||
| const double a = 1.0 / c4; | const double a = 1.0 / c4; | ||||
| c[0] = (float) (c1 * a); | |||||
| c[1] = (float) (c2 * a); | |||||
| c[2] = (float) (c3 * a); | |||||
| c[3] = (float) (c5 * a); | |||||
| c[4] = (float) (c6 * a); | |||||
| coefficients[0] = (float) (c1 * a); | |||||
| coefficients[1] = (float) (c2 * a); | |||||
| coefficients[2] = (float) (c3 * a); | |||||
| coefficients[3] = (float) (c5 * a); | |||||
| coefficients[4] = (float) (c6 * a); | |||||
| } | } | ||||
| IIRCoefficients IIRCoefficients::makeLowPass (const double sampleRate, | IIRCoefficients IIRCoefficients::makeLowPass (const double sampleRate, | ||||
| @@ -69,7 +69,7 @@ IIRCoefficients IIRCoefficients::makeLowPass (const double sampleRate, | |||||
| const double c1 = 1.0 / (1.0 + std::sqrt (2.0) * n + nSquared); | const double c1 = 1.0 / (1.0 + std::sqrt (2.0) * n + nSquared); | ||||
| return IIRCoefficients (c1, | return IIRCoefficients (c1, | ||||
| c1 * 2.0f, | |||||
| c1 * 2.0, | |||||
| c1, | c1, | ||||
| 1.0, | 1.0, | ||||
| c1 * 2.0 * (1.0 - nSquared), | c1 * 2.0 * (1.0 - nSquared), | ||||
| @@ -84,7 +84,7 @@ IIRCoefficients IIRCoefficients::makeHighPass (const double sampleRate, | |||||
| const double c1 = 1.0 / (1.0 + std::sqrt (2.0) * n + nSquared); | const double c1 = 1.0 / (1.0 + std::sqrt (2.0) * n + nSquared); | ||||
| return IIRCoefficients (c1, | return IIRCoefficients (c1, | ||||
| c1 * -2.0f, | |||||
| c1 * -2.0, | |||||
| c1, | c1, | ||||
| 1.0, | 1.0, | ||||
| c1 * 2.0 * (nSquared - 1.0), | c1 * 2.0 * (nSquared - 1.0), | ||||
| @@ -203,28 +203,27 @@ void IIRFilter::reset() noexcept | |||||
| float IIRFilter::processSingleSampleRaw (const float in) noexcept | float IIRFilter::processSingleSampleRaw (const float in) noexcept | ||||
| { | { | ||||
| float out = coefficients.c[0] * in + v1; | |||||
| float out = coefficients.coefficients[0] * in + v1; | |||||
| JUCE_SNAP_TO_ZERO (out); | JUCE_SNAP_TO_ZERO (out); | ||||
| v1 = coefficients.c[1] * in - coefficients.c[3] * out + v2; | |||||
| v2 = coefficients.c[2] * in - coefficients.c[4] * out; | |||||
| v1 = coefficients.coefficients[1] * in - coefficients.coefficients[3] * out + v2; | |||||
| v2 = coefficients.coefficients[2] * in - coefficients.coefficients[4] * out; | |||||
| return out; | return out; | ||||
| } | } | ||||
| void IIRFilter::processSamples (float* const samples, | |||||
| const int numSamples) noexcept | |||||
| void IIRFilter::processSamples (float* const samples, const int numSamples) noexcept | |||||
| { | { | ||||
| const SpinLock::ScopedLockType sl (processLock); | const SpinLock::ScopedLockType sl (processLock); | ||||
| if (active) | if (active) | ||||
| { | { | ||||
| const float c0 = coefficients.c[0]; | |||||
| const float c1 = coefficients.c[1]; | |||||
| const float c2 = coefficients.c[2]; | |||||
| const float c3 = coefficients.c[3]; | |||||
| const float c4 = coefficients.c[4]; | |||||
| const float c0 = coefficients.coefficients[0]; | |||||
| const float c1 = coefficients.coefficients[1]; | |||||
| const float c2 = coefficients.coefficients[2]; | |||||
| const float c3 = coefficients.coefficients[3]; | |||||
| const float c4 = coefficients.coefficients[4]; | |||||
| float lv1 = v1, lv2 = v2; | float lv1 = v1, lv2 = v2; | ||||
| for (int i = 0; i < numSamples; ++i) | for (int i = 0; i < numSamples; ++i) | ||||
| @@ -98,9 +98,11 @@ public: | |||||
| double Q, | double Q, | ||||
| float gainFactor) noexcept; | float gainFactor) noexcept; | ||||
| private: | |||||
| friend class IIRFilter; | |||||
| float c[5]; | |||||
| //============================================================================== | |||||
| /** The raw coefficients. | |||||
| You should leave these numbers alone unless you really know what you're doing. | |||||
| */ | |||||
| float coefficients[5]; | |||||
| }; | }; | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -83,7 +83,7 @@ int LagrangeInterpolator::process (const double actualRatio, const float* in, | |||||
| { | { | ||||
| if (actualRatio == 1.0) | if (actualRatio == 1.0) | ||||
| { | { | ||||
| memcpy (out, in, numOut * sizeof (float)); | |||||
| memcpy (out, in, (size_t) numOut * sizeof (float)); | |||||
| if (numOut >= 4) | if (numOut >= 4) | ||||
| { | { | ||||
| @@ -25,6 +25,7 @@ | |||||
| #ifndef JUCE_LAGRANGEINTERPOLATOR_H_INCLUDED | #ifndef JUCE_LAGRANGEINTERPOLATOR_H_INCLUDED | ||||
| #define JUCE_LAGRANGEINTERPOLATOR_H_INCLUDED | #define JUCE_LAGRANGEINTERPOLATOR_H_INCLUDED | ||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| Interpolator for resampling a stream of floats using 4-point lagrange interpolation. | Interpolator for resampling a stream of floats using 4-point lagrange interpolation. | ||||
| @@ -48,19 +48,24 @@ | |||||
| #include <emmintrin.h> | #include <emmintrin.h> | ||||
| #endif | #endif | ||||
| #if JUCE_MAC || JUCE_IOS | |||||
| #ifndef JUCE_USE_VDSP_FRAMEWORK | |||||
| #define JUCE_USE_VDSP_FRAMEWORK 1 | #define JUCE_USE_VDSP_FRAMEWORK 1 | ||||
| #endif | |||||
| #if (JUCE_MAC || JUCE_IOS) && JUCE_USE_VDSP_FRAMEWORK | |||||
| #include <Accelerate/Accelerate.h> | #include <Accelerate/Accelerate.h> | ||||
| #else | |||||
| #undef JUCE_USE_VDSP_FRAMEWORK | |||||
| #endif | #endif | ||||
| namespace juce | namespace juce | ||||
| { | { | ||||
| // START_AUTOINCLUDE buffers/*.cpp, effects/*.cpp, midi/*.cpp, sources/*.cpp, synthesisers/*.cpp | |||||
| #include "buffers/juce_AudioDataConverters.cpp" | #include "buffers/juce_AudioDataConverters.cpp" | ||||
| #include "buffers/juce_AudioSampleBuffer.cpp" | #include "buffers/juce_AudioSampleBuffer.cpp" | ||||
| #include "buffers/juce_FloatVectorOperations.cpp" | #include "buffers/juce_FloatVectorOperations.cpp" | ||||
| #include "effects/juce_IIRFilter.cpp" | #include "effects/juce_IIRFilter.cpp" | ||||
| #include "effects/juce_IIRFilterOld.cpp" | |||||
| #include "effects/juce_LagrangeInterpolator.cpp" | #include "effects/juce_LagrangeInterpolator.cpp" | ||||
| #include "midi/juce_MidiBuffer.cpp" | #include "midi/juce_MidiBuffer.cpp" | ||||
| #include "midi/juce_MidiFile.cpp" | #include "midi/juce_MidiFile.cpp" | ||||
| @@ -75,6 +80,5 @@ namespace juce | |||||
| #include "sources/juce_ReverbAudioSource.cpp" | #include "sources/juce_ReverbAudioSource.cpp" | ||||
| #include "sources/juce_ToneGeneratorAudioSource.cpp" | #include "sources/juce_ToneGeneratorAudioSource.cpp" | ||||
| #include "synthesisers/juce_Synthesiser.cpp" | #include "synthesisers/juce_Synthesiser.cpp" | ||||
| // END_AUTOINCLUDE | |||||
| } | } | ||||
| @@ -31,30 +31,29 @@ | |||||
| namespace juce | namespace juce | ||||
| { | { | ||||
| // START_AUTOINCLUDE buffers, effects, midi, sources, synthesisers | |||||
| #include "buffers/juce_AudioDataConverters.h" | #include "buffers/juce_AudioDataConverters.h" | ||||
| #include "buffers/juce_AudioSampleBuffer.h" | #include "buffers/juce_AudioSampleBuffer.h" | ||||
| #include "buffers/juce_FloatVectorOperations.h" | #include "buffers/juce_FloatVectorOperations.h" | ||||
| #include "effects/juce_Decibels.h" | #include "effects/juce_Decibels.h" | ||||
| #include "effects/juce_IIRFilter.h" | #include "effects/juce_IIRFilter.h" | ||||
| #include "effects/juce_IIRFilterOld.h" | |||||
| #include "effects/juce_LagrangeInterpolator.h" | #include "effects/juce_LagrangeInterpolator.h" | ||||
| #include "effects/juce_Reverb.h" | #include "effects/juce_Reverb.h" | ||||
| #include "midi/juce_MidiMessage.h" | |||||
| #include "midi/juce_MidiBuffer.h" | #include "midi/juce_MidiBuffer.h" | ||||
| #include "midi/juce_MidiMessageSequence.h" | |||||
| #include "midi/juce_MidiFile.h" | #include "midi/juce_MidiFile.h" | ||||
| #include "midi/juce_MidiKeyboardState.h" | #include "midi/juce_MidiKeyboardState.h" | ||||
| #include "midi/juce_MidiMessage.h" | |||||
| #include "midi/juce_MidiMessageSequence.h" | |||||
| #include "sources/juce_AudioSource.h" | #include "sources/juce_AudioSource.h" | ||||
| #include "sources/juce_PositionableAudioSource.h" | |||||
| #include "sources/juce_BufferingAudioSource.h" | #include "sources/juce_BufferingAudioSource.h" | ||||
| #include "sources/juce_ChannelRemappingAudioSource.h" | #include "sources/juce_ChannelRemappingAudioSource.h" | ||||
| #include "sources/juce_IIRFilterAudioSource.h" | #include "sources/juce_IIRFilterAudioSource.h" | ||||
| #include "sources/juce_MixerAudioSource.h" | #include "sources/juce_MixerAudioSource.h" | ||||
| #include "sources/juce_PositionableAudioSource.h" | |||||
| #include "sources/juce_ResamplingAudioSource.h" | #include "sources/juce_ResamplingAudioSource.h" | ||||
| #include "sources/juce_ReverbAudioSource.h" | #include "sources/juce_ReverbAudioSource.h" | ||||
| #include "sources/juce_ToneGeneratorAudioSource.h" | #include "sources/juce_ToneGeneratorAudioSource.h" | ||||
| #include "synthesisers/juce_Synthesiser.h" | #include "synthesisers/juce_Synthesiser.h" | ||||
| // END_AUTOINCLUDE | |||||
| } | } | ||||
| @@ -25,8 +25,6 @@ | |||||
| #ifndef JUCE_MIDIBUFFER_H_INCLUDED | #ifndef JUCE_MIDIBUFFER_H_INCLUDED | ||||
| #define JUCE_MIDIBUFFER_H_INCLUDED | #define JUCE_MIDIBUFFER_H_INCLUDED | ||||
| #include "juce_MidiMessage.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -25,8 +25,6 @@ | |||||
| #ifndef JUCE_MIDIFILE_H_INCLUDED | #ifndef JUCE_MIDIFILE_H_INCLUDED | ||||
| #define JUCE_MIDIFILE_H_INCLUDED | #define JUCE_MIDIFILE_H_INCLUDED | ||||
| #include "juce_MidiMessageSequence.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -25,7 +25,6 @@ | |||||
| #ifndef JUCE_MIDIKEYBOARDSTATE_H_INCLUDED | #ifndef JUCE_MIDIKEYBOARDSTATE_H_INCLUDED | ||||
| #define JUCE_MIDIKEYBOARDSTATE_H_INCLUDED | #define JUCE_MIDIKEYBOARDSTATE_H_INCLUDED | ||||
| #include "juce_MidiBuffer.h" | |||||
| class MidiKeyboardState; | class MidiKeyboardState; | ||||
| @@ -25,8 +25,6 @@ | |||||
| #ifndef JUCE_MIDIMESSAGESEQUENCE_H_INCLUDED | #ifndef JUCE_MIDIMESSAGESEQUENCE_H_INCLUDED | ||||
| #define JUCE_MIDIMESSAGESEQUENCE_H_INCLUDED | #define JUCE_MIDIMESSAGESEQUENCE_H_INCLUDED | ||||
| #include "juce_MidiMessage.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -25,8 +25,6 @@ | |||||
| #ifndef JUCE_AUDIOSOURCE_H_INCLUDED | #ifndef JUCE_AUDIOSOURCE_H_INCLUDED | ||||
| #define JUCE_AUDIOSOURCE_H_INCLUDED | #define JUCE_AUDIOSOURCE_H_INCLUDED | ||||
| #include "../buffers/juce_AudioSampleBuffer.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -25,8 +25,6 @@ | |||||
| #ifndef JUCE_BUFFERINGAUDIOSOURCE_H_INCLUDED | #ifndef JUCE_BUFFERINGAUDIOSOURCE_H_INCLUDED | ||||
| #define JUCE_BUFFERINGAUDIOSOURCE_H_INCLUDED | #define JUCE_BUFFERINGAUDIOSOURCE_H_INCLUDED | ||||
| #include "juce_PositionableAudioSource.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -76,7 +74,7 @@ public: | |||||
| void releaseResources() override; | void releaseResources() override; | ||||
| /** Implementation of the AudioSource method. */ | /** Implementation of the AudioSource method. */ | ||||
| void getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill) override; | |||||
| void getNextAudioBlock (const AudioSourceChannelInfo&) override; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Implements the PositionableAudioSource method. */ | /** Implements the PositionableAudioSource method. */ | ||||
| @@ -104,7 +102,7 @@ private: | |||||
| bool readNextBufferChunk(); | bool readNextBufferChunk(); | ||||
| void readBufferSection (int64 start, int length, int bufferOffset); | void readBufferSection (int64 start, int length, int bufferOffset); | ||||
| int useTimeSlice(); | |||||
| int useTimeSlice() override; | |||||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BufferingAudioSource) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BufferingAudioSource) | ||||
| }; | }; | ||||
| @@ -25,8 +25,6 @@ | |||||
| #ifndef JUCE_CHANNELREMAPPINGAUDIOSOURCE_H_INCLUDED | #ifndef JUCE_CHANNELREMAPPINGAUDIOSOURCE_H_INCLUDED | ||||
| #define JUCE_CHANNELREMAPPINGAUDIOSOURCE_H_INCLUDED | #define JUCE_CHANNELREMAPPINGAUDIOSOURCE_H_INCLUDED | ||||
| #include "juce_AudioSource.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -113,32 +111,29 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Returns an XML object to encapsulate the state of the mappings. | /** Returns an XML object to encapsulate the state of the mappings. | ||||
| @see restoreFromXml | @see restoreFromXml | ||||
| */ | */ | ||||
| XmlElement* createXml() const; | XmlElement* createXml() const; | ||||
| /** Restores the mappings from an XML object created by createXML(). | /** Restores the mappings from an XML object created by createXML(). | ||||
| @see createXml | @see createXml | ||||
| */ | */ | ||||
| void restoreFromXml (const XmlElement& e); | |||||
| void restoreFromXml (const XmlElement&); | |||||
| //============================================================================== | //============================================================================== | ||||
| void prepareToPlay (int samplesPerBlockExpected, double sampleRate); | |||||
| void releaseResources(); | |||||
| void getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill); | |||||
| void prepareToPlay (int samplesPerBlockExpected, double sampleRate) override; | |||||
| void releaseResources() override; | |||||
| void getNextAudioBlock (const AudioSourceChannelInfo&) override; | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| OptionalScopedPointer<AudioSource> source; | OptionalScopedPointer<AudioSource> source; | ||||
| Array <int> remappedInputs, remappedOutputs; | |||||
| Array<int> remappedInputs, remappedOutputs; | |||||
| int requiredNumberOfChannels; | int requiredNumberOfChannels; | ||||
| AudioSampleBuffer buffer; | AudioSampleBuffer buffer; | ||||
| AudioSourceChannelInfo remappedInfo; | AudioSourceChannelInfo remappedInfo; | ||||
| CriticalSection lock; | CriticalSection lock; | ||||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChannelRemappingAudioSource) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChannelRemappingAudioSource) | ||||
| @@ -25,9 +25,6 @@ | |||||
| #ifndef JUCE_IIRFILTERAUDIOSOURCE_H_INCLUDED | #ifndef JUCE_IIRFILTERAUDIOSOURCE_H_INCLUDED | ||||
| #define JUCE_IIRFILTERAUDIOSOURCE_H_INCLUDED | #define JUCE_IIRFILTERAUDIOSOURCE_H_INCLUDED | ||||
| #include "juce_AudioSource.h" | |||||
| #include "../effects/juce_IIRFilter.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -57,14 +54,14 @@ public: | |||||
| void makeInactive(); | void makeInactive(); | ||||
| //============================================================================== | //============================================================================== | ||||
| void prepareToPlay (int samplesPerBlockExpected, double sampleRate); | |||||
| void releaseResources(); | |||||
| void getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill); | |||||
| void prepareToPlay (int samplesPerBlockExpected, double sampleRate) override; | |||||
| void releaseResources() override; | |||||
| void getNextAudioBlock (const AudioSourceChannelInfo&) override; | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| OptionalScopedPointer<AudioSource> input; | OptionalScopedPointer<AudioSource> input; | ||||
| OwnedArray <IIRFilter> iirFilters; | |||||
| OwnedArray<IIRFilter> iirFilters; | |||||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (IIRFilterAudioSource) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (IIRFilterAudioSource) | ||||
| }; | }; | ||||
| @@ -25,8 +25,6 @@ | |||||
| #ifndef JUCE_MIXERAUDIOSOURCE_H_INCLUDED | #ifndef JUCE_MIXERAUDIOSOURCE_H_INCLUDED | ||||
| #define JUCE_MIXERAUDIOSOURCE_H_INCLUDED | #define JUCE_MIXERAUDIOSOURCE_H_INCLUDED | ||||
| #include "juce_AudioSource.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -76,20 +74,20 @@ public: | |||||
| /** Implementation of the AudioSource method. | /** Implementation of the AudioSource method. | ||||
| This will call prepareToPlay() on all its input sources. | This will call prepareToPlay() on all its input sources. | ||||
| */ | */ | ||||
| void prepareToPlay (int samplesPerBlockExpected, double sampleRate); | |||||
| void prepareToPlay (int samplesPerBlockExpected, double sampleRate) override; | |||||
| /** Implementation of the AudioSource method. | /** Implementation of the AudioSource method. | ||||
| This will call releaseResources() on all its input sources. | This will call releaseResources() on all its input sources. | ||||
| */ | */ | ||||
| void releaseResources(); | |||||
| void releaseResources() override; | |||||
| /** Implementation of the AudioSource method. */ | /** Implementation of the AudioSource method. */ | ||||
| void getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill); | |||||
| void getNextAudioBlock (const AudioSourceChannelInfo&) override; | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| Array <AudioSource*> inputs; | |||||
| Array<AudioSource*> inputs; | |||||
| BigInteger inputsToDelete; | BigInteger inputsToDelete; | ||||
| CriticalSection lock; | CriticalSection lock; | ||||
| AudioSampleBuffer tempBuffer; | AudioSampleBuffer tempBuffer; | ||||
| @@ -25,8 +25,6 @@ | |||||
| #ifndef JUCE_POSITIONABLEAUDIOSOURCE_H_INCLUDED | #ifndef JUCE_POSITIONABLEAUDIOSOURCE_H_INCLUDED | ||||
| #define JUCE_POSITIONABLEAUDIOSOURCE_H_INCLUDED | #define JUCE_POSITIONABLEAUDIOSOURCE_H_INCLUDED | ||||
| #include "juce_AudioSource.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -25,8 +25,6 @@ | |||||
| #ifndef JUCE_RESAMPLINGAUDIOSOURCE_H_INCLUDED | #ifndef JUCE_RESAMPLINGAUDIOSOURCE_H_INCLUDED | ||||
| #define JUCE_RESAMPLINGAUDIOSOURCE_H_INCLUDED | #define JUCE_RESAMPLINGAUDIOSOURCE_H_INCLUDED | ||||
| #include "juce_AudioSource.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -69,9 +67,9 @@ public: | |||||
| double getResamplingRatio() const noexcept { return ratio; } | double getResamplingRatio() const noexcept { return ratio; } | ||||
| //============================================================================== | //============================================================================== | ||||
| void prepareToPlay (int samplesPerBlockExpected, double sampleRate); | |||||
| void releaseResources(); | |||||
| void getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill); | |||||
| void prepareToPlay (int samplesPerBlockExpected, double sampleRate) override; | |||||
| void releaseResources() override; | |||||
| void getNextAudioBlock (const AudioSourceChannelInfo&) override; | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -25,9 +25,6 @@ | |||||
| #ifndef JUCE_REVERBAUDIOSOURCE_H_INCLUDED | #ifndef JUCE_REVERBAUDIOSOURCE_H_INCLUDED | ||||
| #define JUCE_REVERBAUDIOSOURCE_H_INCLUDED | #define JUCE_REVERBAUDIOSOURCE_H_INCLUDED | ||||
| #include "juce_AudioSource.h" | |||||
| #include "../effects/juce_Reverb.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -61,9 +58,9 @@ public: | |||||
| bool isBypassed() const noexcept { return bypass; } | bool isBypassed() const noexcept { return bypass; } | ||||
| //============================================================================== | //============================================================================== | ||||
| void prepareToPlay (int samplesPerBlockExpected, double sampleRate); | |||||
| void releaseResources(); | |||||
| void getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill); | |||||
| void prepareToPlay (int samplesPerBlockExpected, double sampleRate) override; | |||||
| void releaseResources() override; | |||||
| void getNextAudioBlock (const AudioSourceChannelInfo&) override; | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -25,8 +25,6 @@ | |||||
| #ifndef JUCE_TONEGENERATORAUDIOSOURCE_H_INCLUDED | #ifndef JUCE_TONEGENERATORAUDIOSOURCE_H_INCLUDED | ||||
| #define JUCE_TONEGENERATORAUDIOSOURCE_H_INCLUDED | #define JUCE_TONEGENERATORAUDIOSOURCE_H_INCLUDED | ||||
| #include "juce_AudioSource.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -53,13 +51,13 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Implementation of the AudioSource method. */ | /** Implementation of the AudioSource method. */ | ||||
| void prepareToPlay (int samplesPerBlockExpected, double sampleRate); | |||||
| void prepareToPlay (int samplesPerBlockExpected, double sampleRate) override; | |||||
| /** Implementation of the AudioSource method. */ | /** Implementation of the AudioSource method. */ | ||||
| void releaseResources(); | |||||
| void releaseResources() override; | |||||
| /** Implementation of the AudioSource method. */ | /** Implementation of the AudioSource method. */ | ||||
| void getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill); | |||||
| void getNextAudioBlock (const AudioSourceChannelInfo&) override; | |||||
| private: | private: | ||||
| @@ -25,9 +25,6 @@ | |||||
| #ifndef JUCE_SYNTHESISER_H_INCLUDED | #ifndef JUCE_SYNTHESISER_H_INCLUDED | ||||
| #define JUCE_SYNTHESISER_H_INCLUDED | #define JUCE_SYNTHESISER_H_INCLUDED | ||||
| #include "../buffers/juce_AudioSampleBuffer.h" | |||||
| #include "../midi/juce_MidiBuffer.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -29,8 +29,6 @@ | |||||
| #ifndef JUCE_ABSTRACTFIFO_H_INCLUDED | #ifndef JUCE_ABSTRACTFIFO_H_INCLUDED | ||||
| #define JUCE_ABSTRACTFIFO_H_INCLUDED | #define JUCE_ABSTRACTFIFO_H_INCLUDED | ||||
| #include "../memory/juce_Atomic.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -29,10 +29,6 @@ | |||||
| #ifndef JUCE_ARRAY_H_INCLUDED | #ifndef JUCE_ARRAY_H_INCLUDED | ||||
| #define JUCE_ARRAY_H_INCLUDED | #define JUCE_ARRAY_H_INCLUDED | ||||
| #include "juce_ArrayAllocationBase.h" | |||||
| #include "juce_ElementComparator.h" | |||||
| #include "../threads/juce_CriticalSection.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -1025,9 +1021,11 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| #ifndef DOXYGEN | |||||
| // Note that the swapWithArray method has been replaced by a more flexible templated version, | // Note that the swapWithArray method has been replaced by a more flexible templated version, | ||||
| // and renamed "swapWith" to be more consistent with the names used in other classes. | // and renamed "swapWith" to be more consistent with the names used in other classes. | ||||
| JUCE_DEPRECATED_WITH_BODY (void swapWithArray (Array& other) noexcept, { swapWith (other); }) | JUCE_DEPRECATED_WITH_BODY (void swapWithArray (Array& other) noexcept, { swapWith (other); }) | ||||
| #endif | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -29,8 +29,6 @@ | |||||
| #ifndef JUCE_ARRAYALLOCATIONBASE_H_INCLUDED | #ifndef JUCE_ARRAYALLOCATIONBASE_H_INCLUDED | ||||
| #define JUCE_ARRAYALLOCATIONBASE_H_INCLUDED | #define JUCE_ARRAYALLOCATIONBASE_H_INCLUDED | ||||
| #include "../memory/juce_HeapBlock.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -29,9 +29,6 @@ | |||||
| #ifndef JUCE_DYNAMICOBJECT_H_INCLUDED | #ifndef JUCE_DYNAMICOBJECT_H_INCLUDED | ||||
| #define JUCE_DYNAMICOBJECT_H_INCLUDED | #define JUCE_DYNAMICOBJECT_H_INCLUDED | ||||
| #include "juce_NamedValueSet.h" | |||||
| #include "../memory/juce_ReferenceCountedObject.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -29,6 +29,27 @@ | |||||
| #ifndef JUCE_ELEMENTCOMPARATOR_H_INCLUDED | #ifndef JUCE_ELEMENTCOMPARATOR_H_INCLUDED | ||||
| #define JUCE_ELEMENTCOMPARATOR_H_INCLUDED | #define JUCE_ELEMENTCOMPARATOR_H_INCLUDED | ||||
| #ifndef DOXYGEN | |||||
| /** This is an internal helper class which converts a juce ElementComparator style | |||||
| class (using a "compareElements" method) into a class that's compatible with | |||||
| std::sort (i.e. using an operator() to compare the elements) | |||||
| */ | |||||
| template <typename ElementComparator> | |||||
| struct SortFunctionConverter | |||||
| { | |||||
| SortFunctionConverter (ElementComparator& e) : comparator (e) {} | |||||
| template <typename Type> | |||||
| bool operator() (Type a, Type b) { return comparator.compareElements (a, b) < 0; } | |||||
| private: | |||||
| ElementComparator& comparator; | |||||
| SortFunctionConverter& operator= (const SortFunctionConverter&) JUCE_DELETED_FUNCTION; | |||||
| }; | |||||
| #endif | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -65,117 +86,12 @@ static void sortArray (ElementComparator& comparator, | |||||
| int lastElement, | int lastElement, | ||||
| const bool retainOrderOfEquivalentItems) | const bool retainOrderOfEquivalentItems) | ||||
| { | { | ||||
| (void) comparator; // if you pass in an object with a static compareElements() method, this | |||||
| // avoids getting warning messages about the parameter being unused | |||||
| if (lastElement > firstElement) | |||||
| { | |||||
| if (retainOrderOfEquivalentItems) | |||||
| { | |||||
| for (int i = firstElement; i < lastElement; ++i) | |||||
| { | |||||
| if (comparator.compareElements (array[i], array [i + 1]) > 0) | |||||
| { | |||||
| std::swap (array[i], array[i + 1]); | |||||
| if (i > firstElement) | |||||
| i -= 2; | |||||
| } | |||||
| } | |||||
| } | |||||
| else | |||||
| { | |||||
| int fromStack[30], toStack[30]; | |||||
| int stackIndex = 0; | |||||
| SortFunctionConverter<ElementComparator> converter (comparator); | |||||
| for (;;) | |||||
| { | |||||
| const int size = (lastElement - firstElement) + 1; | |||||
| if (size <= 8) | |||||
| { | |||||
| int j = lastElement; | |||||
| int maxIndex; | |||||
| while (j > firstElement) | |||||
| { | |||||
| maxIndex = firstElement; | |||||
| for (int k = firstElement + 1; k <= j; ++k) | |||||
| if (comparator.compareElements (array[k], array [maxIndex]) > 0) | |||||
| maxIndex = k; | |||||
| std::swap (array[j], array[maxIndex]); | |||||
| --j; | |||||
| } | |||||
| } | |||||
| else | |||||
| { | |||||
| const int mid = firstElement + (size >> 1); | |||||
| std::swap (array[mid], array[firstElement]); | |||||
| int i = firstElement; | |||||
| int j = lastElement + 1; | |||||
| for (;;) | |||||
| { | |||||
| while (++i <= lastElement | |||||
| && comparator.compareElements (array[i], array [firstElement]) <= 0) | |||||
| {} | |||||
| while (--j > firstElement | |||||
| && comparator.compareElements (array[j], array [firstElement]) >= 0) | |||||
| {} | |||||
| if (j < i) | |||||
| break; | |||||
| std::swap (array[i], array[j]); | |||||
| } | |||||
| std::swap (array[j], array[firstElement]); | |||||
| if (j - 1 - firstElement >= lastElement - i) | |||||
| { | |||||
| if (firstElement + 1 < j) | |||||
| { | |||||
| fromStack [stackIndex] = firstElement; | |||||
| toStack [stackIndex] = j - 1; | |||||
| ++stackIndex; | |||||
| } | |||||
| if (i < lastElement) | |||||
| { | |||||
| firstElement = i; | |||||
| continue; | |||||
| } | |||||
| } | |||||
| else | |||||
| { | |||||
| if (i < lastElement) | |||||
| { | |||||
| fromStack [stackIndex] = i; | |||||
| toStack [stackIndex] = lastElement; | |||||
| ++stackIndex; | |||||
| } | |||||
| if (firstElement + 1 < j) | |||||
| { | |||||
| lastElement = j - 1; | |||||
| continue; | |||||
| } | |||||
| } | |||||
| } | |||||
| if (--stackIndex < 0) | |||||
| break; | |||||
| jassert (stackIndex < numElementsInArray (fromStack)); | |||||
| firstElement = fromStack [stackIndex]; | |||||
| lastElement = toStack [stackIndex]; | |||||
| } | |||||
| } | |||||
| } | |||||
| if (retainOrderOfEquivalentItems) | |||||
| std::stable_sort (array + firstElement, array + lastElement + 1, converter); | |||||
| else | |||||
| std::sort (array + firstElement, array + lastElement + 1, converter); | |||||
| } | } | ||||
| @@ -29,10 +29,6 @@ | |||||
| #ifndef JUCE_HASHMAP_H_INCLUDED | #ifndef JUCE_HASHMAP_H_INCLUDED | ||||
| #define JUCE_HASHMAP_H_INCLUDED | #define JUCE_HASHMAP_H_INCLUDED | ||||
| #include "juce_OwnedArray.h" | |||||
| #include "juce_LinkedListPointer.h" | |||||
| #include "../memory/juce_ScopedPointer.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -109,11 +105,10 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Creates an empty hash-map. | /** Creates an empty hash-map. | ||||
| The numberOfSlots parameter specifies the number of hash entries the map will | |||||
| use. This will be the "upperLimit" parameter that is passed to your generateHash() | |||||
| function. The number of hash slots will grow automatically if necessary, or | |||||
| it can be remapped manually using remapTable(). | |||||
| @param numberOfSlots Specifies the number of hash entries the map will use. This will be | |||||
| the "upperLimit" parameter that is passed to your generateHash() | |||||
| function. The number of hash slots will grow automatically if necessary, | |||||
| or it can be remapped manually using remapTable(). | |||||
| @param hashFunction An instance of HashFunctionType, which will be copied and | @param hashFunction An instance of HashFunctionType, which will be copied and | ||||
| stored to use with the HashMap. This parameter can be omitted | stored to use with the HashMap. This parameter can be omitted | ||||
| if HashFunctionType has a default constructor. | if HashFunctionType has a default constructor. | ||||
| @@ -29,13 +29,6 @@ | |||||
| #ifndef JUCE_NAMEDVALUESET_H_INCLUDED | #ifndef JUCE_NAMEDVALUESET_H_INCLUDED | ||||
| #define JUCE_NAMEDVALUESET_H_INCLUDED | #define JUCE_NAMEDVALUESET_H_INCLUDED | ||||
| #include "juce_Variant.h" | |||||
| #include "../containers/juce_LinkedListPointer.h" | |||||
| class XmlElement; | |||||
| #ifndef DOXYGEN | |||||
| class JSONFormatter; | |||||
| #endif | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Holds a set of named var objects. | /** Holds a set of named var objects. | ||||
| @@ -29,10 +29,6 @@ | |||||
| #ifndef JUCE_OWNEDARRAY_H_INCLUDED | #ifndef JUCE_OWNEDARRAY_H_INCLUDED | ||||
| #define JUCE_OWNEDARRAY_H_INCLUDED | #define JUCE_OWNEDARRAY_H_INCLUDED | ||||
| #include "juce_ArrayAllocationBase.h" | |||||
| #include "juce_ElementComparator.h" | |||||
| #include "../threads/juce_CriticalSection.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** An array designed for holding objects. | /** An array designed for holding objects. | ||||
| @@ -389,7 +385,7 @@ public: | |||||
| { | { | ||||
| if (indexToChange >= 0) | if (indexToChange >= 0) | ||||
| { | { | ||||
| ObjectClass* toDelete = nullptr; | |||||
| ScopedPointer<ObjectClass> toDelete; | |||||
| { | { | ||||
| const ScopedLockType lock (getLock()); | const ScopedLockType lock (getLock()); | ||||
| @@ -401,7 +397,7 @@ public: | |||||
| toDelete = data.elements [indexToChange]; | toDelete = data.elements [indexToChange]; | ||||
| if (toDelete == newObject) | if (toDelete == newObject) | ||||
| toDelete = nullptr; | |||||
| toDelete.release(); | |||||
| } | } | ||||
| data.elements [indexToChange] = const_cast <ObjectClass*> (newObject); | data.elements [indexToChange] = const_cast <ObjectClass*> (newObject); | ||||
| @@ -412,10 +408,6 @@ public: | |||||
| data.elements [numUsed++] = const_cast <ObjectClass*> (newObject); | data.elements [numUsed++] = const_cast <ObjectClass*> (newObject); | ||||
| } | } | ||||
| } | } | ||||
| delete toDelete; // don't want to use a ScopedPointer here because if the | |||||
| // object has a private destructor, both OwnedArray and | |||||
| // ScopedPointer would need to be friend classes.. | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -575,7 +567,7 @@ public: | |||||
| void remove (const int indexToRemove, | void remove (const int indexToRemove, | ||||
| const bool deleteObject = true) | const bool deleteObject = true) | ||||
| { | { | ||||
| ObjectClass* toDelete = nullptr; | |||||
| ScopedPointer<ObjectClass> toDelete; | |||||
| { | { | ||||
| const ScopedLockType lock (getLock()); | const ScopedLockType lock (getLock()); | ||||
| @@ -595,10 +587,6 @@ public: | |||||
| } | } | ||||
| } | } | ||||
| delete toDelete; // don't want to use a ScopedPointer here because if the | |||||
| // object has a private destructor, both OwnedArray and | |||||
| // ScopedPointer would need to be friend classes.. | |||||
| if ((numUsed << 1) < data.numAllocated) | if ((numUsed << 1) < data.numAllocated) | ||||
| minimiseStorageOverheads(); | minimiseStorageOverheads(); | ||||
| } | } | ||||
| @@ -686,7 +674,7 @@ public: | |||||
| { | { | ||||
| for (int i = startIndex; i < endIndex; ++i) | for (int i = startIndex; i < endIndex; ++i) | ||||
| { | { | ||||
| delete data.elements [i]; | |||||
| ContainerDeletePolicy<ObjectClass>::destroy (data.elements [i]); | |||||
| data.elements [i] = nullptr; // (in case one of the destructors accesses this array and hits a dangling pointer) | data.elements [i] = nullptr; // (in case one of the destructors accesses this array and hits a dangling pointer) | ||||
| } | } | ||||
| } | } | ||||
| @@ -875,9 +863,11 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| #ifndef DOXYGEN | |||||
| // Note that the swapWithArray method has been replaced by a more flexible templated version, | // Note that the swapWithArray method has been replaced by a more flexible templated version, | ||||
| // and renamed "swapWith" to be more consistent with the names used in other classes. | // and renamed "swapWith" to be more consistent with the names used in other classes. | ||||
| JUCE_DEPRECATED_WITH_BODY (void swapWithArray (OwnedArray& other) noexcept, { swapWith (other); }) | JUCE_DEPRECATED_WITH_BODY (void swapWithArray (OwnedArray& other) noexcept, { swapWith (other); }) | ||||
| #endif | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -887,7 +877,7 @@ private: | |||||
| void deleteAllObjects() | void deleteAllObjects() | ||||
| { | { | ||||
| while (numUsed > 0) | while (numUsed > 0) | ||||
| delete data.elements [--numUsed]; | |||||
| ContainerDeletePolicy<ObjectClass>::destroy (data.elements [--numUsed]); | |||||
| } | } | ||||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OwnedArray) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OwnedArray) | ||||
| @@ -29,10 +29,6 @@ | |||||
| #ifndef JUCE_PROPERTYSET_H_INCLUDED | #ifndef JUCE_PROPERTYSET_H_INCLUDED | ||||
| #define JUCE_PROPERTYSET_H_INCLUDED | #define JUCE_PROPERTYSET_H_INCLUDED | ||||
| #include "../text/juce_StringPairArray.h" | |||||
| #include "../xml/juce_XmlElement.h" | |||||
| #include "../containers/juce_Variant.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -29,15 +29,18 @@ | |||||
| #ifndef JUCE_REFERENCECOUNTEDARRAY_H_INCLUDED | #ifndef JUCE_REFERENCECOUNTEDARRAY_H_INCLUDED | ||||
| #define JUCE_REFERENCECOUNTEDARRAY_H_INCLUDED | #define JUCE_REFERENCECOUNTEDARRAY_H_INCLUDED | ||||
| #include "../memory/juce_ReferenceCountedObject.h" | |||||
| #include "juce_ArrayAllocationBase.h" | |||||
| #include "juce_ElementComparator.h" | |||||
| #include "../threads/juce_CriticalSection.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| Holds a list of objects derived from ReferenceCountedObject. | |||||
| Holds a list of objects derived from ReferenceCountedObject, or which implement basic | |||||
| reference-count handling methods. | |||||
| The template parameter specifies the class of the object you want to point to - the easiest | |||||
| way to make a class reference-countable is to simply make it inherit from ReferenceCountedObject | |||||
| or SingleThreadedReferenceCountedObject, but if you need to, you can roll your own reference-countable | |||||
| class by implementing a set of mathods called incReferenceCount(), decReferenceCount(), and | |||||
| decReferenceCountWithoutDeleting(). See ReferenceCountedObject for examples of how these methods | |||||
| should behave. | |||||
| A ReferenceCountedArray holds objects derived from ReferenceCountedObject, | A ReferenceCountedArray holds objects derived from ReferenceCountedObject, | ||||
| and takes care of incrementing and decrementing their ref counts when they | and takes care of incrementing and decrementing their ref counts when they | ||||
| @@ -130,7 +133,7 @@ public: | |||||
| while (numUsed > 0) | while (numUsed > 0) | ||||
| if (ObjectClass* o = data.elements [--numUsed]) | if (ObjectClass* o = data.elements [--numUsed]) | ||||
| o->decReferenceCount(); | |||||
| releaseObject (o); | |||||
| jassert (numUsed == 0); | jassert (numUsed == 0); | ||||
| data.setAllocatedSize (0); | data.setAllocatedSize (0); | ||||
| @@ -392,7 +395,7 @@ public: | |||||
| if (indexToChange < numUsed) | if (indexToChange < numUsed) | ||||
| { | { | ||||
| if (ObjectClass* o = data.elements [indexToChange]) | if (ObjectClass* o = data.elements [indexToChange]) | ||||
| o->decReferenceCount(); | |||||
| releaseObject (o); | |||||
| data.elements [indexToChange] = newObject; | data.elements [indexToChange] = newObject; | ||||
| } | } | ||||
| @@ -542,7 +545,7 @@ public: | |||||
| ObjectClass** const e = data.elements + indexToRemove; | ObjectClass** const e = data.elements + indexToRemove; | ||||
| if (ObjectClass* o = *e) | if (ObjectClass* o = *e) | ||||
| o->decReferenceCount(); | |||||
| releaseObject (o); | |||||
| --numUsed; | --numUsed; | ||||
| const int numberToShift = numUsed - indexToRemove; | const int numberToShift = numUsed - indexToRemove; | ||||
| @@ -576,7 +579,7 @@ public: | |||||
| if (ObjectClass* o = *e) | if (ObjectClass* o = *e) | ||||
| { | { | ||||
| removedItem = o; | removedItem = o; | ||||
| o->decReferenceCount(); | |||||
| releaseObject (o); | |||||
| } | } | ||||
| --numUsed; | --numUsed; | ||||
| @@ -636,7 +639,7 @@ public: | |||||
| { | { | ||||
| if (ObjectClass* o = data.elements[i]) | if (ObjectClass* o = data.elements[i]) | ||||
| { | { | ||||
| o->decReferenceCount(); | |||||
| releaseObject (o); | |||||
| data.elements[i] = nullptr; // (in case one of the destructors accesses this array and hits a dangling pointer) | data.elements[i] = nullptr; // (in case one of the destructors accesses this array and hits a dangling pointer) | ||||
| } | } | ||||
| } | } | ||||
| @@ -858,14 +861,22 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| #ifndef DOXYGEN | |||||
| // Note that the swapWithArray method has been replaced by a more flexible templated version, | // Note that the swapWithArray method has been replaced by a more flexible templated version, | ||||
| // and renamed "swapWith" to be more consistent with the names used in other classes. | // and renamed "swapWith" to be more consistent with the names used in other classes. | ||||
| JUCE_DEPRECATED_WITH_BODY (void swapWithArray (ReferenceCountedArray& other) noexcept, { swapWith (other); }) | JUCE_DEPRECATED_WITH_BODY (void swapWithArray (ReferenceCountedArray& other) noexcept, { swapWith (other); }) | ||||
| #endif | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| ArrayAllocationBase <ObjectClass*, TypeOfCriticalSectionToUse> data; | ArrayAllocationBase <ObjectClass*, TypeOfCriticalSectionToUse> data; | ||||
| int numUsed; | int numUsed; | ||||
| static void releaseObject (ObjectClass* o) | |||||
| { | |||||
| if (o->decReferenceCountWithoutDeleting()) | |||||
| ContainerDeletePolicy<ObjectClass>::destroy (o); | |||||
| } | |||||
| }; | }; | ||||
| @@ -29,15 +29,11 @@ | |||||
| #ifndef JUCE_SORTEDSET_H_INCLUDED | #ifndef JUCE_SORTEDSET_H_INCLUDED | ||||
| #define JUCE_SORTEDSET_H_INCLUDED | #define JUCE_SORTEDSET_H_INCLUDED | ||||
| #include "juce_ArrayAllocationBase.h" | |||||
| #include "../threads/juce_CriticalSection.h" | |||||
| #if JUCE_MSVC | #if JUCE_MSVC | ||||
| #pragma warning (push) | |||||
| #pragma warning (disable: 4512) | |||||
| #pragma warning (push) | |||||
| #pragma warning (disable: 4512) | |||||
| #endif | #endif | ||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| Holds a set of unique primitive objects, such as ints or doubles. | Holds a set of unique primitive objects, such as ints or doubles. | ||||
| @@ -491,7 +487,7 @@ private: | |||||
| }; | }; | ||||
| #if JUCE_MSVC | #if JUCE_MSVC | ||||
| #pragma warning (pop) | |||||
| #pragma warning (pop) | |||||
| #endif | #endif | ||||
| #endif // JUCE_SORTEDSET_H_INCLUDED | #endif // JUCE_SORTEDSET_H_INCLUDED | ||||
| @@ -29,9 +29,6 @@ | |||||
| #ifndef JUCE_SPARSESET_H_INCLUDED | #ifndef JUCE_SPARSESET_H_INCLUDED | ||||
| #define JUCE_SPARSESET_H_INCLUDED | #define JUCE_SPARSESET_H_INCLUDED | ||||
| #include "../maths/juce_Range.h" | |||||
| #include "../threads/juce_CriticalSection.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -678,12 +678,12 @@ var var::readFromStream (InputStream& input) | |||||
| case varMarker_Binary: | case varMarker_Binary: | ||||
| { | { | ||||
| MemoryBlock mb (numBytes - 1); | |||||
| MemoryBlock mb ((size_t) numBytes - 1); | |||||
| if (numBytes > 1) | if (numBytes > 1) | ||||
| { | { | ||||
| const int numRead = input.read (mb.getData(), numBytes - 1); | const int numRead = input.read (mb.getData(), numBytes - 1); | ||||
| mb.setSize (numRead); | |||||
| mb.setSize ((size_t) numRead); | |||||
| } | } | ||||
| return var (mb); | return var (mb); | ||||
| @@ -29,15 +29,6 @@ | |||||
| #ifndef JUCE_VARIANT_H_INCLUDED | #ifndef JUCE_VARIANT_H_INCLUDED | ||||
| #define JUCE_VARIANT_H_INCLUDED | #define JUCE_VARIANT_H_INCLUDED | ||||
| #include "../text/juce_Identifier.h" | |||||
| #include "../streams/juce_OutputStream.h" | |||||
| #include "../streams/juce_InputStream.h" | |||||
| #include "../containers/juce_Array.h" | |||||
| #ifndef DOXYGEN | |||||
| class ReferenceCountedObject; | |||||
| class DynamicObject; | |||||
| #endif | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -109,8 +109,8 @@ bool DirectoryIterator::next (bool* const isDirResult, bool* const isHiddenResul | |||||
| matches = (whatToLookFor & File::findFiles) != 0; | matches = (whatToLookFor & File::findFiles) != 0; | ||||
| } | } | ||||
| // if recursive, we're not relying on the OS iterator to do the wildcard match, so do it now.. | |||||
| if (matches && isRecursive) | |||||
| // if we're not relying on the OS iterator to do the wildcard match, do it now.. | |||||
| if (matches && (isRecursive || wildCards.size() > 1)) | |||||
| matches = fileMatches (wildCards, filename); | matches = fileMatches (wildCards, filename); | ||||
| if (matches && (whatToLookFor & File::ignoreHiddenFiles) != 0) | if (matches && (whatToLookFor & File::ignoreHiddenFiles) != 0) | ||||
| @@ -29,9 +29,6 @@ | |||||
| #ifndef JUCE_DIRECTORYITERATOR_H_INCLUDED | #ifndef JUCE_DIRECTORYITERATOR_H_INCLUDED | ||||
| #define JUCE_DIRECTORYITERATOR_H_INCLUDED | #define JUCE_DIRECTORYITERATOR_H_INCLUDED | ||||
| #include "juce_File.h" | |||||
| #include "../memory/juce_ScopedPointer.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -135,13 +132,13 @@ private: | |||||
| private: | private: | ||||
| friend class DirectoryIterator; | friend class DirectoryIterator; | ||||
| friend class ScopedPointer<Pimpl>; | |||||
| friend struct ContainerDeletePolicy<Pimpl>; | |||||
| ScopedPointer<Pimpl> pimpl; | ScopedPointer<Pimpl> pimpl; | ||||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NativeIterator) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NativeIterator) | ||||
| }; | }; | ||||
| friend class ScopedPointer<NativeIterator::Pimpl>; | |||||
| friend struct ContainerDeletePolicy<NativeIterator::Pimpl>; | |||||
| StringArray wildCards; | StringArray wildCards; | ||||
| NativeIterator fileFinder; | NativeIterator fileFinder; | ||||
| String wildCard, path; | String wildCard, path; | ||||
| @@ -150,7 +147,7 @@ private: | |||||
| const int whatToLookFor; | const int whatToLookFor; | ||||
| const bool isRecursive; | const bool isRecursive; | ||||
| bool hasBeenAdvanced; | bool hasBeenAdvanced; | ||||
| ScopedPointer <DirectoryIterator> subIterator; | |||||
| ScopedPointer<DirectoryIterator> subIterator; | |||||
| File currentFile; | File currentFile; | ||||
| static StringArray parseWildcards (const String& pattern); | static StringArray parseWildcards (const String& pattern); | ||||
| @@ -665,7 +665,7 @@ FileInputStream* File::createInputStream() const | |||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| FileOutputStream* File::createOutputStream (const int bufferSize) const | |||||
| FileOutputStream* File::createOutputStream (const size_t bufferSize) const | |||||
| { | { | ||||
| ScopedPointer<FileOutputStream> out (new FileOutputStream (*this, bufferSize)); | ScopedPointer<FileOutputStream> out (new FileOutputStream (*this, bufferSize)); | ||||
| @@ -29,15 +29,6 @@ | |||||
| #ifndef JUCE_FILE_H_INCLUDED | #ifndef JUCE_FILE_H_INCLUDED | ||||
| #define JUCE_FILE_H_INCLUDED | #define JUCE_FILE_H_INCLUDED | ||||
| #include "../containers/juce_Array.h" | |||||
| #include "../time/juce_Time.h" | |||||
| #include "../text/juce_StringArray.h" | |||||
| #include "../memory/juce_MemoryBlock.h" | |||||
| #include "../memory/juce_ScopedPointer.h" | |||||
| #include "../misc/juce_Result.h" | |||||
| class FileInputStream; | |||||
| class FileOutputStream; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -589,7 +580,7 @@ public: | |||||
| end of the file), or nullptr if the file can't be opened for some reason | end of the file), or nullptr if the file can't be opened for some reason | ||||
| @see createInputStream, appendData, appendText | @see createInputStream, appendData, appendText | ||||
| */ | */ | ||||
| FileOutputStream* createOutputStream (int bufferSize = 0x8000) const; | |||||
| FileOutputStream* createOutputStream (size_t bufferSize = 0x8000) const; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Loads a file's contents into memory as a block of binary data. | /** Loads a file's contents into memory as a block of binary data. | ||||
| @@ -771,6 +762,15 @@ public: | |||||
| /** The folder that contains the user's desktop objects. */ | /** The folder that contains the user's desktop objects. */ | ||||
| userDesktopDirectory, | userDesktopDirectory, | ||||
| /** The most likely place where a user might store their music files. */ | |||||
| userMusicDirectory, | |||||
| /** The most likely place where a user might store their movie files. */ | |||||
| userMoviesDirectory, | |||||
| /** The most likely place where a user might store their picture files. */ | |||||
| userPicturesDirectory, | |||||
| /** The folder in which applications store their persistent user-specific settings. | /** The folder in which applications store their persistent user-specific settings. | ||||
| On Windows, this might be "\Documents and Settings\username\Application Data". | On Windows, this might be "\Documents and Settings\username\Application Data". | ||||
| On the Mac, it might be "~/Library". If you're going to store your settings in here, | On the Mac, it might be "~/Library". If you're going to store your settings in here, | ||||
| @@ -788,6 +788,13 @@ public: | |||||
| */ | */ | ||||
| commonApplicationDataDirectory, | commonApplicationDataDirectory, | ||||
| /** A place to put documents which are shared by all users of the machine. | |||||
| On Windows this may be somewhere like "C:\Users\Public\Documents", on OSX it | |||||
| will be something like "/Users/Shared". Other OSes may have no such concept | |||||
| though, so be careful. | |||||
| */ | |||||
| commonDocumentsDirectory, | |||||
| /** The folder that should be used for temporary files. | /** The folder that should be used for temporary files. | ||||
| Always delete them when you're finished, to keep the user's computer tidy! | Always delete them when you're finished, to keep the user's computer tidy! | ||||
| */ | */ | ||||
| @@ -830,16 +837,7 @@ public: | |||||
| So on windows, this would be something like "c:\program files", on the | So on windows, this would be something like "c:\program files", on the | ||||
| Mac "/Applications", or "/usr" on linux. | Mac "/Applications", or "/usr" on linux. | ||||
| */ | */ | ||||
| globalApplicationsDirectory, | |||||
| /** The most likely place where a user might store their music files. */ | |||||
| userMusicDirectory, | |||||
| /** The most likely place where a user might store their movie files. */ | |||||
| userMoviesDirectory, | |||||
| /** The most likely place where a user might store their picture files. */ | |||||
| userPicturesDirectory | |||||
| globalApplicationsDirectory | |||||
| }; | }; | ||||
| /** Finds the location of a special type of file or directory, such as a home folder or | /** Finds the location of a special type of file or directory, such as a home folder or | ||||
| @@ -29,9 +29,6 @@ | |||||
| #ifndef JUCE_FILEINPUTSTREAM_H_INCLUDED | #ifndef JUCE_FILEINPUTSTREAM_H_INCLUDED | ||||
| #define JUCE_FILEINPUTSTREAM_H_INCLUDED | #define JUCE_FILEINPUTSTREAM_H_INCLUDED | ||||
| #include "juce_File.h" | |||||
| #include "../streams/juce_InputStream.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -29,14 +29,14 @@ | |||||
| int64 juce_fileSetPosition (void* handle, int64 pos); | int64 juce_fileSetPosition (void* handle, int64 pos); | ||||
| //============================================================================== | //============================================================================== | ||||
| FileOutputStream::FileOutputStream (const File& f, const int bufferSize_) | |||||
| FileOutputStream::FileOutputStream (const File& f, const size_t bufferSizeToUse) | |||||
| : file (f), | : file (f), | ||||
| fileHandle (nullptr), | fileHandle (nullptr), | ||||
| status (Result::ok()), | status (Result::ok()), | ||||
| currentPosition (0), | currentPosition (0), | ||||
| bufferSize (bufferSize_), | |||||
| bufferSize (bufferSizeToUse), | |||||
| bytesInBuffer (0), | bytesInBuffer (0), | ||||
| buffer ((size_t) jmax (bufferSize_, 16)) | |||||
| buffer (jmax (bufferSizeToUse, (size_t) 16)) | |||||
| { | { | ||||
| openHandle(); | openHandle(); | ||||
| } | } | ||||
| @@ -29,9 +29,6 @@ | |||||
| #ifndef JUCE_FILEOUTPUTSTREAM_H_INCLUDED | #ifndef JUCE_FILEOUTPUTSTREAM_H_INCLUDED | ||||
| #define JUCE_FILEOUTPUTSTREAM_H_INCLUDED | #define JUCE_FILEOUTPUTSTREAM_H_INCLUDED | ||||
| #include "juce_File.h" | |||||
| #include "../streams/juce_OutputStream.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -57,7 +54,7 @@ public: | |||||
| @see TemporaryFile | @see TemporaryFile | ||||
| */ | */ | ||||
| FileOutputStream (const File& fileToWriteTo, | FileOutputStream (const File& fileToWriteTo, | ||||
| int bufferSizeToUse = 16384); | |||||
| size_t bufferSizeToUse = 16384); | |||||
| /** Destructor. */ | /** Destructor. */ | ||||
| ~FileOutputStream(); | ~FileOutputStream(); | ||||
| @@ -26,9 +26,8 @@ | |||||
| ============================================================================== | ============================================================================== | ||||
| */ | */ | ||||
| FileSearchPath::FileSearchPath() | |||||
| { | |||||
| } | |||||
| FileSearchPath::FileSearchPath() {} | |||||
| FileSearchPath::~FileSearchPath() {} | |||||
| FileSearchPath::FileSearchPath (const String& path) | FileSearchPath::FileSearchPath (const String& path) | ||||
| { | { | ||||
| @@ -36,12 +35,14 @@ FileSearchPath::FileSearchPath (const String& path) | |||||
| } | } | ||||
| FileSearchPath::FileSearchPath (const FileSearchPath& other) | FileSearchPath::FileSearchPath (const FileSearchPath& other) | ||||
| : directories (other.directories) | |||||
| : directories (other.directories) | |||||
| { | { | ||||
| } | } | ||||
| FileSearchPath::~FileSearchPath() | |||||
| FileSearchPath& FileSearchPath::operator= (const FileSearchPath& other) | |||||
| { | { | ||||
| directories = other.directories; | |||||
| return *this; | |||||
| } | } | ||||
| FileSearchPath& FileSearchPath::operator= (const String& path) | FileSearchPath& FileSearchPath::operator= (const String& path) | ||||
| @@ -29,13 +29,10 @@ | |||||
| #ifndef JUCE_FILESEARCHPATH_H_INCLUDED | #ifndef JUCE_FILESEARCHPATH_H_INCLUDED | ||||
| #define JUCE_FILESEARCHPATH_H_INCLUDED | #define JUCE_FILESEARCHPATH_H_INCLUDED | ||||
| #include "juce_File.h" | |||||
| #include "../text/juce_StringArray.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| Encapsulates a set of folders that make up a search path. | |||||
| Represents a set of folders that make up a search path. | |||||
| @see File | @see File | ||||
| */ | */ | ||||
| @@ -56,7 +53,10 @@ public: | |||||
| FileSearchPath (const String& path); | FileSearchPath (const String& path); | ||||
| /** Creates a copy of another search path. */ | /** Creates a copy of another search path. */ | ||||
| FileSearchPath (const FileSearchPath& other); | |||||
| FileSearchPath (const FileSearchPath&); | |||||
| /** Copies another search path. */ | |||||
| FileSearchPath& operator= (const FileSearchPath&); | |||||
| /** Destructor. */ | /** Destructor. */ | ||||
| ~FileSearchPath(); | ~FileSearchPath(); | ||||
| @@ -70,15 +70,12 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Returns the number of folders in this search path. | /** Returns the number of folders in this search path. | ||||
| @see operator[] | @see operator[] | ||||
| */ | */ | ||||
| int getNumPaths() const; | int getNumPaths() const; | ||||
| /** Returns one of the folders in this search path. | /** Returns one of the folders in this search path. | ||||
| The file returned isn't guaranteed to actually be a valid directory. | The file returned isn't guaranteed to actually be a valid directory. | ||||
| @see getNumPaths | @see getNumPaths | ||||
| */ | */ | ||||
| File operator[] (int index) const; | File operator[] (int index) const; | ||||
| @@ -102,7 +99,6 @@ public: | |||||
| void remove (int indexToRemove); | void remove (int indexToRemove); | ||||
| /** Merges another search path into this one. | /** Merges another search path into this one. | ||||
| This will remove any duplicate directories. | This will remove any duplicate directories. | ||||
| */ | */ | ||||
| void addPath (const FileSearchPath& other); | void addPath (const FileSearchPath& other); | ||||
| @@ -161,7 +157,7 @@ private: | |||||
| //============================================================================== | //============================================================================== | ||||
| StringArray directories; | StringArray directories; | ||||
| void init (const String& path); | |||||
| void init (const String&); | |||||
| JUCE_LEAK_DETECTOR (FileSearchPath) | JUCE_LEAK_DETECTOR (FileSearchPath) | ||||
| }; | }; | ||||
| @@ -29,7 +29,6 @@ | |||||
| #ifndef JUCE_MEMORYMAPPEDFILE_H_INCLUDED | #ifndef JUCE_MEMORYMAPPEDFILE_H_INCLUDED | ||||
| #define JUCE_MEMORYMAPPEDFILE_H_INCLUDED | #define JUCE_MEMORYMAPPEDFILE_H_INCLUDED | ||||
| #include "juce_File.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -29,8 +29,6 @@ | |||||
| #ifndef JUCE_TEMPORARYFILE_H_INCLUDED | #ifndef JUCE_TEMPORARYFILE_H_INCLUDED | ||||
| #define JUCE_TEMPORARYFILE_H_INCLUDED | #define JUCE_TEMPORARYFILE_H_INCLUDED | ||||
| #include "juce_File.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -316,7 +316,7 @@ private: | |||||
| buffer.appendUTF8Char (c); | buffer.appendUTF8Char (c); | ||||
| } | } | ||||
| result = buffer.toString(); | |||||
| result = buffer.toUTF8(); | |||||
| return Result::ok(); | return Result::ok(); | ||||
| } | } | ||||
| }; | }; | ||||
| @@ -526,7 +526,7 @@ String JSON::toString (const var& data, const bool allOnOneLine) | |||||
| { | { | ||||
| MemoryOutputStream mo (1024); | MemoryOutputStream mo (1024); | ||||
| JSONFormatter::write (mo, data, 0, allOnOneLine); | JSONFormatter::write (mo, data, 0, allOnOneLine); | ||||
| return mo.toString(); | |||||
| return mo.toUTF8(); | |||||
| } | } | ||||
| void JSON::writeToStream (OutputStream& output, const var& data, const bool allOnOneLine) | void JSON::writeToStream (OutputStream& output, const var& data, const bool allOnOneLine) | ||||
| @@ -29,12 +29,6 @@ | |||||
| #ifndef JUCE_JSON_H_INCLUDED | #ifndef JUCE_JSON_H_INCLUDED | ||||
| #define JUCE_JSON_H_INCLUDED | #define JUCE_JSON_H_INCLUDED | ||||
| #include "../misc/juce_Result.h" | |||||
| #include "../containers/juce_Variant.h" | |||||
| class InputStream; | |||||
| class OutputStream; | |||||
| class File; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -125,6 +125,10 @@ | |||||
| //#define JUCE_CATCH_UNHANDLED_EXCEPTIONS 1 | //#define JUCE_CATCH_UNHANDLED_EXCEPTIONS 1 | ||||
| #endif | #endif | ||||
| #ifndef JUCE_STRING_UTF_TYPE | |||||
| #define JUCE_STRING_UTF_TYPE 8 | |||||
| #endif | |||||
| //============================================================================= | //============================================================================= | ||||
| //============================================================================= | //============================================================================= | ||||
| #if JUCE_MSVC | #if JUCE_MSVC | ||||
| @@ -141,108 +145,128 @@ | |||||
| namespace juce | namespace juce | ||||
| { | { | ||||
| // START_AUTOINCLUDE containers, files, json, logging, maths, memory, misc, network, | |||||
| // streams, system, text, threads, time, unit_tests, xml, zip | |||||
| #include "containers/juce_AbstractFifo.h" | |||||
| #include "containers/juce_Array.h" | |||||
| #include "containers/juce_ArrayAllocationBase.h" | |||||
| #include "containers/juce_DynamicObject.h" | |||||
| class MemoryBlock; | |||||
| class File; | |||||
| class InputStream; | |||||
| class OutputStream; | |||||
| class DynamicObject; | |||||
| class FileInputStream; | |||||
| class FileOutputStream; | |||||
| class XmlElement; | |||||
| class JSONFormatter; | |||||
| extern JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger(); | |||||
| extern JUCE_API void JUCE_CALLTYPE logAssertion (const char* file, int line) noexcept; | |||||
| #include "memory/juce_Memory.h" | |||||
| #include "maths/juce_MathsFunctions.h" | |||||
| #include "memory/juce_ByteOrder.h" | |||||
| #include "memory/juce_Atomic.h" | |||||
| #include "text/juce_CharacterFunctions.h" | |||||
| #if JUCE_MSVC | |||||
| #pragma warning (push) | |||||
| #pragma warning (disable: 4514 4996) | |||||
| #endif | |||||
| #include "text/juce_CharPointer_UTF8.h" | |||||
| #include "text/juce_CharPointer_UTF16.h" | |||||
| #include "text/juce_CharPointer_UTF32.h" | |||||
| #include "text/juce_CharPointer_ASCII.h" | |||||
| #if JUCE_MSVC | |||||
| #pragma warning (pop) | |||||
| #endif | |||||
| #include "text/juce_String.h" | |||||
| #include "logging/juce_Logger.h" | |||||
| #include "memory/juce_LeakedObjectDetector.h" | |||||
| #include "memory/juce_ContainerDeletePolicy.h" | |||||
| #include "memory/juce_HeapBlock.h" | |||||
| #include "memory/juce_MemoryBlock.h" | |||||
| #include "memory/juce_ReferenceCountedObject.h" | |||||
| #include "memory/juce_ScopedPointer.h" | |||||
| #include "memory/juce_OptionalScopedPointer.h" | |||||
| #include "memory/juce_Singleton.h" | |||||
| #include "memory/juce_WeakReference.h" | |||||
| #include "threads/juce_ScopedLock.h" | |||||
| #include "threads/juce_CriticalSection.h" | |||||
| #include "maths/juce_Range.h" | |||||
| #include "containers/juce_ElementComparator.h" | #include "containers/juce_ElementComparator.h" | ||||
| #include "containers/juce_HashMap.h" | |||||
| #include "containers/juce_ArrayAllocationBase.h" | |||||
| #include "containers/juce_Array.h" | |||||
| #include "containers/juce_LinkedListPointer.h" | #include "containers/juce_LinkedListPointer.h" | ||||
| #include "containers/juce_NamedValueSet.h" | |||||
| #include "containers/juce_OwnedArray.h" | #include "containers/juce_OwnedArray.h" | ||||
| #include "containers/juce_PropertySet.h" | |||||
| #include "containers/juce_ReferenceCountedArray.h" | #include "containers/juce_ReferenceCountedArray.h" | ||||
| #include "containers/juce_ScopedValueSetter.h" | #include "containers/juce_ScopedValueSetter.h" | ||||
| #include "containers/juce_SortedSet.h" | #include "containers/juce_SortedSet.h" | ||||
| #include "containers/juce_SparseSet.h" | #include "containers/juce_SparseSet.h" | ||||
| #include "containers/juce_AbstractFifo.h" | |||||
| #include "text/juce_NewLine.h" | |||||
| #include "text/juce_StringPool.h" | |||||
| #include "text/juce_Identifier.h" | |||||
| #include "text/juce_StringArray.h" | |||||
| #include "text/juce_StringPairArray.h" | |||||
| #include "text/juce_TextDiff.h" | |||||
| #include "text/juce_LocalisedStrings.h" | |||||
| #include "misc/juce_Result.h" | |||||
| #include "containers/juce_Variant.h" | #include "containers/juce_Variant.h" | ||||
| #include "files/juce_DirectoryIterator.h" | |||||
| #include "containers/juce_NamedValueSet.h" | |||||
| #include "containers/juce_DynamicObject.h" | |||||
| #include "containers/juce_HashMap.h" | |||||
| #include "time/juce_RelativeTime.h" | |||||
| #include "time/juce_Time.h" | |||||
| #include "streams/juce_InputStream.h" | |||||
| #include "streams/juce_OutputStream.h" | |||||
| #include "streams/juce_BufferedInputStream.h" | |||||
| #include "streams/juce_MemoryInputStream.h" | |||||
| #include "streams/juce_MemoryOutputStream.h" | |||||
| #include "streams/juce_SubregionStream.h" | |||||
| #include "streams/juce_InputSource.h" | |||||
| #include "files/juce_File.h" | #include "files/juce_File.h" | ||||
| #include "files/juce_DirectoryIterator.h" | |||||
| #include "files/juce_FileInputStream.h" | #include "files/juce_FileInputStream.h" | ||||
| #include "files/juce_FileOutputStream.h" | #include "files/juce_FileOutputStream.h" | ||||
| #include "files/juce_FileSearchPath.h" | #include "files/juce_FileSearchPath.h" | ||||
| #include "files/juce_MemoryMappedFile.h" | #include "files/juce_MemoryMappedFile.h" | ||||
| #include "files/juce_TemporaryFile.h" | #include "files/juce_TemporaryFile.h" | ||||
| #include "json/juce_JSON.h" | |||||
| #include "streams/juce_FileInputSource.h" | |||||
| #include "logging/juce_FileLogger.h" | #include "logging/juce_FileLogger.h" | ||||
| #include "logging/juce_Logger.h" | |||||
| #include "json/juce_JSON.h" | |||||
| #include "maths/juce_BigInteger.h" | #include "maths/juce_BigInteger.h" | ||||
| #include "maths/juce_Expression.h" | #include "maths/juce_Expression.h" | ||||
| #include "maths/juce_MathsFunctions.h" | |||||
| #include "maths/juce_Random.h" | #include "maths/juce_Random.h" | ||||
| #include "maths/juce_Range.h" | |||||
| #include "memory/juce_Atomic.h" | |||||
| #include "memory/juce_ByteOrder.h" | |||||
| #include "memory/juce_HeapBlock.h" | |||||
| #include "memory/juce_LeakedObjectDetector.h" | |||||
| #include "memory/juce_Memory.h" | |||||
| #include "memory/juce_MemoryBlock.h" | |||||
| #include "memory/juce_OptionalScopedPointer.h" | |||||
| #include "memory/juce_ReferenceCountedObject.h" | |||||
| #include "memory/juce_ScopedPointer.h" | |||||
| #include "memory/juce_Singleton.h" | |||||
| #include "memory/juce_WeakReference.h" | |||||
| #include "misc/juce_Result.h" | |||||
| #include "misc/juce_Uuid.h" | #include "misc/juce_Uuid.h" | ||||
| #include "misc/juce_WindowsRegistry.h" | #include "misc/juce_WindowsRegistry.h" | ||||
| #include "network/juce_IPAddress.h" | |||||
| #include "network/juce_MACAddress.h" | |||||
| #include "network/juce_NamedPipe.h" | |||||
| #include "network/juce_Socket.h" | |||||
| #include "network/juce_URL.h" | |||||
| #include "streams/juce_BufferedInputStream.h" | |||||
| #include "streams/juce_FileInputSource.h" | |||||
| #include "streams/juce_InputSource.h" | |||||
| #include "streams/juce_InputStream.h" | |||||
| #include "streams/juce_MemoryInputStream.h" | |||||
| #include "streams/juce_MemoryOutputStream.h" | |||||
| #include "streams/juce_OutputStream.h" | |||||
| #include "streams/juce_SubregionStream.h" | |||||
| #include "system/juce_PlatformDefs.h" | #include "system/juce_PlatformDefs.h" | ||||
| #include "system/juce_StandardHeader.h" | |||||
| #include "system/juce_SystemStats.h" | #include "system/juce_SystemStats.h" | ||||
| #include "system/juce_TargetPlatform.h" | |||||
| #include "text/juce_CharacterFunctions.h" | |||||
| #include "text/juce_CharPointer_ASCII.h" | |||||
| #include "text/juce_CharPointer_UTF16.h" | |||||
| #include "text/juce_CharPointer_UTF32.h" | |||||
| #include "text/juce_CharPointer_UTF8.h" | |||||
| #include "text/juce_Identifier.h" | |||||
| #include "text/juce_LocalisedStrings.h" | |||||
| #include "text/juce_NewLine.h" | |||||
| #include "text/juce_String.h" | |||||
| #include "text/juce_StringArray.h" | |||||
| #include "text/juce_StringPairArray.h" | |||||
| #include "text/juce_StringPool.h" | |||||
| #include "text/juce_TextDiff.h" | |||||
| #include "threads/juce_ChildProcess.h" | #include "threads/juce_ChildProcess.h" | ||||
| #include "threads/juce_CriticalSection.h" | |||||
| #include "threads/juce_DynamicLibrary.h" | #include "threads/juce_DynamicLibrary.h" | ||||
| #include "threads/juce_HighResolutionTimer.h" | #include "threads/juce_HighResolutionTimer.h" | ||||
| #include "threads/juce_InterProcessLock.h" | #include "threads/juce_InterProcessLock.h" | ||||
| #include "threads/juce_Process.h" | #include "threads/juce_Process.h" | ||||
| #include "threads/juce_ReadWriteLock.h" | |||||
| #include "threads/juce_ScopedLock.h" | |||||
| #include "threads/juce_ScopedReadLock.h" | |||||
| #include "threads/juce_ScopedWriteLock.h" | |||||
| #include "threads/juce_SpinLock.h" | #include "threads/juce_SpinLock.h" | ||||
| #include "threads/juce_WaitableEvent.h" | |||||
| #include "threads/juce_Thread.h" | #include "threads/juce_Thread.h" | ||||
| #include "threads/juce_ThreadLocalValue.h" | #include "threads/juce_ThreadLocalValue.h" | ||||
| #include "threads/juce_ThreadPool.h" | #include "threads/juce_ThreadPool.h" | ||||
| #include "threads/juce_TimeSliceThread.h" | #include "threads/juce_TimeSliceThread.h" | ||||
| #include "threads/juce_WaitableEvent.h" | |||||
| #include "threads/juce_ReadWriteLock.h" | |||||
| #include "threads/juce_ScopedReadLock.h" | |||||
| #include "threads/juce_ScopedWriteLock.h" | |||||
| #include "network/juce_IPAddress.h" | |||||
| #include "network/juce_MACAddress.h" | |||||
| #include "network/juce_NamedPipe.h" | |||||
| #include "network/juce_Socket.h" | |||||
| #include "network/juce_URL.h" | |||||
| #include "time/juce_PerformanceCounter.h" | #include "time/juce_PerformanceCounter.h" | ||||
| #include "time/juce_RelativeTime.h" | |||||
| #include "time/juce_Time.h" | |||||
| #include "unit_tests/juce_UnitTest.h" | #include "unit_tests/juce_UnitTest.h" | ||||
| #include "xml/juce_XmlDocument.h" | #include "xml/juce_XmlDocument.h" | ||||
| #include "xml/juce_XmlElement.h" | #include "xml/juce_XmlElement.h" | ||||
| #include "zip/juce_GZIPCompressorOutputStream.h" | #include "zip/juce_GZIPCompressorOutputStream.h" | ||||
| #include "zip/juce_GZIPDecompressorInputStream.h" | #include "zip/juce_GZIPDecompressorInputStream.h" | ||||
| #include "zip/juce_ZipFile.h" | #include "zip/juce_ZipFile.h" | ||||
| // END_AUTOINCLUDE | |||||
| #include "containers/juce_PropertySet.h" | |||||
| } | } | ||||
| @@ -29,10 +29,6 @@ | |||||
| #ifndef JUCE_FILELOGGER_H_INCLUDED | #ifndef JUCE_FILELOGGER_H_INCLUDED | ||||
| #define JUCE_FILELOGGER_H_INCLUDED | #define JUCE_FILELOGGER_H_INCLUDED | ||||
| #include "juce_Logger.h" | |||||
| #include "../files/juce_File.h" | |||||
| #include "../memory/juce_ScopedPointer.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -29,8 +29,6 @@ | |||||
| #ifndef JUCE_LOGGER_H_INCLUDED | #ifndef JUCE_LOGGER_H_INCLUDED | ||||
| #define JUCE_LOGGER_H_INCLUDED | #define JUCE_LOGGER_H_INCLUDED | ||||
| #include "../text/juce_String.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -956,7 +956,9 @@ String BigInteger::toString (const int base, const int minimumNumCharacters) con | |||||
| void BigInteger::parseString (const String& text, const int base) | void BigInteger::parseString (const String& text, const int base) | ||||
| { | { | ||||
| clear(); | clear(); | ||||
| String::CharPointerType t (text.getCharPointer()); | |||||
| String::CharPointerType t (text.getCharPointer().findEndOfWhitespace()); | |||||
| setNegative (*t == (juce_wchar) '-'); | |||||
| if (base == 2 || base == 8 || base == 16) | if (base == 2 || base == 8 || base == 16) | ||||
| { | { | ||||
| @@ -997,8 +999,6 @@ void BigInteger::parseString (const String& text, const int base) | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| setNegative (text.trimStart().startsWithChar ('-')); | |||||
| } | } | ||||
| MemoryBlock BigInteger::toMemoryBlock() const | MemoryBlock BigInteger::toMemoryBlock() const | ||||
| @@ -29,10 +29,6 @@ | |||||
| #ifndef JUCE_BIGINTEGER_H_INCLUDED | #ifndef JUCE_BIGINTEGER_H_INCLUDED | ||||
| #define JUCE_BIGINTEGER_H_INCLUDED | #define JUCE_BIGINTEGER_H_INCLUDED | ||||
| #include "../text/juce_String.h" | |||||
| #include "../memory/juce_HeapBlock.h" | |||||
| class MemoryBlock; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -29,10 +29,6 @@ | |||||
| #ifndef JUCE_EXPRESSION_H_INCLUDED | #ifndef JUCE_EXPRESSION_H_INCLUDED | ||||
| #define JUCE_EXPRESSION_H_INCLUDED | #define JUCE_EXPRESSION_H_INCLUDED | ||||
| #include "../memory/juce_ReferenceCountedObject.h" | |||||
| #include "../containers/juce_Array.h" | |||||
| #include "../memory/juce_ScopedPointer.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -264,7 +260,7 @@ private: | |||||
| struct Helpers; | struct Helpers; | ||||
| friend class Term; | friend class Term; | ||||
| friend struct Helpers; | friend struct Helpers; | ||||
| friend class ScopedPointer<Term>; | |||||
| friend struct ContainerDeletePolicy<Term>; | |||||
| friend class ReferenceCountedObjectPtr<Term>; | friend class ReferenceCountedObjectPtr<Term>; | ||||
| ReferenceCountedObjectPtr<Term> term; | ReferenceCountedObjectPtr<Term> term; | ||||
| @@ -443,6 +443,13 @@ IntegerType negativeAwareModulo (IntegerType dividend, const IntegerType divisor | |||||
| return (dividend < 0) ? (dividend + divisor) : dividend; | return (dividend < 0) ? (dividend + divisor) : dividend; | ||||
| } | } | ||||
| /** Returns the square of its argument. */ | |||||
| template <typename NumericType> | |||||
| NumericType square (NumericType n) noexcept | |||||
| { | |||||
| return n * n; | |||||
| } | |||||
| //============================================================================== | //============================================================================== | ||||
| #if (JUCE_INTEL && JUCE_32BIT) || defined (DOXYGEN) | #if (JUCE_INTEL && JUCE_32BIT) || defined (DOXYGEN) | ||||
| /** This macro can be applied to a float variable to check whether it contains a denormalised | /** This macro can be applied to a float variable to check whether it contains a denormalised | ||||
| @@ -29,8 +29,6 @@ | |||||
| #ifndef JUCE_RANDOM_H_INCLUDED | #ifndef JUCE_RANDOM_H_INCLUDED | ||||
| #define JUCE_RANDOM_H_INCLUDED | #define JUCE_RANDOM_H_INCLUDED | ||||
| #include "juce_BigInteger.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -39,65 +39,71 @@ class JUCE_API ByteOrder | |||||
| public: | public: | ||||
| //============================================================================== | //============================================================================== | ||||
| /** Swaps the upper and lower bytes of a 16-bit integer. */ | /** Swaps the upper and lower bytes of a 16-bit integer. */ | ||||
| static uint16 swap (uint16 value); | |||||
| static uint16 swap (uint16 value) noexcept; | |||||
| /** Reverses the order of the 4 bytes in a 32-bit integer. */ | /** Reverses the order of the 4 bytes in a 32-bit integer. */ | ||||
| static uint32 swap (uint32 value); | |||||
| static uint32 swap (uint32 value) noexcept; | |||||
| /** Reverses the order of the 8 bytes in a 64-bit integer. */ | /** Reverses the order of the 8 bytes in a 64-bit integer. */ | ||||
| static uint64 swap (uint64 value); | |||||
| static uint64 swap (uint64 value) noexcept; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Swaps the byte order of a 16-bit int if the CPU is big-endian */ | /** Swaps the byte order of a 16-bit int if the CPU is big-endian */ | ||||
| static uint16 swapIfBigEndian (uint16 value); | |||||
| static uint16 swapIfBigEndian (uint16 value) noexcept; | |||||
| /** Swaps the byte order of a 32-bit int if the CPU is big-endian */ | /** Swaps the byte order of a 32-bit int if the CPU is big-endian */ | ||||
| static uint32 swapIfBigEndian (uint32 value); | |||||
| static uint32 swapIfBigEndian (uint32 value) noexcept; | |||||
| /** Swaps the byte order of a 64-bit int if the CPU is big-endian */ | /** Swaps the byte order of a 64-bit int if the CPU is big-endian */ | ||||
| static uint64 swapIfBigEndian (uint64 value); | |||||
| static uint64 swapIfBigEndian (uint64 value) noexcept; | |||||
| /** Swaps the byte order of a 16-bit int if the CPU is little-endian */ | /** Swaps the byte order of a 16-bit int if the CPU is little-endian */ | ||||
| static uint16 swapIfLittleEndian (uint16 value); | |||||
| static uint16 swapIfLittleEndian (uint16 value) noexcept; | |||||
| /** Swaps the byte order of a 32-bit int if the CPU is little-endian */ | /** Swaps the byte order of a 32-bit int if the CPU is little-endian */ | ||||
| static uint32 swapIfLittleEndian (uint32 value); | |||||
| static uint32 swapIfLittleEndian (uint32 value) noexcept; | |||||
| /** Swaps the byte order of a 64-bit int if the CPU is little-endian */ | /** Swaps the byte order of a 64-bit int if the CPU is little-endian */ | ||||
| static uint64 swapIfLittleEndian (uint64 value); | |||||
| static uint64 swapIfLittleEndian (uint64 value) noexcept; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Turns 4 bytes into a little-endian integer. */ | /** Turns 4 bytes into a little-endian integer. */ | ||||
| static uint32 littleEndianInt (const void* bytes); | |||||
| static uint32 littleEndianInt (const void* bytes) noexcept; | |||||
| /** Turns 8 bytes into a little-endian integer. */ | |||||
| static uint64 littleEndianInt64 (const void* bytes) noexcept; | |||||
| /** Turns 2 bytes into a little-endian integer. */ | /** Turns 2 bytes into a little-endian integer. */ | ||||
| static uint16 littleEndianShort (const void* bytes); | |||||
| static uint16 littleEndianShort (const void* bytes) noexcept; | |||||
| /** Turns 4 bytes into a big-endian integer. */ | /** Turns 4 bytes into a big-endian integer. */ | ||||
| static uint32 bigEndianInt (const void* bytes); | |||||
| static uint32 bigEndianInt (const void* bytes) noexcept; | |||||
| /** Turns 8 bytes into a big-endian integer. */ | |||||
| static uint64 bigEndianInt64 (const void* bytes) noexcept; | |||||
| /** Turns 2 bytes into a big-endian integer. */ | /** Turns 2 bytes into a big-endian integer. */ | ||||
| static uint16 bigEndianShort (const void* bytes); | |||||
| static uint16 bigEndianShort (const void* bytes) noexcept; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Converts 3 little-endian bytes into a signed 24-bit value (which is sign-extended to 32 bits). */ | /** Converts 3 little-endian bytes into a signed 24-bit value (which is sign-extended to 32 bits). */ | ||||
| static int littleEndian24Bit (const char* bytes); | |||||
| static int littleEndian24Bit (const char* bytes) noexcept; | |||||
| /** Converts 3 big-endian bytes into a signed 24-bit value (which is sign-extended to 32 bits). */ | /** Converts 3 big-endian bytes into a signed 24-bit value (which is sign-extended to 32 bits). */ | ||||
| static int bigEndian24Bit (const char* bytes); | |||||
| static int bigEndian24Bit (const char* bytes) noexcept; | |||||
| /** Copies a 24-bit number to 3 little-endian bytes. */ | /** Copies a 24-bit number to 3 little-endian bytes. */ | ||||
| static void littleEndian24BitToChars (int value, char* destBytes); | |||||
| static void littleEndian24BitToChars (int value, char* destBytes) noexcept; | |||||
| /** Copies a 24-bit number to 3 big-endian bytes. */ | /** Copies a 24-bit number to 3 big-endian bytes. */ | ||||
| static void bigEndian24BitToChars (int value, char* destBytes); | |||||
| static void bigEndian24BitToChars (int value, char* destBytes) noexcept; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Returns true if the current CPU is big-endian. */ | /** Returns true if the current CPU is big-endian. */ | ||||
| static bool isBigEndian(); | |||||
| static bool isBigEndian() noexcept; | |||||
| private: | private: | ||||
| ByteOrder(); | |||||
| ByteOrder() JUCE_DELETED_FUNCTION; | |||||
| JUCE_DECLARE_NON_COPYABLE (ByteOrder) | JUCE_DECLARE_NON_COPYABLE (ByteOrder) | ||||
| }; | }; | ||||
| @@ -108,7 +114,7 @@ private: | |||||
| #pragma intrinsic (_byteswap_ulong) | #pragma intrinsic (_byteswap_ulong) | ||||
| #endif | #endif | ||||
| inline uint16 ByteOrder::swap (uint16 n) | |||||
| inline uint16 ByteOrder::swap (uint16 n) noexcept | |||||
| { | { | ||||
| #if JUCE_USE_INTRINSICSxxx // agh - the MS compiler has an internal error when you try to use this intrinsic! | #if JUCE_USE_INTRINSICSxxx // agh - the MS compiler has an internal error when you try to use this intrinsic! | ||||
| return static_cast <uint16> (_byteswap_ushort (n)); | return static_cast <uint16> (_byteswap_ushort (n)); | ||||
| @@ -117,7 +123,7 @@ inline uint16 ByteOrder::swap (uint16 n) | |||||
| #endif | #endif | ||||
| } | } | ||||
| inline uint32 ByteOrder::swap (uint32 n) | |||||
| inline uint32 ByteOrder::swap (uint32 n) noexcept | |||||
| { | { | ||||
| #if JUCE_MAC || JUCE_IOS | #if JUCE_MAC || JUCE_IOS | ||||
| return OSSwapInt32 (n); | return OSSwapInt32 (n); | ||||
| @@ -140,7 +146,7 @@ inline uint32 ByteOrder::swap (uint32 n) | |||||
| #endif | #endif | ||||
| } | } | ||||
| inline uint64 ByteOrder::swap (uint64 value) | |||||
| inline uint64 ByteOrder::swap (uint64 value) noexcept | |||||
| { | { | ||||
| #if JUCE_MAC || JUCE_IOS | #if JUCE_MAC || JUCE_IOS | ||||
| return OSSwapInt64 (value); | return OSSwapInt64 (value); | ||||
| @@ -152,35 +158,39 @@ inline uint64 ByteOrder::swap (uint64 value) | |||||
| } | } | ||||
| #if JUCE_LITTLE_ENDIAN | #if JUCE_LITTLE_ENDIAN | ||||
| inline uint16 ByteOrder::swapIfBigEndian (const uint16 v) { return v; } | |||||
| inline uint32 ByteOrder::swapIfBigEndian (const uint32 v) { return v; } | |||||
| inline uint64 ByteOrder::swapIfBigEndian (const uint64 v) { return v; } | |||||
| inline uint16 ByteOrder::swapIfLittleEndian (const uint16 v) { return swap (v); } | |||||
| inline uint32 ByteOrder::swapIfLittleEndian (const uint32 v) { return swap (v); } | |||||
| inline uint64 ByteOrder::swapIfLittleEndian (const uint64 v) { return swap (v); } | |||||
| inline uint32 ByteOrder::littleEndianInt (const void* const bytes) { return *static_cast <const uint32*> (bytes); } | |||||
| inline uint16 ByteOrder::littleEndianShort (const void* const bytes) { return *static_cast <const uint16*> (bytes); } | |||||
| inline uint32 ByteOrder::bigEndianInt (const void* const bytes) { return swap (*static_cast <const uint32*> (bytes)); } | |||||
| inline uint16 ByteOrder::bigEndianShort (const void* const bytes) { return swap (*static_cast <const uint16*> (bytes)); } | |||||
| inline bool ByteOrder::isBigEndian() { return false; } | |||||
| inline uint16 ByteOrder::swapIfBigEndian (const uint16 v) noexcept { return v; } | |||||
| inline uint32 ByteOrder::swapIfBigEndian (const uint32 v) noexcept { return v; } | |||||
| inline uint64 ByteOrder::swapIfBigEndian (const uint64 v) noexcept { return v; } | |||||
| inline uint16 ByteOrder::swapIfLittleEndian (const uint16 v) noexcept { return swap (v); } | |||||
| inline uint32 ByteOrder::swapIfLittleEndian (const uint32 v) noexcept { return swap (v); } | |||||
| inline uint64 ByteOrder::swapIfLittleEndian (const uint64 v) noexcept { return swap (v); } | |||||
| inline uint32 ByteOrder::littleEndianInt (const void* const bytes) noexcept { return *static_cast <const uint32*> (bytes); } | |||||
| inline uint64 ByteOrder::littleEndianInt64 (const void* const bytes) noexcept { return *static_cast <const uint64*> (bytes); } | |||||
| inline uint16 ByteOrder::littleEndianShort (const void* const bytes) noexcept { return *static_cast <const uint16*> (bytes); } | |||||
| inline uint32 ByteOrder::bigEndianInt (const void* const bytes) noexcept { return swap (*static_cast <const uint32*> (bytes)); } | |||||
| inline uint64 ByteOrder::bigEndianInt64 (const void* const bytes) noexcept { return swap (*static_cast <const uint64*> (bytes)); } | |||||
| inline uint16 ByteOrder::bigEndianShort (const void* const bytes) noexcept { return swap (*static_cast <const uint16*> (bytes)); } | |||||
| inline bool ByteOrder::isBigEndian() noexcept { return false; } | |||||
| #else | #else | ||||
| inline uint16 ByteOrder::swapIfBigEndian (const uint16 v) { return swap (v); } | |||||
| inline uint32 ByteOrder::swapIfBigEndian (const uint32 v) { return swap (v); } | |||||
| inline uint64 ByteOrder::swapIfBigEndian (const uint64 v) { return swap (v); } | |||||
| inline uint16 ByteOrder::swapIfLittleEndian (const uint16 v) { return v; } | |||||
| inline uint32 ByteOrder::swapIfLittleEndian (const uint32 v) { return v; } | |||||
| inline uint64 ByteOrder::swapIfLittleEndian (const uint64 v) { return v; } | |||||
| inline uint32 ByteOrder::littleEndianInt (const void* const bytes) { return swap (*static_cast <const uint32*> (bytes)); } | |||||
| inline uint16 ByteOrder::littleEndianShort (const void* const bytes) { return swap (*static_cast <const uint16*> (bytes)); } | |||||
| inline uint32 ByteOrder::bigEndianInt (const void* const bytes) { return *static_cast <const uint32*> (bytes); } | |||||
| inline uint16 ByteOrder::bigEndianShort (const void* const bytes) { return *static_cast <const uint16*> (bytes); } | |||||
| inline bool ByteOrder::isBigEndian() { return true; } | |||||
| inline uint16 ByteOrder::swapIfBigEndian (const uint16 v) noexcept { return swap (v); } | |||||
| inline uint32 ByteOrder::swapIfBigEndian (const uint32 v) noexcept { return swap (v); } | |||||
| inline uint64 ByteOrder::swapIfBigEndian (const uint64 v) noexcept { return swap (v); } | |||||
| inline uint16 ByteOrder::swapIfLittleEndian (const uint16 v) noexcept { return v; } | |||||
| inline uint32 ByteOrder::swapIfLittleEndian (const uint32 v) noexcept { return v; } | |||||
| inline uint64 ByteOrder::swapIfLittleEndian (const uint64 v) noexcept { return v; } | |||||
| inline uint32 ByteOrder::littleEndianInt (const void* const bytes) noexcept { return swap (*static_cast <const uint32*> (bytes)); } | |||||
| inline uint64 ByteOrder::littleEndianInt64 (const void* const bytes) noexcept { return swap (*static_cast <const uint64*> (bytes)); } | |||||
| inline uint16 ByteOrder::littleEndianShort (const void* const bytes) noexcept { return swap (*static_cast <const uint16*> (bytes)); } | |||||
| inline uint32 ByteOrder::bigEndianInt (const void* const bytes) noexcept { return *static_cast <const uint32*> (bytes); } | |||||
| inline uint64 ByteOrder::bigEndianInt64 (const void* const bytes) noexcept { return *static_cast <const uint64*> (bytes); } | |||||
| inline uint16 ByteOrder::bigEndianShort (const void* const bytes) noexcept { return *static_cast <const uint16*> (bytes); } | |||||
| inline bool ByteOrder::isBigEndian() noexcept { return true; } | |||||
| #endif | #endif | ||||
| inline int ByteOrder::littleEndian24Bit (const char* const bytes) { return (((int) bytes[2]) << 16) | (((int) (uint8) bytes[1]) << 8) | ((int) (uint8) bytes[0]); } | |||||
| inline int ByteOrder::bigEndian24Bit (const char* const bytes) { return (((int) bytes[0]) << 16) | (((int) (uint8) bytes[1]) << 8) | ((int) (uint8) bytes[2]); } | |||||
| inline void ByteOrder::littleEndian24BitToChars (const int value, char* const destBytes) { destBytes[0] = (char)(value & 0xff); destBytes[1] = (char)((value >> 8) & 0xff); destBytes[2] = (char)((value >> 16) & 0xff); } | |||||
| inline void ByteOrder::bigEndian24BitToChars (const int value, char* const destBytes) { destBytes[0] = (char)((value >> 16) & 0xff); destBytes[1] = (char)((value >> 8) & 0xff); destBytes[2] = (char)(value & 0xff); } | |||||
| inline int ByteOrder::littleEndian24Bit (const char* const bytes) noexcept { return (((int) bytes[2]) << 16) | (((int) (uint8) bytes[1]) << 8) | ((int) (uint8) bytes[0]); } | |||||
| inline int ByteOrder::bigEndian24Bit (const char* const bytes) noexcept { return (((int) bytes[0]) << 16) | (((int) (uint8) bytes[1]) << 8) | ((int) (uint8) bytes[2]); } | |||||
| inline void ByteOrder::littleEndian24BitToChars (const int value, char* const destBytes) noexcept { destBytes[0] = (char)(value & 0xff); destBytes[1] = (char)((value >> 8) & 0xff); destBytes[2] = (char)((value >> 16) & 0xff); } | |||||
| inline void ByteOrder::bigEndian24BitToChars (const int value, char* const destBytes) noexcept { destBytes[0] = (char)((value >> 16) & 0xff); destBytes[1] = (char)((value >> 8) & 0xff); destBytes[2] = (char)(value & 0xff); } | |||||
| #endif // JUCE_BYTEORDER_H_INCLUDED | #endif // JUCE_BYTEORDER_H_INCLUDED | ||||
| @@ -0,0 +1,53 @@ | |||||
| /* | |||||
| ============================================================================== | |||||
| This file is part of the juce_core module of the JUCE library. | |||||
| Copyright (c) 2013 - Raw Material Software Ltd. | |||||
| Permission to use, copy, modify, and/or distribute this software for any purpose with | |||||
| or without fee is hereby granted, provided that the above copyright notice and this | |||||
| permission notice appear in all copies. | |||||
| THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||||
| TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||||
| NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||||
| DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||||
| IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||||
| CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||||
| ------------------------------------------------------------------------------ | |||||
| NOTE! This permissive ISC license applies ONLY to files within the juce_core module! | |||||
| All other JUCE modules are covered by a dual GPL/commercial license, so if you are | |||||
| using any other modules, be sure to check that you also comply with their license. | |||||
| For more details, visit www.juce.com | |||||
| ============================================================================== | |||||
| */ | |||||
| #ifndef JUCE_CONTAINERDELETEPOLICY_H_INCLUDED | |||||
| #define JUCE_CONTAINERDELETEPOLICY_H_INCLUDED | |||||
| //============================================================================== | |||||
| /** | |||||
| Used by container classes as an indirect way to delete an object of a | |||||
| particular type. | |||||
| The generic implementation of this class simply calls 'delete', but you can | |||||
| create a specialised version of it for a particular class if you need to | |||||
| delete that type of object in a more appropriate way. | |||||
| @see ScopedPointer, OwnedArray | |||||
| */ | |||||
| template <typename ObjectType> | |||||
| struct ContainerDeletePolicy | |||||
| { | |||||
| static void destroy (ObjectType* object) | |||||
| { | |||||
| delete object; | |||||
| } | |||||
| }; | |||||
| #endif // JUCE_CONTAINERDELETEPOLICY_H_INCLUDED | |||||
| @@ -29,9 +29,6 @@ | |||||
| #ifndef JUCE_LEAKEDOBJECTDETECTOR_H_INCLUDED | #ifndef JUCE_LEAKEDOBJECTDETECTOR_H_INCLUDED | ||||
| #define JUCE_LEAKEDOBJECTDETECTOR_H_INCLUDED | #define JUCE_LEAKEDOBJECTDETECTOR_H_INCLUDED | ||||
| #include "../text/juce_String.h" | |||||
| #include "juce_Atomic.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -88,14 +88,14 @@ MemoryBlock& MemoryBlock::operator= (const MemoryBlock& other) | |||||
| #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS | #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS | ||||
| MemoryBlock::MemoryBlock (MemoryBlock&& other) noexcept | MemoryBlock::MemoryBlock (MemoryBlock&& other) noexcept | ||||
| : data (static_cast <HeapBlock <char>&&> (other.data)), | |||||
| : data (static_cast <HeapBlock<char>&&> (other.data)), | |||||
| size (other.size) | size (other.size) | ||||
| { | { | ||||
| } | } | ||||
| MemoryBlock& MemoryBlock::operator= (MemoryBlock&& other) noexcept | MemoryBlock& MemoryBlock::operator= (MemoryBlock&& other) noexcept | ||||
| { | { | ||||
| data = static_cast <HeapBlock <char>&&> (other.data); | |||||
| data = static_cast <HeapBlock<char>&&> (other.data); | |||||
| size = other.size; | size = other.size; | ||||
| return *this; | return *this; | ||||
| } | } | ||||
| @@ -229,12 +229,12 @@ void MemoryBlock::copyFrom (const void* const src, int offset, size_t num) noexc | |||||
| if (offset < 0) | if (offset < 0) | ||||
| { | { | ||||
| d -= offset; | d -= offset; | ||||
| num -= offset; | |||||
| num += (size_t) -offset; | |||||
| offset = 0; | offset = 0; | ||||
| } | } | ||||
| if (offset + num > size) | |||||
| num = size - offset; | |||||
| if ((size_t) offset + num > size) | |||||
| num = size - (size_t) offset; | |||||
| if (num > 0) | if (num > 0) | ||||
| memcpy (data + offset, d, num); | memcpy (data + offset, d, num); | ||||
| @@ -248,14 +248,13 @@ void MemoryBlock::copyTo (void* const dst, int offset, size_t num) const noexcep | |||||
| { | { | ||||
| zeromem (d, (size_t) -offset); | zeromem (d, (size_t) -offset); | ||||
| d -= offset; | d -= offset; | ||||
| num += offset; | |||||
| num -= (size_t) -offset; | |||||
| offset = 0; | offset = 0; | ||||
| } | } | ||||
| if (offset + num > size) | |||||
| if ((size_t) offset + num > size) | |||||
| { | { | ||||
| const size_t newNum = size - offset; | |||||
| const size_t newNum = size - (size_t) offset; | |||||
| zeromem (d + newNum, num - newNum); | zeromem (d + newNum, num - newNum); | ||||
| num = newNum; | num = newNum; | ||||
| } | } | ||||
| @@ -275,12 +274,12 @@ int MemoryBlock::getBitRange (const size_t bitRangeStart, size_t numBits) const | |||||
| int res = 0; | int res = 0; | ||||
| size_t byte = bitRangeStart >> 3; | size_t byte = bitRangeStart >> 3; | ||||
| int offsetInByte = (int) bitRangeStart & 7; | |||||
| size_t offsetInByte = bitRangeStart & 7; | |||||
| size_t bitsSoFar = 0; | size_t bitsSoFar = 0; | ||||
| while (numBits > 0 && (size_t) byte < size) | while (numBits > 0 && (size_t) byte < size) | ||||
| { | { | ||||
| const int bitsThisTime = jmin ((int) numBits, 8 - offsetInByte); | |||||
| const size_t bitsThisTime = jmin (numBits, 8 - offsetInByte); | |||||
| const int mask = (0xff >> (8 - bitsThisTime)) << offsetInByte; | const int mask = (0xff >> (8 - bitsThisTime)) << offsetInByte; | ||||
| res |= (((data[byte] & mask) >> offsetInByte) << bitsSoFar); | res |= (((data[byte] & mask) >> offsetInByte) << bitsSoFar); | ||||
| @@ -297,17 +296,17 @@ int MemoryBlock::getBitRange (const size_t bitRangeStart, size_t numBits) const | |||||
| void MemoryBlock::setBitRange (const size_t bitRangeStart, size_t numBits, int bitsToSet) noexcept | void MemoryBlock::setBitRange (const size_t bitRangeStart, size_t numBits, int bitsToSet) noexcept | ||||
| { | { | ||||
| size_t byte = bitRangeStart >> 3; | size_t byte = bitRangeStart >> 3; | ||||
| int offsetInByte = (int) bitRangeStart & 7; | |||||
| unsigned int mask = ~((((unsigned int) 0xffffffff) << (32 - numBits)) >> (32 - numBits)); | |||||
| size_t offsetInByte = bitRangeStart & 7; | |||||
| uint32 mask = ~((((uint32) 0xffffffff) << (32 - numBits)) >> (32 - numBits)); | |||||
| while (numBits > 0 && (size_t) byte < size) | while (numBits > 0 && (size_t) byte < size) | ||||
| { | { | ||||
| const int bitsThisTime = jmin ((int) numBits, 8 - offsetInByte); | |||||
| const size_t bitsThisTime = jmin (numBits, 8 - offsetInByte); | |||||
| const unsigned int tempMask = (mask << offsetInByte) | ~((((unsigned int) 0xffffffff) >> offsetInByte) << offsetInByte); | |||||
| const unsigned int tempBits = (unsigned int) bitsToSet << offsetInByte; | |||||
| const uint32 tempMask = (mask << offsetInByte) | ~((((uint32) 0xffffffff) >> offsetInByte) << offsetInByte); | |||||
| const uint32 tempBits = (uint32) bitsToSet << offsetInByte; | |||||
| data[byte] = (char) ((data[byte] & tempMask) | tempBits); | |||||
| data[byte] = (char) (((uint32) data[byte] & tempMask) | tempBits); | |||||
| ++byte; | ++byte; | ||||
| numBits -= bitsThisTime; | numBits -= bitsThisTime; | ||||
| @@ -336,22 +335,11 @@ void MemoryBlock::loadFromHexString (const String& hex) | |||||
| { | { | ||||
| const juce_wchar c = t.getAndAdvance(); | const juce_wchar c = t.getAndAdvance(); | ||||
| if (c >= '0' && c <= '9') | |||||
| { | |||||
| byte |= c - '0'; | |||||
| break; | |||||
| } | |||||
| else if (c >= 'a' && c <= 'z') | |||||
| { | |||||
| byte |= c - ('a' - 10); | |||||
| break; | |||||
| } | |||||
| else if (c >= 'A' && c <= 'Z') | |||||
| { | |||||
| byte |= c - ('A' - 10); | |||||
| break; | |||||
| } | |||||
| else if (c == 0) | |||||
| if (c >= '0' && c <= '9') { byte |= c - '0'; break; } | |||||
| if (c >= 'a' && c <= 'z') { byte |= c - ('a' - 10); break; } | |||||
| if (c >= 'A' && c <= 'Z') { byte |= c - ('A' - 10); break; } | |||||
| if (c == 0) | |||||
| { | { | ||||
| setSize (static_cast <size_t> (dest - data)); | setSize (static_cast <size_t> (dest - data)); | ||||
| return; | return; | ||||
| @@ -364,7 +352,7 @@ void MemoryBlock::loadFromHexString (const String& hex) | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| const char* const MemoryBlock::encodingTable = ".ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+"; | |||||
| static const char* const base64EncodingTable = ".ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+"; | |||||
| String MemoryBlock::toBase64Encoding() const | String MemoryBlock::toBase64Encoding() const | ||||
| { | { | ||||
| @@ -372,14 +360,14 @@ String MemoryBlock::toBase64Encoding() const | |||||
| String destString ((unsigned int) size); // store the length, followed by a '.', and then the data. | String destString ((unsigned int) size); // store the length, followed by a '.', and then the data. | ||||
| const int initialLen = destString.length(); | const int initialLen = destString.length(); | ||||
| destString.preallocateBytes (sizeof (String::CharPointerType::CharType) * (size_t) (initialLen + 2 + numChars)); | |||||
| destString.preallocateBytes (sizeof (String::CharPointerType::CharType) * (size_t) initialLen + 2 + numChars); | |||||
| String::CharPointerType d (destString.getCharPointer()); | String::CharPointerType d (destString.getCharPointer()); | ||||
| d += initialLen; | d += initialLen; | ||||
| d.write ('.'); | d.write ('.'); | ||||
| for (size_t i = 0; i < numChars; ++i) | for (size_t i = 0; i < numChars; ++i) | ||||
| d.write ((juce_wchar) (uint8) encodingTable [getBitRange (i * 6, 6)]); | |||||
| d.write ((juce_wchar) (uint8) base64EncodingTable [getBitRange (i * 6, 6)]); | |||||
| d.writeNull(); | d.writeNull(); | ||||
| return destString; | return destString; | ||||
| @@ -408,7 +396,7 @@ bool MemoryBlock::fromBase64Encoding (const String& s) | |||||
| for (int j = 0; j < 64; ++j) | for (int j = 0; j < 64; ++j) | ||||
| { | { | ||||
| if (encodingTable[j] == c) | |||||
| if (base64EncodingTable[j] == c) | |||||
| { | { | ||||
| setBitRange ((size_t) pos, 6, j); | setBitRange ((size_t) pos, 6, j); | ||||
| pos += 6; | pos += 6; | ||||
| @@ -29,9 +29,6 @@ | |||||
| #ifndef JUCE_MEMORYBLOCK_H_INCLUDED | #ifndef JUCE_MEMORYBLOCK_H_INCLUDED | ||||
| #define JUCE_MEMORYBLOCK_H_INCLUDED | #define JUCE_MEMORYBLOCK_H_INCLUDED | ||||
| #include "../text/juce_String.h" | |||||
| #include "../memory/juce_HeapBlock.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -54,7 +51,7 @@ public: | |||||
| bool initialiseToZero = false); | bool initialiseToZero = false); | ||||
| /** Creates a copy of another memory block. */ | /** Creates a copy of another memory block. */ | ||||
| MemoryBlock (const MemoryBlock& other); | |||||
| MemoryBlock (const MemoryBlock&); | |||||
| /** Creates a memory block using a copy of a block of data. | /** Creates a memory block using a copy of a block of data. | ||||
| @@ -67,31 +64,27 @@ public: | |||||
| ~MemoryBlock() noexcept; | ~MemoryBlock() noexcept; | ||||
| /** Copies another memory block onto this one. | /** Copies another memory block onto this one. | ||||
| This block will be resized and copied to exactly match the other one. | This block will be resized and copied to exactly match the other one. | ||||
| */ | */ | ||||
| MemoryBlock& operator= (const MemoryBlock& other); | |||||
| MemoryBlock& operator= (const MemoryBlock&); | |||||
| #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS | #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS | ||||
| MemoryBlock (MemoryBlock&& other) noexcept; | |||||
| MemoryBlock& operator= (MemoryBlock&& other) noexcept; | |||||
| MemoryBlock (MemoryBlock&&) noexcept; | |||||
| MemoryBlock& operator= (MemoryBlock&&) noexcept; | |||||
| #endif | #endif | ||||
| //============================================================================== | //============================================================================== | ||||
| /** Compares two memory blocks. | /** Compares two memory blocks. | ||||
| @returns true only if the two blocks are the same size and have identical contents. | @returns true only if the two blocks are the same size and have identical contents. | ||||
| */ | */ | ||||
| bool operator== (const MemoryBlock& other) const noexcept; | bool operator== (const MemoryBlock& other) const noexcept; | ||||
| /** Compares two memory blocks. | /** Compares two memory blocks. | ||||
| @returns true if the two blocks are different sizes or have different contents. | @returns true if the two blocks are different sizes or have different contents. | ||||
| */ | */ | ||||
| bool operator!= (const MemoryBlock& other) const noexcept; | bool operator!= (const MemoryBlock& other) const noexcept; | ||||
| /** Returns true if the data in this MemoryBlock matches the raw bytes passed-in. | |||||
| */ | |||||
| /** Returns true if the data in this MemoryBlock matches the raw bytes passed-in. */ | |||||
| bool matches (const void* data, size_t dataSize) const noexcept; | bool matches (const void* data, size_t dataSize) const noexcept; | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -103,7 +96,6 @@ public: | |||||
| void* getData() const noexcept { return data; } | void* getData() const noexcept { return data; } | ||||
| /** Returns a byte from the memory block. | /** Returns a byte from the memory block. | ||||
| This returns a reference, so you can also use it to set a byte. | This returns a reference, so you can also use it to set a byte. | ||||
| */ | */ | ||||
| template <typename Type> | template <typename Type> | ||||
| @@ -143,7 +135,6 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Fills the entire memory block with a repeated byte value. | /** Fills the entire memory block with a repeated byte value. | ||||
| This is handy for clearing a block of memory to zero. | This is handy for clearing a block of memory to zero. | ||||
| */ | */ | ||||
| void fillWith (uint8 valueToUse) noexcept; | void fillWith (uint8 valueToUse) noexcept; | ||||
| @@ -249,9 +240,8 @@ public: | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| HeapBlock <char> data; | |||||
| HeapBlock<char> data; | |||||
| size_t size; | size_t size; | ||||
| static const char* const encodingTable; | |||||
| JUCE_LEAK_DETECTOR (MemoryBlock) | JUCE_LEAK_DETECTOR (MemoryBlock) | ||||
| }; | }; | ||||
| @@ -29,8 +29,6 @@ | |||||
| #ifndef JUCE_OPTIONALSCOPEDPOINTER_H_INCLUDED | #ifndef JUCE_OPTIONALSCOPEDPOINTER_H_INCLUDED | ||||
| #define JUCE_OPTIONALSCOPEDPOINTER_H_INCLUDED | #define JUCE_OPTIONALSCOPEDPOINTER_H_INCLUDED | ||||
| #include "juce_ScopedPointer.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -29,12 +29,10 @@ | |||||
| #ifndef JUCE_REFERENCECOUNTEDOBJECT_H_INCLUDED | #ifndef JUCE_REFERENCECOUNTEDOBJECT_H_INCLUDED | ||||
| #define JUCE_REFERENCECOUNTEDOBJECT_H_INCLUDED | #define JUCE_REFERENCECOUNTEDOBJECT_H_INCLUDED | ||||
| #include "juce_Atomic.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| Adds reference-counting to an object. | |||||
| A base class which provides methods for reference-counting. | |||||
| To add reference-counting to a class, derive it from this class, and | To add reference-counting to a class, derive it from this class, and | ||||
| use the ReferenceCountedObjectPtr class to point to it. | use the ReferenceCountedObjectPtr class to point to it. | ||||
| @@ -73,16 +71,15 @@ public: | |||||
| This is done automatically by the smart pointer, but is public just | This is done automatically by the smart pointer, but is public just | ||||
| in case it's needed for nefarious purposes. | in case it's needed for nefarious purposes. | ||||
| */ | */ | ||||
| inline void incReferenceCount() noexcept | |||||
| void incReferenceCount() noexcept | |||||
| { | { | ||||
| ++refCount; | ++refCount; | ||||
| } | } | ||||
| /** Decreases the object's reference count. | /** Decreases the object's reference count. | ||||
| If the count gets to zero, the object will be deleted. | If the count gets to zero, the object will be deleted. | ||||
| */ | */ | ||||
| inline void decReferenceCount() noexcept | |||||
| void decReferenceCount() noexcept | |||||
| { | { | ||||
| jassert (getReferenceCount() > 0); | jassert (getReferenceCount() > 0); | ||||
| @@ -90,16 +87,24 @@ public: | |||||
| delete this; | delete this; | ||||
| } | } | ||||
| /** Decreases the object's reference count. | |||||
| If the count gets to zero, the object will not be deleted, but this method | |||||
| will return true, allowing the caller to take care of deletion. | |||||
| */ | |||||
| bool decReferenceCountWithoutDeleting() noexcept | |||||
| { | |||||
| jassert (getReferenceCount() > 0); | |||||
| return --refCount == 0; | |||||
| } | |||||
| /** Returns the object's current reference count. */ | /** Returns the object's current reference count. */ | ||||
| inline int getReferenceCount() const noexcept { return refCount.get(); } | |||||
| int getReferenceCount() const noexcept { return refCount.get(); } | |||||
| protected: | protected: | ||||
| //============================================================================== | //============================================================================== | ||||
| /** Creates the reference-counted object (with an initial ref count of zero). */ | /** Creates the reference-counted object (with an initial ref count of zero). */ | ||||
| ReferenceCountedObject() | |||||
| { | |||||
| } | |||||
| ReferenceCountedObject() {} | |||||
| /** Destructor. */ | /** Destructor. */ | ||||
| virtual ~ReferenceCountedObject() | virtual ~ReferenceCountedObject() | ||||
| @@ -120,6 +125,7 @@ private: | |||||
| //============================================================================== | //============================================================================== | ||||
| Atomic <int> refCount; | Atomic <int> refCount; | ||||
| friend struct ContainerDeletePolicy<ReferenceCountedObject>; | |||||
| JUCE_DECLARE_NON_COPYABLE (ReferenceCountedObject) | JUCE_DECLARE_NON_COPYABLE (ReferenceCountedObject) | ||||
| }; | }; | ||||
| @@ -144,16 +150,15 @@ public: | |||||
| This is done automatically by the smart pointer, but is public just | This is done automatically by the smart pointer, but is public just | ||||
| in case it's needed for nefarious purposes. | in case it's needed for nefarious purposes. | ||||
| */ | */ | ||||
| inline void incReferenceCount() noexcept | |||||
| void incReferenceCount() noexcept | |||||
| { | { | ||||
| ++refCount; | ++refCount; | ||||
| } | } | ||||
| /** Decreases the object's reference count. | /** Decreases the object's reference count. | ||||
| If the count gets to zero, the object will be deleted. | If the count gets to zero, the object will be deleted. | ||||
| */ | */ | ||||
| inline void decReferenceCount() noexcept | |||||
| void decReferenceCount() noexcept | |||||
| { | { | ||||
| jassert (getReferenceCount() > 0); | jassert (getReferenceCount() > 0); | ||||
| @@ -161,8 +166,18 @@ public: | |||||
| delete this; | delete this; | ||||
| } | } | ||||
| /** Decreases the object's reference count. | |||||
| If the count gets to zero, the object will not be deleted, but this method | |||||
| will return true, allowing the caller to take care of deletion. | |||||
| */ | |||||
| bool decReferenceCountWithoutDeleting() noexcept | |||||
| { | |||||
| jassert (getReferenceCount() > 0); | |||||
| return --refCount == 0; | |||||
| } | |||||
| /** Returns the object's current reference count. */ | /** Returns the object's current reference count. */ | ||||
| inline int getReferenceCount() const noexcept { return refCount; } | |||||
| int getReferenceCount() const noexcept { return refCount; } | |||||
| protected: | protected: | ||||
| @@ -181,6 +196,7 @@ private: | |||||
| //============================================================================== | //============================================================================== | ||||
| int refCount; | int refCount; | ||||
| friend struct ContainerDeletePolicy<ReferenceCountedObject>; | |||||
| JUCE_DECLARE_NON_COPYABLE (SingleThreadedReferenceCountedObject) | JUCE_DECLARE_NON_COPYABLE (SingleThreadedReferenceCountedObject) | ||||
| }; | }; | ||||
| @@ -190,13 +206,20 @@ private: | |||||
| A smart-pointer class which points to a reference-counted object. | A smart-pointer class which points to a reference-counted object. | ||||
| The template parameter specifies the class of the object you want to point to - the easiest | The template parameter specifies the class of the object you want to point to - the easiest | ||||
| way to make a class reference-countable is to simply make it inherit from ReferenceCountedObject, | |||||
| but if you need to, you could roll your own reference-countable class by implementing a pair of | |||||
| mathods called incReferenceCount() and decReferenceCount(). | |||||
| way to make a class reference-countable is to simply make it inherit from ReferenceCountedObject | |||||
| or SingleThreadedReferenceCountedObject, but if you need to, you can roll your own reference-countable | |||||
| class by implementing a set of mathods called incReferenceCount(), decReferenceCount(), and | |||||
| decReferenceCountWithoutDeleting(). See ReferenceCountedObject for examples of how these methods | |||||
| should behave. | |||||
| When using this class, you'll probably want to create a typedef to abbreviate the full | When using this class, you'll probably want to create a typedef to abbreviate the full | ||||
| templated name - e.g. | templated name - e.g. | ||||
| @code typedef ReferenceCountedObjectPtr<MyClass> MyClassPtr;@endcode | |||||
| @code | |||||
| struct MyClass : public ReferenceCountedObject | |||||
| { | |||||
| typedef ReferenceCountedObjectPtr<MyClass> Ptr; | |||||
| ... | |||||
| @endcode | |||||
| @see ReferenceCountedObject, ReferenceCountedObjectArray | @see ReferenceCountedObject, ReferenceCountedObjectArray | ||||
| */ | */ | ||||
| @@ -209,54 +232,40 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Creates a pointer to a null object. */ | /** Creates a pointer to a null object. */ | ||||
| inline ReferenceCountedObjectPtr() noexcept | |||||
| ReferenceCountedObjectPtr() noexcept | |||||
| : referencedObject (nullptr) | : referencedObject (nullptr) | ||||
| { | { | ||||
| } | } | ||||
| /** Creates a pointer to an object. | /** Creates a pointer to an object. | ||||
| This will increment the object's reference-count if it is non-null. | |||||
| This will increment the object's reference-count. | |||||
| */ | */ | ||||
| inline ReferenceCountedObjectPtr (ReferenceCountedObjectClass* const refCountedObject) noexcept | |||||
| ReferenceCountedObjectPtr (ReferencedType* refCountedObject) noexcept | |||||
| : referencedObject (refCountedObject) | : referencedObject (refCountedObject) | ||||
| { | { | ||||
| if (refCountedObject != nullptr) | |||||
| refCountedObject->incReferenceCount(); | |||||
| incIfNotNull (refCountedObject); | |||||
| } | } | ||||
| /** Copies another pointer. | /** Copies another pointer. | ||||
| This will increment the object's reference-count (if it is non-null). | |||||
| This will increment the object's reference-count. | |||||
| */ | */ | ||||
| inline ReferenceCountedObjectPtr (const ReferenceCountedObjectPtr& other) noexcept | |||||
| : referencedObject (other.referencedObject) | |||||
| { | |||||
| if (referencedObject != nullptr) | |||||
| referencedObject->incReferenceCount(); | |||||
| } | |||||
| #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS | |||||
| /** Takes-over the object from another pointer. */ | |||||
| inline ReferenceCountedObjectPtr (ReferenceCountedObjectPtr&& other) noexcept | |||||
| ReferenceCountedObjectPtr (const ReferenceCountedObjectPtr& other) noexcept | |||||
| : referencedObject (other.referencedObject) | : referencedObject (other.referencedObject) | ||||
| { | { | ||||
| other.referencedObject = nullptr; | |||||
| incIfNotNull (referencedObject); | |||||
| } | } | ||||
| #endif | |||||
| /** Copies another pointer. | /** Copies another pointer. | ||||
| This will increment the object's reference-count (if it is non-null). | This will increment the object's reference-count (if it is non-null). | ||||
| */ | */ | ||||
| template <class DerivedClass> | |||||
| inline ReferenceCountedObjectPtr (const ReferenceCountedObjectPtr<DerivedClass>& other) noexcept | |||||
| : referencedObject (static_cast <ReferenceCountedObjectClass*> (other.get())) | |||||
| template <class Convertible> | |||||
| ReferenceCountedObjectPtr (const ReferenceCountedObjectPtr<Convertible>& other) noexcept | |||||
| : referencedObject (static_cast <ReferencedType*> (other.get())) | |||||
| { | { | ||||
| if (referencedObject != nullptr) | |||||
| referencedObject->incReferenceCount(); | |||||
| incIfNotNull (referencedObject); | |||||
| } | } | ||||
| /** Changes this pointer to point at a different object. | /** Changes this pointer to point at a different object. | ||||
| The reference count of the old object is decremented, and it might be | The reference count of the old object is decremented, and it might be | ||||
| deleted if it hits zero. The new object's count is incremented. | deleted if it hits zero. The new object's count is incremented. | ||||
| */ | */ | ||||
| @@ -266,94 +275,100 @@ public: | |||||
| } | } | ||||
| /** Changes this pointer to point at a different object. | /** Changes this pointer to point at a different object. | ||||
| The reference count of the old object is decremented, and it might be | The reference count of the old object is decremented, and it might be | ||||
| deleted if it hits zero. The new object's count is incremented. | deleted if it hits zero. The new object's count is incremented. | ||||
| */ | */ | ||||
| template <class DerivedClass> | |||||
| ReferenceCountedObjectPtr& operator= (const ReferenceCountedObjectPtr<DerivedClass>& other) | |||||
| template <class Convertible> | |||||
| ReferenceCountedObjectPtr& operator= (const ReferenceCountedObjectPtr<Convertible>& other) | |||||
| { | { | ||||
| return operator= (static_cast <ReferenceCountedObjectClass*> (other.get())); | |||||
| return operator= (static_cast<ReferencedType*> (other.get())); | |||||
| } | } | ||||
| #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS | |||||
| /** Takes-over the object from another pointer. */ | |||||
| ReferenceCountedObjectPtr& operator= (ReferenceCountedObjectPtr&& other) | |||||
| { | |||||
| std::swap (referencedObject, other.referencedObject); | |||||
| return *this; | |||||
| } | |||||
| #endif | |||||
| /** Changes this pointer to point at a different object. | /** Changes this pointer to point at a different object. | ||||
| The reference count of the old object is decremented, and it might be | The reference count of the old object is decremented, and it might be | ||||
| deleted if it hits zero. The new object's count is incremented. | deleted if it hits zero. The new object's count is incremented. | ||||
| */ | */ | ||||
| ReferenceCountedObjectPtr& operator= (ReferenceCountedObjectClass* const newObject) | |||||
| ReferenceCountedObjectPtr& operator= (ReferencedType* const newObject) | |||||
| { | { | ||||
| if (referencedObject != newObject) | if (referencedObject != newObject) | ||||
| { | { | ||||
| if (newObject != nullptr) | |||||
| newObject->incReferenceCount(); | |||||
| ReferenceCountedObjectClass* const oldObject = referencedObject; | |||||
| incIfNotNull (newObject); | |||||
| ReferencedType* const oldObject = referencedObject; | |||||
| referencedObject = newObject; | referencedObject = newObject; | ||||
| if (oldObject != nullptr) | |||||
| oldObject->decReferenceCount(); | |||||
| decIfNotNull (oldObject); | |||||
| } | } | ||||
| return *this; | return *this; | ||||
| } | } | ||||
| /** Destructor. | |||||
| This will decrement the object's reference-count, and may delete it if it | |||||
| gets to zero. | |||||
| */ | |||||
| inline ~ReferenceCountedObjectPtr() | |||||
| #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS | |||||
| /** Takes-over the object from another pointer. */ | |||||
| ReferenceCountedObjectPtr (ReferenceCountedObjectPtr&& other) noexcept | |||||
| : referencedObject (other.referencedObject) | |||||
| { | { | ||||
| if (referencedObject != nullptr) | |||||
| referencedObject->decReferenceCount(); | |||||
| other.referencedObject = nullptr; | |||||
| } | } | ||||
| /** Returns the object that this pointer references. | |||||
| The pointer returned may be zero, of course. | |||||
| */ | |||||
| inline operator ReferenceCountedObjectClass*() const noexcept | |||||
| /** Takes-over the object from another pointer. */ | |||||
| ReferenceCountedObjectPtr& operator= (ReferenceCountedObjectPtr&& other) | |||||
| { | { | ||||
| return referencedObject; | |||||
| std::swap (referencedObject, other.referencedObject); | |||||
| return *this; | |||||
| } | } | ||||
| #endif | |||||
| // the -> operator is called on the referenced object | |||||
| inline ReferenceCountedObjectClass* operator->() const noexcept | |||||
| /** Destructor. | |||||
| This will decrement the object's reference-count, which will cause the | |||||
| object to be deleted when the ref-count hits zero. | |||||
| */ | |||||
| ~ReferenceCountedObjectPtr() | |||||
| { | { | ||||
| return referencedObject; | |||||
| decIfNotNull (referencedObject); | |||||
| } | } | ||||
| //============================================================================== | |||||
| /** Returns the object that this pointer references. | /** Returns the object that this pointer references. | ||||
| The pointer returned may be zero, of course. | The pointer returned may be zero, of course. | ||||
| */ | */ | ||||
| inline ReferenceCountedObjectClass* get() const noexcept | |||||
| { | |||||
| return referencedObject; | |||||
| } | |||||
| operator ReferencedType*() const noexcept { return referencedObject; } | |||||
| /** Returns the object that this pointer references. | |||||
| The pointer returned may be zero, of course. | |||||
| */ | |||||
| ReferencedType* get() const noexcept { return referencedObject; } | |||||
| /** Returns the object that this pointer references. | /** Returns the object that this pointer references. | ||||
| The pointer returned may be zero, of course. | The pointer returned may be zero, of course. | ||||
| */ | */ | ||||
| inline ReferenceCountedObjectClass* getObject() const noexcept | |||||
| ReferencedType* getObject() const noexcept { return referencedObject; } | |||||
| // the -> operator is called on the referenced object | |||||
| ReferencedType* operator->() const noexcept | |||||
| { | { | ||||
| jassert (referencedObject != nullptr); // null pointer method call! | |||||
| return referencedObject; | return referencedObject; | ||||
| } | } | ||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| ReferenceCountedObjectClass* referencedObject; | |||||
| ReferencedType* referencedObject; | |||||
| static void incIfNotNull (ReferencedType* o) noexcept | |||||
| { | |||||
| if (o != nullptr) | |||||
| o->incReferenceCount(); | |||||
| } | |||||
| static void decIfNotNull (ReferencedType* o) noexcept | |||||
| { | |||||
| if (o != nullptr && o->decReferenceCountWithoutDeleting()) | |||||
| ContainerDeletePolicy<ReferencedType>::destroy (o); | |||||
| } | |||||
| }; | }; | ||||
| //============================================================================== | |||||
| /** Compares two ReferenceCountedObjectPointers. */ | /** Compares two ReferenceCountedObjectPointers. */ | ||||
| template <class ReferenceCountedObjectClass> | template <class ReferenceCountedObjectClass> | ||||
| bool operator== (const ReferenceCountedObjectPtr<ReferenceCountedObjectClass>& object1, ReferenceCountedObjectClass* const object2) noexcept | bool operator== (const ReferenceCountedObjectPtr<ReferenceCountedObjectClass>& object1, ReferenceCountedObjectClass* const object2) noexcept | ||||
| @@ -370,7 +385,7 @@ bool operator== (const ReferenceCountedObjectPtr<ReferenceCountedObjectClass>& o | |||||
| /** Compares two ReferenceCountedObjectPointers. */ | /** Compares two ReferenceCountedObjectPointers. */ | ||||
| template <class ReferenceCountedObjectClass> | template <class ReferenceCountedObjectClass> | ||||
| bool operator== (ReferenceCountedObjectClass* object1, ReferenceCountedObjectPtr<ReferenceCountedObjectClass>& object2) noexcept | |||||
| bool operator== (ReferenceCountedObjectClass* object1, const ReferenceCountedObjectPtr<ReferenceCountedObjectClass>& object2) noexcept | |||||
| { | { | ||||
| return object1 == object2.get(); | return object1 == object2.get(); | ||||
| } | } | ||||
| @@ -384,14 +399,14 @@ bool operator!= (const ReferenceCountedObjectPtr<ReferenceCountedObjectClass>& o | |||||
| /** Compares two ReferenceCountedObjectPointers. */ | /** Compares two ReferenceCountedObjectPointers. */ | ||||
| template <class ReferenceCountedObjectClass> | template <class ReferenceCountedObjectClass> | ||||
| bool operator!= (const ReferenceCountedObjectPtr<ReferenceCountedObjectClass>& object1, ReferenceCountedObjectPtr<ReferenceCountedObjectClass>& object2) noexcept | |||||
| bool operator!= (const ReferenceCountedObjectPtr<ReferenceCountedObjectClass>& object1, const ReferenceCountedObjectPtr<ReferenceCountedObjectClass>& object2) noexcept | |||||
| { | { | ||||
| return object1.get() != object2.get(); | return object1.get() != object2.get(); | ||||
| } | } | ||||
| /** Compares two ReferenceCountedObjectPointers. */ | /** Compares two ReferenceCountedObjectPointers. */ | ||||
| template <class ReferenceCountedObjectClass> | template <class ReferenceCountedObjectClass> | ||||
| bool operator!= (ReferenceCountedObjectClass* object1, ReferenceCountedObjectPtr<ReferenceCountedObjectClass>& object2) noexcept | |||||
| bool operator!= (ReferenceCountedObjectClass* object1, const ReferenceCountedObjectPtr<ReferenceCountedObjectClass>& object2) noexcept | |||||
| { | { | ||||
| return object1 != object2.get(); | return object1 != object2.get(); | ||||
| } | } | ||||
| @@ -97,7 +97,7 @@ public: | |||||
| /** Destructor. | /** Destructor. | ||||
| This will delete the object that this ScopedPointer currently refers to. | This will delete the object that this ScopedPointer currently refers to. | ||||
| */ | */ | ||||
| inline ~ScopedPointer() { delete object; } | |||||
| inline ~ScopedPointer() { ContainerDeletePolicy<ObjectType>::destroy (object); } | |||||
| /** Changes this ScopedPointer to point to a new object. | /** Changes this ScopedPointer to point to a new object. | ||||
| @@ -119,7 +119,7 @@ public: | |||||
| ObjectType* const oldObject = object; | ObjectType* const oldObject = object; | ||||
| object = objectToTransferFrom.object; | object = objectToTransferFrom.object; | ||||
| objectToTransferFrom.object = nullptr; | objectToTransferFrom.object = nullptr; | ||||
| delete oldObject; | |||||
| ContainerDeletePolicy<ObjectType>::destroy (oldObject); | |||||
| } | } | ||||
| return *this; | return *this; | ||||
| @@ -138,7 +138,7 @@ public: | |||||
| { | { | ||||
| ObjectType* const oldObject = object; | ObjectType* const oldObject = object; | ||||
| object = newObjectToTakePossessionOf; | object = newObjectToTakePossessionOf; | ||||
| delete oldObject; | |||||
| ContainerDeletePolicy<ObjectType>::destroy (oldObject); | |||||
| } | } | ||||
| return *this; | return *this; | ||||
| @@ -29,8 +29,6 @@ | |||||
| #ifndef JUCE_WEAKREFERENCE_H_INCLUDED | #ifndef JUCE_WEAKREFERENCE_H_INCLUDED | ||||
| #define JUCE_WEAKREFERENCE_H_INCLUDED | #define JUCE_WEAKREFERENCE_H_INCLUDED | ||||
| #include "juce_ReferenceCountedObject.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -29,8 +29,6 @@ | |||||
| #ifndef JUCE_RESULT_H_INCLUDED | #ifndef JUCE_RESULT_H_INCLUDED | ||||
| #define JUCE_RESULT_H_INCLUDED | #define JUCE_RESULT_H_INCLUDED | ||||
| #include "../text/juce_String.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -29,8 +29,6 @@ | |||||
| #ifndef JUCE_UUID_H_INCLUDED | #ifndef JUCE_UUID_H_INCLUDED | ||||
| #define JUCE_UUID_H_INCLUDED | #define JUCE_UUID_H_INCLUDED | ||||
| #include "../text/juce_String.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -38,65 +38,69 @@ | |||||
| class WindowsRegistry | class WindowsRegistry | ||||
| { | { | ||||
| public: | public: | ||||
| /** These values can be used to specify whether the 32- or 64-bit registry should be used. | |||||
| When running on a 32-bit OS, there is no 64-bit registry, so the mode will be ignored. | |||||
| */ | |||||
| enum WoW64Mode | |||||
| { | |||||
| /** Default handling: 32-bit apps will use the 32-bit registry, and 64-bit apps | |||||
| will use the 64-bit registry. */ | |||||
| WoW64_Default = 0, | |||||
| /** Always use the 64-bit registry store. (KEY_WOW64_64KEY). */ | |||||
| WoW64_64bit = 0x100, | |||||
| /** Always use the 32-bit registry store. (KEY_WOW64_32KEY). */ | |||||
| WoW64_32bit = 0x200 | |||||
| }; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Returns a string from the registry. | /** Returns a string from the registry. | ||||
| The path is a string for the entire path of a value in the registry, | The path is a string for the entire path of a value in the registry, | ||||
| e.g. "HKEY_CURRENT_USER\Software\foo\bar" | e.g. "HKEY_CURRENT_USER\Software\foo\bar" | ||||
| */ | */ | ||||
| static String getValue (const String& regValuePath, | static String getValue (const String& regValuePath, | ||||
| const String& defaultValue = String::empty); | |||||
| /** Returns a string from the WOW64 registry. | |||||
| The path is a string for the entire path of a value in the registry, | |||||
| e.g. "HKEY_CURRENT_USER\Software\foo\bar" | |||||
| */ | |||||
| static String getValueWow64 (const String& regValuePath, | |||||
| const String& defaultValue = String::empty); | |||||
| const String& defaultValue = String::empty, | |||||
| WoW64Mode mode = WoW64_Default); | |||||
| /** Reads a binary block from the registry. | /** Reads a binary block from the registry. | ||||
| The path is a string for the entire path of a value in the registry, | The path is a string for the entire path of a value in the registry, | ||||
| e.g. "HKEY_CURRENT_USER\Software\foo\bar" | e.g. "HKEY_CURRENT_USER\Software\foo\bar" | ||||
| @returns a DWORD indicating the type of the key. | @returns a DWORD indicating the type of the key. | ||||
| */ | */ | ||||
| static uint32 getBinaryValue (const String& regValuePath, MemoryBlock& resultData); | |||||
| static uint32 getBinaryValue (const String& regValuePath, MemoryBlock& resultData, WoW64Mode mode = WoW64_Default); | |||||
| /** Sets a registry value as a string. | /** Sets a registry value as a string. | ||||
| This will take care of creating any groups needed to get to the given registry value. | This will take care of creating any groups needed to get to the given registry value. | ||||
| */ | */ | ||||
| static bool setValue (const String& regValuePath, const String& value); | |||||
| static bool setValue (const String& regValuePath, const String& value, WoW64Mode mode = WoW64_Default); | |||||
| /** Sets a registry value as a DWORD. | /** Sets a registry value as a DWORD. | ||||
| This will take care of creating any groups needed to get to the given registry value. | This will take care of creating any groups needed to get to the given registry value. | ||||
| */ | */ | ||||
| static bool setValue (const String& regValuePath, uint32 value); | |||||
| static bool setValue (const String& regValuePath, uint32 value, WoW64Mode mode = WoW64_Default); | |||||
| /** Sets a registry value as a QWORD. | /** Sets a registry value as a QWORD. | ||||
| This will take care of creating any groups needed to get to the given registry value. | This will take care of creating any groups needed to get to the given registry value. | ||||
| */ | */ | ||||
| static bool setValue (const String& regValuePath, uint64 value); | |||||
| static bool setValue (const String& regValuePath, uint64 value, WoW64Mode mode = WoW64_Default); | |||||
| /** Sets a registry value as a binary block. | /** Sets a registry value as a binary block. | ||||
| This will take care of creating any groups needed to get to the given registry value. | This will take care of creating any groups needed to get to the given registry value. | ||||
| */ | */ | ||||
| static bool setValue (const String& regValuePath, const MemoryBlock& value); | |||||
| /** Returns true if the given value exists in the registry. */ | |||||
| static bool valueExists (const String& regValuePath); | |||||
| static bool setValue (const String& regValuePath, const MemoryBlock& value, WoW64Mode mode = WoW64_Default); | |||||
| /** Returns true if the given value exists in the registry. */ | /** Returns true if the given value exists in the registry. */ | ||||
| static bool valueExistsWow64 (const String& regValuePath); | |||||
| static bool valueExists (const String& regValuePath, WoW64Mode mode = WoW64_Default); | |||||
| /** Returns true if the given key exists in the registry. */ | /** Returns true if the given key exists in the registry. */ | ||||
| static bool keyExists (const String& regValuePath); | |||||
| /** Returns true if the given key exists in the registry. */ | |||||
| static bool keyExistsWow64 (const String& regValuePath); | |||||
| static bool keyExists (const String& regValuePath, WoW64Mode mode = WoW64_Default); | |||||
| /** Deletes a registry value. */ | /** Deletes a registry value. */ | ||||
| static void deleteValue (const String& regValuePath); | |||||
| static void deleteValue (const String& regValuePath, WoW64Mode mode = WoW64_Default); | |||||
| /** Deletes a registry key (which is registry-talk for 'folder'). */ | /** Deletes a registry key (which is registry-talk for 'folder'). */ | ||||
| static void deleteKey (const String& regKeyPath); | |||||
| static void deleteKey (const String& regKeyPath, WoW64Mode mode = WoW64_Default); | |||||
| /** Creates a file association in the registry. | /** Creates a file association in the registry. | ||||
| @@ -113,16 +117,23 @@ public: | |||||
| for all users (you might not have permission to do this | for all users (you might not have permission to do this | ||||
| unless running in an installer). If true, it will register the | unless running in an installer). If true, it will register the | ||||
| association in HKEY_CURRENT_USER. | association in HKEY_CURRENT_USER. | ||||
| @param mode the WoW64 mode to use for choosing the database | |||||
| */ | */ | ||||
| static bool registerFileAssociation (const String& fileExtension, | static bool registerFileAssociation (const String& fileExtension, | ||||
| const String& symbolicDescription, | const String& symbolicDescription, | ||||
| const String& fullDescription, | const String& fullDescription, | ||||
| const File& targetExecutable, | const File& targetExecutable, | ||||
| int iconResourceNumber, | int iconResourceNumber, | ||||
| bool registerForCurrentUserOnly); | |||||
| bool registerForCurrentUserOnly, | |||||
| WoW64Mode mode = WoW64_Default); | |||||
| // DEPRECATED: use the other methods with a WoW64Mode parameter of WoW64_64bit instead. | |||||
| JUCE_DEPRECATED (static String getValueWow64 (const String&, const String& defaultValue = String::empty)); | |||||
| JUCE_DEPRECATED (static bool valueExistsWow64 (const String&)); | |||||
| JUCE_DEPRECATED (static bool keyExistsWow64 (const String&)); | |||||
| private: | private: | ||||
| WindowsRegistry(); | |||||
| WindowsRegistry() JUCE_DELETED_FUNCTION; | |||||
| JUCE_DECLARE_NON_COPYABLE (WindowsRegistry) | JUCE_DECLARE_NON_COPYABLE (WindowsRegistry) | ||||
| }; | }; | ||||
| @@ -87,7 +87,7 @@ | |||||
| #define STRICT 1 | #define STRICT 1 | ||||
| #define WIN32_LEAN_AND_MEAN 1 | #define WIN32_LEAN_AND_MEAN 1 | ||||
| #if JUCE_MINGW | #if JUCE_MINGW | ||||
| #define _WIN32_WINNT 0x0501 | |||||
| #define _WIN32_WINNT 0x0502 | |||||
| #else | #else | ||||
| #define _WIN32_WINNT 0x0600 | #define _WIN32_WINNT 0x0600 | ||||
| #endif | #endif | ||||
| @@ -112,13 +112,13 @@ File File::getSpecialLocation (const SpecialLocationType type) | |||||
| return File (android.appDataDir); | return File (android.appDataDir); | ||||
| case commonApplicationDataDirectory: | case commonApplicationDataDirectory: | ||||
| case commonDocumentsDirectory: | |||||
| return File (android.appDataDir); | return File (android.appDataDir); | ||||
| case globalApplicationsDirectory: | case globalApplicationsDirectory: | ||||
| return File ("/system/app"); | return File ("/system/app"); | ||||
| case tempDirectory: | case tempDirectory: | ||||
| //return File (AndroidStatsHelpers::getSystemProperty ("java.io.tmpdir")); | |||||
| return File (android.appDataDir).getChildFile (".temp"); | return File (android.appDataDir).getChildFile (".temp"); | ||||
| case invokedExecutableFile: | case invokedExecutableFile: | ||||
| @@ -230,10 +230,11 @@ bool DirectoryIterator::NativeIterator::next (String& filenameFound, | |||||
| //============================================================================== | //============================================================================== | ||||
| bool Process::openDocument (const String& fileName, const String& parameters) | |||||
| JUCE_API bool JUCE_CALLTYPE Process::openDocument (const String& fileName, const String& parameters) | |||||
| { | { | ||||
| const LocalRef<jstring> t (javaString (fileName)); | const LocalRef<jstring> t (javaString (fileName)); | ||||
| android.activity.callVoidMethod (JuceAppActivity.launchURL, t.get()); | android.activity.callVoidMethod (JuceAppActivity.launchURL, t.get()); | ||||
| return true; | |||||
| } | } | ||||
| void File::revealToUser() const | void File::revealToUser() const | ||||
| @@ -28,5 +28,5 @@ | |||||
| void Logger::outputDebugString (const String& text) | void Logger::outputDebugString (const String& text) | ||||
| { | { | ||||
| __android_log_print (ANDROID_LOG_INFO, "JUCE", text.toUTF8()); | |||||
| __android_log_print (ANDROID_LOG_INFO, "JUCE", "%s", text.toUTF8().getAddress()); | |||||
| } | } | ||||
| @@ -54,10 +54,10 @@ void MACAddress::findAllAddresses (Array<MACAddress>& result) | |||||
| } | } | ||||
| bool Process::openEmailWithAttachments (const String& targetEmailAddress, | |||||
| const String& emailSubject, | |||||
| const String& bodyText, | |||||
| const StringArray& filesToAttach) | |||||
| JUCE_API bool JUCE_CALLTYPE Process::openEmailWithAttachments (const String& targetEmailAddress, | |||||
| const String& emailSubject, | |||||
| const String& bodyText, | |||||
| const StringArray& filesToAttach) | |||||
| { | { | ||||
| // TODO | // TODO | ||||
| return false; | return false; | ||||
| @@ -33,7 +33,7 @@ | |||||
| //============================================================================== | //============================================================================== | ||||
| // sets the process to 0=low priority, 1=normal, 2=high, 3=realtime | // sets the process to 0=low priority, 1=normal, 2=high, 3=realtime | ||||
| void Process::setPriority (ProcessPriority prior) | |||||
| JUCE_API void JUCE_CALLTYPE Process::setPriority (ProcessPriority prior) | |||||
| { | { | ||||
| // TODO | // TODO | ||||
| @@ -62,11 +62,6 @@ void Process::setPriority (ProcessPriority prior) | |||||
| pthread_setschedparam (pthread_self(), policy, ¶m); | pthread_setschedparam (pthread_self(), policy, ¶m); | ||||
| } | } | ||||
| void Process::terminate() | |||||
| { | |||||
| std::exit (EXIT_FAILURE); | |||||
| } | |||||
| JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger() | JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger() | ||||
| { | { | ||||
| return false; | return false; | ||||
| @@ -77,5 +72,5 @@ JUCE_API bool JUCE_CALLTYPE Process::isRunningUnderDebugger() | |||||
| return juce_isRunningUnderDebugger(); | return juce_isRunningUnderDebugger(); | ||||
| } | } | ||||
| void Process::raisePrivilege() {} | |||||
| void Process::lowerPrivilege() {} | |||||
| JUCE_API void JUCE_CALLTYPE Process::raisePrivilege() {} | |||||
| JUCE_API void JUCE_CALLTYPE Process::lowerPrivilege() {} | |||||
| @@ -168,11 +168,8 @@ File File::getSpecialLocation (const SpecialLocationType type) | |||||
| const char* homeDir = getenv ("HOME"); | const char* homeDir = getenv ("HOME"); | ||||
| if (homeDir == nullptr) | if (homeDir == nullptr) | ||||
| { | |||||
| struct passwd* const pw = getpwuid (getuid()); | |||||
| if (pw != nullptr) | |||||
| if (struct passwd* const pw = getpwuid (getuid())) | |||||
| homeDir = pw->pw_dir; | homeDir = pw->pw_dir; | ||||
| } | |||||
| return File (CharPointer_UTF8 (homeDir)); | return File (CharPointer_UTF8 (homeDir)); | ||||
| } | } | ||||
| @@ -183,6 +180,7 @@ File File::getSpecialLocation (const SpecialLocationType type) | |||||
| case userPicturesDirectory: return resolveXDGFolder ("XDG_PICTURES_DIR", "~"); | case userPicturesDirectory: return resolveXDGFolder ("XDG_PICTURES_DIR", "~"); | ||||
| case userDesktopDirectory: return resolveXDGFolder ("XDG_DESKTOP_DIR", "~/Desktop"); | case userDesktopDirectory: return resolveXDGFolder ("XDG_DESKTOP_DIR", "~/Desktop"); | ||||
| case userApplicationDataDirectory: return File ("~"); | case userApplicationDataDirectory: return File ("~"); | ||||
| case commonDocumentsDirectory: | |||||
| case commonApplicationDataDirectory: return File ("/var"); | case commonApplicationDataDirectory: return File ("/var"); | ||||
| case globalApplicationsDirectory: return File ("/usr"); | case globalApplicationsDirectory: return File ("/usr"); | ||||
| @@ -55,13 +55,12 @@ void MACAddress::findAllAddresses (Array<MACAddress>& result) | |||||
| } | } | ||||
| bool Process::openEmailWithAttachments (const String& /* targetEmailAddress */, | |||||
| const String& /* emailSubject */, | |||||
| const String& /* bodyText */, | |||||
| const StringArray& /* filesToAttach */) | |||||
| bool JUCE_CALLTYPE Process::openEmailWithAttachments (const String& /* targetEmailAddress */, | |||||
| const String& /* emailSubject */, | |||||
| const String& /* bodyText */, | |||||
| const StringArray& /* filesToAttach */) | |||||
| { | { | ||||
| jassertfalse; // xxx todo | jassertfalse; // xxx todo | ||||
| return false; | return false; | ||||
| } | } | ||||
| @@ -32,7 +32,7 @@ | |||||
| */ | */ | ||||
| //============================================================================== | //============================================================================== | ||||
| void Process::setPriority (const ProcessPriority prior) | |||||
| JUCE_API void JUCE_CALLTYPE Process::setPriority (const ProcessPriority prior) | |||||
| { | { | ||||
| const int policy = (prior <= NormalPriority) ? SCHED_OTHER : SCHED_RR; | const int policy = (prior <= NormalPriority) ? SCHED_OTHER : SCHED_RR; | ||||
| const int minp = sched_get_priority_min (policy); | const int minp = sched_get_priority_min (policy); | ||||
| @@ -52,11 +52,6 @@ void Process::setPriority (const ProcessPriority prior) | |||||
| pthread_setschedparam (pthread_self(), policy, ¶m); | pthread_setschedparam (pthread_self(), policy, ¶m); | ||||
| } | } | ||||
| void Process::terminate() | |||||
| { | |||||
| std::exit (EXIT_FAILURE); | |||||
| } | |||||
| JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger() | JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger() | ||||
| { | { | ||||
| #if JUCE_BSD | #if JUCE_BSD | ||||
| @@ -90,5 +85,5 @@ static void swapUserAndEffectiveUser() | |||||
| (void) setregid (getegid(), getgid()); | (void) setregid (getegid(), getgid()); | ||||
| } | } | ||||
| void Process::raisePrivilege() { if (geteuid() != 0 && getuid() == 0) swapUserAndEffectiveUser(); } | |||||
| void Process::lowerPrivilege() { if (geteuid() == 0 && getuid() != 0) swapUserAndEffectiveUser(); } | |||||
| JUCE_API void JUCE_CALLTYPE Process::raisePrivilege() { if (geteuid() != 0 && getuid() == 0) swapUserAndEffectiveUser(); } | |||||
| JUCE_API void JUCE_CALLTYPE Process::lowerPrivilege() { if (geteuid() == 0 && getuid() != 0) swapUserAndEffectiveUser(); } | |||||
| @@ -213,6 +213,7 @@ File File::getSpecialLocation (const SpecialLocationType type) | |||||
| case userPicturesDirectory: resultPath = "~/Pictures"; break; | case userPicturesDirectory: resultPath = "~/Pictures"; break; | ||||
| case userApplicationDataDirectory: resultPath = "~/Library"; break; | case userApplicationDataDirectory: resultPath = "~/Library"; break; | ||||
| case commonApplicationDataDirectory: resultPath = "/Library"; break; | case commonApplicationDataDirectory: resultPath = "/Library"; break; | ||||
| case commonDocumentsDirectory: resultPath = "/Users/Shared"; break; | |||||
| case globalApplicationsDirectory: resultPath = "/Applications"; break; | case globalApplicationsDirectory: resultPath = "/Applications"; break; | ||||
| case invokedExecutableFile: | case invokedExecutableFile: | ||||
| @@ -391,45 +392,48 @@ bool DirectoryIterator::NativeIterator::next (String& filenameFound, | |||||
| //============================================================================== | //============================================================================== | ||||
| bool Process::openDocument (const String& fileName, const String& parameters) | |||||
| bool JUCE_CALLTYPE Process::openDocument (const String& fileName, const String& parameters) | |||||
| { | { | ||||
| #if JUCE_IOS | |||||
| return [[UIApplication sharedApplication] openURL: [NSURL URLWithString: juceStringToNS (fileName)]]; | |||||
| #else | |||||
| JUCE_AUTORELEASEPOOL | JUCE_AUTORELEASEPOOL | ||||
| { | { | ||||
| NSURL* filenameAsURL = [NSURL URLWithString: juceStringToNS (fileName)]; | |||||
| #if JUCE_IOS | |||||
| return [[UIApplication sharedApplication] openURL: filenameAsURL]; | |||||
| #else | |||||
| NSWorkspace* workspace = [NSWorkspace sharedWorkspace]; | |||||
| if (parameters.isEmpty()) | if (parameters.isEmpty()) | ||||
| { | |||||
| return [[NSWorkspace sharedWorkspace] openFile: juceStringToNS (fileName)] | |||||
| || [[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: juceStringToNS (fileName)]]; | |||||
| } | |||||
| return [workspace openFile: juceStringToNS (fileName)] | |||||
| || [workspace openURL: filenameAsURL]; | |||||
| bool ok = false; | |||||
| const File file (fileName); | const File file (fileName); | ||||
| if (file.isBundle()) | if (file.isBundle()) | ||||
| { | { | ||||
| NSMutableArray* urls = [NSMutableArray array]; | |||||
| StringArray docs; | |||||
| docs.addTokens (parameters, true); | |||||
| for (int i = 0; i < docs.size(); ++i) | |||||
| [urls addObject: juceStringToNS (docs[i])]; | |||||
| ok = [[NSWorkspace sharedWorkspace] openURLs: urls | |||||
| withAppBundleIdentifier: [[NSBundle bundleWithPath: juceStringToNS (fileName)] bundleIdentifier] | |||||
| options: 0 | |||||
| additionalEventParamDescriptor: nil | |||||
| launchIdentifiers: nil]; | |||||
| } | |||||
| else if (file.exists()) | |||||
| { | |||||
| ok = FileHelpers::launchExecutable ("\"" + fileName + "\" " + parameters); | |||||
| StringArray params; | |||||
| params.addTokens (parameters, true); | |||||
| NSMutableArray* paramArray = [[[NSMutableArray alloc] init] autorelease]; | |||||
| for (int i = 0; i < params.size(); ++i) | |||||
| [paramArray addObject: juceStringToNS (params[i])]; | |||||
| NSMutableDictionary* dict = [[[NSMutableDictionary alloc] init] autorelease]; | |||||
| [dict setObject: paramArray | |||||
| forKey: nsStringLiteral ("NSWorkspaceLaunchConfigurationArguments")]; | |||||
| return [workspace launchApplicationAtURL: filenameAsURL | |||||
| options: NSWorkspaceLaunchDefault | NSWorkspaceLaunchNewInstance | |||||
| configuration: dict | |||||
| error: nil]; | |||||
| } | } | ||||
| return ok; | |||||
| if (file.exists()) | |||||
| return FileHelpers::launchExecutable ("\"" + fileName + "\" " + parameters); | |||||
| return false; | |||||
| #endif | |||||
| } | } | ||||
| #endif | |||||
| } | } | ||||
| void File::revealToUser() const | void File::revealToUser() const | ||||
| @@ -53,10 +53,10 @@ void MACAddress::findAllAddresses (Array<MACAddress>& result) | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| bool Process::openEmailWithAttachments (const String& targetEmailAddress, | |||||
| const String& emailSubject, | |||||
| const String& bodyText, | |||||
| const StringArray& filesToAttach) | |||||
| bool JUCE_CALLTYPE Process::openEmailWithAttachments (const String& targetEmailAddress, | |||||
| const String& emailSubject, | |||||
| const String& bodyText, | |||||
| const StringArray& filesToAttach) | |||||
| { | { | ||||
| #if JUCE_IOS | #if JUCE_IOS | ||||
| //xxx probably need to use MFMailComposeViewController | //xxx probably need to use MFMailComposeViewController | ||||
| @@ -32,7 +32,7 @@ | |||||
| */ | */ | ||||
| //============================================================================== | //============================================================================== | ||||
| bool Process::isForegroundProcess() | |||||
| JUCE_API bool JUCE_CALLTYPE Process::isForegroundProcess() | |||||
| { | { | ||||
| #if JUCE_MAC | #if JUCE_MAC | ||||
| return [NSApp isActive]; | return [NSApp isActive]; | ||||
| @@ -41,36 +41,31 @@ bool Process::isForegroundProcess() | |||||
| #endif | #endif | ||||
| } | } | ||||
| void Process::makeForegroundProcess() | |||||
| JUCE_API void JUCE_CALLTYPE Process::makeForegroundProcess() | |||||
| { | { | ||||
| #if JUCE_MAC | #if JUCE_MAC | ||||
| [NSApp activateIgnoringOtherApps: YES]; | [NSApp activateIgnoringOtherApps: YES]; | ||||
| #endif | #endif | ||||
| } | } | ||||
| void Process::hide() | |||||
| JUCE_API void JUCE_CALLTYPE Process::hide() | |||||
| { | { | ||||
| #if JUCE_MAC | #if JUCE_MAC | ||||
| [NSApp hide: nil]; | [NSApp hide: nil]; | ||||
| #endif | #endif | ||||
| } | } | ||||
| void Process::raisePrivilege() | |||||
| JUCE_API void JUCE_CALLTYPE Process::raisePrivilege() | |||||
| { | { | ||||
| jassertfalse; | jassertfalse; | ||||
| } | } | ||||
| void Process::lowerPrivilege() | |||||
| JUCE_API void JUCE_CALLTYPE Process::lowerPrivilege() | |||||
| { | { | ||||
| jassertfalse; | jassertfalse; | ||||
| } | } | ||||
| void Process::terminate() | |||||
| { | |||||
| std::exit (EXIT_FAILURE); | |||||
| } | |||||
| void Process::setPriority (ProcessPriority) | |||||
| JUCE_API void JUCE_CALLTYPE Process::setPriority (ProcessPriority) | |||||
| { | { | ||||
| // xxx | // xxx | ||||
| } | } | ||||
| @@ -56,6 +56,7 @@ namespace | |||||
| return [NSString string]; | return [NSString string]; | ||||
| } | } | ||||
| #if JUCE_MAC | |||||
| template <typename RectangleType> | template <typename RectangleType> | ||||
| static NSRect makeNSRect (const RectangleType& r) noexcept | static NSRect makeNSRect (const RectangleType& r) noexcept | ||||
| { | { | ||||
| @@ -64,6 +65,7 @@ namespace | |||||
| static_cast <CGFloat> (r.getWidth()), | static_cast <CGFloat> (r.getWidth()), | ||||
| static_cast <CGFloat> (r.getHeight())); | static_cast <CGFloat> (r.getHeight())); | ||||
| } | } | ||||
| #endif | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -150,6 +150,14 @@ void JUCE_CALLTYPE Thread::sleep (int millisecs) | |||||
| nanosleep (&time, nullptr); | nanosleep (&time, nullptr); | ||||
| } | } | ||||
| void JUCE_CALLTYPE Process::terminate() | |||||
| { | |||||
| #if JUCE_ANDROID | |||||
| _exit (EXIT_FAILURE); | |||||
| #else | |||||
| std::_Exit (EXIT_FAILURE); | |||||
| #endif | |||||
| } | |||||
| //============================================================================== | //============================================================================== | ||||
| const juce_wchar File::separator = '/'; | const juce_wchar File::separator = '/'; | ||||
| @@ -882,7 +890,7 @@ void Thread::killThread() | |||||
| } | } | ||||
| } | } | ||||
| void Thread::setCurrentThreadName (const String& name) | |||||
| void JUCE_CALLTYPE Thread::setCurrentThreadName (const String& name) | |||||
| { | { | ||||
| #if JUCE_IOS || (JUCE_MAC && defined (MAC_OS_X_VERSION_10_5) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5) | #if JUCE_IOS || (JUCE_MAC && defined (MAC_OS_X_VERSION_10_5) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5) | ||||
| JUCE_AUTORELEASEPOOL | JUCE_AUTORELEASEPOOL | ||||
| @@ -919,12 +927,12 @@ bool Thread::setThreadPriority (void* handle, int priority) | |||||
| return pthread_setschedparam ((pthread_t) handle, policy, ¶m) == 0; | return pthread_setschedparam ((pthread_t) handle, policy, ¶m) == 0; | ||||
| } | } | ||||
| Thread::ThreadID Thread::getCurrentThreadId() | |||||
| Thread::ThreadID JUCE_CALLTYPE Thread::getCurrentThreadId() | |||||
| { | { | ||||
| return (ThreadID) pthread_self(); | return (ThreadID) pthread_self(); | ||||
| } | } | ||||
| void Thread::yield() | |||||
| void JUCE_CALLTYPE Thread::yield() | |||||
| { | { | ||||
| sched_yield(); | sched_yield(); | ||||
| } | } | ||||
| @@ -938,7 +946,7 @@ void Thread::yield() | |||||
| #define SUPPORT_AFFINITIES 1 | #define SUPPORT_AFFINITIES 1 | ||||
| #endif | #endif | ||||
| void Thread::setCurrentThreadAffinityMask (const uint32 affinityMask) | |||||
| void JUCE_CALLTYPE Thread::setCurrentThreadAffinityMask (const uint32 affinityMask) | |||||
| { | { | ||||
| #if SUPPORT_AFFINITIES | #if SUPPORT_AFFINITIES | ||||
| cpu_set_t affinity; | cpu_set_t affinity; | ||||
| @@ -1143,7 +1151,7 @@ struct HighResolutionTimer::Pimpl | |||||
| shouldStop = false; | shouldStop = false; | ||||
| if (pthread_create (&thread, nullptr, timerThread, this) == 0) | if (pthread_create (&thread, nullptr, timerThread, this) == 0) | ||||
| setThreadToRealtime (thread, newPeriod); | |||||
| setThreadToRealtime (thread, (uint64) newPeriod); | |||||
| else | else | ||||
| jassertfalse; | jassertfalse; | ||||
| } | } | ||||
| @@ -518,6 +518,7 @@ File JUCE_CALLTYPE File::getSpecialLocation (const SpecialLocationType type) | |||||
| case userDesktopDirectory: csidlType = CSIDL_DESKTOP; break; | case userDesktopDirectory: csidlType = CSIDL_DESKTOP; break; | ||||
| case userApplicationDataDirectory: csidlType = CSIDL_APPDATA; break; | case userApplicationDataDirectory: csidlType = CSIDL_APPDATA; break; | ||||
| case commonApplicationDataDirectory: csidlType = CSIDL_COMMON_APPDATA; break; | case commonApplicationDataDirectory: csidlType = CSIDL_COMMON_APPDATA; break; | ||||
| case commonDocumentsDirectory: csidlType = CSIDL_COMMON_DOCUMENTS; break; | |||||
| case globalApplicationsDirectory: csidlType = CSIDL_PROGRAM_FILES; break; | case globalApplicationsDirectory: csidlType = CSIDL_PROGRAM_FILES; break; | ||||
| case userMusicDirectory: csidlType = 0x0d; /*CSIDL_MYMUSIC*/ break; | case userMusicDirectory: csidlType = 0x0d; /*CSIDL_MYMUSIC*/ break; | ||||
| case userMoviesDirectory: csidlType = 0x0e; /*CSIDL_MYVIDEO*/ break; | case userMoviesDirectory: csidlType = 0x0e; /*CSIDL_MYVIDEO*/ break; | ||||
| @@ -704,7 +705,7 @@ bool DirectoryIterator::NativeIterator::next (String& filenameFound, | |||||
| //============================================================================== | //============================================================================== | ||||
| bool Process::openDocument (const String& fileName, const String& parameters) | |||||
| bool JUCE_CALLTYPE Process::openDocument (const String& fileName, const String& parameters) | |||||
| { | { | ||||
| HINSTANCE hInstance = 0; | HINSTANCE hInstance = 0; | ||||
| @@ -428,10 +428,10 @@ void IPAddress::findAllAddresses (Array<IPAddress>& result) | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| bool Process::openEmailWithAttachments (const String& targetEmailAddress, | |||||
| const String& emailSubject, | |||||
| const String& bodyText, | |||||
| const StringArray& filesToAttach) | |||||
| bool JUCE_CALLTYPE Process::openEmailWithAttachments (const String& targetEmailAddress, | |||||
| const String& emailSubject, | |||||
| const String& bodyText, | |||||
| const StringArray& filesToAttach) | |||||
| { | { | ||||
| DynamicLibrary dll ("MAPI32.dll"); | DynamicLibrary dll ("MAPI32.dll"); | ||||
| JUCE_LOAD_WINAPI_FUNCTION (dll, MAPISendMail, mapiSendMail, | JUCE_LOAD_WINAPI_FUNCTION (dll, MAPISendMail, mapiSendMail, | ||||
| @@ -64,9 +64,9 @@ struct RegistryKeyWrapper | |||||
| } | } | ||||
| static bool setValue (const String& regValuePath, const DWORD type, | static bool setValue (const String& regValuePath, const DWORD type, | ||||
| const void* data, size_t dataSize) | |||||
| const void* data, size_t dataSize, const DWORD wow64Flags) | |||||
| { | { | ||||
| const RegistryKeyWrapper key (regValuePath, true, 0); | |||||
| const RegistryKeyWrapper key (regValuePath, true, wow64Flags); | |||||
| return key.key != 0 | return key.key != 0 | ||||
| && RegSetValueEx (key.key, key.wideCharValueName, 0, type, | && RegSetValueEx (key.key, key.wideCharValueName, 0, type, | ||||
| @@ -144,73 +144,58 @@ struct RegistryKeyWrapper | |||||
| JUCE_DECLARE_NON_COPYABLE (RegistryKeyWrapper) | JUCE_DECLARE_NON_COPYABLE (RegistryKeyWrapper) | ||||
| }; | }; | ||||
| uint32 WindowsRegistry::getBinaryValue (const String& regValuePath, MemoryBlock& result) | |||||
| uint32 WindowsRegistry::getBinaryValue (const String& regValuePath, MemoryBlock& result, WoW64Mode mode) | |||||
| { | { | ||||
| return RegistryKeyWrapper::getBinaryValue (regValuePath, result, 0); | |||||
| return RegistryKeyWrapper::getBinaryValue (regValuePath, result, (DWORD) mode); | |||||
| } | } | ||||
| String WindowsRegistry::getValue (const String& regValuePath, const String& defaultValue) | |||||
| String WindowsRegistry::getValue (const String& regValuePath, const String& defaultValue, WoW64Mode mode) | |||||
| { | { | ||||
| return RegistryKeyWrapper::getValue (regValuePath, defaultValue, 0); | |||||
| return RegistryKeyWrapper::getValue (regValuePath, defaultValue, (DWORD) mode); | |||||
| } | } | ||||
| String WindowsRegistry::getValueWow64 (const String& regValuePath, const String& defaultValue) | |||||
| { | |||||
| return RegistryKeyWrapper::getValue (regValuePath, defaultValue, 0x100 /*KEY_WOW64_64KEY*/); | |||||
| } | |||||
| bool WindowsRegistry::valueExistsWow64 (const String& regValuePath) | |||||
| { | |||||
| return RegistryKeyWrapper::valueExists (regValuePath, 0x100 /*KEY_WOW64_64KEY*/); | |||||
| } | |||||
| bool WindowsRegistry::keyExistsWow64 (const String& regValuePath) | |||||
| { | |||||
| return RegistryKeyWrapper::keyExists (regValuePath, 0x100 /*KEY_WOW64_64KEY*/); | |||||
| } | |||||
| bool WindowsRegistry::setValue (const String& regValuePath, const String& value) | |||||
| bool WindowsRegistry::setValue (const String& regValuePath, const String& value, WoW64Mode mode) | |||||
| { | { | ||||
| return RegistryKeyWrapper::setValue (regValuePath, REG_SZ, value.toWideCharPointer(), | return RegistryKeyWrapper::setValue (regValuePath, REG_SZ, value.toWideCharPointer(), | ||||
| CharPointer_UTF16::getBytesRequiredFor (value.getCharPointer())); | |||||
| CharPointer_UTF16::getBytesRequiredFor (value.getCharPointer()), mode); | |||||
| } | } | ||||
| bool WindowsRegistry::setValue (const String& regValuePath, const uint32 value) | |||||
| bool WindowsRegistry::setValue (const String& regValuePath, const uint32 value, WoW64Mode mode) | |||||
| { | { | ||||
| return RegistryKeyWrapper::setValue (regValuePath, REG_DWORD, &value, sizeof (value)); | |||||
| return RegistryKeyWrapper::setValue (regValuePath, REG_DWORD, &value, sizeof (value), (DWORD) mode); | |||||
| } | } | ||||
| bool WindowsRegistry::setValue (const String& regValuePath, const uint64 value) | |||||
| bool WindowsRegistry::setValue (const String& regValuePath, const uint64 value, WoW64Mode mode) | |||||
| { | { | ||||
| return RegistryKeyWrapper::setValue (regValuePath, REG_QWORD, &value, sizeof (value)); | |||||
| return RegistryKeyWrapper::setValue (regValuePath, REG_QWORD, &value, sizeof (value), (DWORD) mode); | |||||
| } | } | ||||
| bool WindowsRegistry::setValue (const String& regValuePath, const MemoryBlock& value) | |||||
| bool WindowsRegistry::setValue (const String& regValuePath, const MemoryBlock& value, WoW64Mode mode) | |||||
| { | { | ||||
| return RegistryKeyWrapper::setValue (regValuePath, REG_BINARY, value.getData(), value.getSize()); | |||||
| return RegistryKeyWrapper::setValue (regValuePath, REG_BINARY, value.getData(), value.getSize(), (DWORD) mode); | |||||
| } | } | ||||
| bool WindowsRegistry::valueExists (const String& regValuePath) | |||||
| bool WindowsRegistry::valueExists (const String& regValuePath, WoW64Mode mode) | |||||
| { | { | ||||
| return RegistryKeyWrapper::valueExists (regValuePath, 0); | |||||
| return RegistryKeyWrapper::valueExists (regValuePath, (DWORD) mode); | |||||
| } | } | ||||
| bool WindowsRegistry::keyExists (const String& regValuePath) | |||||
| bool WindowsRegistry::keyExists (const String& regValuePath, WoW64Mode mode) | |||||
| { | { | ||||
| return RegistryKeyWrapper::keyExists (regValuePath, 0); | |||||
| return RegistryKeyWrapper::keyExists (regValuePath, (DWORD) mode); | |||||
| } | } | ||||
| void WindowsRegistry::deleteValue (const String& regValuePath) | |||||
| void WindowsRegistry::deleteValue (const String& regValuePath, WoW64Mode mode) | |||||
| { | { | ||||
| const RegistryKeyWrapper key (regValuePath, true, 0); | |||||
| const RegistryKeyWrapper key (regValuePath, true, (DWORD) mode); | |||||
| if (key.key != 0) | if (key.key != 0) | ||||
| RegDeleteValue (key.key, key.wideCharValueName); | RegDeleteValue (key.key, key.wideCharValueName); | ||||
| } | } | ||||
| void WindowsRegistry::deleteKey (const String& regKeyPath) | |||||
| void WindowsRegistry::deleteKey (const String& regKeyPath, WoW64Mode mode) | |||||
| { | { | ||||
| const RegistryKeyWrapper key (regKeyPath, true, 0); | |||||
| const RegistryKeyWrapper key (regKeyPath, true, (DWORD) mode); | |||||
| if (key.key != 0) | if (key.key != 0) | ||||
| RegDeleteKey (key.key, key.wideCharValueName); | RegDeleteKey (key.key, key.wideCharValueName); | ||||
| @@ -221,16 +206,22 @@ bool WindowsRegistry::registerFileAssociation (const String& fileExtension, | |||||
| const String& fullDescription, | const String& fullDescription, | ||||
| const File& targetExecutable, | const File& targetExecutable, | ||||
| const int iconResourceNumber, | const int iconResourceNumber, | ||||
| const bool registerForCurrentUserOnly) | |||||
| const bool registerForCurrentUserOnly, | |||||
| WoW64Mode mode) | |||||
| { | { | ||||
| const char* const root = registerForCurrentUserOnly ? "HKEY_CURRENT_USER\\Software\\Classes\\" | const char* const root = registerForCurrentUserOnly ? "HKEY_CURRENT_USER\\Software\\Classes\\" | ||||
| : "HKEY_CLASSES_ROOT\\"; | : "HKEY_CLASSES_ROOT\\"; | ||||
| const String key (root + symbolicDescription); | const String key (root + symbolicDescription); | ||||
| return setValue (root + fileExtension + "\\", symbolicDescription) | |||||
| && setValue (key + "\\", fullDescription) | |||||
| && setValue (key + "\\shell\\open\\command\\", targetExecutable.getFullPathName() + " \"%1\"") | |||||
| return setValue (root + fileExtension + "\\", symbolicDescription, mode) | |||||
| && setValue (key + "\\", fullDescription, mode) | |||||
| && setValue (key + "\\shell\\open\\command\\", targetExecutable.getFullPathName() + " \"%1\"", mode) | |||||
| && (iconResourceNumber == 0 | && (iconResourceNumber == 0 | ||||
| || setValue (key + "\\DefaultIcon\\", | || setValue (key + "\\DefaultIcon\\", | ||||
| targetExecutable.getFullPathName() + "," + String (-iconResourceNumber))); | targetExecutable.getFullPathName() + "," + String (-iconResourceNumber))); | ||||
| } | } | ||||
| // These methods are deprecated: | |||||
| String WindowsRegistry::getValueWow64 (const String& p, const String& defVal) { return getValue (p, defVal, WoW64_64bit); } | |||||
| bool WindowsRegistry::valueExistsWow64 (const String& p) { return valueExists (p, WoW64_64bit); } | |||||
| bool WindowsRegistry::keyExistsWow64 (const String& p) { return keyExists (p, WoW64_64bit); } | |||||
| @@ -150,7 +150,7 @@ void Thread::killThread() | |||||
| } | } | ||||
| } | } | ||||
| void Thread::setCurrentThreadName (const String& name) | |||||
| void JUCE_CALLTYPE Thread::setCurrentThreadName (const String& name) | |||||
| { | { | ||||
| #if JUCE_DEBUG && JUCE_MSVC | #if JUCE_DEBUG && JUCE_MSVC | ||||
| struct | struct | ||||
| @@ -177,7 +177,7 @@ void Thread::setCurrentThreadName (const String& name) | |||||
| #endif | #endif | ||||
| } | } | ||||
| Thread::ThreadID Thread::getCurrentThreadId() | |||||
| Thread::ThreadID JUCE_CALLTYPE Thread::getCurrentThreadId() | |||||
| { | { | ||||
| return (ThreadID) (pointer_sized_int) GetCurrentThreadId(); | return (ThreadID) (pointer_sized_int) GetCurrentThreadId(); | ||||
| } | } | ||||
| @@ -199,7 +199,7 @@ bool Thread::setThreadPriority (void* handle, int priority) | |||||
| return SetThreadPriority (handle, pri) != FALSE; | return SetThreadPriority (handle, pri) != FALSE; | ||||
| } | } | ||||
| void Thread::setCurrentThreadAffinityMask (const uint32 affinityMask) | |||||
| void JUCE_CALLTYPE Thread::setCurrentThreadAffinityMask (const uint32 affinityMask) | |||||
| { | { | ||||
| SetThreadAffinityMask (GetCurrentThread(), affinityMask); | SetThreadAffinityMask (GetCurrentThread(), affinityMask); | ||||
| } | } | ||||
| @@ -271,7 +271,7 @@ void juce_repeatLastProcessPriority() | |||||
| } | } | ||||
| } | } | ||||
| void Process::setPriority (ProcessPriority prior) | |||||
| void JUCE_CALLTYPE Process::setPriority (ProcessPriority prior) | |||||
| { | { | ||||
| if (lastProcessPriority != (int) prior) | if (lastProcessPriority != (int) prior) | ||||
| { | { | ||||
| @@ -292,7 +292,7 @@ bool JUCE_CALLTYPE Process::isRunningUnderDebugger() | |||||
| static void* currentModuleHandle = nullptr; | static void* currentModuleHandle = nullptr; | ||||
| void* Process::getCurrentModuleInstanceHandle() noexcept | |||||
| void* JUCE_CALLTYPE Process::getCurrentModuleInstanceHandle() noexcept | |||||
| { | { | ||||
| if (currentModuleHandle == nullptr) | if (currentModuleHandle == nullptr) | ||||
| currentModuleHandle = GetModuleHandleA (nullptr); | currentModuleHandle = GetModuleHandleA (nullptr); | ||||
| @@ -300,22 +300,22 @@ void* Process::getCurrentModuleInstanceHandle() noexcept | |||||
| return currentModuleHandle; | return currentModuleHandle; | ||||
| } | } | ||||
| void Process::setCurrentModuleInstanceHandle (void* const newHandle) noexcept | |||||
| void JUCE_CALLTYPE Process::setCurrentModuleInstanceHandle (void* const newHandle) noexcept | |||||
| { | { | ||||
| currentModuleHandle = newHandle; | currentModuleHandle = newHandle; | ||||
| } | } | ||||
| void Process::raisePrivilege() | |||||
| void JUCE_CALLTYPE Process::raisePrivilege() | |||||
| { | { | ||||
| jassertfalse; // xxx not implemented | jassertfalse; // xxx not implemented | ||||
| } | } | ||||
| void Process::lowerPrivilege() | |||||
| void JUCE_CALLTYPE Process::lowerPrivilege() | |||||
| { | { | ||||
| jassertfalse; // xxx not implemented | jassertfalse; // xxx not implemented | ||||
| } | } | ||||
| void Process::terminate() | |||||
| void JUCE_CALLTYPE Process::terminate() | |||||
| { | { | ||||
| #if JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS | #if JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS | ||||
| _CrtDumpMemoryLeaks(); | _CrtDumpMemoryLeaks(); | ||||
| @@ -101,12 +101,12 @@ static void findIPAddresses (int sock, Array<IPAddress>& result) | |||||
| { | { | ||||
| ifconf cfg; | ifconf cfg; | ||||
| HeapBlock<char> buffer; | HeapBlock<char> buffer; | ||||
| size_t bufferSize = 1024; | |||||
| int bufferSize = 1024; | |||||
| do | do | ||||
| { | { | ||||
| bufferSize *= 2; | bufferSize *= 2; | ||||
| buffer.calloc (bufferSize); | |||||
| buffer.calloc ((size_t) bufferSize); | |||||
| cfg.ifc_len = bufferSize; | cfg.ifc_len = bufferSize; | ||||
| cfg.ifc_buf = buffer; | cfg.ifc_buf = buffer; | ||||
| @@ -114,7 +114,7 @@ static void findIPAddresses (int sock, Array<IPAddress>& result) | |||||
| if (ioctl (sock, SIOCGIFCONF, &cfg) < 0 && errno != EINVAL) | if (ioctl (sock, SIOCGIFCONF, &cfg) < 0 && errno != EINVAL) | ||||
| return; | return; | ||||
| } while (bufferSize < cfg.ifc_len + 2 * (IFNAMSIZ + sizeof (struct sockaddr_in6))); | |||||
| } while (bufferSize < cfg.ifc_len + 2 * (int) (IFNAMSIZ + sizeof (struct sockaddr_in6))); | |||||
| #if JUCE_MAC || JUCE_IOS | #if JUCE_MAC || JUCE_IOS | ||||
| while (cfg.ifc_len >= (int) (IFNAMSIZ + sizeof (struct sockaddr_in))) | while (cfg.ifc_len >= (int) (IFNAMSIZ + sizeof (struct sockaddr_in))) | ||||
| @@ -126,7 +126,7 @@ static void findIPAddresses (int sock, Array<IPAddress>& result) | |||||
| cfg.ifc_buf += IFNAMSIZ + cfg.ifc_req->ifr_addr.sa_len; | cfg.ifc_buf += IFNAMSIZ + cfg.ifc_req->ifr_addr.sa_len; | ||||
| } | } | ||||
| #else | #else | ||||
| for (int i = 0; i < cfg.ifc_len / sizeof (struct ifreq); ++i) | |||||
| for (size_t i = 0; i < cfg.ifc_len / sizeof (struct ifreq); ++i) | |||||
| { | { | ||||
| const ifreq& item = cfg.ifc_req[i]; | const ifreq& item = cfg.ifc_req[i]; | ||||
| @@ -29,8 +29,6 @@ | |||||
| #ifndef JUCE_MACADDRESS_H_INCLUDED | #ifndef JUCE_MACADDRESS_H_INCLUDED | ||||
| #define JUCE_MACADDRESS_H_INCLUDED | #define JUCE_MACADDRESS_H_INCLUDED | ||||
| #include "../containers/juce_Array.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -29,7 +29,6 @@ | |||||
| #ifndef JUCE_NAMEDPIPE_H_INCLUDED | #ifndef JUCE_NAMEDPIPE_H_INCLUDED | ||||
| #define JUCE_NAMEDPIPE_H_INCLUDED | #define JUCE_NAMEDPIPE_H_INCLUDED | ||||
| #include "../threads/juce_ReadWriteLock.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -29,8 +29,6 @@ | |||||
| #ifndef JUCE_SOCKET_H_INCLUDED | #ifndef JUCE_SOCKET_H_INCLUDED | ||||
| #define JUCE_SOCKET_H_INCLUDED | #define JUCE_SOCKET_H_INCLUDED | ||||
| #include "../text/juce_String.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -29,11 +29,6 @@ | |||||
| #ifndef JUCE_URL_H_INCLUDED | #ifndef JUCE_URL_H_INCLUDED | ||||
| #define JUCE_URL_H_INCLUDED | #define JUCE_URL_H_INCLUDED | ||||
| #include "../text/juce_StringPairArray.h" | |||||
| #include "../files/juce_File.h" | |||||
| class InputStream; | |||||
| class XmlElement; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -29,10 +29,6 @@ | |||||
| #ifndef JUCE_BUFFEREDINPUTSTREAM_H_INCLUDED | #ifndef JUCE_BUFFEREDINPUTSTREAM_H_INCLUDED | ||||
| #define JUCE_BUFFEREDINPUTSTREAM_H_INCLUDED | #define JUCE_BUFFEREDINPUTSTREAM_H_INCLUDED | ||||
| #include "juce_InputStream.h" | |||||
| #include "../memory/juce_OptionalScopedPointer.h" | |||||
| #include "../memory/juce_HeapBlock.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Wraps another input stream, and reads from it using an intermediate buffer | /** Wraps another input stream, and reads from it using an intermediate buffer | ||||
| @@ -29,9 +29,6 @@ | |||||
| #ifndef JUCE_FILEINPUTSOURCE_H_INCLUDED | #ifndef JUCE_FILEINPUTSOURCE_H_INCLUDED | ||||
| #define JUCE_FILEINPUTSOURCE_H_INCLUDED | #define JUCE_FILEINPUTSOURCE_H_INCLUDED | ||||
| #include "juce_InputSource.h" | |||||
| #include "../files/juce_File.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -29,7 +29,6 @@ | |||||
| #ifndef JUCE_INPUTSOURCE_H_INCLUDED | #ifndef JUCE_INPUTSOURCE_H_INCLUDED | ||||
| #define JUCE_INPUTSOURCE_H_INCLUDED | #define JUCE_INPUTSOURCE_H_INCLUDED | ||||
| #include "juce_InputStream.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -175,7 +175,8 @@ String InputStream::readString() | |||||
| } | } | ||||
| } | } | ||||
| return String::fromUTF8 (data, (int) i); | |||||
| return String (CharPointer_UTF8 (data), | |||||
| CharPointer_UTF8 (data + i)); | |||||
| } | } | ||||
| String InputStream::readNextLine() | String InputStream::readNextLine() | ||||
| @@ -29,9 +29,6 @@ | |||||
| #ifndef JUCE_INPUTSTREAM_H_INCLUDED | #ifndef JUCE_INPUTSTREAM_H_INCLUDED | ||||
| #define JUCE_INPUTSTREAM_H_INCLUDED | #define JUCE_INPUTSTREAM_H_INCLUDED | ||||
| #include "../text/juce_String.h" | |||||
| class MemoryBlock; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** The base class for streams that read data. | /** The base class for streams that read data. | ||||