upgrade to JUCE 5.4.3. Remove (probably) unused JUCE modules. Remove VST2 target (it's been end-of-life'd by Steinberg and by JUCE)

This commit is contained in:
Alex Birch
2019-06-22 20:41:38 +01:00
parent d22c2cd4fa
commit 9ee566b251
1140 changed files with 67534 additions and 105952 deletions

View File

@ -196,4 +196,81 @@ String BufferedInputStream::readString()
return InputStream::readString();
}
//==============================================================================
#if JUCE_UNIT_TESTS
struct BufferedInputStreamTests : public UnitTest
{
BufferedInputStreamTests()
: UnitTest ("BufferedInputStream", "Streams")
{}
void runTest() override
{
const MemoryBlock data ("abcdefghijklmnopqrstuvwxyz", 26);
MemoryInputStream mi (data, true);
BufferedInputStream stream (mi, (int) data.getSize());
beginTest ("Read");
expectEquals (stream.getPosition(), (int64) 0);
expectEquals (stream.getTotalLength(), (int64) data.getSize());
expectEquals (stream.getNumBytesRemaining(), stream.getTotalLength());
expect (! stream.isExhausted());
size_t numBytesRead = 0;
MemoryBlock readBuffer (data.getSize());
while (numBytesRead < data.getSize())
{
expectEquals (stream.peekByte(), *(char*) (data.begin() + numBytesRead));
numBytesRead += (size_t) stream.read (&readBuffer[numBytesRead], 3);
expectEquals (stream.getPosition(), (int64) numBytesRead);
expectEquals (stream.getNumBytesRemaining(), (int64) (data.getSize() - numBytesRead));
expect (stream.isExhausted() == (numBytesRead == data.getSize()));
}
expectEquals (stream.getPosition(), (int64) data.getSize());
expectEquals (stream.getNumBytesRemaining(), (int64) 0);
expect (stream.isExhausted());
expect (readBuffer == data);
beginTest ("Skip");
stream.setPosition (0);
expectEquals (stream.getPosition(), (int64) 0);
expectEquals (stream.getTotalLength(), (int64) data.getSize());
expectEquals (stream.getNumBytesRemaining(), stream.getTotalLength());
expect (! stream.isExhausted());
numBytesRead = 0;
const int numBytesToSkip = 5;
while (numBytesRead < data.getSize())
{
expectEquals (stream.peekByte(), *(char*) (data.begin() + numBytesRead));
stream.skipNextBytes (numBytesToSkip);
numBytesRead += numBytesToSkip;
numBytesRead = std::min (numBytesRead, data.getSize());
expectEquals (stream.getPosition(), (int64) numBytesRead);
expectEquals (stream.getNumBytesRemaining(), (int64) (data.getSize() - numBytesRead));
expect (stream.isExhausted() == (numBytesRead == data.getSize()));
}
expectEquals (stream.getPosition(), (int64) data.getSize());
expectEquals (stream.getNumBytesRemaining(), (int64) 0);
expect (stream.isExhausted());
}
};
static BufferedInputStreamTests bufferedInputStreamTests;
#endif
} // namespace juce

View File

@ -61,7 +61,7 @@ public:
This may also delete the source stream, if that option was chosen when the
buffered stream was created.
*/
~BufferedInputStream();
~BufferedInputStream() override;
//==============================================================================

View File

@ -43,11 +43,11 @@ public:
FileInputSource (const File& file, bool useFileTimeInHashGeneration = false);
/** Destructor. */
~FileInputSource();
~FileInputSource() override;
InputStream* createInputStream();
InputStream* createInputStreamFor (const String& relatedItemPath);
int64 hashCode() const;
InputStream* createInputStream() override;
InputStream* createInputStreamFor (const String& relatedItemPath) override;
int64 hashCode() const override;
private:
//==============================================================================

View File

@ -38,10 +38,10 @@ class JUCE_API InputSource
{
public:
//==============================================================================
InputSource() noexcept {}
InputSource() = default;
/** Destructor. */
virtual ~InputSource() {}
virtual ~InputSource() = default;
//==============================================================================
/** Returns a new InputStream to read this item.

View File

@ -37,7 +37,7 @@ class JUCE_API InputStream
{
public:
/** Destructor. */
virtual ~InputStream() {}
virtual ~InputStream() = default;
//==============================================================================
/** Returns the total number of bytes available for reading in this stream.
@ -243,16 +243,17 @@ public:
/** Reads and discards a number of bytes from the stream.
Some input streams might implement this efficiently, but the base
Some input streams might implement this more efficiently, but the base
class will just keep reading data until the requisite number of bytes
have been done.
have been done. For large skips it may be quicker to call setPosition()
with the required position.
*/
virtual void skipNextBytes (int64 numBytesToSkip);
protected:
//==============================================================================
InputStream() noexcept {}
InputStream() = default;
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (InputStream)

View File

@ -89,6 +89,11 @@ int64 MemoryInputStream::getPosition()
return (int64) position;
}
void MemoryInputStream::skipNextBytes (int64 numBytesToSkip)
{
if (numBytesToSkip > 0)
setPosition (getPosition() + numBytesToSkip);
}
//==============================================================================
#if JUCE_UNIT_TESTS
@ -96,7 +101,9 @@ int64 MemoryInputStream::getPosition()
class MemoryStreamTests : public UnitTest
{
public:
MemoryStreamTests() : UnitTest ("MemoryInputStream & MemoryOutputStream", "Memory Streams") {}
MemoryStreamTests()
: UnitTest ("MemoryInputStream & MemoryOutputStream", "Streams")
{}
void runTest() override
{
@ -127,6 +134,60 @@ public:
expect (mi.readInt64BigEndian() == randomInt64);
expect (mi.readDouble() == randomDouble);
expect (mi.readDoubleBigEndian() == randomDouble);
const MemoryBlock data ("abcdefghijklmnopqrstuvwxyz", 26);
MemoryInputStream stream (data, true);
beginTest ("Read");
expectEquals (stream.getPosition(), (int64) 0);
expectEquals (stream.getTotalLength(), (int64) data.getSize());
expectEquals (stream.getNumBytesRemaining(), stream.getTotalLength());
expect (! stream.isExhausted());
size_t numBytesRead = 0;
MemoryBlock readBuffer (data.getSize());
while (numBytesRead < data.getSize())
{
numBytesRead += (size_t) stream.read (&readBuffer[numBytesRead], 3);
expectEquals (stream.getPosition(), (int64) numBytesRead);
expectEquals (stream.getNumBytesRemaining(), (int64) (data.getSize() - numBytesRead));
expect (stream.isExhausted() == (numBytesRead == data.getSize()));
}
expectEquals (stream.getPosition(), (int64) data.getSize());
expectEquals (stream.getNumBytesRemaining(), (int64) 0);
expect (stream.isExhausted());
expect (readBuffer == data);
beginTest ("Skip");
stream.setPosition (0);
expectEquals (stream.getPosition(), (int64) 0);
expectEquals (stream.getTotalLength(), (int64) data.getSize());
expectEquals (stream.getNumBytesRemaining(), stream.getTotalLength());
expect (! stream.isExhausted());
numBytesRead = 0;
const int numBytesToSkip = 5;
while (numBytesRead < data.getSize())
{
stream.skipNextBytes (numBytesToSkip);
numBytesRead += numBytesToSkip;
numBytesRead = std::min (numBytesRead, data.getSize());
expectEquals (stream.getPosition(), (int64) numBytesRead);
expectEquals (stream.getNumBytesRemaining(), (int64) (data.getSize() - numBytesRead));
expect (stream.isExhausted() == (numBytesRead == data.getSize()));
}
expectEquals (stream.getPosition(), (int64) data.getSize());
expectEquals (stream.getNumBytesRemaining(), (int64) 0);
expect (stream.isExhausted());
}
static String createRandomWideCharString (Random& r)

View File

@ -63,7 +63,7 @@ public:
bool keepInternalCopyOfData);
/** Destructor. */
~MemoryInputStream();
~MemoryInputStream() override;
/** Returns a pointer to the source data block from which this stream is reading. */
const void* getData() const noexcept { return data; }
@ -77,6 +77,7 @@ public:
int64 getTotalLength() override;
bool isExhausted() override;
int read (void* destBuffer, int maxBytesToRead) override;
void skipNextBytes (int64 numBytesToSkip) override;
private:
//==============================================================================

View File

@ -101,11 +101,11 @@ char* MemoryOutputStream::prepareToWrite (size_t numBytes)
bool MemoryOutputStream::write (const void* const buffer, size_t howMany)
{
jassert (buffer != nullptr);
if (howMany == 0)
return true;
jassert (buffer != nullptr);
if (auto* dest = prepareToWrite (howMany))
{
memcpy (dest, buffer, howMany);

View File

@ -37,7 +37,7 @@ class JUCE_API MemoryOutputStream : public OutputStream
public:
//==============================================================================
/** Creates an empty memory stream, ready to be written into.
@param initialSize the intial amount of capacity to allocate for writing into
@param initialSize the initial amount of capacity to allocate for writing into
*/
MemoryOutputStream (size_t initialSize = 256);
@ -66,7 +66,7 @@ public:
/** Destructor.
This will free any data that was written to it.
*/
~MemoryOutputStream();
~MemoryOutputStream() override;
//==============================================================================
/** Returns a pointer to the data that has been written to the stream.

View File

@ -78,4 +78,81 @@ bool SubregionStream::isExhausted()
return source->isExhausted();
}
//==============================================================================
#if JUCE_UNIT_TESTS
struct SubregionInputStreamTests : public UnitTest
{
SubregionInputStreamTests()
: UnitTest ("SubregionInputStream", "Streams")
{}
void runTest() override
{
const MemoryBlock data ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", 52);
MemoryInputStream mi (data, true);
const int offset = getRandom().nextInt ((int) data.getSize());
const size_t subregionSize = data.getSize() - (size_t) offset;
SubregionStream stream (&mi, offset, (int) subregionSize, false);
beginTest ("Read");
expectEquals (stream.getPosition(), (int64) 0);
expectEquals (stream.getTotalLength(), (int64) subregionSize);
expectEquals (stream.getNumBytesRemaining(), stream.getTotalLength());
expect (! stream.isExhausted());
size_t numBytesRead = 0;
MemoryBlock readBuffer (subregionSize);
while (numBytesRead < subregionSize)
{
numBytesRead += (size_t) stream.read (&readBuffer[numBytesRead], 3);
expectEquals (stream.getPosition(), (int64) numBytesRead);
expectEquals (stream.getNumBytesRemaining(), (int64) (subregionSize - numBytesRead));
expect (stream.isExhausted() == (numBytesRead == subregionSize));
}
expectEquals (stream.getPosition(), (int64) subregionSize);
expectEquals (stream.getNumBytesRemaining(), (int64) 0);
expect (stream.isExhausted());
const MemoryBlock memoryBlockToCheck (data.begin() + (size_t) offset, data.getSize() - (size_t) offset);
expect (readBuffer == memoryBlockToCheck);
beginTest ("Skip");
stream.setPosition (0);
expectEquals (stream.getPosition(), (int64) 0);
expectEquals (stream.getTotalLength(), (int64) subregionSize);
expectEquals (stream.getNumBytesRemaining(), stream.getTotalLength());
expect (! stream.isExhausted());
numBytesRead = 0;
const int64 numBytesToSkip = 5;
while (numBytesRead < subregionSize)
{
stream.skipNextBytes (numBytesToSkip);
numBytesRead += numBytesToSkip;
numBytesRead = std::min (numBytesRead, subregionSize);
expectEquals (stream.getPosition(), (int64) numBytesRead);
expectEquals (stream.getNumBytesRemaining(), (int64) (subregionSize - numBytesRead));
expect (stream.isExhausted() == (numBytesRead == subregionSize));
}
expectEquals (stream.getPosition(), (int64) subregionSize);
expectEquals (stream.getNumBytesRemaining(), (int64) 0);
expect (stream.isExhausted());
}
};
static SubregionInputStreamTests subregionInputStreamTests;
#endif
} // namespace juce

View File

@ -62,7 +62,7 @@ public:
This may also delete the source stream, if that option was chosen when the
buffered stream was created.
*/
~SubregionStream();
~SubregionStream() override;
//==============================================================================

View File

@ -29,7 +29,7 @@ URLInputSource::URLInputSource (const URL& url)
}
URLInputSource::URLInputSource (URL&& url)
: u (static_cast<URL&&> (url))
: u (std::move (url))
{
}

View File

@ -45,11 +45,11 @@ public:
URLInputSource (URL&& url);
/** Destructor. */
~URLInputSource();
~URLInputSource() override;
InputStream* createInputStream();
InputStream* createInputStreamFor (const String& relatedItemPath);
int64 hashCode() const;
InputStream* createInputStream() override;
InputStream* createInputStreamFor (const String& relatedItemPath) override;
int64 hashCode() const override;
private:
//==============================================================================