From 22c72de73677b44d76f284a6e26586a3d5bcef2d Mon Sep 17 00:00:00 2001 From: jules Date: Thu, 1 Mar 2012 09:26:40 +0000 Subject: [PATCH] VC2011 compiler tweaks. ReferenceCountedArray fix. --- .../codecs/flac/libFLAC/stream_decoder.c | 2 +- .../codecs/flac/libFLAC/stream_encoder.c | 2 +- .../containers/juce_ReferenceCountedArray.h | 26 +++++++++++++++++-- modules/juce_core/system/juce_PlatformDefs.h | 6 ++++- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/modules/juce_audio_formats/codecs/flac/libFLAC/stream_decoder.c b/modules/juce_audio_formats/codecs/flac/libFLAC/stream_decoder.c index 43ab75d635..77f66f3a63 100644 --- a/modules/juce_audio_formats/codecs/flac/libFLAC/stream_decoder.c +++ b/modules/juce_audio_formats/codecs/flac/libFLAC/stream_decoder.c @@ -47,7 +47,7 @@ #include /* for stat() */ #include /* for off_t */ #if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ -#if _MSC_VER <= 1600 || defined __BORLANDC__ /* @@@ [2G limit] */ +#if _MSC_VER <= 1700 || defined __BORLANDC__ /* @@@ [2G limit] */ #define fseeko fseek #define ftello ftell #endif diff --git a/modules/juce_audio_formats/codecs/flac/libFLAC/stream_encoder.c b/modules/juce_audio_formats/codecs/flac/libFLAC/stream_encoder.c index 25cddb7d78..741d7242e6 100644 --- a/modules/juce_audio_formats/codecs/flac/libFLAC/stream_encoder.c +++ b/modules/juce_audio_formats/codecs/flac/libFLAC/stream_encoder.c @@ -47,7 +47,7 @@ #include /* for memcpy() */ #include /* for off_t */ #if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ -#if _MSC_VER <= 1600 || defined __BORLANDC__ /* @@@ [2G limit] */ +#if _MSC_VER <= 1700 || defined __BORLANDC__ /* @@@ [2G limit] */ #define fseeko fseek #define ftello ftell #endif diff --git a/modules/juce_core/containers/juce_ReferenceCountedArray.h b/modules/juce_core/containers/juce_ReferenceCountedArray.h index ec44c78faf..95ace6643f 100644 --- a/modules/juce_core/containers/juce_ReferenceCountedArray.h +++ b/modules/juce_core/containers/juce_ReferenceCountedArray.h @@ -61,8 +61,7 @@ public: } /** Creates a copy of another array */ - template - ReferenceCountedArray (const ReferenceCountedArray& other) noexcept + ReferenceCountedArray (const ReferenceCountedArray& other) noexcept { const ScopedLockType lock (other.getLock()); numUsed = other.size(); @@ -74,8 +73,31 @@ public: data.elements[i]->incReferenceCount(); } + /** Creates a copy of another array */ + template + ReferenceCountedArray (const ReferenceCountedArray& other) noexcept + { + const typename ReferenceCountedArray::ScopedLockType lock (other.getLock()); + numUsed = other.size(); + data.setAllocatedSize (numUsed); + memcpy (data.elements, other.getRawDataPointer(), numUsed * sizeof (ObjectClass*)); + + for (int i = numUsed; --i >= 0;) + if (data.elements[i] != nullptr) + data.elements[i]->incReferenceCount(); + } + /** Copies another array into this one. + Any existing objects in this array will first be released. + */ + ReferenceCountedArray& operator= (const ReferenceCountedArray& other) noexcept + { + ReferenceCountedArray otherCopy (other); + swapWithArray (otherCopy); + return *this; + } + /** Copies another array into this one. Any existing objects in this array will first be released. */ template diff --git a/modules/juce_core/system/juce_PlatformDefs.h b/modules/juce_core/system/juce_PlatformDefs.h index 6eb8ba0b9b..144685842b 100644 --- a/modules/juce_core/system/juce_PlatformDefs.h +++ b/modules/juce_core/system/juce_PlatformDefs.h @@ -298,7 +298,11 @@ namespace juce #endif #if defined (_MSC_VER) && _MSC_VER >= 1600 - #define JUCE_COMPILER_SUPPORTS_NOEXCEPT 0 + #if _MSC_VER >= 1700 + #define JUCE_COMPILER_SUPPORTS_NOEXCEPT 1 + #else + #define JUCE_COMPILER_SUPPORTS_NOEXCEPT 0 + #endif #define JUCE_COMPILER_SUPPORTS_NULLPTR 1 #define JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS 1 #endif