diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index b02bb1e9c7..e8b659ec42 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -3586,12 +3586,6 @@ void MemoryBlock::copyTo (void* const dst, int offset, size_t num) const throw() void MemoryBlock::removeSection (size_t startByte, size_t numBytesToRemove) { - if (startByte < 0) - { - numBytesToRemove += startByte; - startByte = 0; - } - if (startByte + numBytesToRemove >= size) { setSize (startByte); @@ -5271,25 +5265,17 @@ public: text = textString; } - const TermPtr readExpression() + const TermPtr readUpToComma() { - TermPtr lhs (readMultiplyOrDivideExpression()); + if (textString.isEmpty()) + return new Constant (0.0, false); - char opType; - while (lhs != 0 && readOperator ("+-", &opType)) - { - TermPtr rhs (readMultiplyOrDivideExpression()); + const TermPtr e (readExpression()); - if (rhs == 0) - throw ParseError ("Expected expression after \"" + String::charToString (opType) + "\""); + if (e == 0 || ((! readOperator (",")) && text [textIndex] != 0)) + throw ParseError ("Syntax error: \"" + textString.substring (textIndex) + "\""); - if (opType == '+') - lhs = new Add (lhs, rhs); - else - lhs = new Subtract (lhs, rhs); - } - - return lhs; + return e; } private: @@ -5431,6 +5417,27 @@ public: return new Constant (String (text + start, i - start).getDoubleValue(), isResolutionTarget); } + const TermPtr readExpression() + { + TermPtr lhs (readMultiplyOrDivideExpression()); + + char opType; + while (lhs != 0 && readOperator ("+-", &opType)) + { + TermPtr rhs (readMultiplyOrDivideExpression()); + + if (rhs == 0) + throw ParseError ("Expected expression after \"" + String::charToString (opType) + "\""); + + if (opType == '+') + lhs = new Add (lhs, rhs); + else + lhs = new Subtract (lhs, rhs); + } + + return lhs; + } + const TermPtr readMultiplyOrDivideExpression() { TermPtr lhs (readUnaryExpression()); @@ -5594,21 +5601,13 @@ Expression::Expression (const String& stringToParse) { int i = 0; Helpers::Parser parser (stringToParse, i); - term = parser.readExpression(); - - if (term == 0) - term = new Helpers::Constant (0, false); + term = parser.readUpToComma(); } const Expression Expression::parse (const String& stringToParse, int& textIndexToStartFrom) { Helpers::Parser parser (stringToParse, textIndexToStartFrom); - const Helpers::TermPtr term (parser.readExpression()); - - if (term != 0) - return Expression (term); - - return Expression(); + return Expression (parser.readUpToComma()); } double Expression::evaluate() const @@ -28419,9 +28418,6 @@ bool MidiFile::readFrom (InputStream& sourceStream) if (chunkSize <= 0) break; - if (size < 0) - return false; - if (chunkType == (int) ByteOrder::bigEndianInt ("MTrk")) { readNextTrack (d, chunkSize); @@ -28733,6 +28729,19 @@ END_JUCE_NAMESPACE /*** Start of inlined file: juce_MidiMessage.cpp ***/ BEGIN_JUCE_NAMESPACE +namespace MidiHelpers +{ + inline uint8 initialByte (const int type, const int channel) throw() + { + return (uint8) (type | jlimit (0, 15, channel - 1)); + } + + inline uint8 validVelocity (const int v) throw() + { + return (uint8) jlimit (0, 127, v); + } +} + int MidiMessage::readVariableLengthVal (const uint8* data, int& numBytesUsed) throw() { numBytesUsed = 0; @@ -29036,7 +29045,7 @@ int MidiMessage::getNoteNumber() const throw() void MidiMessage::setNoteNumber (const int newNoteNumber) throw() { if (isNoteOnOrOff()) - data[1] = (uint8) jlimit (0, 127, newNoteNumber); + data[1] = newNoteNumber & 127; } uint8 MidiMessage::getVelocity() const throw() @@ -29055,13 +29064,13 @@ float MidiMessage::getFloatVelocity() const throw() void MidiMessage::setVelocity (const float newVelocity) throw() { if (isNoteOnOrOff()) - data[2] = (uint8) jlimit (0, 0x7f, roundToInt (newVelocity * 127.0f)); + data[2] = MidiHelpers::validVelocity (roundToInt (newVelocity * 127.0f)); } void MidiMessage::multiplyVelocity (const float scaleFactor) throw() { if (isNoteOnOrOff()) - data[2] = (uint8) jlimit (0, 0x7f, roundToInt (scaleFactor * data[2])); + data[2] = MidiHelpers::validVelocity (roundToInt (scaleFactor * data[2])); } bool MidiMessage::isAftertouch() const throw() @@ -29082,7 +29091,7 @@ const MidiMessage MidiMessage::aftertouchChange (const int channel, jassert (isPositiveAndBelow (noteNum, (int) 128)); jassert (isPositiveAndBelow (aftertouchValue, (int) 128)); - return MidiMessage (0xa0 | jlimit (0, 15, channel - 1), + return MidiMessage (MidiHelpers::initialByte (0xa0, channel), noteNum & 0x7f, aftertouchValue & 0x7f); } @@ -29105,8 +29114,7 @@ const MidiMessage MidiMessage::channelPressureChange (const int channel, jassert (channel > 0 && channel <= 16); // valid channels are numbered 1 to 16 jassert (isPositiveAndBelow (pressure, (int) 128)); - return MidiMessage (0xd0 | jlimit (0, 15, channel - 1), - pressure & 0x7f); + return MidiMessage (MidiHelpers::initialByte (0xd0, channel), pressure & 0x7f); } bool MidiMessage::isProgramChange() const throw() @@ -29124,8 +29132,7 @@ const MidiMessage MidiMessage::programChange (const int channel, { jassert (channel > 0 && channel <= 16); // valid channels are numbered 1 to 16 - return MidiMessage (0xc0 | jlimit (0, 15, channel - 1), - programNumber & 0x7f); + return MidiMessage (MidiHelpers::initialByte (0xc0, channel), programNumber & 0x7f); } bool MidiMessage::isPitchWheel() const throw() @@ -29144,9 +29151,7 @@ const MidiMessage MidiMessage::pitchWheel (const int channel, jassert (channel > 0 && channel <= 16); // valid channels are numbered 1 to 16 jassert (isPositiveAndBelow (position, (int) 0x4000)); - return MidiMessage (0xe0 | jlimit (0, 15, channel - 1), - position & 127, - (position >> 7) & 127); + return MidiMessage (MidiHelpers::initialByte (0xe0, channel), position & 127, (position >> 7) & 127); } bool MidiMessage::isController() const throw() @@ -29168,44 +29173,33 @@ int MidiMessage::getControllerValue() const throw() return data[2]; } -const MidiMessage MidiMessage::controllerEvent (const int channel, - const int controllerType, - const int value) throw() +const MidiMessage MidiMessage::controllerEvent (const int channel, const int controllerType, const int value) throw() { // the channel must be between 1 and 16 inclusive jassert (channel > 0 && channel <= 16); - return MidiMessage (0xb0 | jlimit (0, 15, channel - 1), - controllerType & 127, - value & 127); + return MidiMessage (MidiHelpers::initialByte (0xb0, channel), controllerType & 127, value & 127); } -const MidiMessage MidiMessage::noteOn (const int channel, - const int noteNumber, - const float velocity) throw() +const MidiMessage MidiMessage::noteOn (const int channel, const int noteNumber, const float velocity) throw() { return noteOn (channel, noteNumber, (uint8)(velocity * 127.0f)); } -const MidiMessage MidiMessage::noteOn (const int channel, - const int noteNumber, - const uint8 velocity) throw() +const MidiMessage MidiMessage::noteOn (const int channel, const int noteNumber, const uint8 velocity) throw() { jassert (channel > 0 && channel <= 16); jassert (isPositiveAndBelow (noteNumber, (int) 128)); - return MidiMessage (0x90 | jlimit (0, 15, channel - 1), - noteNumber & 127, - jlimit (0, 127, roundToInt (velocity))); + return MidiMessage (MidiHelpers::initialByte (0x90, channel), noteNumber & 127, MidiHelpers::validVelocity (velocity)); } -const MidiMessage MidiMessage::noteOff (const int channel, - const int noteNumber) throw() +const MidiMessage MidiMessage::noteOff (const int channel, const int noteNumber, uint8 velocity) throw() { jassert (channel > 0 && channel <= 16); jassert (isPositiveAndBelow (noteNumber, (int) 128)); - return MidiMessage (0x80 | jlimit (0, 15, channel - 1), noteNumber & 127, 0); + return MidiMessage (MidiHelpers::initialByte (0x80, channel), noteNumber & 127, MidiHelpers::validVelocity (velocity)); } const MidiMessage MidiMessage::allNotesOff (const int channel) throw() @@ -29257,8 +29251,7 @@ bool MidiMessage::isSysEx() const throw() const MidiMessage MidiMessage::createSysExMessage (const uint8* sysexData, const int dataSize) { - MemoryBlock mm (dataSize + 2); - uint8* const m = static_cast (mm.getData()); + HeapBlock m (dataSize + 2); m[0] = 0xf0; memcpy (m + 1, sysexData, dataSize); @@ -32820,7 +32813,7 @@ END_JUCE_NAMESPACE #define STRICT #include #include - #pragma warning (disable : 4312 4355) + #pragma warning (disable : 4312 4355 1899) #elif JUCE_LINUX #include #include @@ -38621,26 +38614,16 @@ bool InterprocessConnection::sendMessage (const MemoryBlock& message) messageData.copyFrom (messageHeader, 0, sizeof (messageHeader)); messageData.copyFrom (message.getData(), sizeof (messageHeader), message.getSize()); - size_t bytesWritten = 0; + int bytesWritten = 0; const ScopedLock sl (pipeAndSocketLock); if (socket != 0) - { bytesWritten = socket->write (messageData.getData(), (int) messageData.getSize()); - } else if (pipe != 0) - { bytesWritten = pipe->write (messageData.getData(), (int) messageData.getSize()); - } - if (bytesWritten < 0) - { - // error.. - return false; - } - - return (bytesWritten == messageData.getSize()); + return bytesWritten == (int) messageData.getSize(); } void InterprocessConnection::initialiseWithSocket (StreamingSocket* const socket_) @@ -48259,18 +48242,17 @@ void Label::showEditor() } } -void Label::editorShown (TextEditor* /*editorComponent*/) +void Label::editorShown (TextEditor*) { } -void Label::editorAboutToBeHidden (TextEditor* /*editorComponent*/) +void Label::editorAboutToBeHidden (TextEditor*) { } -bool Label::updateFromTextEditorContents() +bool Label::updateFromTextEditorContents (TextEditor& ed) { - jassert (editor != 0); - const String newText (editor->getText()); + const String newText (ed.getText()); if (textValue.toString() != newText) { @@ -48295,12 +48277,13 @@ void Label::hideEditor (const bool discardCurrentEditorContents) { WeakReference deletionChecker (this); - editorAboutToBeHidden (editor); + ScopedPointer outgoingEditor (editor); + + editorAboutToBeHidden (outgoingEditor); const bool changed = (! discardCurrentEditorContents) - && updateFromTextEditorContents(); - - editor = 0; + && updateFromTextEditorContents (*outgoingEditor); + outgoingEditor = 0; repaint(); if (changed) @@ -48466,9 +48449,8 @@ void Label::textEditorReturnKeyPressed (TextEditor& ed) if (editor != 0) { jassert (&ed == editor); - (void) ed; - const bool changed = updateFromTextEditorContents(); + const bool changed = updateFromTextEditorContents (ed); hideEditor (true); if (changed) @@ -61221,7 +61203,7 @@ public: component->setVisible (! useProxyComponent); } - int useTimeslice (const int elapsed) + bool useTimeslice (const int elapsed) { Component* const c = proxy != 0 ? static_cast (proxy) : static_cast (component); @@ -61269,13 +61251,13 @@ public: } if (stillBusy) - return 0; + return true; } } } moveToFinalDestination(); - return -1; + return false; } void moveToFinalDestination() @@ -80302,7 +80284,7 @@ void RelativeCoordinatePositionerBase::ComponentScope::visitRelativeScope (const const String RelativeCoordinatePositionerBase::ComponentScope::getScopeUID() const { - return String::toHexString ((pointer_sized_int) (void*) &component); + return String::toHexString ((int) (pointer_sized_int) (void*) &component); } Component* RelativeCoordinatePositionerBase::ComponentScope::findSiblingComponent (const String& componentID) const @@ -84066,7 +84048,7 @@ private: SrcPixelType* sourceLineStart; template - forcedinline static void copyRow (PixelType1* dest, PixelType2* src, int width) throw() + static forcedinline void copyRow (PixelType1* dest, PixelType2* src, int width) throw() { do { @@ -84074,7 +84056,7 @@ private: } while (--width > 0); } - forcedinline static void copyRow (PixelRGB* dest, PixelRGB* src, int width) throw() + static forcedinline void copyRow (PixelRGB* dest, PixelRGB* src, int width) throw() { memcpy (dest, src, width * sizeof (PixelRGB)); } @@ -86520,7 +86502,7 @@ const Rectangle DrawableShape::getDrawableBounds() const return path.getBounds(); } -bool DrawableShape::hitTest (int x, int y) const +bool DrawableShape::hitTest (int x, int y) { const float globalX = (float) (x - originRelativeToComponent.getX()); const float globalY = (float) (y - originRelativeToComponent.getY()); @@ -92255,7 +92237,7 @@ void Path::closeSubPath() const Point Path::getCurrentPosition() const { - size_t i = numElements - 1; + int i = (int) numElements - 1; if (i > 0 && data.elements[i] == closeSubPathMarker) { @@ -105773,8 +105755,8 @@ namespace FlacNamespace { #if JUCE_INCLUDE_FLAC_CODE #if JUCE_MSVC - #pragma warning (disable : 4505) // (unreferenced static function removal warning) - #endif + #pragma warning (disable: 4505 181 111) +#endif #define FLAC__NO_DLL 1 @@ -211698,6 +211680,9 @@ END_JUCE_NAMESPACE #if JUCE_MSVC #pragma warning (push) #pragma warning (disable: 4390 4611) + #ifdef __INTEL_COMPILER + #pragma warning (disable: 2544 2545) + #endif #endif namespace zlibNamespace @@ -239184,8 +239169,6 @@ void NamedPipe::cancelPendingReads() #define INTERNET_OPTION_DISABLE_AUTODIAL 70 #endif -static HINTERNET sessionHandle = 0; - #ifndef WORKAROUND_TIMEOUT_BUG //#define WORKAROUND_TIMEOUT_BUG 1 #endif @@ -239195,8 +239178,8 @@ static HINTERNET sessionHandle = 0; class InternetConnectThread : public Thread { public: - InternetConnectThread (URL_COMPONENTS& uc_, HINTERNET& connection_, const bool isFtp_) - : Thread ("Internet"), uc (uc_), connection (connection_), isFtp (isFtp_) + InternetConnectThread (URL_COMPONENTS& uc_, HINTERNET sessionHandle_, HINTERNET& connection_, const bool isFtp_) + : Thread ("Internet"), uc (uc_), sessionHandle (sessionHandle_), connection (connection_), isFtp (isFtp_) { startThread(); } @@ -239218,6 +239201,7 @@ public: private: URL_COMPONENTS& uc; + HINTERNET sessionHandle; HINTERNET& connection; const bool isFtp; @@ -239398,7 +239382,7 @@ private: connection = 0; { - InternetConnectThread connectThread (uc, connection, isFtp); + InternetConnectThread connectThread (uc, sessionHandle, connection, isFtp); connectThread.wait (timeOutMs); if (connection == 0) @@ -240224,7 +240208,7 @@ class FontDCHolder : private DeletedAtShutdown public: FontDCHolder() - : dc (0), fontH (0), previousFontH (0), numKPs (0), size (0), + : fontH (0), previousFontH (0), dc (0), numKPs (0), size (0), bold (false), italic (false) { } @@ -241817,8 +241801,8 @@ public: constrainerIsResizing (false), currentWindowIcon (0), dropTarget (0), - updateLayeredWindowAlpha (255), - parentToAddTo (parentToAddTo_) + parentToAddTo (parentToAddTo_), + updateLayeredWindowAlpha (255) { callFunctionIfNotLocked (&createWindowCallback, this); @@ -243218,7 +243202,7 @@ private: if (pDropFiles->fWide) { - const WCHAR* const fname = (WCHAR*) (((const char*) pDropFiles) + sizeof (DROPFILES)); + const WCHAR* const fname = (WCHAR*) addBytesToPointer (pDropFiles, sizeof (DROPFILES)); for (;;) { @@ -243235,7 +243219,7 @@ private: } else { - const char* const fname = ((const char*) pDropFiles) + sizeof (DROPFILES); + const char* const fname = (const char*) addBytesToPointer (pDropFiles, sizeof (DROPFILES)); for (;;) { @@ -245807,8 +245791,8 @@ public: HGLRC contextToShareWith, const OpenGLPixelFormat& pixelFormat) : renderContext (0), - dc (0), - component (component_) + component (component_), + dc (0) { jassert (component != 0); @@ -251056,16 +251040,16 @@ public: const int inputDeviceIndex_) : AudioIODevice (deviceName, "DirectSound"), Thread ("Juce DSound"), - isOpen_ (false), - isStarted (false), outputDeviceIndex (outputDeviceIndex_), inputDeviceIndex (inputDeviceIndex_), + isOpen_ (false), + isStarted (false), + bufferSizeSamples (0), totalSamplesOut (0), sampleRate (0.0), inputBuffers (1, 1), outputBuffers (1, 1), - callback (0), - bufferSizeSamples (0) + callback (0) { if (outputDeviceIndex_ >= 0) { @@ -251750,9 +251734,9 @@ public: WASAPIDeviceBase (const ComSmartPtr & device_, const bool useExclusiveMode_) : device (device_), sampleRate (0), + defaultSampleRate (0), numChannels (0), actualNumChannels (0), - defaultSampleRate (0), minBufferSize (0), defaultBufferSize (0), latencySamples (0), @@ -252162,11 +252146,11 @@ public: const bool useExclusiveMode_) : AudioIODevice (deviceName, "Windows Audio"), Thread ("Juce WASAPI"), - isOpen_ (false), - isStarted (false), outputDeviceId (outputDeviceId_), inputDeviceId (inputDeviceId_), useExclusiveMode (useExclusiveMode_), + isOpen_ (false), + isStarted (false), currentBufferSizeSamples (0), currentSampleRate (0), callback (0) diff --git a/juce_amalgamated.h b/juce_amalgamated.h index c162ac7e13..095866bb82 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -35743,7 +35743,7 @@ public: @param noteNumber the key number, 0 to 127 @see isNoteOff */ - static const MidiMessage noteOff (int channel, int noteNumber) throw(); + static const MidiMessage noteOff (int channel, int noteNumber, uint8 velocity = 0) throw(); /** Returns true if this message is a 'key-down' or 'key-up' event. @@ -39463,7 +39463,7 @@ private: bool lossOfFocusDiscardsChanges : 1; bool leftOfOwnerComp : 1; - bool updateFromTextEditorContents(); + bool updateFromTextEditorContents (TextEditor&); void callChangeListeners(); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Label); @@ -62185,7 +62185,7 @@ public: /** @internal */ void paint (Graphics& g); /** @internal */ - bool hitTest (int x, int y) const; + bool hitTest (int x, int y); protected: diff --git a/src/audio/audio_file_formats/juce_FlacAudioFormat.cpp b/src/audio/audio_file_formats/juce_FlacAudioFormat.cpp index ca88be48f7..075afc1244 100644 --- a/src/audio/audio_file_formats/juce_FlacAudioFormat.cpp +++ b/src/audio/audio_file_formats/juce_FlacAudioFormat.cpp @@ -38,8 +38,8 @@ namespace FlacNamespace { #if JUCE_INCLUDE_FLAC_CODE #if JUCE_MSVC - #pragma warning (disable : 4505) // (unreferenced static function removal warning) - #endif + #pragma warning (disable: 4505 181 111) +#endif #define FLAC__NO_DLL 1 diff --git a/src/audio/midi/juce_MidiFile.cpp b/src/audio/midi/juce_MidiFile.cpp index 4618aaf3bd..acd2549ed9 100644 --- a/src/audio/midi/juce_MidiFile.cpp +++ b/src/audio/midi/juce_MidiFile.cpp @@ -309,9 +309,6 @@ bool MidiFile::readFrom (InputStream& sourceStream) if (chunkSize <= 0) break; - if (size < 0) - return false; - if (chunkType == (int) ByteOrder::bigEndianInt ("MTrk")) { readNextTrack (d, chunkSize); diff --git a/src/audio/midi/juce_MidiMessage.cpp b/src/audio/midi/juce_MidiMessage.cpp index bf1fea414c..437ba7a638 100644 --- a/src/audio/midi/juce_MidiMessage.cpp +++ b/src/audio/midi/juce_MidiMessage.cpp @@ -28,8 +28,20 @@ BEGIN_JUCE_NAMESPACE #include "juce_MidiMessage.h" -#include "../../memory/juce_MemoryBlock.h" +#include "../../memory/juce_HeapBlock.h" +namespace MidiHelpers +{ + inline uint8 initialByte (const int type, const int channel) throw() + { + return (uint8) (type | jlimit (0, 15, channel - 1)); + } + + inline uint8 validVelocity (const int v) throw() + { + return (uint8) jlimit (0, 127, v); + } +} //============================================================================== int MidiMessage::readVariableLengthVal (const uint8* data, int& numBytesUsed) throw() @@ -336,7 +348,7 @@ int MidiMessage::getNoteNumber() const throw() void MidiMessage::setNoteNumber (const int newNoteNumber) throw() { if (isNoteOnOrOff()) - data[1] = (uint8) jlimit (0, 127, newNoteNumber); + data[1] = newNoteNumber & 127; } uint8 MidiMessage::getVelocity() const throw() @@ -355,13 +367,13 @@ float MidiMessage::getFloatVelocity() const throw() void MidiMessage::setVelocity (const float newVelocity) throw() { if (isNoteOnOrOff()) - data[2] = (uint8) jlimit (0, 0x7f, roundToInt (newVelocity * 127.0f)); + data[2] = MidiHelpers::validVelocity (roundToInt (newVelocity * 127.0f)); } void MidiMessage::multiplyVelocity (const float scaleFactor) throw() { if (isNoteOnOrOff()) - data[2] = (uint8) jlimit (0, 0x7f, roundToInt (scaleFactor * data[2])); + data[2] = MidiHelpers::validVelocity (roundToInt (scaleFactor * data[2])); } bool MidiMessage::isAftertouch() const throw() @@ -382,7 +394,7 @@ const MidiMessage MidiMessage::aftertouchChange (const int channel, jassert (isPositiveAndBelow (noteNum, (int) 128)); jassert (isPositiveAndBelow (aftertouchValue, (int) 128)); - return MidiMessage (0xa0 | jlimit (0, 15, channel - 1), + return MidiMessage (MidiHelpers::initialByte (0xa0, channel), noteNum & 0x7f, aftertouchValue & 0x7f); } @@ -405,8 +417,7 @@ const MidiMessage MidiMessage::channelPressureChange (const int channel, jassert (channel > 0 && channel <= 16); // valid channels are numbered 1 to 16 jassert (isPositiveAndBelow (pressure, (int) 128)); - return MidiMessage (0xd0 | jlimit (0, 15, channel - 1), - pressure & 0x7f); + return MidiMessage (MidiHelpers::initialByte (0xd0, channel), pressure & 0x7f); } bool MidiMessage::isProgramChange() const throw() @@ -424,8 +435,7 @@ const MidiMessage MidiMessage::programChange (const int channel, { jassert (channel > 0 && channel <= 16); // valid channels are numbered 1 to 16 - return MidiMessage (0xc0 | jlimit (0, 15, channel - 1), - programNumber & 0x7f); + return MidiMessage (MidiHelpers::initialByte (0xc0, channel), programNumber & 0x7f); } bool MidiMessage::isPitchWheel() const throw() @@ -444,9 +454,7 @@ const MidiMessage MidiMessage::pitchWheel (const int channel, jassert (channel > 0 && channel <= 16); // valid channels are numbered 1 to 16 jassert (isPositiveAndBelow (position, (int) 0x4000)); - return MidiMessage (0xe0 | jlimit (0, 15, channel - 1), - position & 127, - (position >> 7) & 127); + return MidiMessage (MidiHelpers::initialByte (0xe0, channel), position & 127, (position >> 7) & 127); } bool MidiMessage::isController() const throw() @@ -468,44 +476,33 @@ int MidiMessage::getControllerValue() const throw() return data[2]; } -const MidiMessage MidiMessage::controllerEvent (const int channel, - const int controllerType, - const int value) throw() +const MidiMessage MidiMessage::controllerEvent (const int channel, const int controllerType, const int value) throw() { // the channel must be between 1 and 16 inclusive jassert (channel > 0 && channel <= 16); - return MidiMessage (0xb0 | jlimit (0, 15, channel - 1), - controllerType & 127, - value & 127); + return MidiMessage (MidiHelpers::initialByte (0xb0, channel), controllerType & 127, value & 127); } -const MidiMessage MidiMessage::noteOn (const int channel, - const int noteNumber, - const float velocity) throw() +const MidiMessage MidiMessage::noteOn (const int channel, const int noteNumber, const float velocity) throw() { return noteOn (channel, noteNumber, (uint8)(velocity * 127.0f)); } -const MidiMessage MidiMessage::noteOn (const int channel, - const int noteNumber, - const uint8 velocity) throw() +const MidiMessage MidiMessage::noteOn (const int channel, const int noteNumber, const uint8 velocity) throw() { jassert (channel > 0 && channel <= 16); jassert (isPositiveAndBelow (noteNumber, (int) 128)); - return MidiMessage (0x90 | jlimit (0, 15, channel - 1), - noteNumber & 127, - jlimit (0, 127, roundToInt (velocity))); + return MidiMessage (MidiHelpers::initialByte (0x90, channel), noteNumber & 127, MidiHelpers::validVelocity (velocity)); } -const MidiMessage MidiMessage::noteOff (const int channel, - const int noteNumber) throw() +const MidiMessage MidiMessage::noteOff (const int channel, const int noteNumber, uint8 velocity) throw() { jassert (channel > 0 && channel <= 16); jassert (isPositiveAndBelow (noteNumber, (int) 128)); - return MidiMessage (0x80 | jlimit (0, 15, channel - 1), noteNumber & 127, 0); + return MidiMessage (MidiHelpers::initialByte (0x80, channel), noteNumber & 127, MidiHelpers::validVelocity (velocity)); } const MidiMessage MidiMessage::allNotesOff (const int channel) throw() @@ -558,8 +555,7 @@ bool MidiMessage::isSysEx() const throw() const MidiMessage MidiMessage::createSysExMessage (const uint8* sysexData, const int dataSize) { - MemoryBlock mm (dataSize + 2); - uint8* const m = static_cast (mm.getData()); + HeapBlock m (dataSize + 2); m[0] = 0xf0; memcpy (m + 1, sysexData, dataSize); diff --git a/src/audio/midi/juce_MidiMessage.h b/src/audio/midi/juce_MidiMessage.h index 20a3a811d3..c7d8b23f71 100644 --- a/src/audio/midi/juce_MidiMessage.h +++ b/src/audio/midi/juce_MidiMessage.h @@ -245,7 +245,7 @@ public: @param noteNumber the key number, 0 to 127 @see isNoteOff */ - static const MidiMessage noteOff (int channel, int noteNumber) throw(); + static const MidiMessage noteOff (int channel, int noteNumber, uint8 velocity = 0) throw(); /** Returns true if this message is a 'key-down' or 'key-up' event. diff --git a/src/audio/plugins/formats/juce_VSTPluginFormat.cpp b/src/audio/plugins/formats/juce_VSTPluginFormat.cpp index ff97c434b0..17905977f0 100644 --- a/src/audio/plugins/formats/juce_VSTPluginFormat.cpp +++ b/src/audio/plugins/formats/juce_VSTPluginFormat.cpp @@ -35,7 +35,7 @@ #define STRICT #include #include - #pragma warning (disable : 4312 4355) + #pragma warning (disable : 4312 4355 1899) #elif JUCE_LINUX #include #include diff --git a/src/events/juce_InterprocessConnection.cpp b/src/events/juce_InterprocessConnection.cpp index cc0949b061..c9ad324fad 100644 --- a/src/events/juce_InterprocessConnection.cpp +++ b/src/events/juce_InterprocessConnection.cpp @@ -168,26 +168,16 @@ bool InterprocessConnection::sendMessage (const MemoryBlock& message) messageData.copyFrom (messageHeader, 0, sizeof (messageHeader)); messageData.copyFrom (message.getData(), sizeof (messageHeader), message.getSize()); - size_t bytesWritten = 0; + int bytesWritten = 0; const ScopedLock sl (pipeAndSocketLock); if (socket != 0) - { bytesWritten = socket->write (messageData.getData(), (int) messageData.getSize()); - } else if (pipe != 0) - { bytesWritten = pipe->write (messageData.getData(), (int) messageData.getSize()); - } - if (bytesWritten < 0) - { - // error.. - return false; - } - - return (bytesWritten == messageData.getSize()); + return bytesWritten == (int) messageData.getSize(); } //============================================================================== diff --git a/src/gui/components/controls/juce_Label.cpp b/src/gui/components/controls/juce_Label.cpp index f19b6b94f0..e16ef28eb1 100644 --- a/src/gui/components/controls/juce_Label.cpp +++ b/src/gui/components/controls/juce_Label.cpp @@ -230,18 +230,17 @@ void Label::showEditor() } } -void Label::editorShown (TextEditor* /*editorComponent*/) +void Label::editorShown (TextEditor*) { } -void Label::editorAboutToBeHidden (TextEditor* /*editorComponent*/) +void Label::editorAboutToBeHidden (TextEditor*) { } -bool Label::updateFromTextEditorContents() +bool Label::updateFromTextEditorContents (TextEditor& ed) { - jassert (editor != 0); - const String newText (editor->getText()); + const String newText (ed.getText()); if (textValue.toString() != newText) { @@ -266,12 +265,13 @@ void Label::hideEditor (const bool discardCurrentEditorContents) { WeakReference deletionChecker (this); - editorAboutToBeHidden (editor); + ScopedPointer outgoingEditor (editor); + + editorAboutToBeHidden (outgoingEditor); const bool changed = (! discardCurrentEditorContents) - && updateFromTextEditorContents(); - - editor = 0; + && updateFromTextEditorContents (*outgoingEditor); + outgoingEditor = 0; repaint(); if (changed) @@ -441,9 +441,8 @@ void Label::textEditorReturnKeyPressed (TextEditor& ed) if (editor != 0) { jassert (&ed == editor); - (void) ed; - const bool changed = updateFromTextEditorContents(); + const bool changed = updateFromTextEditorContents (ed); hideEditor (true); if (changed) diff --git a/src/gui/components/controls/juce_Label.h b/src/gui/components/controls/juce_Label.h index 8af28c48c1..ea4071ce11 100644 --- a/src/gui/components/controls/juce_Label.h +++ b/src/gui/components/controls/juce_Label.h @@ -327,7 +327,7 @@ private: bool lossOfFocusDiscardsChanges : 1; bool leftOfOwnerComp : 1; - bool updateFromTextEditorContents(); + bool updateFromTextEditorContents (TextEditor&); void callChangeListeners(); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Label); diff --git a/src/gui/components/positioning/juce_RelativeCoordinatePositioner.cpp b/src/gui/components/positioning/juce_RelativeCoordinatePositioner.cpp index 3de66a14eb..5f2f8af420 100644 --- a/src/gui/components/positioning/juce_RelativeCoordinatePositioner.cpp +++ b/src/gui/components/positioning/juce_RelativeCoordinatePositioner.cpp @@ -75,7 +75,7 @@ void RelativeCoordinatePositionerBase::ComponentScope::visitRelativeScope (const const String RelativeCoordinatePositionerBase::ComponentScope::getScopeUID() const { - return String::toHexString ((pointer_sized_int) (void*) &component); + return String::toHexString ((int) (pointer_sized_int) (void*) &component); } Component* RelativeCoordinatePositionerBase::ComponentScope::findSiblingComponent (const String& componentID) const diff --git a/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp b/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp index a4f74f64e2..b3b1f03e82 100644 --- a/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp +++ b/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp @@ -543,7 +543,7 @@ private: SrcPixelType* sourceLineStart; template - forcedinline static void copyRow (PixelType1* dest, PixelType2* src, int width) throw() + static forcedinline void copyRow (PixelType1* dest, PixelType2* src, int width) throw() { do { @@ -551,7 +551,7 @@ private: } while (--width > 0); } - forcedinline static void copyRow (PixelRGB* dest, PixelRGB* src, int width) throw() + static forcedinline void copyRow (PixelRGB* dest, PixelRGB* src, int width) throw() { memcpy (dest, src, width * sizeof (PixelRGB)); } diff --git a/src/gui/graphics/drawables/juce_DrawableShape.cpp b/src/gui/graphics/drawables/juce_DrawableShape.cpp index 0eed3fc833..4b0a479a72 100644 --- a/src/gui/graphics/drawables/juce_DrawableShape.cpp +++ b/src/gui/graphics/drawables/juce_DrawableShape.cpp @@ -196,7 +196,7 @@ const Rectangle DrawableShape::getDrawableBounds() const return path.getBounds(); } -bool DrawableShape::hitTest (int x, int y) const +bool DrawableShape::hitTest (int x, int y) { const float globalX = (float) (x - originRelativeToComponent.getX()); const float globalY = (float) (y - originRelativeToComponent.getY()); diff --git a/src/gui/graphics/drawables/juce_DrawableShape.h b/src/gui/graphics/drawables/juce_DrawableShape.h index 421e9dde52..05bc04b290 100644 --- a/src/gui/graphics/drawables/juce_DrawableShape.h +++ b/src/gui/graphics/drawables/juce_DrawableShape.h @@ -152,7 +152,7 @@ public: /** @internal */ void paint (Graphics& g); /** @internal */ - bool hitTest (int x, int y) const; + bool hitTest (int x, int y); protected: //============================================================================== diff --git a/src/gui/graphics/geometry/juce_Path.cpp b/src/gui/graphics/geometry/juce_Path.cpp index 4415d44d30..64f43f461a 100644 --- a/src/gui/graphics/geometry/juce_Path.cpp +++ b/src/gui/graphics/geometry/juce_Path.cpp @@ -337,7 +337,7 @@ void Path::closeSubPath() const Point Path::getCurrentPosition() const { - size_t i = numElements - 1; + int i = (int) numElements - 1; if (i > 0 && data.elements[i] == closeSubPathMarker) { diff --git a/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp b/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp index d9847785a5..18c1955d4e 100644 --- a/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp +++ b/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp @@ -28,6 +28,9 @@ #if JUCE_MSVC #pragma warning (push) #pragma warning (disable: 4390 4611) + #ifdef __INTEL_COMPILER + #pragma warning (disable: 2544 2545) + #endif #endif namespace zlibNamespace diff --git a/src/maths/juce_Expression.cpp b/src/maths/juce_Expression.cpp index a294430ce8..738a62596a 100644 --- a/src/maths/juce_Expression.cpp +++ b/src/maths/juce_Expression.cpp @@ -656,25 +656,17 @@ public: text = textString; } - const TermPtr readExpression() + const TermPtr readUpToComma() { - TermPtr lhs (readMultiplyOrDivideExpression()); + if (textString.isEmpty()) + return new Constant (0.0, false); - char opType; - while (lhs != 0 && readOperator ("+-", &opType)) - { - TermPtr rhs (readMultiplyOrDivideExpression()); + const TermPtr e (readExpression()); - if (rhs == 0) - throw ParseError ("Expected expression after \"" + String::charToString (opType) + "\""); + if (e == 0 || ((! readOperator (",")) && text [textIndex] != 0)) + throw ParseError ("Syntax error: \"" + textString.substring (textIndex) + "\""); - if (opType == '+') - lhs = new Add (lhs, rhs); - else - lhs = new Subtract (lhs, rhs); - } - - return lhs; + return e; } private: @@ -817,6 +809,27 @@ public: return new Constant (String (text + start, i - start).getDoubleValue(), isResolutionTarget); } + const TermPtr readExpression() + { + TermPtr lhs (readMultiplyOrDivideExpression()); + + char opType; + while (lhs != 0 && readOperator ("+-", &opType)) + { + TermPtr rhs (readMultiplyOrDivideExpression()); + + if (rhs == 0) + throw ParseError ("Expected expression after \"" + String::charToString (opType) + "\""); + + if (opType == '+') + lhs = new Add (lhs, rhs); + else + lhs = new Subtract (lhs, rhs); + } + + return lhs; + } + const TermPtr readMultiplyOrDivideExpression() { TermPtr lhs (readUnaryExpression()); @@ -981,21 +994,13 @@ Expression::Expression (const String& stringToParse) { int i = 0; Helpers::Parser parser (stringToParse, i); - term = parser.readExpression(); - - if (term == 0) - term = new Helpers::Constant (0, false); + term = parser.readUpToComma(); } const Expression Expression::parse (const String& stringToParse, int& textIndexToStartFrom) { Helpers::Parser parser (stringToParse, textIndexToStartFrom); - const Helpers::TermPtr term (parser.readExpression()); - - if (term != 0) - return Expression (term); - - return Expression(); + return Expression (parser.readUpToComma()); } double Expression::evaluate() const diff --git a/src/memory/juce_MemoryBlock.cpp b/src/memory/juce_MemoryBlock.cpp index ebfb704543..f0ab797227 100644 --- a/src/memory/juce_MemoryBlock.cpp +++ b/src/memory/juce_MemoryBlock.cpp @@ -212,12 +212,6 @@ void MemoryBlock::copyTo (void* const dst, int offset, size_t num) const throw() void MemoryBlock::removeSection (size_t startByte, size_t numBytesToRemove) { - if (startByte < 0) - { - numBytesToRemove += startByte; - startByte = 0; - } - if (startByte + numBytesToRemove >= size) { setSize (startByte); diff --git a/src/native/windows/juce_win32_DirectSound.cpp b/src/native/windows/juce_win32_DirectSound.cpp index 599df288c9..64e36e71b5 100644 --- a/src/native/windows/juce_win32_DirectSound.cpp +++ b/src/native/windows/juce_win32_DirectSound.cpp @@ -801,16 +801,16 @@ public: const int inputDeviceIndex_) : AudioIODevice (deviceName, "DirectSound"), Thread ("Juce DSound"), - isOpen_ (false), - isStarted (false), outputDeviceIndex (outputDeviceIndex_), inputDeviceIndex (inputDeviceIndex_), + isOpen_ (false), + isStarted (false), + bufferSizeSamples (0), totalSamplesOut (0), sampleRate (0.0), inputBuffers (1, 1), outputBuffers (1, 1), - callback (0), - bufferSizeSamples (0) + callback (0) { if (outputDeviceIndex_ >= 0) { diff --git a/src/native/windows/juce_win32_Fonts.cpp b/src/native/windows/juce_win32_Fonts.cpp index 9c4a35f98f..d73cd99528 100644 --- a/src/native/windows/juce_win32_Fonts.cpp +++ b/src/native/windows/juce_win32_Fonts.cpp @@ -129,7 +129,7 @@ class FontDCHolder : private DeletedAtShutdown public: //============================================================================== FontDCHolder() - : dc (0), fontH (0), previousFontH (0), numKPs (0), size (0), + : fontH (0), previousFontH (0), dc (0), numKPs (0), size (0), bold (false), italic (false) { } diff --git a/src/native/windows/juce_win32_Network.cpp b/src/native/windows/juce_win32_Network.cpp index 6b0c132dff..a3bd584351 100644 --- a/src/native/windows/juce_win32_Network.cpp +++ b/src/native/windows/juce_win32_Network.cpp @@ -37,8 +37,6 @@ #endif //============================================================================== -static HINTERNET sessionHandle = 0; - #ifndef WORKAROUND_TIMEOUT_BUG //#define WORKAROUND_TIMEOUT_BUG 1 #endif @@ -48,8 +46,8 @@ static HINTERNET sessionHandle = 0; class InternetConnectThread : public Thread { public: - InternetConnectThread (URL_COMPONENTS& uc_, HINTERNET& connection_, const bool isFtp_) - : Thread ("Internet"), uc (uc_), connection (connection_), isFtp (isFtp_) + InternetConnectThread (URL_COMPONENTS& uc_, HINTERNET sessionHandle_, HINTERNET& connection_, const bool isFtp_) + : Thread ("Internet"), uc (uc_), sessionHandle (sessionHandle_), connection (connection_), isFtp (isFtp_) { startThread(); } @@ -71,6 +69,7 @@ public: private: URL_COMPONENTS& uc; + HINTERNET sessionHandle; HINTERNET& connection; const bool isFtp; @@ -254,7 +253,7 @@ private: connection = 0; { - InternetConnectThread connectThread (uc, connection, isFtp); + InternetConnectThread connectThread (uc, sessionHandle, connection, isFtp); connectThread.wait (timeOutMs); if (connection == 0) diff --git a/src/native/windows/juce_win32_OpenGLComponent.cpp b/src/native/windows/juce_win32_OpenGLComponent.cpp index 840f12b65d..97ae6715f7 100644 --- a/src/native/windows/juce_win32_OpenGLComponent.cpp +++ b/src/native/windows/juce_win32_OpenGLComponent.cpp @@ -81,8 +81,8 @@ public: HGLRC contextToShareWith, const OpenGLPixelFormat& pixelFormat) : renderContext (0), - dc (0), - component (component_) + component (component_), + dc (0) { jassert (component != 0); diff --git a/src/native/windows/juce_win32_WASAPI.cpp b/src/native/windows/juce_win32_WASAPI.cpp index df7b926603..a20d04b605 100644 --- a/src/native/windows/juce_win32_WASAPI.cpp +++ b/src/native/windows/juce_win32_WASAPI.cpp @@ -133,9 +133,9 @@ public: WASAPIDeviceBase (const ComSmartPtr & device_, const bool useExclusiveMode_) : device (device_), sampleRate (0), + defaultSampleRate (0), numChannels (0), actualNumChannels (0), - defaultSampleRate (0), minBufferSize (0), defaultBufferSize (0), latencySamples (0), @@ -548,11 +548,11 @@ public: const bool useExclusiveMode_) : AudioIODevice (deviceName, "Windows Audio"), Thread ("Juce WASAPI"), - isOpen_ (false), - isStarted (false), outputDeviceId (outputDeviceId_), inputDeviceId (inputDeviceId_), useExclusiveMode (useExclusiveMode_), + isOpen_ (false), + isStarted (false), currentBufferSizeSamples (0), currentSampleRate (0), callback (0) diff --git a/src/native/windows/juce_win32_Windowing.cpp b/src/native/windows/juce_win32_Windowing.cpp index ce66c1d1e5..b12937ed84 100644 --- a/src/native/windows/juce_win32_Windowing.cpp +++ b/src/native/windows/juce_win32_Windowing.cpp @@ -476,8 +476,8 @@ public: constrainerIsResizing (false), currentWindowIcon (0), dropTarget (0), - updateLayeredWindowAlpha (255), - parentToAddTo (parentToAddTo_) + parentToAddTo (parentToAddTo_), + updateLayeredWindowAlpha (255) { callFunctionIfNotLocked (&createWindowCallback, this); @@ -1893,7 +1893,7 @@ private: if (pDropFiles->fWide) { - const WCHAR* const fname = (WCHAR*) (((const char*) pDropFiles) + sizeof (DROPFILES)); + const WCHAR* const fname = (WCHAR*) addBytesToPointer (pDropFiles, sizeof (DROPFILES)); for (;;) { @@ -1910,7 +1910,7 @@ private: } else { - const char* const fname = ((const char*) pDropFiles) + sizeof (DROPFILES); + const char* const fname = (const char*) addBytesToPointer (pDropFiles, sizeof (DROPFILES)); for (;;) {