1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

VC2011 compiler tweaks. ReferenceCountedArray fix.

This commit is contained in:
jules 2012-03-01 09:26:40 +00:00
parent 96976db624
commit 22c72de736
4 changed files with 32 additions and 6 deletions

View file

@ -47,7 +47,7 @@
#include <sys/stat.h> /* for stat() */ #include <sys/stat.h> /* for stat() */
#include <sys/types.h> /* for off_t */ #include <sys/types.h> /* for off_t */
#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ #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 fseeko fseek
#define ftello ftell #define ftello ftell
#endif #endif

View file

@ -47,7 +47,7 @@
#include <string.h> /* for memcpy() */ #include <string.h> /* for memcpy() */
#include <sys/types.h> /* for off_t */ #include <sys/types.h> /* for off_t */
#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ #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 fseeko fseek
#define ftello ftell #define ftello ftell
#endif #endif

View file

@ -61,8 +61,7 @@ public:
} }
/** Creates a copy of another array */ /** Creates a copy of another array */
template <class OtherObjectClass> ReferenceCountedArray (const ReferenceCountedArray& other) noexcept
ReferenceCountedArray (const ReferenceCountedArray<OtherObjectClass, TypeOfCriticalSectionToUse>& other) noexcept
{ {
const ScopedLockType lock (other.getLock()); const ScopedLockType lock (other.getLock());
numUsed = other.size(); numUsed = other.size();
@ -74,8 +73,31 @@ public:
data.elements[i]->incReferenceCount(); data.elements[i]->incReferenceCount();
} }
/** Copies another array into this one. /** Creates a copy of another array */
template <class OtherObjectClass, class OtherCriticalSection>
ReferenceCountedArray (const ReferenceCountedArray<OtherObjectClass, OtherCriticalSection>& other) noexcept
{
const typename ReferenceCountedArray<OtherObjectClass, OtherCriticalSection>::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. Any existing objects in this array will first be released.
*/ */
template <class OtherObjectClass> template <class OtherObjectClass>

View file

@ -298,7 +298,11 @@ namespace juce
#endif #endif
#if defined (_MSC_VER) && _MSC_VER >= 1600 #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_NULLPTR 1
#define JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS 1 #define JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS 1
#endif #endif