diff --git a/extras/audio plugin demo/Source/PluginProcessor.cpp b/extras/audio plugin demo/Source/PluginProcessor.cpp index f642e66cf8..6999914b25 100644 --- a/extras/audio plugin demo/Source/PluginProcessor.cpp +++ b/extras/audio plugin demo/Source/PluginProcessor.cpp @@ -11,14 +11,15 @@ #include "PluginProcessor.h" #include "PluginEditor.h" +AudioProcessor* JUCE_CALLTYPE createPluginFilter(); + + //============================================================================== /** A demo synth sound that's just a basic sine wave.. */ class SineWaveSound : public SynthesiserSound { public: - SineWaveSound() - { - } + SineWaveSound() {} bool appliesToNote (const int /*midiNoteNumber*/) { return true; } bool appliesToChannel (const int /*midiChannel*/) { return true; } @@ -273,7 +274,7 @@ void JuceDemoPluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, Midi // ask the host for the current time so we can display it... AudioPlayHead::CurrentPositionInfo newTime; - if (getPlayHead() != 0 && getPlayHead()->getCurrentPosition (newTime)) + if (getPlayHead() != nullptr && getPlayHead()->getCurrentPosition (newTime)) { // Successfully got the current time from the host.. lastPosInfo = newTime; @@ -318,7 +319,7 @@ void JuceDemoPluginAudioProcessor::setStateInformation (const void* data, int si // This getXmlFromBinary() helper function retrieves our XML from the binary blob.. ScopedPointer xmlState (getXmlFromBinary (data, sizeInBytes)); - if (xmlState != 0) + if (xmlState != nullptr) { // make sure that it's actually our type of XML object.. if (xmlState->hasTagName ("MYPLUGINSETTINGS")) @@ -355,20 +356,20 @@ bool JuceDemoPluginAudioProcessor::isOutputChannelStereoPair (int /*index*/) con bool JuceDemoPluginAudioProcessor::acceptsMidi() const { -#if JucePlugin_WantsMidiInput + #if JucePlugin_WantsMidiInput return true; -#else + #else return false; -#endif + #endif } bool JuceDemoPluginAudioProcessor::producesMidi() const { -#if JucePlugin_ProducesMidiOutput + #if JucePlugin_ProducesMidiOutput return true; -#else + #else return false; -#endif + #endif } //============================================================================== diff --git a/modules/juce_audio_devices/native/juce_MidiDataConcatenator.h b/modules/juce_audio_devices/native/juce_MidiDataConcatenator.h index ebb1370e9b..83d0517be6 100644 --- a/modules/juce_audio_devices/native/juce_MidiDataConcatenator.h +++ b/modules/juce_audio_devices/native/juce_MidiDataConcatenator.h @@ -48,10 +48,10 @@ public: pendingDataTime = 0; } - void pushMidiData (const void* data, int numBytes, double time, + void pushMidiData (const void* inputData, int numBytes, double time, MidiInput* input, MidiInputCallback& callback) { - const uint8* d = static_cast (data); + const uint8* d = static_cast (inputData); while (numBytes > 0) { diff --git a/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp index dbf0e50e4b..8977286b3c 100644 --- a/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp @@ -46,6 +46,12 @@ namespace FlacNamespace #define SIZE_MAX 0xffffffff #endif + #if JUCE_CLANG + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wconversion" + #pragma clang diagnostic ignored "-Wshadow" + #endif + #define __STDC_LIMIT_MACROS 1 #include "flac/all.h" #include "flac/libFLAC/bitmath.c" @@ -67,6 +73,10 @@ namespace FlacNamespace #else #include #endif + + #if JUCE_CLANG + #pragma clang diagnostic pop + #endif } #undef max diff --git a/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp index b61a833f5c..f89e3ace49 100644 --- a/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp @@ -37,6 +37,12 @@ namespace OggVorbisNamespace #pragma warning (disable: 4267 4127 4244 4996 4100 4701 4702 4013 4133 4206 4305 4189 4706 4995 4365) #endif +#if JUCE_CLANG + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wconversion" + #pragma clang diagnostic ignored "-Wshadow" +#endif + #include "oggvorbis/vorbisenc.h" #include "oggvorbis/codec.h" #include "oggvorbis/vorbisfile.h" @@ -68,6 +74,10 @@ namespace OggVorbisNamespace #if JUCE_MSVC #pragma warning (pop) #endif + + #if JUCE_CLANG + #pragma clang diagnostic pop + #endif #else #include #include diff --git a/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp b/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp index 5657a84b17..998bb1b325 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp +++ b/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp @@ -170,11 +170,11 @@ class AudioFormatWriter::ThreadedWriter::Buffer : public AbstractFifo, private TimeSliceClient { public: - Buffer (TimeSliceThread& timeSliceThread_, AudioFormatWriter* writer_, int numChannels, int bufferSize_) - : AbstractFifo (bufferSize_), - buffer (numChannels, bufferSize_), - timeSliceThread (timeSliceThread_), - writer (writer_), + Buffer (TimeSliceThread& tst, AudioFormatWriter* w, int channels, int bufferSize) + : AbstractFifo (bufferSize), + buffer (channels, bufferSize), + timeSliceThread (tst), + writer (w), receiver (nullptr), samplesWritten (0), isRunning (true) diff --git a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm index 167efb6ed4..faaa080f71 100644 --- a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm +++ b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm @@ -687,8 +687,7 @@ public: const int numIn = juceFilter->getNumInputChannels(); const int numOut = juceFilter->getNumOutputChannels(); - unsigned int i; - for (i = 0; i < outBuffer.mNumberBuffers; ++i) + for (unsigned int i = 0; i < outBuffer.mNumberBuffers; ++i) { AudioBuffer& buf = outBuffer.mBuffers[i]; @@ -710,7 +709,7 @@ public: int numInChans = 0; - for (i = 0; i < inBuffer.mNumberBuffers; ++i) + for (unsigned int i = 0; i < inBuffer.mNumberBuffers; ++i) { const AudioBuffer& buf = inBuffer.mBuffers[i]; @@ -767,8 +766,8 @@ public: if (juceFilter->isSuspended()) { - for (int i = 0; i < numOut; ++i) - zeromem (channels [i], sizeof (float) * numSamples); + for (int j = 0; j < numOut; ++j) + zeromem (channels [j], sizeof (float) * numSamples); } else { @@ -805,7 +804,7 @@ public: { nextSpareBufferChan = 0; - for (i = 0; i < outBuffer.mNumberBuffers; ++i) + for (unsigned int i = 0; i < outBuffer.mNumberBuffers; ++i) { AudioBuffer& buf = outBuffer.mBuffers[i]; @@ -872,17 +871,17 @@ protected: presetsArray.ensureSize (sizeof (AUPreset) * numPrograms, true); AUPreset* const presets = (AUPreset*) presetsArray.getData(); - CFMutableArrayRef presetsArray = CFArrayCreateMutable (0, numPrograms, 0); + CFMutableArrayRef presetsArrayRef = CFArrayCreateMutable (0, numPrograms, 0); for (int i = 0; i < numPrograms; ++i) { presets[i].presetNumber = i; presets[i].presetName = juceFilter->getProgramName(i).toCFString(); - CFArrayAppendValue (presetsArray, presets + i); + CFArrayAppendValue (presetsArrayRef, presets + i); } - *outData = (CFArrayRef) presetsArray; + *outData = (CFArrayRef) presetsArrayRef; } return noErr; @@ -1273,7 +1272,7 @@ private: setBroughtToFrontOnMouseClick (true); setSize (editor.getWidth(), editor.getHeight()); - SizeControl (parentHIView, editor.getWidth(), editor.getHeight()); + SizeControl (parentHIView, (SInt16) editor.getWidth(), (SInt16) editor.getHeight()); WindowRef windowRef = HIViewGetWindow (parentHIView); hostWindow = [[NSWindow alloc] initWithWindowRef: windowRef]; @@ -1355,7 +1354,7 @@ private: const int w = jmax (32, editor.getWidth()); const int h = jmax (32, editor.getHeight()); - SizeControl (parentView, w, h); + SizeControl (parentView, (SInt16) w, (SInt16) h); if (getWidth() != w || getHeight() != h) setSize (w, h); diff --git a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp index b3a947ae59..faf09fb69a 100644 --- a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp @@ -66,6 +66,12 @@ #define __cdecl #endif +#ifdef __clang__ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wconversion" + #pragma clang diagnostic ignored "-Wshadow" +#endif + // VSTSDK V2.4 includes.. #include #include @@ -76,6 +82,10 @@ #error "It looks like you're trying to include an out-of-date VSTSDK version - make sure you have at least version 2.4" #endif +#ifdef __clang__ + #pragma clang diagnostic pop +#endif + //============================================================================== #ifdef _MSC_VER #pragma pack (push, 8) @@ -1471,12 +1481,14 @@ namespace // Mac startup code.. #if JUCE_MAC + extern "C" __attribute__ ((visibility("default"))) AEffect* VSTPluginMain (audioMasterCallback audioMaster); extern "C" __attribute__ ((visibility("default"))) AEffect* VSTPluginMain (audioMasterCallback audioMaster) { initialiseMac(); return pluginEntryPoint (audioMaster); } + extern "C" __attribute__ ((visibility("default"))) AEffect* main_macho (audioMasterCallback audioMaster); extern "C" __attribute__ ((visibility("default"))) AEffect* main_macho (audioMasterCallback audioMaster) { initialiseMac(); diff --git a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.mm b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.mm index 06c714d841..11c4f4d670 100644 --- a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.mm +++ b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.mm @@ -70,6 +70,7 @@ static pascal OSStatus viewBoundsChangedEvent (EventHandlerCallRef, EventRef, vo #endif //============================================================================== +void initialiseMac(); void initialiseMac() { #if ! JUCE_64BIT @@ -77,6 +78,7 @@ void initialiseMac() #endif } +void* attachComponentToWindowRef (Component* comp, void* windowRef); void* attachComponentToWindowRef (Component* comp, void* windowRef) { JUCE_AUTORELEASEPOOL @@ -166,6 +168,7 @@ void* attachComponentToWindowRef (Component* comp, void* windowRef) #endif } +void detachComponentFromWindowRef (Component* comp, void* nsWindow); void detachComponentFromWindowRef (Component* comp, void* nsWindow) { #if JUCE_64BIT @@ -206,6 +209,7 @@ void detachComponentFromWindowRef (Component* comp, void* nsWindow) #endif } +void setNativeHostWindowSize (void* nsWindow, Component* component, int newWidth, int newHeight, const PluginHostType& host); void setNativeHostWindowSize (void* nsWindow, Component* component, int newWidth, int newHeight, const PluginHostType& host) { JUCE_AUTORELEASEPOOL @@ -233,6 +237,7 @@ void setNativeHostWindowSize (void* nsWindow, Component* component, int newWidth #endif } +void checkWindowVisibility (void* nsWindow, Component* comp); void checkWindowVisibility (void* nsWindow, Component* comp) { #if ! JUCE_64BIT @@ -240,6 +245,7 @@ void checkWindowVisibility (void* nsWindow, Component* comp) #endif } +bool forwardCurrentKeyEventToHost (Component* comp); bool forwardCurrentKeyEventToHost (Component* comp) { #if JUCE_64BIT diff --git a/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp b/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp index d0313d2f5d..290555daaa 100644 --- a/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp @@ -313,7 +313,7 @@ public: result.set (1, 0); } - void write (const MinMaxValue* const source, const int startIndex, const int numValues) + void write (const MinMaxValue* const values, const int startIndex, const int numValues) { resetPeak(); @@ -323,7 +323,7 @@ public: MinMaxValue* const dest = getData (startIndex); for (int i = 0; i < numValues; ++i) - dest[i] = source[i]; + dest[i] = values[i]; } void resetPeak() noexcept @@ -377,11 +377,11 @@ public: void drawChannel (Graphics& g, const Rectangle& area, const double startTime, const double endTime, const int channelNum, const float verticalZoomFactor, - const double sampleRate, const int numChannels, const int samplesPerThumbSample, - LevelDataSource* levelData, const OwnedArray& channels) + const double rate, const int numChans, const int sampsPerThumbSample, + LevelDataSource* levelData, const OwnedArray& chans) { - refillCache (area.getWidth(), startTime, endTime, sampleRate, - numChannels, samplesPerThumbSample, levelData, channels); + refillCache (area.getWidth(), startTime, endTime, rate, + numChans, sampsPerThumbSample, levelData, chans); if (isPositiveAndBelow (channelNum, numChannelsCached)) { @@ -417,19 +417,19 @@ private: bool cacheNeedsRefilling; void refillCache (const int numSamples, double startTime, const double endTime, - const double sampleRate, const int numChannels, const int samplesPerThumbSample, - LevelDataSource* levelData, const OwnedArray& channels) + const double rate, const int numChans, const int sampsPerThumbSample, + LevelDataSource* levelData, const OwnedArray& chans) { const double timePerPixel = (endTime - startTime) / numSamples; - if (numSamples <= 0 || timePerPixel <= 0.0 || sampleRate <= 0) + if (numSamples <= 0 || timePerPixel <= 0.0 || rate <= 0) { invalidate(); return; } if (numSamples == numSamplesCached - && numChannelsCached == numChannels + && numChannelsCached == numChans && startTime == cachedStart && timePerPixel == cachedTimePerPixel && ! cacheNeedsRefilling) @@ -438,22 +438,22 @@ private: } numSamplesCached = numSamples; - numChannelsCached = numChannels; + numChannelsCached = numChans; cachedStart = startTime; cachedTimePerPixel = timePerPixel; cacheNeedsRefilling = false; ensureSize (numSamples); - if (timePerPixel * sampleRate <= samplesPerThumbSample && levelData != nullptr) + if (timePerPixel * rate <= sampsPerThumbSample && levelData != nullptr) { - int sample = roundToInt (startTime * sampleRate); + int sample = roundToInt (startTime * rate); Array levels; int i; for (i = 0; i < numSamples; ++i) { - const int nextSample = roundToInt ((startTime + timePerPixel) * sampleRate); + const int nextSample = roundToInt ((startTime + timePerPixel) * rate); if (sample >= 0) { @@ -462,9 +462,9 @@ private: levelData->getLevels (sample, jmax (1, nextSample - sample), levels); - const int numChans = jmin (levels.size() / 2, numChannelsCached); + const int totalChans = jmin (levels.size() / 2, numChannelsCached); - for (int chan = 0; chan < numChans; ++chan) + for (int chan = 0; chan < totalChans; ++chan) getData (chan, i)->setFloat (levels.getUnchecked (chan * 2), levels.getUnchecked (chan * 2 + 1)); } @@ -477,14 +477,14 @@ private: } else { - jassert (channels.size() == numChannelsCached); + jassert (chans.size() == numChannelsCached); for (int channelNum = 0; channelNum < numChannelsCached; ++channelNum) { - ThumbData* channelData = channels.getUnchecked (channelNum); + ThumbData* channelData = chans.getUnchecked (channelNum); MinMaxValue* cacheData = getData (channelNum, 0); - const double timeToThumbSampleFactor = sampleRate / (double) samplesPerThumbSample; + const double timeToThumbSampleFactor = rate / (double) sampsPerThumbSample; startTime = cachedStart; int sample = roundToInt (startTime * timeToThumbSampleFactor); diff --git a/modules/juce_core/maths/juce_Expression.cpp b/modules/juce_core/maths/juce_Expression.cpp index 8cb98639d8..19fedcf3df 100644 --- a/modules/juce_core/maths/juce_Expression.cpp +++ b/modules/juce_core/maths/juce_Expression.cpp @@ -350,8 +350,8 @@ struct Expression::Helpers class EvaluationVisitor : public Scope::Visitor { public: - EvaluationVisitor (const TermPtr& term, const int recursion) - : input (term), output (term), recursionCount (recursion) {} + EvaluationVisitor (const TermPtr& t, const int recursion) + : input (t), output (t), recursionCount (recursion) {} void visit (const Scope& scope) { output = input->resolve (scope, recursionCount); } @@ -366,8 +366,8 @@ struct Expression::Helpers class SymbolVisitingVisitor : public Scope::Visitor { public: - SymbolVisitingVisitor (const TermPtr& term, SymbolVisitor& v, const int recursion) - : input (term), visitor (v), recursionCount (recursion) {} + SymbolVisitingVisitor (const TermPtr& t, SymbolVisitor& v, const int recursion) + : input (t), visitor (v), recursionCount (recursion) {} void visit (const Scope& scope) { input->visitAllSymbols (visitor, scope, recursionCount); } @@ -382,8 +382,8 @@ struct Expression::Helpers class SymbolRenamingVisitor : public Scope::Visitor { public: - SymbolRenamingVisitor (const TermPtr& term, const Expression::Symbol& symbol_, const String& newName_, const int recursionCount_) - : input (term), symbol (symbol_), newName (newName_), recursionCount (recursionCount_) {} + SymbolRenamingVisitor (const TermPtr& t, const Expression::Symbol& symbol_, const String& newName_, const int recursionCount_) + : input (t), symbol (symbol_), newName (newName_), recursionCount (recursionCount_) {} void visit (const Scope& scope) { input->renameSymbol (symbol, newName, scope, recursionCount); } @@ -405,9 +405,9 @@ struct Expression::Helpers class Negate : public Term { public: - explicit Negate (const TermPtr& term) : input (term) + explicit Negate (const TermPtr& t) : input (t) { - jassert (term != nullptr); + jassert (t != nullptr); } Type getType() const noexcept { return operatorType; } @@ -424,10 +424,10 @@ struct Expression::Helpers String getName() const { return "-"; } TermPtr negated() { return input; } - TermPtr createTermToEvaluateInput (const Scope& scope, const Term* term, double overallTarget, Term* topLevelTerm) const + TermPtr createTermToEvaluateInput (const Scope& scope, const Term* t, double overallTarget, Term* topLevelTerm) const { - (void) term; - jassert (term == input); + (void) t; + jassert (t == input); const Term* const dest = findDestinationFor (topLevelTerm, this); @@ -813,15 +813,15 @@ struct Expression::Helpers char opType; if (readOperator ("+-", &opType)) { - TermPtr term (readUnaryExpression()); + TermPtr e (readUnaryExpression()); - if (term == nullptr) + if (e == nullptr) throw ParseError ("Expected expression after \"" + String::charToString ((juce_wchar) (uint8) opType) + "\""); if (opType == '-') - term = term->negated(); + e = e->negated(); - return term; + return e; } return readPrimaryExpression(); diff --git a/modules/juce_core/native/juce_mac_Files.mm b/modules/juce_core/native/juce_mac_Files.mm index 64f12e34e4..b824ce902e 100644 --- a/modules/juce_core/native/juce_mac_Files.mm +++ b/modules/juce_core/native/juce_mac_Files.mm @@ -351,11 +351,11 @@ public: if (fnmatch (wildcardUTF8, filenameFound.toUTF8(), FNM_CASEFOLD) != 0) continue; - const String path (parentDir + filenameFound); - updateStatInfoForFile (path, isDir, fileSize, modTime, creationTime, isReadOnly); + const String fullPath (parentDir + filenameFound); + updateStatInfoForFile (fullPath, isDir, fileSize, modTime, creationTime, isReadOnly); if (isHidden != nullptr) - *isHidden = FileHelpers::isHiddenFile (path); + *isHidden = FileHelpers::isHiddenFile (fullPath); return true; } @@ -368,8 +368,8 @@ private: JUCE_DECLARE_NON_COPYABLE (Pimpl); }; -DirectoryIterator::NativeIterator::NativeIterator (const File& directory, const String& wildCard) - : pimpl (new DirectoryIterator::NativeIterator::Pimpl (directory, wildCard)) +DirectoryIterator::NativeIterator::NativeIterator (const File& directory, const String& wildcard) + : pimpl (new DirectoryIterator::NativeIterator::Pimpl (directory, wildcard)) { } diff --git a/modules/juce_core/native/juce_posix_SharedCode.h b/modules/juce_core/native/juce_posix_SharedCode.h index cbdeb72aec..a34bb12101 100644 --- a/modules/juce_core/native/juce_posix_SharedCode.h +++ b/modules/juce_core/native/juce_posix_SharedCode.h @@ -701,7 +701,7 @@ String juce_getOutputFromCommand (const String& command) class InterProcessLock::Pimpl { public: - Pimpl (const String& name, const int timeOutMillisecs) + Pimpl (const String& lockName, const int timeOutMillisecs) : handle (0), refCount (1) { #if JUCE_IOS @@ -718,7 +718,7 @@ public: tempFolder = "/tmp"; #endif - const File temp (tempFolder.getChildFile (name)); + const File temp (tempFolder.getChildFile (lockName)); temp.create(); handle = open (temp.getFullPathName().toUTF8(), O_RDWR); diff --git a/modules/juce_core/text/juce_LocalisedStrings.cpp b/modules/juce_core/text/juce_LocalisedStrings.cpp index 2ac7fae085..a42b1da461 100644 --- a/modules/juce_core/text/juce_LocalisedStrings.cpp +++ b/modules/juce_core/text/juce_LocalisedStrings.cpp @@ -180,9 +180,8 @@ String translate (const String& text, const String& resultIfNotFound) { const SpinLock::ScopedLockType sl (currentMappingsLock); - const LocalisedStrings* const currentMappings = LocalisedStrings::getCurrentMappings(); - if (currentMappings != nullptr) - return currentMappings->translate (text, resultIfNotFound); + if (const LocalisedStrings* const mappings = LocalisedStrings::getCurrentMappings()) + return mappings->translate (text, resultIfNotFound); return resultIfNotFound; } diff --git a/modules/juce_core/threads/juce_InterProcessLock.h b/modules/juce_core/threads/juce_InterProcessLock.h index 8381b65f42..7c70e7729a 100644 --- a/modules/juce_core/threads/juce_InterProcessLock.h +++ b/modules/juce_core/threads/juce_InterProcessLock.h @@ -90,7 +90,7 @@ public: otherwise there are no guarantees what will happen! Best just to use it as a local stack object, rather than creating one with the new() operator. */ - explicit ScopedLockType (InterProcessLock& lock) : ipLock (lock) { lockWasSuccessful = lock.enter(); } + explicit ScopedLockType (InterProcessLock& l) : ipLock (l) { lockWasSuccessful = l.enter(); } /** Destructor. @@ -99,10 +99,10 @@ public: Make sure this object is created and deleted by the same thread, otherwise there are no guarantees what will happen! */ - inline ~ScopedLockType() { ipLock.exit(); } + inline ~ScopedLockType() { ipLock.exit(); } /** Returns true if the InterProcessLock was successfully locked. */ - bool isLocked() const noexcept { return lockWasSuccessful; } + bool isLocked() const noexcept { return lockWasSuccessful; } private: //============================================================================== diff --git a/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp b/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp index f5ff68bed2..af25e047d6 100644 --- a/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp +++ b/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp @@ -46,26 +46,26 @@ public: zlibNamespace::deflateEnd (&stream); } - bool write (const uint8* data, int dataSize, OutputStream& destStream) + bool write (const uint8* data, int dataSize, OutputStream& out) { // When you call flush() on a gzip stream, the stream is closed, and you can // no longer continue to write data to it! jassert (! finished); while (dataSize > 0) - if (! doNextBlock (data, dataSize, destStream, Z_NO_FLUSH)) + if (! doNextBlock (data, dataSize, out, Z_NO_FLUSH)) return false; return true; } - void finish (OutputStream& destStream) + void finish (OutputStream& out) { const uint8* data = nullptr; int dataSize = 0; while (! finished) - doNextBlock (data, dataSize, destStream, Z_FINISH); + doNextBlock (data, dataSize, out, Z_FINISH); } private: @@ -76,7 +76,7 @@ private: bool isFirstDeflate, streamIsValid, finished; zlibNamespace::Bytef buffer[32768]; - bool doNextBlock (const uint8*& data, int& dataSize, OutputStream& destStream, const int flushMode) + bool doNextBlock (const uint8*& data, int& dataSize, OutputStream& out, const int flushMode) { using namespace zlibNamespace; if (streamIsValid) @@ -100,7 +100,7 @@ private: data += dataSize - stream.avail_in; dataSize = (int) stream.avail_in; const int bytesDone = ((int) sizeof (buffer)) - (int) stream.avail_out; - return bytesDone <= 0 || destStream.write (buffer, bytesDone); + return bytesDone <= 0 || out.write (buffer, bytesDone); } default: @@ -115,14 +115,14 @@ private: }; //============================================================================== -GZIPCompressorOutputStream::GZIPCompressorOutputStream (OutputStream* const destStream_, +GZIPCompressorOutputStream::GZIPCompressorOutputStream (OutputStream* const out, const int compressionLevel, const bool deleteDestStream, const int windowBits) - : destStream (destStream_, deleteDestStream), + : destStream (out, deleteDestStream), helper (new GZIPCompressorHelper (compressionLevel, windowBits)) { - jassert (destStream_ != nullptr); + jassert (out != nullptr); } GZIPCompressorOutputStream::~GZIPCompressorOutputStream() diff --git a/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp b/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp index ed4a7bbdef..65d23df203 100644 --- a/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp +++ b/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp @@ -31,6 +31,12 @@ namespace zlibNamespace { #if JUCE_INCLUDE_ZLIB_CODE + #if JUCE_CLANG + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wconversion" + #pragma clang diagnostic ignored "-Wshadow" + #endif + #undef OS_CODE #undef fdopen #define ZLIB_INTERNAL @@ -55,6 +61,10 @@ namespace zlibNamespace #include "zlib/trees.c" #include "zlib/zutil.c" #undef Byte + + #if JUCE_CLANG + #pragma clang diagnostic pop + #endif #else #include JUCE_ZLIB_INCLUDE_PATH #endif @@ -70,7 +80,7 @@ namespace zlibNamespace class GZIPDecompressorInputStream::GZIPDecompressHelper { public: - GZIPDecompressHelper (const bool noWrap) + GZIPDecompressHelper (const bool dontWrap) : finished (true), needsDictionary (false), error (true), @@ -80,7 +90,7 @@ public: { using namespace zlibNamespace; zerostruct (stream); - streamIsValid = (inflateInit2 (&stream, noWrap ? -MAX_WBITS : MAX_WBITS) == Z_OK); + streamIsValid = (inflateInit2 (&stream, dontWrap ? -MAX_WBITS : MAX_WBITS) == Z_OK); finished = error = ! streamIsValid; } diff --git a/modules/juce_events/native/juce_linux_Messaging.cpp b/modules/juce_events/native/juce_linux_Messaging.cpp index 1750bed7d1..a58a011a8d 100644 --- a/modules/juce_events/native/juce_linux_Messaging.cpp +++ b/modules/juce_events/native/juce_linux_Messaging.cpp @@ -31,7 +31,7 @@ Display* display = nullptr; Window juce_messageWindowHandle = None; XContext windowHandleXContext; // This is referenced from Windowing.cpp -extern void juce_windowMessageReceive (XEvent*); // Defined in Windowing.cpp +extern void juce_windowMessageReceive (XEvent* event); // Defined in Windowing.cpp extern void juce_handleSelectionRequest (XSelectionRequestEvent&); // Defined in Clipboard.cpp //============================================================================== diff --git a/modules/juce_graphics/geometry/juce_Path.cpp b/modules/juce_graphics/geometry/juce_Path.cpp index 6330b30ac9..1180554bb2 100644 --- a/modules/juce_graphics/geometry/juce_Path.cpp +++ b/modules/juce_graphics/geometry/juce_Path.cpp @@ -941,15 +941,15 @@ AffineTransform Path::getTransformToScaleToFit (const float x, const float y, const bool preserveProportions, const Justification& justification) const { - Rectangle bounds (getBounds()); + Rectangle boundsRect (getBounds()); if (preserveProportions) { - if (w <= 0 || h <= 0 || bounds.isEmpty()) + if (w <= 0 || h <= 0 || boundsRect.isEmpty()) return AffineTransform::identity; float newW, newH; - const float srcRatio = bounds.getHeight() / bounds.getWidth(); + const float srcRatio = boundsRect.getHeight() / boundsRect.getWidth(); if (srcRatio > h / w) { @@ -973,17 +973,17 @@ AffineTransform Path::getTransformToScaleToFit (const float x, const float y, else if (justification.testFlags (Justification::bottom)) newYCentre += h - newH * 0.5f; else newYCentre += h * 0.5f; - return AffineTransform::translation (bounds.getWidth() * -0.5f - bounds.getX(), - bounds.getHeight() * -0.5f - bounds.getY()) - .scaled (newW / bounds.getWidth(), - newH / bounds.getHeight()) + return AffineTransform::translation (boundsRect.getWidth() * -0.5f - boundsRect.getX(), + boundsRect.getHeight() * -0.5f - boundsRect.getY()) + .scaled (newW / boundsRect.getWidth(), + newH / boundsRect.getHeight()) .translated (newXCentre, newYCentre); } else { - return AffineTransform::translation (-bounds.getX(), -bounds.getY()) - .scaled (w / bounds.getWidth(), - h / bounds.getHeight()) + return AffineTransform::translation (-boundsRect.getX(), -boundsRect.getY()) + .scaled (w / boundsRect.getWidth(), + h / boundsRect.getHeight()) .translated (x, y); } } diff --git a/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp b/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp index 997d2bafa3..5cee5fe455 100644 --- a/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp +++ b/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp @@ -34,6 +34,13 @@ namespace jpeglibNamespace #if JUCE_MINGW typedef unsigned char boolean; #endif + + #if JUCE_CLANG + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wconversion" + #endif + + #define JPEG_INTERNALS #undef FAR #include "jpglib/jpeglib.h" @@ -106,6 +113,10 @@ namespace jpeglibNamespace #include "jpglib/jquant2.c" #include "jpglib/jutils.c" #include "jpglib/transupp.c" + + #if JUCE_CLANG + #pragma clang diagnostic pop + #endif #else #define JPEG_INTERNALS #undef FAR diff --git a/modules/juce_graphics/images/juce_Image.cpp b/modules/juce_graphics/images/juce_Image.cpp index f447e138fe..d3a31f7978 100644 --- a/modules/juce_graphics/images/juce_Image.cpp +++ b/modules/juce_graphics/images/juce_Image.cpp @@ -338,36 +338,36 @@ NamedValueSet* Image::getProperties() const } //============================================================================== -Image::BitmapData::BitmapData (Image& image, const int x, const int y, const int w, const int h, BitmapData::ReadWriteMode mode) +Image::BitmapData::BitmapData (Image& im, const int x, const int y, const int w, const int h, BitmapData::ReadWriteMode mode) : width (w), height (h) { // The BitmapData class must be given a valid image, and a valid rectangle within it! - jassert (image.image != nullptr); - jassert (x >= 0 && y >= 0 && w > 0 && h > 0 && x + w <= image.getWidth() && y + h <= image.getHeight()); + jassert (im.image != nullptr); + jassert (x >= 0 && y >= 0 && w > 0 && h > 0 && x + w <= im.getWidth() && y + h <= im.getHeight()); - image.image->initialiseBitmapData (*this, x, y, mode); + im.image->initialiseBitmapData (*this, x, y, mode); jassert (data != nullptr && pixelStride > 0 && lineStride != 0); } -Image::BitmapData::BitmapData (const Image& image, const int x, const int y, const int w, const int h) +Image::BitmapData::BitmapData (const Image& im, const int x, const int y, const int w, const int h) : width (w), height (h) { // The BitmapData class must be given a valid image, and a valid rectangle within it! - jassert (image.image != nullptr); - jassert (x >= 0 && y >= 0 && w > 0 && h > 0 && x + w <= image.getWidth() && y + h <= image.getHeight()); + jassert (im.image != nullptr); + jassert (x >= 0 && y >= 0 && w > 0 && h > 0 && x + w <= im.getWidth() && y + h <= im.getHeight()); - image.image->initialiseBitmapData (*this, x, y, readOnly); + im.image->initialiseBitmapData (*this, x, y, readOnly); jassert (data != nullptr && pixelStride > 0 && lineStride != 0); } -Image::BitmapData::BitmapData (const Image& image, BitmapData::ReadWriteMode mode) - : width (image.getWidth()), - height (image.getHeight()) +Image::BitmapData::BitmapData (const Image& im, BitmapData::ReadWriteMode mode) + : width (im.getWidth()), + height (im.getHeight()) { // The BitmapData class must be given a valid image! - jassert (image.image != nullptr); + jassert (im.image != nullptr); - image.image->initialiseBitmapData (*this, 0, 0, mode); + im.image->initialiseBitmapData (*this, 0, 0, mode); jassert (data != nullptr && pixelStride > 0 && lineStride != 0); } diff --git a/modules/juce_graphics/native/juce_RenderingHelpers.h b/modules/juce_graphics/native/juce_RenderingHelpers.h index 838b4f074b..4f21b7d5ef 100644 --- a/modules/juce_graphics/native/juce_RenderingHelpers.h +++ b/modules/juce_graphics/native/juce_RenderingHelpers.h @@ -1357,24 +1357,24 @@ namespace EdgeTableFillers pixelOffset (offsetFloat), pixelOffsetInt (offsetInt) {} - void setStartOfLine (float x, float y, const int numPixels) noexcept + void setStartOfLine (float sx, float sy, const int numPixels) noexcept { jassert (numPixels > 0); - x += pixelOffset; - y += pixelOffset; - float x1 = x, y1 = y; - x += numPixels; - inverseTransform.transformPoints (x1, y1, x, y); + sx += pixelOffset; + sy += pixelOffset; + float x1 = sx, y1 = sy; + sx += numPixels; + inverseTransform.transformPoints (x1, y1, sx, sy); - xBresenham.set ((int) (x1 * 256.0f), (int) (x * 256.0f), numPixels, pixelOffsetInt); - yBresenham.set ((int) (y1 * 256.0f), (int) (y * 256.0f), numPixels, pixelOffsetInt); + xBresenham.set ((int) (x1 * 256.0f), (int) (sx * 256.0f), numPixels, pixelOffsetInt); + yBresenham.set ((int) (y1 * 256.0f), (int) (sy * 256.0f), numPixels, pixelOffsetInt); } - void next (int& x, int& y) noexcept + void next (int& px, int& py) noexcept { - x = xBresenham.n; xBresenham.stepToNext(); - y = yBresenham.n; yBresenham.stepToNext(); + px = xBresenham.n; xBresenham.stepToNext(); + py = yBresenham.n; yBresenham.stepToNext(); } private: @@ -1383,12 +1383,12 @@ namespace EdgeTableFillers public: BresenhamInterpolator() noexcept {} - void set (const int n1, const int n2, const int numSteps_, const int pixelOffsetInt) noexcept + void set (const int n1, const int n2, const int numSteps_, const int offsetInt) noexcept { numSteps = numSteps_; step = (n2 - n1) / numSteps; remainder = modulo = (n2 - n1) % numSteps; - n = n1 + pixelOffsetInt; + n = n1 + offsetInt; if (modulo <= 0) { diff --git a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm index afa1fcaa3d..bf0e4d6a6d 100644 --- a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm +++ b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm @@ -585,7 +585,7 @@ void CoreGraphicsContext::drawGlyph (int glyphNumber, const AffineTransform& tra { CGContextSetTextMatrix (context, state->fontTransform); // have to set this each time, as it's not saved as part of the state - CGGlyph g = glyphNumber; + CGGlyph g = (CGGlyph) glyphNumber; CGContextShowGlyphsAtPoint (context, transform.getTranslationX(), flipHeight - roundToInt (transform.getTranslationY()), &g, 1); } @@ -599,7 +599,7 @@ void CoreGraphicsContext::drawGlyph (int glyphNumber, const AffineTransform& tra t.d = -t.d; CGContextSetTextMatrix (context, t); - CGGlyph g = glyphNumber; + CGGlyph g = (CGGlyph) glyphNumber; CGContextShowGlyphsAtPoint (context, 0, 0, &g, 1); CGContextRestoreGState (context); diff --git a/modules/juce_graphics/native/juce_mac_Fonts.mm b/modules/juce_graphics/native/juce_mac_Fonts.mm index 82f262f244..a74ab83347 100644 --- a/modules/juce_graphics/native/juce_mac_Fonts.mm +++ b/modules/juce_graphics/native/juce_mac_Fonts.mm @@ -426,8 +426,8 @@ public: fontRef = CTFontCopyGraphicsFont (ctFontRef, nullptr); - const int totalHeight = abs (CGFontGetAscent (fontRef)) + abs (CGFontGetDescent (fontRef)); - const float ctTotalHeight = abs (CTFontGetAscent (ctFontRef)) + abs (CTFontGetDescent (ctFontRef)); + const int totalHeight = std::abs (CGFontGetAscent (fontRef)) + std::abs (CGFontGetDescent (fontRef)); + const float ctTotalHeight = std::abs (CTFontGetAscent (ctFontRef)) + std::abs (CTFontGetDescent (ctFontRef)); unitsToHeightScaleFactor = 1.0f / ctTotalHeight; fontHeightToCGSizeFactor = CGFontGetUnitsPerEm (fontRef) / (float) totalHeight; diff --git a/modules/juce_gui_basics/components/juce_Component.cpp b/modules/juce_gui_basics/components/juce_Component.cpp index f93d76b087..2a6bea0051 100644 --- a/modules/juce_gui_basics/components/juce_Component.cpp +++ b/modules/juce_gui_basics/components/juce_Component.cpp @@ -1427,11 +1427,11 @@ void Component::addAndMakeVisible (Component* const child, int zOrder) } } -void Component::addChildAndSetID (Component* const child, const String& componentID) +void Component::addChildAndSetID (Component* const child, const String& childID) { if (child != nullptr) { - child->setComponentID (componentID); + child->setComponentID (childID); addAndMakeVisible (child); } } diff --git a/modules/juce_gui_basics/components/juce_Desktop.cpp b/modules/juce_gui_basics/components/juce_Desktop.cpp index fbd0a8a12a..898f19a23e 100644 --- a/modules/juce_gui_basics/components/juce_Desktop.cpp +++ b/modules/juce_gui_basics/components/juce_Desktop.cpp @@ -379,6 +379,7 @@ Rectangle Desktop::Displays::getTotalBounds (bool userAreasOnly) const return getRectangleList (userAreasOnly).getBounds(); } +bool operator== (const Desktop::Displays::Display& d1, const Desktop::Displays::Display& d2) noexcept; bool operator== (const Desktop::Displays::Display& d1, const Desktop::Displays::Display& d2) noexcept { return d1.userArea == d2.userArea @@ -387,6 +388,7 @@ bool operator== (const Desktop::Displays::Display& d1, const Desktop::Displays:: && d1.isMain == d2.isMain; } +bool operator!= (const Desktop::Displays::Display& d1, const Desktop::Displays::Display& d2) noexcept; bool operator!= (const Desktop::Displays::Display& d1, const Desktop::Displays::Display& d2) noexcept { return ! (d1 == d2); diff --git a/modules/juce_gui_basics/drawables/juce_DrawableComposite.cpp b/modules/juce_gui_basics/drawables/juce_DrawableComposite.cpp index 0c307622d1..f0736cd510 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawableComposite.cpp +++ b/modules/juce_gui_basics/drawables/juce_DrawableComposite.cpp @@ -271,24 +271,24 @@ void DrawableComposite::ValueTreeWrapper::resetBoundingBoxToContentArea (UndoMan RelativeRectangle DrawableComposite::ValueTreeWrapper::getContentArea() const { - MarkerList::ValueTreeWrapper markersX (getMarkerList (true)); - MarkerList::ValueTreeWrapper markersY (getMarkerList (false)); + MarkerList::ValueTreeWrapper marksX (getMarkerList (true)); + MarkerList::ValueTreeWrapper marksY (getMarkerList (false)); - return RelativeRectangle (markersX.getMarker (markersX.getMarkerState (0)).position, - markersX.getMarker (markersX.getMarkerState (1)).position, - markersY.getMarker (markersY.getMarkerState (0)).position, - markersY.getMarker (markersY.getMarkerState (1)).position); + return RelativeRectangle (marksX.getMarker (marksX.getMarkerState (0)).position, + marksX.getMarker (marksX.getMarkerState (1)).position, + marksY.getMarker (marksY.getMarkerState (0)).position, + marksY.getMarker (marksY.getMarkerState (1)).position); } void DrawableComposite::ValueTreeWrapper::setContentArea (const RelativeRectangle& newArea, UndoManager* undoManager) { - MarkerList::ValueTreeWrapper markersX (getMarkerListCreating (true, nullptr)); - MarkerList::ValueTreeWrapper markersY (getMarkerListCreating (false, nullptr)); + MarkerList::ValueTreeWrapper marksX (getMarkerListCreating (true, nullptr)); + MarkerList::ValueTreeWrapper marksY (getMarkerListCreating (false, nullptr)); - markersX.setMarker (MarkerList::Marker (contentLeftMarkerName, newArea.left), undoManager); - markersX.setMarker (MarkerList::Marker (contentRightMarkerName, newArea.right), undoManager); - markersY.setMarker (MarkerList::Marker (contentTopMarkerName, newArea.top), undoManager); - markersY.setMarker (MarkerList::Marker (contentBottomMarkerName, newArea.bottom), undoManager); + marksX.setMarker (MarkerList::Marker (contentLeftMarkerName, newArea.left), undoManager); + marksX.setMarker (MarkerList::Marker (contentRightMarkerName, newArea.right), undoManager); + marksY.setMarker (MarkerList::Marker (contentTopMarkerName, newArea.top), undoManager); + marksY.setMarker (MarkerList::Marker (contentBottomMarkerName, newArea.bottom), undoManager); } MarkerList::ValueTreeWrapper DrawableComposite::ValueTreeWrapper::getMarkerList (bool xAxis) const diff --git a/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp b/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp index 9890d6b22c..7f4795f81a 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp +++ b/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp @@ -174,20 +174,20 @@ void DrawablePath::ValueTreeWrapper::setUsesNonZeroWinding (bool b, UndoManager* state.setProperty (nonZeroWinding, b, undoManager); } -void DrawablePath::ValueTreeWrapper::readFrom (const RelativePointPath& relativePath, UndoManager* undoManager) +void DrawablePath::ValueTreeWrapper::readFrom (const RelativePointPath& p, UndoManager* undoManager) { - setUsesNonZeroWinding (relativePath.usesNonZeroWinding, undoManager); + setUsesNonZeroWinding (p.usesNonZeroWinding, undoManager); ValueTree pathTree (getPathState()); pathTree.removeAllChildren (undoManager); - for (int i = 0; i < relativePath.elements.size(); ++i) - pathTree.addChild (relativePath.elements.getUnchecked(i)->createTree(), -1, undoManager); + for (int i = 0; i < p.elements.size(); ++i) + pathTree.addChild (p.elements.getUnchecked(i)->createTree(), -1, undoManager); } -void DrawablePath::ValueTreeWrapper::writeTo (RelativePointPath& relativePath) const +void DrawablePath::ValueTreeWrapper::writeTo (RelativePointPath& p) const { - relativePath.usesNonZeroWinding = usesNonZeroWinding(); + p.usesNonZeroWinding = usesNonZeroWinding(); RelativePoint points[3]; const ValueTree pathTree (state.getChildWithName (path)); @@ -210,7 +210,7 @@ void DrawablePath::ValueTreeWrapper::writeTo (RelativePointPath& relativePath) c else if (t == Element::cubicToElement) newElement = new RelativePointPath::CubicTo (points[0], points[1], points[2]); else jassertfalse; - relativePath.addElement (newElement); + p.addElement (newElement); } } diff --git a/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp b/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp index 1220a4f71d..7fbe5e4c85 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp +++ b/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp @@ -138,25 +138,25 @@ public: class ProxyComponent : public Component { public: - ProxyComponent (Component& component) - : image (component.createComponentSnapshot (component.getLocalBounds())) + ProxyComponent (Component& c) + : image (c.createComponentSnapshot (c.getLocalBounds())) { - setBounds (component.getBounds()); - setTransform (component.getTransform()); - setAlpha (component.getAlpha()); + setBounds (c.getBounds()); + setTransform (c.getTransform()); + setAlpha (c.getAlpha()); setInterceptsMouseClicks (false, false); - Component* const parent = component.getParentComponent(); + Component* const parent = c.getParentComponent(); if (parent != nullptr) parent->addAndMakeVisible (this); - else if (component.isOnDesktop() && component.getPeer() != nullptr) - addToDesktop (component.getPeer()->getStyleFlags() | ComponentPeer::windowIgnoresKeyPresses); + else if (c.isOnDesktop() && c.getPeer() != nullptr) + addToDesktop (c.getPeer()->getStyleFlags() | ComponentPeer::windowIgnoresKeyPresses); else jassertfalse; // seem to be trying to animate a component that's not visible.. setVisible (true); - toBehind (&component); + toBehind (&c); } void paint (Graphics& g) diff --git a/modules/juce_gui_basics/misc/juce_DropShadower.cpp b/modules/juce_gui_basics/misc/juce_DropShadower.cpp index 706298186d..15d794d8ff 100644 --- a/modules/juce_gui_basics/misc/juce_DropShadower.cpp +++ b/modules/juce_gui_basics/misc/juce_DropShadower.cpp @@ -26,24 +26,24 @@ class DropShadower::ShadowWindow : public Component { public: - ShadowWindow (Component& owner, const int type_, const Image shadowImageSections [12]) - : topLeft (shadowImageSections [type_ * 3]), - bottomRight (shadowImageSections [type_ * 3 + 1]), - filler (shadowImageSections [type_ * 3 + 2]), - type (type_) + ShadowWindow (Component& comp, const int shadowType, const Image imageSections [12]) + : topLeft (imageSections [shadowType * 3]), + bottomRight (imageSections [shadowType * 3 + 1]), + filler (imageSections [shadowType * 3 + 2]), + type (shadowType) { setInterceptsMouseClicks (false, false); - if (owner.isOnDesktop()) + if (comp.isOnDesktop()) { setSize (1, 1); // to keep the OS happy by not having zero-size windows addToDesktop (ComponentPeer::windowIgnoresMouseClicks | ComponentPeer::windowIsTemporary | ComponentPeer::windowIgnoresKeyPresses); } - else if (owner.getParentComponent() != nullptr) + else if (Component* const parent = comp.getParentComponent()) { - owner.getParentComponent()->addChildComponent (this); + parent->addChildComponent (this); } } diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 6816ab3b89..7e647177c0 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -241,16 +241,16 @@ public: Rectangle getBounds (const bool global) const { NSRect r = [view frame]; - NSWindow* window = [view window]; + NSWindow* viewWindow = [view window]; - if (global && window != nil) + if (global && viewWindow != nil) { r = [[view superview] convertRect: r toView: nil]; #if defined (MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 - r = [window convertRectToScreen: r]; + r = [viewWindow convertRectToScreen: r]; #else - r.origin = [window convertBaseToScreen: r.origin]; + r.origin = [viewWindow convertBaseToScreen: r.origin]; #endif r.origin.y = [[[NSScreen screens] objectAtIndex: 0] frame].size.height - r.origin.y - r.size.height; @@ -396,9 +396,8 @@ public: if (hasNativeTitleBar()) { const Rectangle screen (getFrameSize().subtractedFrom (component.getParentMonitorArea())); - const Rectangle window (component.getScreenBounds()); - fullScreen = window.expanded (2, 2).contains (screen); + fullScreen = component.getScreenBounds().expanded (2, 2).contains (screen); } } @@ -1791,16 +1790,16 @@ void Desktop::createMouseInputSources() } //============================================================================== -void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDisable, bool allowMenusAndBars) +void Desktop::setKioskComponent (Component* kioskComp, bool enableOrDisable, bool allowMenusAndBars) { #if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 - NSViewComponentPeer* const peer = dynamic_cast (kioskModeComponent->getPeer()); + NSViewComponentPeer* const peer = dynamic_cast (kioskComp->getPeer()); + jassert (peer != nullptr); // (this should have been checked by the caller) #if defined (MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 - if (peer != nullptr - && peer->hasNativeTitleBar() - && [peer->window respondsToSelector: @selector (toggleFullScreen:)]) + if (peer->hasNativeTitleBar() + && [peer->window respondsToSelector: @selector (toggleFullScreen:)]) { [peer->window performSelector: @selector (toggleFullScreen:) withObject: [NSNumber numberWithBool: (BOOL) enableOrDisable]]; @@ -1815,7 +1814,7 @@ void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDis [NSApp setPresentationOptions: (allowMenusAndBars ? (NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar) : (NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar))]; - kioskModeComponent->setBounds (Desktop::getInstance().getDisplays().getMainDisplay().totalArea); + kioskComp->setBounds (Desktop::getInstance().getDisplays().getMainDisplay().totalArea); peer->becomeKeyWindow(); } else @@ -1833,7 +1832,7 @@ void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDis if (enableOrDisable) { SetSystemUIMode (kUIModeAllSuppressed, allowMenusAndBars ? kUIOptionAutoShowMenuBar : 0); - kioskModeComponent->setBounds (Desktop::getInstance().getDisplays().getMainDisplay().totalArea); + kioskComp->setBounds (Desktop::getInstance().getDisplays().getMainDisplay().totalArea); } else { diff --git a/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp b/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp index 5b67d0940c..baacb7e707 100644 --- a/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp +++ b/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp @@ -42,16 +42,16 @@ public: TextEditor* createEditorComponent() { - TextEditor* const textEditor = Label::createEditorComponent(); - textEditor->setInputRestrictions (maxChars); + TextEditor* const ed = Label::createEditorComponent(); + ed->setInputRestrictions (maxChars); if (isMultiline) { - textEditor->setMultiLine (true, true); - textEditor->setReturnKeyStartsNewLine (true); + ed->setMultiLine (true, true); + ed->setReturnKeyStartsNewLine (true); } - return textEditor; + return ed; } void textWasEdited() diff --git a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp index a563008e1b..33d7d57299 100644 --- a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp @@ -118,10 +118,10 @@ void ComboBox::addItem (const String& newItemText, const int newItemId) } } -void ComboBox::addItemList (const StringArray& items, const int firstItemIdOffset) +void ComboBox::addItemList (const StringArray& itemsToAdd, const int firstItemIdOffset) { - for (int i = 0; i < items.size(); ++i) - addItem (items[i], i + firstItemIdOffset); + for (int i = 0; i < itemsToAdd.size(); ++i) + addItem (itemsToAdd[i], i + firstItemIdOffset); } void ComboBox::addSeparator() diff --git a/modules/juce_gui_basics/widgets/juce_ListBox.cpp b/modules/juce_gui_basics/widgets/juce_ListBox.cpp index 58e9d32dae..9faef2d7f8 100644 --- a/modules/juce_gui_basics/widgets/juce_ListBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ListBox.cpp @@ -209,14 +209,14 @@ public: void updateContents() { hasUpdated = true; - const int rowHeight = owner.getRowHeight(); + const int rowH = owner.getRowHeight(); - if (rowHeight > 0) + if (rowH > 0) { const int y = getViewPositionY(); const int w = getViewedComponent()->getWidth(); - const int numNeeded = 2 + getMaximumVisibleHeight() / rowHeight; + const int numNeeded = 2 + getMaximumVisibleHeight() / rowH; rows.removeRange (numNeeded, rows.size()); while (numNeeded > rows.size()) @@ -226,9 +226,9 @@ public: getViewedComponent()->addAndMakeVisible (newRow); } - firstIndex = y / rowHeight; - firstWholeIndex = (y + rowHeight - 1) / rowHeight; - lastWholeIndex = (y + getMaximumVisibleHeight() - 1) / rowHeight; + firstIndex = y / rowH; + firstWholeIndex = (y + rowH - 1) / rowH; + lastWholeIndex = (y + getMaximumVisibleHeight() - 1) / rowH; for (int i = 0; i < numNeeded; ++i) { @@ -237,7 +237,7 @@ public: if (rowComp != nullptr) { - rowComp->setBounds (0, row * rowHeight, w, rowHeight); + rowComp->setBounds (0, row * rowH, w, rowH); rowComp->update (row, owner.isRowSelected (row)); } } @@ -251,30 +251,30 @@ public: owner.headerComponent->getHeight()); } - void selectRow (const int row, const int rowHeight, const bool dontScroll, - const int lastRowSelected, const int totalItems, const bool isMouseClick) + void selectRow (const int row, const int rowH, const bool dontScroll, + const int lastSelectedRow, const int totalRows, const bool isMouseClick) { hasUpdated = false; if (row < firstWholeIndex && ! dontScroll) { - setViewPosition (getViewPositionX(), row * rowHeight); + setViewPosition (getViewPositionX(), row * rowH); } else if (row >= lastWholeIndex && ! dontScroll) { const int rowsOnScreen = lastWholeIndex - firstWholeIndex; - if (row >= lastRowSelected + rowsOnScreen - && rowsOnScreen < totalItems - 1 + if (row >= lastSelectedRow + rowsOnScreen + && rowsOnScreen < totalRows - 1 && ! isMouseClick) { setViewPosition (getViewPositionX(), - jlimit (0, jmax (0, totalItems - rowsOnScreen), row) * rowHeight); + jlimit (0, jmax (0, totalRows - rowsOnScreen), row) * rowH); } else { setViewPosition (getViewPositionX(), - jmax (0, (row + 1) * rowHeight - getMaximumVisibleHeight())); + jmax (0, (row + 1) * rowH - getMaximumVisibleHeight())); } } @@ -282,16 +282,16 @@ public: updateContents(); } - void scrollToEnsureRowIsOnscreen (const int row, const int rowHeight) + void scrollToEnsureRowIsOnscreen (const int row, const int rowH) { if (row < firstWholeIndex) { - setViewPosition (getViewPositionX(), row * rowHeight); + setViewPosition (getViewPositionX(), row * rowH); } else if (row >= lastWholeIndex) { setViewPosition (getViewPositionX(), - jmax (0, (row + 1) * rowHeight - getMaximumVisibleHeight())); + jmax (0, (row + 1) * rowH - getMaximumVisibleHeight())); } } diff --git a/modules/juce_gui_basics/widgets/juce_TableListBox.cpp b/modules/juce_gui_basics/widgets/juce_TableListBox.cpp index 2515f61265..56df9584f2 100644 --- a/modules/juce_gui_basics/widgets/juce_TableListBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_TableListBox.cpp @@ -27,34 +27,31 @@ class TableListBox::RowComp : public Component, public TooltipClient { public: - RowComp (TableListBox& owner_) - : owner (owner_), row (-1), isSelected (false) + RowComp (TableListBox& tlb) : owner (tlb), row (-1), isSelected (false) { } void paint (Graphics& g) { - TableListBoxModel* const model = owner.getModel(); - - if (model != nullptr) + if (TableListBoxModel* const tableModel = owner.getModel()) { - model->paintRowBackground (g, row, getWidth(), getHeight(), isSelected); + tableModel->paintRowBackground (g, row, getWidth(), getHeight(), isSelected); - const TableHeaderComponent& header = owner.getHeader(); - const int numColumns = header.getNumColumns (true); + const TableHeaderComponent& headerComp = owner.getHeader(); + const int numColumns = headerComp.getNumColumns (true); for (int i = 0; i < numColumns; ++i) { if (columnComponents[i] == nullptr) { - const int columnId = header.getColumnIdOfIndex (i, true); - const Rectangle columnRect (header.getColumnPosition(i).withHeight (getHeight())); + const int columnId = headerComp.getColumnIdOfIndex (i, true); + const Rectangle columnRect (headerComp.getColumnPosition(i).withHeight (getHeight())); Graphics::ScopedSaveState ss (g); g.reduceClipRegion (columnRect); g.setOrigin (columnRect.getX(), 0); - model->paintCell (g, row, columnId, columnRect.getWidth(), columnRect.getHeight(), isSelected); + tableModel->paintCell (g, row, columnId, columnRect.getWidth(), columnRect.getHeight(), isSelected); } } } @@ -71,9 +68,9 @@ public: repaint(); } - TableListBoxModel* const model = owner.getModel(); + TableListBoxModel* const tableModel = owner.getModel(); - if (model != nullptr && row < owner.getNumRows()) + if (tableModel != nullptr && row < owner.getNumRows()) { const Identifier columnProperty ("_tableColumnId"); const int numColumns = owner.getHeader().getNumColumns (true); @@ -89,7 +86,7 @@ public: comp = nullptr; } - comp = model->refreshComponentForCell (row, columnId, isSelected, comp); + comp = tableModel->refreshComponentForCell (row, columnId, isSelected, comp); columnComponents.set (i, comp, false); if (comp != nullptr) @@ -117,9 +114,7 @@ public: void resizeCustomComp (const int index) { - Component* const c = columnComponents.getUnchecked (index); - - if (c != nullptr) + if (Component* const c = columnComponents.getUnchecked (index)) c->setBounds (owner.getHeader().getColumnPosition (index) .withY (0).withHeight (getHeight())); } @@ -216,10 +211,7 @@ private: class TableListBox::Header : public TableHeaderComponent { public: - Header (TableListBox& owner_) - : owner (owner_) - { - } + Header (TableListBox& tlb) : owner (tlb) {} void addMenuItems (PopupMenu& menu, int columnIdClicked) { @@ -252,10 +244,10 @@ private: }; //============================================================================== -TableListBox::TableListBox (const String& name, TableListBoxModel* const model_) +TableListBox::TableListBox (const String& name, TableListBoxModel* const m) : ListBox (name, nullptr), header (nullptr), - model (model_), + model (m), autoSizeOptionsShown (true) { ListBox::model = this; diff --git a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp index f3e750786b..d34a82c5d0 100644 --- a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp +++ b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp @@ -30,41 +30,41 @@ public: { } - bool update (CodeDocument& document, int lineNum, + bool update (CodeDocument& codeDoc, int lineNum, CodeDocument::Iterator& source, - CodeTokeniser* tokeniser, const int spacesPerTab, - const CodeDocument::Position& selectionStart, - const CodeDocument::Position& selectionEnd) + CodeTokeniser* tokeniser, const int tabSpaces, + const CodeDocument::Position& selStart, + const CodeDocument::Position& selEnd) { Array newTokens; newTokens.ensureStorageAllocated (8); if (tokeniser == nullptr) { - const String line (document.getLine (lineNum)); + const String line (codeDoc.getLine (lineNum)); addToken (newTokens, line, line.length(), -1); } - else if (lineNum < document.getNumLines()) + else if (lineNum < codeDoc.getNumLines()) { - const CodeDocument::Position pos (document, lineNum, 0); + const CodeDocument::Position pos (codeDoc, lineNum, 0); createTokens (pos.getPosition(), pos.getLineText(), source, *tokeniser, newTokens); } - replaceTabsWithSpaces (newTokens, spacesPerTab); + replaceTabsWithSpaces (newTokens, tabSpaces); int newHighlightStart = 0; int newHighlightEnd = 0; - if (selectionStart.getLineNumber() <= lineNum && selectionEnd.getLineNumber() >= lineNum) + if (selStart.getLineNumber() <= lineNum && selEnd.getLineNumber() >= lineNum) { - const String line (document.getLine (lineNum)); + const String line (codeDoc.getLine (lineNum)); - CodeDocument::Position lineStart (document, lineNum, 0), lineEnd (document, lineNum + 1, 0); - newHighlightStart = indexToColumn (jmax (0, selectionStart.getPosition() - lineStart.getPosition()), - line, spacesPerTab); - newHighlightEnd = indexToColumn (jmin (lineEnd.getPosition() - lineStart.getPosition(), selectionEnd.getPosition() - lineStart.getPosition()), - line, spacesPerTab); + CodeDocument::Position lineStart (codeDoc, lineNum, 0), lineEnd (codeDoc, lineNum + 1, 0); + newHighlightStart = indexToColumn (jmax (0, selStart.getPosition() - lineStart.getPosition()), + line, tabSpaces); + newHighlightEnd = indexToColumn (jmin (lineEnd.getPosition() - lineStart.getPosition(), selEnd.getPosition() - lineStart.getPosition()), + line, tabSpaces); } if (newHighlightStart != highlightColumnStart || newHighlightEnd != highlightColumnEnd) @@ -81,17 +81,17 @@ public: return true; } - void draw (CodeEditorComponent& owner, Graphics& g, const Font& font, + void draw (CodeEditorComponent& owner, Graphics& g, const Font& fontToUse, const float leftClip, const float rightClip, - const float xOffset, const int y, const int baselineOffset, - const int lineHeight, const float charWidth, + const float x, const int y, const int baselineOffset, + const int lineH, const float characterWidth, const Colour& highlightColour) const { if (highlightColumnStart < highlightColumnEnd) { g.setColour (highlightColour); - g.fillRect (roundToInt (xOffset + highlightColumnStart * owner.getCharWidth()), y, - roundToInt ((highlightColumnEnd - highlightColumnStart) * owner.getCharWidth()), lineHeight); + g.fillRect (roundToInt (x + highlightColumnStart * characterWidth), y, + roundToInt ((highlightColumnEnd - highlightColumnStart) * characterWidth), lineH); } const float baselineY = (float) (y + baselineOffset); @@ -101,7 +101,7 @@ public: for (int i = 0; i < tokens.size(); ++i) { - const float tokenX = xOffset + column * charWidth; + const float tokenX = x + column * characterWidth; if (tokenX > rightClip) break; @@ -119,9 +119,9 @@ public: column += token.length; - if (xOffset + column * charWidth >= leftClip) - ga.addCurtailedLineOfText (font, token.text, tokenX, baselineY, - (rightClip - tokenX) + charWidth, false); + if (x + column * characterWidth >= leftClip) + ga.addCurtailedLineOfText (fontToUse, token.text, tokenX, baselineY, + (rightClip - tokenX) + characterWidth, false); } ga.draw (g); @@ -207,7 +207,7 @@ private: } } - int indexToColumn (int index, const String& line, int spacesPerTab) const noexcept + int indexToColumn (int index, const String& line, int tabSpaces) const noexcept { jassert (index <= line.length()); @@ -218,7 +218,7 @@ private: if (t.getAndAdvance() != '\t') ++col; else - col += spacesPerTab - (col % spacesPerTab); + col += tabSpaces - (col % tabSpaces); } return col; @@ -316,10 +316,10 @@ public: .overlaidWith (editor.findColour (lineNumberBackgroundId))); const Rectangle clip (g.getClipBounds()); - const int lineHeight = editor.lineHeight; - const float lineHeightFloat = (float) lineHeight; - const int firstLineToDraw = jmax (0, clip.getY() / lineHeight); - const int lastLineToDraw = jmin (editor.lines.size(), clip.getBottom() / lineHeight + 1, + const int lineH = editor.lineHeight; + const float lineHeightFloat = (float) lineH; + const int firstLineToDraw = jmax (0, clip.getY() / lineH); + const int lastLineToDraw = jmin (editor.lines.size(), clip.getBottom() / lineH + 1, lastNumLines - editor.firstLineOnScreen); const Font lineNumberFont (editor.getFont().withHeight (jmin (13.0f, lineHeightFloat * 0.8f))); @@ -328,7 +328,7 @@ public: GlyphArrangement ga; for (int i = firstLineToDraw; i < lastLineToDraw; ++i) ga.addFittedText (lineNumberFont, String (editor.firstLineOnScreen + i + 1), - 0, (float) (lineHeight * i), w, lineHeightFloat, + 0, (float) (lineH * i), w, lineHeightFloat, Justification::centredRight, 1, 0.2f); g.setColour (editor.findColour (lineNumberTextId)); @@ -481,8 +481,8 @@ void CodeEditorComponent::paint (Graphics& g) g.fillAll (findColour (CodeEditorComponent::backgroundColourId)); - const int gutter = getGutterSize(); - g.reduceClipRegion (gutter, 0, verticalScrollBar.getX() - gutter, horizontalScrollBar.getY()); + const int gutterSize = getGutterSize(); + g.reduceClipRegion (gutterSize, 0, verticalScrollBar.getX() - gutterSize, horizontalScrollBar.getY()); g.setFont (font); const int baselineOffset = (int) font.getAscent(); @@ -491,7 +491,7 @@ void CodeEditorComponent::paint (Graphics& g) const Rectangle clip (g.getClipBounds()); const int firstLineToDraw = jmax (0, clip.getY() / lineHeight); const int lastLineToDraw = jmin (lines.size(), clip.getBottom() / lineHeight + 1); - const float x = (float) (gutter - xOffset * charWidth); + const float x = (float) (gutterSize - xOffset * charWidth); const float leftClip = (float) clip.getX(); const float rightClip = (float) clip.getRight(); @@ -709,12 +709,12 @@ void CodeEditorComponent::scrollBy (int deltaLines) scrollToLine (firstLineOnScreen + deltaLines); } -void CodeEditorComponent::scrollToKeepLinesOnScreen (const Range& lines) +void CodeEditorComponent::scrollToKeepLinesOnScreen (const Range& rangeToShow) { - if (lines.getStart() < firstLineOnScreen) - scrollBy (lines.getStart() - firstLineOnScreen); - else if (lines.getEnd() >= firstLineOnScreen + linesOnScreen) - scrollBy (lines.getEnd() - (firstLineOnScreen + linesOnScreen - 1)); + if (rangeToShow.getStart() < firstLineOnScreen) + scrollBy (rangeToShow.getStart() - firstLineOnScreen); + else if (rangeToShow.getEnd() >= firstLineOnScreen + linesOnScreen) + scrollBy (rangeToShow.getEnd() - (firstLineOnScreen + linesOnScreen - 1)); } void CodeEditorComponent::scrollToKeepCaretOnScreen() diff --git a/modules/juce_gui_extra/misc/juce_ColourSelector.cpp b/modules/juce_gui_extra/misc/juce_ColourSelector.cpp index cc92ca3e94..e73d9d3689 100644 --- a/modules/juce_gui_extra/misc/juce_ColourSelector.cpp +++ b/modules/juce_gui_extra/misc/juce_ColourSelector.cpp @@ -167,17 +167,17 @@ public: void paint (Graphics& g) { - const float w = (float) getWidth(); - const float h = (float) getHeight(); + const float cw = (float) getWidth(); + const float ch = (float) getHeight(); Path p; p.addTriangle (1.0f, 1.0f, - w * 0.3f, h * 0.5f, - 1.0f, h - 1.0f); + cw * 0.3f, ch * 0.5f, + 1.0f, ch - 1.0f); - p.addTriangle (w - 1.0f, 1.0f, - w * 0.7f, h * 0.5f, - w - 1.0f, h - 1.0f); + p.addTriangle (cw - 1.0f, 1.0f, + cw * 0.7f, ch * 0.5f, + cw - 1.0f, ch - 1.0f); g.setColour (Colours::white.withAlpha (0.75f)); g.fillPath (p); @@ -255,11 +255,11 @@ public: void paint (Graphics& g) { - const Colour colour (owner.getSwatchColour (index)); + const Colour c (owner.getSwatchColour (index)); g.fillCheckerBoard (getLocalBounds(), 6, 6, - Colour (0xffdddddd).overlaidWith (colour), - Colour (0xffffffff).overlaidWith (colour)); + Colour (0xffdddddd).overlaidWith (c), + Colour (0xffffffff).overlaidWith (c)); } void mouseDown (const MouseEvent&)