diff --git a/build/macosx/Juce.xcodeproj/project.pbxproj b/build/macosx/Juce.xcodeproj/project.pbxproj index 50edc3cf77..1b119fad8d 100644 --- a/build/macosx/Juce.xcodeproj/project.pbxproj +++ b/build/macosx/Juce.xcodeproj/project.pbxproj @@ -4236,10 +4236,13 @@ GCC_SYMBOLS_PRIVATE_EXTERN = YES; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; + GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_UNKNOWN_PRAGMAS = YES; + GCC_WARN_UNUSED_VALUE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PRODUCT_NAME = jucedebug; RUN_CLANG_STATIC_ANALYZER = YES; @@ -4260,10 +4263,13 @@ "NDEBUG=1", ); GCC_SYMBOLS_PRIVATE_EXTERN = YES; + GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_SIGN_COMPARE = YES; + GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_VALUE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PRODUCT_NAME = juce; diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 896d2b5a4f..d34d632ad9 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -5364,27 +5364,24 @@ int InputStream::readIntBigEndian() int InputStream::readCompressedInt() { - int num = 0; + const unsigned char sizeByte = readByte(); + if (sizeByte == 0) + return 0; - if (! isExhausted()) + const int numBytes = (sizeByte & 0x7f); + if (numBytes > 4) { - unsigned char numBytes = readByte(); - const bool negative = (numBytes & 0x80) != 0; - numBytes &= 0x7f; - - if (numBytes <= 4) - { - if (read (&num, numBytes) != numBytes) - return 0; - - num = (int) swapIfBigEndian ((uint32) num); - - if (negative) - num = -num; - } + jassertfalse // trying to read corrupt data - this method must only be used + // to read data that was written by OutputStream::writeCompressedInt() + return 0; } - return num; + char bytes[4] = { 0, 0, 0, 0 }; + if (read (bytes, numBytes) != numBytes) + return 0; + + const int num = (int) littleEndianInt (bytes); + return (sizeByte >> 7) ? -num : num; } int64 InputStream::readInt64() @@ -5639,23 +5636,22 @@ void OutputStream::writeCompressedInt (int value) { unsigned int un = (value < 0) ? (unsigned int) -value : (unsigned int) value; - unsigned int tn = un; - int numSigBytes = 0; + uint8 data[5]; + int num = 0; - do + while (un > 0) { - tn >>= 8; - numSigBytes++; + data[++num] = (uint8) un; + un >>= 8; + } - } while (tn & 0xff); + data[0] = num; if (value < 0) - numSigBytes |= 0x80; + data[0] |= 0x80; - writeByte ((char) numSigBytes); - un = swapIfBigEndian (un); - write (&un, numSigBytes); + write (data, num + 1); } void OutputStream::writeInt64 (int64 value) @@ -21761,7 +21757,7 @@ const StringPairArray WavAudioFormat::createBWAVMetadata (const String& descript #if JUCE_MSVC #pragma pack (push, 1) #define PACKED -#elif defined (JUCE_GCC) +#elif JUCE_GCC #define PACKED __attribute__((packed)) #else #define PACKED @@ -44691,7 +44687,7 @@ void CodeDocument::setSavePoint() throw() bool CodeDocument::hasChangedSinceSavePoint() const throw() { - return currentActionIndex == indexOfSavedState; + return currentActionIndex != indexOfSavedState; } static int getCodeCharacterCategory (const tchar character) throw() @@ -261354,7 +261350,7 @@ bool juce_launchFile (const String& fileName, ok = [[NSWorkspace sharedWorkspace] openURLs: urls withAppBundleIdentifier: [[NSBundle bundleWithPath: juceStringToNS (fileName)] bundleIdentifier] - options: nil + options: 0 additionalEventParamDescriptor: nil launchIdentifiers: nil]; } @@ -262059,7 +262055,7 @@ public: const int length = text.length(); CGGlyph* const glyphs = createGlyphsForString (text, length); - int x = 0; + float x = 0; #if SUPPORT_ONLY_10_4_FONTS NSSize* const advances = (NSSize*) juce_malloc (length * sizeof (NSSize)); @@ -262129,7 +262125,7 @@ public: NSSize* const advances = (NSSize*) juce_malloc (length * sizeof (NSSize)); [nsFont getAdvancements: advances forGlyphs: (NSGlyph*) glyphs count: length]; - int x = 0; + float x = 0; for (int i = 0; i < length; ++i) { x += advances[i].width; @@ -262785,8 +262781,8 @@ public: while (x > clip.origin.x) x -= iw; while (y > clip.origin.y) y -= ih; - const int right = clip.origin.x + clip.size.width; - const int bottom = clip.origin.y + clip.size.height; + const int right = (int) (clip.origin.x + clip.size.width); + const int bottom = (int) (clip.origin.y + clip.size.height); while (y < bottom) { @@ -266525,7 +266521,7 @@ public: const int length = text.length(); CGGlyph* const glyphs = createGlyphsForString (text, length); - int x = 0; + float x = 0; #if SUPPORT_ONLY_10_4_FONTS NSSize* const advances = (NSSize*) juce_malloc (length * sizeof (NSSize)); @@ -266595,7 +266591,7 @@ public: NSSize* const advances = (NSSize*) juce_malloc (length * sizeof (NSSize)); [nsFont getAdvancements: advances forGlyphs: (NSGlyph*) glyphs count: length]; - int x = 0; + float x = 0; for (int i = 0; i < length; ++i) { x += advances[i].width; @@ -267253,8 +267249,8 @@ public: while (x > clip.origin.x) x -= iw; while (y > clip.origin.y) y -= ih; - const int right = clip.origin.x + clip.size.width; - const int bottom = clip.origin.y + clip.size.height; + const int right = (int) (clip.origin.x + clip.size.width); + const int bottom = (int) (clip.origin.y + clip.size.height); while (y < bottom) { @@ -270806,8 +270802,8 @@ void QuickTimeMovieComponent::getMovieNormalSize (int& width, int& height) const if (movie != 0) { NSSize s = [[theMovie attributeForKey: QTMovieNaturalSizeAttribute] sizeValue]; - width = s.width; - height = s.height; + width = (int) s.width; + height = (int) s.height; } } diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 66126a3ef1..e1bb939087 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -46986,6 +46986,11 @@ public: */ void setVelocityBasedMode (const bool isVelocityBased) throw(); + /** Returns true if velocity-based mode is active. + @see setVelocityBasedMode + */ + bool getVelocityBasedMode() const throw() { return isVelocityBased; } + /** Changes aspects of the scaling used when in velocity-sensitive mode. These apply when you've used setVelocityBasedMode() to turn on velocity mode, @@ -47004,6 +47009,26 @@ public: const double offset = 0.0, const bool userCanPressKeyToSwapMode = true) throw(); + /** Returns the velocity sensitivity setting. + @see setVelocityModeParameters + */ + double getVelocitySensitivity() const throw() { return velocityModeSensitivity; } + + /** Returns the velocity threshold setting. + @see setVelocityModeParameters + */ + int getVelocityThreshold() const throw() { return velocityModeThreshold; } + + /** Returns the velocity offset setting. + @see setVelocityModeParameters + */ + double getVelocityOffset() const throw() { return velocityModeOffset; } + + /** Returns the velocity user key setting. + @see setVelocityModeParameters + */ + bool getVelocityModeIsSwappable() const throw() { return userKeyOverridesVelocity; } + /** Sets up a skew factor to alter the way values are distributed. You may want to use a range of values on the slider where more accuracy diff --git a/src/audio/audio_file_formats/juce_WavAudioFormat.cpp b/src/audio/audio_file_formats/juce_WavAudioFormat.cpp index a1cd5306aa..927eeb6ffd 100644 --- a/src/audio/audio_file_formats/juce_WavAudioFormat.cpp +++ b/src/audio/audio_file_formats/juce_WavAudioFormat.cpp @@ -73,7 +73,7 @@ const StringPairArray WavAudioFormat::createBWAVMetadata (const String& descript #if JUCE_MSVC #pragma pack (push, 1) #define PACKED -#elif defined (JUCE_GCC) +#elif JUCE_GCC #define PACKED __attribute__((packed)) #else #define PACKED diff --git a/src/gui/components/code_editor/juce_CodeDocument.cpp b/src/gui/components/code_editor/juce_CodeDocument.cpp index 9d1203b7db..11f4669f2b 100644 --- a/src/gui/components/code_editor/juce_CodeDocument.cpp +++ b/src/gui/components/code_editor/juce_CodeDocument.cpp @@ -580,7 +580,7 @@ void CodeDocument::setSavePoint() throw() bool CodeDocument::hasChangedSinceSavePoint() const throw() { - return currentActionIndex == indexOfSavedState; + return currentActionIndex != indexOfSavedState; } //============================================================================== diff --git a/src/gui/components/controls/juce_Slider.h b/src/gui/components/controls/juce_Slider.h index c3e70d8f5d..0249e696a5 100644 --- a/src/gui/components/controls/juce_Slider.h +++ b/src/gui/components/controls/juce_Slider.h @@ -151,6 +151,11 @@ public: */ void setVelocityBasedMode (const bool isVelocityBased) throw(); + /** Returns true if velocity-based mode is active. + @see setVelocityBasedMode + */ + bool getVelocityBasedMode() const throw() { return isVelocityBased; } + /** Changes aspects of the scaling used when in velocity-sensitive mode. These apply when you've used setVelocityBasedMode() to turn on velocity mode, @@ -169,6 +174,26 @@ public: const double offset = 0.0, const bool userCanPressKeyToSwapMode = true) throw(); + /** Returns the velocity sensitivity setting. + @see setVelocityModeParameters + */ + double getVelocitySensitivity() const throw() { return velocityModeSensitivity; } + + /** Returns the velocity threshold setting. + @see setVelocityModeParameters + */ + int getVelocityThreshold() const throw() { return velocityModeThreshold; } + + /** Returns the velocity offset setting. + @see setVelocityModeParameters + */ + double getVelocityOffset() const throw() { return velocityModeOffset; } + + /** Returns the velocity user key setting. + @see setVelocityModeParameters + */ + bool getVelocityModeIsSwappable() const throw() { return userKeyOverridesVelocity; } + //============================================================================== /** Sets up a skew factor to alter the way values are distributed. diff --git a/src/io/streams/juce_InputStream.cpp b/src/io/streams/juce_InputStream.cpp index 2012937f28..f7557aacef 100644 --- a/src/io/streams/juce_InputStream.cpp +++ b/src/io/streams/juce_InputStream.cpp @@ -86,27 +86,24 @@ int InputStream::readIntBigEndian() int InputStream::readCompressedInt() { - int num = 0; + const unsigned char sizeByte = readByte(); + if (sizeByte == 0) + return 0; - if (! isExhausted()) + const int numBytes = (sizeByte & 0x7f); + if (numBytes > 4) { - unsigned char numBytes = readByte(); - const bool negative = (numBytes & 0x80) != 0; - numBytes &= 0x7f; - - if (numBytes <= 4) - { - if (read (&num, numBytes) != numBytes) - return 0; - - num = (int) swapIfBigEndian ((uint32) num); - - if (negative) - num = -num; - } + jassertfalse // trying to read corrupt data - this method must only be used + // to read data that was written by OutputStream::writeCompressedInt() + return 0; } - return num; + char bytes[4] = { 0, 0, 0, 0 }; + if (read (bytes, numBytes) != numBytes) + return 0; + + const int num = (int) littleEndianInt (bytes); + return (sizeByte >> 7) ? -num : num; } int64 InputStream::readInt64() diff --git a/src/io/streams/juce_OutputStream.cpp b/src/io/streams/juce_OutputStream.cpp index 22c522ba76..1c2b3ef8c8 100644 --- a/src/io/streams/juce_OutputStream.cpp +++ b/src/io/streams/juce_OutputStream.cpp @@ -109,23 +109,22 @@ void OutputStream::writeCompressedInt (int value) { unsigned int un = (value < 0) ? (unsigned int) -value : (unsigned int) value; - unsigned int tn = un; - int numSigBytes = 0; + uint8 data[5]; + int num = 0; - do + while (un > 0) { - tn >>= 8; - numSigBytes++; + data[++num] = (uint8) un; + un >>= 8; + } - } while (tn & 0xff); + data[0] = num; if (value < 0) - numSigBytes |= 0x80; + data[0] |= 0x80; - writeByte ((char) numSigBytes); - un = swapIfBigEndian (un); - write (&un, numSigBytes); + write (data, num + 1); } void OutputStream::writeInt64 (int64 value) diff --git a/src/native/mac/juce_mac_CoreGraphicsContext.mm b/src/native/mac/juce_mac_CoreGraphicsContext.mm index aa75d91870..6cf7c9b8e1 100644 --- a/src/native/mac/juce_mac_CoreGraphicsContext.mm +++ b/src/native/mac/juce_mac_CoreGraphicsContext.mm @@ -420,8 +420,8 @@ public: while (x > clip.origin.x) x -= iw; while (y > clip.origin.y) y -= ih; - const int right = clip.origin.x + clip.size.width; - const int bottom = clip.origin.y + clip.size.height; + const int right = (int) (clip.origin.x + clip.size.width); + const int bottom = (int) (clip.origin.y + clip.size.height); while (y < bottom) { diff --git a/src/native/mac/juce_mac_Files.mm b/src/native/mac/juce_mac_Files.mm index 72cedef12f..2ec7b7bf5c 100644 --- a/src/native/mac/juce_mac_Files.mm +++ b/src/native/mac/juce_mac_Files.mm @@ -483,7 +483,7 @@ bool juce_launchFile (const String& fileName, ok = [[NSWorkspace sharedWorkspace] openURLs: urls withAppBundleIdentifier: [[NSBundle bundleWithPath: juceStringToNS (fileName)] bundleIdentifier] - options: nil + options: 0 additionalEventParamDescriptor: nil launchIdentifiers: nil]; } diff --git a/src/native/mac/juce_mac_Fonts.mm b/src/native/mac/juce_mac_Fonts.mm index 8ea68db726..e5a3c0e48b 100644 --- a/src/native/mac/juce_mac_Fonts.mm +++ b/src/native/mac/juce_mac_Fonts.mm @@ -203,7 +203,7 @@ public: const int length = text.length(); CGGlyph* const glyphs = createGlyphsForString (text, length); - int x = 0; + float x = 0; #if SUPPORT_ONLY_10_4_FONTS NSSize* const advances = (NSSize*) juce_malloc (length * sizeof (NSSize)); @@ -273,7 +273,7 @@ public: NSSize* const advances = (NSSize*) juce_malloc (length * sizeof (NSSize)); [nsFont getAdvancements: advances forGlyphs: (NSGlyph*) glyphs count: length]; - int x = 0; + float x = 0; for (int i = 0; i < length; ++i) { x += advances[i].width; diff --git a/src/native/mac/juce_mac_QuickTimeMovieComponent.mm b/src/native/mac/juce_mac_QuickTimeMovieComponent.mm index 3b4a963d81..35543b945a 100644 --- a/src/native/mac/juce_mac_QuickTimeMovieComponent.mm +++ b/src/native/mac/juce_mac_QuickTimeMovieComponent.mm @@ -251,8 +251,8 @@ void QuickTimeMovieComponent::getMovieNormalSize (int& width, int& height) const if (movie != 0) { NSSize s = [[theMovie attributeForKey: QTMovieNaturalSizeAttribute] sizeValue]; - width = s.width; - height = s.height; + width = (int) s.width; + height = (int) s.height; } }