diff --git a/src/audio/audio_file_formats/juce_AiffAudioFormat.cpp b/src/audio/audio_file_formats/juce_AiffAudioFormat.cpp index 3ba1986e12..5eaafd9877 100644 --- a/src/audio/audio_file_formats/juce_AiffAudioFormat.cpp +++ b/src/audio/audio_file_formats/juce_AiffAudioFormat.cpp @@ -176,8 +176,6 @@ namespace MarkChunk for (int i = 0; i < numCues; ++i) { const String prefixCue ("Cue" + String (i)); - const String prefixLabel ("CueLabel" + String (i)); - const int identifier = idOffset + values.getValue (prefixCue + "Identifier", "1").getIntValue(); #if JUCE_DEBUG @@ -186,8 +184,7 @@ namespace MarkChunk #endif const int offset = values.getValue (prefixCue + "Offset", "0").getIntValue(); - - String label (prefixLabel); + String label ("CueLabel" + String (i)); for (int labelIndex = 0; labelIndex < numCueLabels; ++labelIndex) { diff --git a/src/audio/audio_file_formats/juce_OggVorbisAudioFormat.cpp b/src/audio/audio_file_formats/juce_OggVorbisAudioFormat.cpp index 5258ef790c..60d41b124e 100644 --- a/src/audio/audio_file_formats/juce_OggVorbisAudioFormat.cpp +++ b/src/audio/audio_file_formats/juce_OggVorbisAudioFormat.cpp @@ -250,18 +250,18 @@ class OggWriter : public AudioFormatWriter public: //============================================================================== OggWriter (OutputStream* const out, - const double sampleRate, - const int numChannels, - const int bitsPerSample, + const double sampleRate_, + const int numChannels_, + const int bitsPerSample_, const int qualityIndex) - : AudioFormatWriter (out, TRANS (oggFormatName), sampleRate, numChannels, bitsPerSample), + : AudioFormatWriter (out, TRANS (oggFormatName), sampleRate_, numChannels_, bitsPerSample_), ok (false) { using namespace OggVorbisNamespace; vorbis_info_init (&vi); - if (vorbis_encode_init_vbr (&vi, numChannels, (int) sampleRate, + if (vorbis_encode_init_vbr (&vi, numChannels_, (int) sampleRate_, jlimit (0.0f, 1.0f, qualityIndex * 0.1f)) == 0) { vorbis_comment_init (&vc); diff --git a/src/audio/audio_sources/juce_ReverbAudioSource.cpp b/src/audio/audio_sources/juce_ReverbAudioSource.cpp index ae86e453af..303e5a0dad 100644 --- a/src/audio/audio_sources/juce_ReverbAudioSource.cpp +++ b/src/audio/audio_sources/juce_ReverbAudioSource.cpp @@ -78,12 +78,12 @@ void ReverbAudioSource::setParameters (const Reverb::Parameters& newParams) reverb.setParameters (newParams); } -void ReverbAudioSource::setBypassed (bool isBypassed) noexcept +void ReverbAudioSource::setBypassed (bool b) noexcept { - if (bypass != isBypassed) + if (bypass != b) { const ScopedLock sl (lock); - bypass = isBypassed; + bypass = b; reverb.reset(); } } diff --git a/src/audio/devices/juce_AudioDeviceManager.cpp b/src/audio/devices/juce_AudioDeviceManager.cpp index e5f035b1f7..451dbaa069 100644 --- a/src/audio/devices/juce_AudioDeviceManager.cpp +++ b/src/audio/devices/juce_AudioDeviceManager.cpp @@ -775,11 +775,11 @@ void AudioDeviceManager::addMidiInputCallback (const String& name, } } -void AudioDeviceManager::removeMidiInputCallback (const String& name, MidiInputCallback* callback) +void AudioDeviceManager::removeMidiInputCallback (const String& name, MidiInputCallback* callbackToRemove) { for (int i = midiCallbacks.size(); --i >= 0;) { - if (midiCallbackDevices[i] == name && midiCallbacks.getUnchecked(i) == callback) + if (midiCallbackDevices[i] == name && midiCallbacks.getUnchecked(i) == callbackToRemove) { const ScopedLock sl (midiCallbackLock); midiCallbacks.remove (i); diff --git a/src/audio/synthesisers/juce_Synthesiser.cpp b/src/audio/synthesisers/juce_Synthesiser.cpp index c4bd28518c..d6c703d315 100644 --- a/src/audio/synthesisers/juce_Synthesiser.cpp +++ b/src/audio/synthesisers/juce_Synthesiser.cpp @@ -235,9 +235,9 @@ void Synthesiser::noteOn (const int midiChannel, { // If hitting a note that's still ringing, stop it first (it could be // still playing because of the sustain or sostenuto pedal). - for (int i = voices.size(); --i >= 0;) + for (int j = voices.size(); --j >= 0;) { - SynthesiserVoice* const voice = voices.getUnchecked (i); + SynthesiserVoice* const voice = voices.getUnchecked (j); if (voice->getCurrentlyPlayingNote() == midiNoteNumber && voice->isPlayingChannel (midiChannel)) diff --git a/src/containers/juce_Array.h b/src/containers/juce_Array.h index e20e0e76a3..5da6d47bb0 100644 --- a/src/containers/juce_Array.h +++ b/src/containers/juce_Array.h @@ -315,9 +315,9 @@ public: { const ScopedLockType lock (getLock()); const ElementType* e = data.elements.getData(); - const ElementType* const end = e + numUsed; + const ElementType* const end_ = e + numUsed; - for (; e != end; ++e) + for (; e != end_; ++e) if (elementToLookFor == *e) return static_cast (e - data.elements.getData()); @@ -333,9 +333,9 @@ public: { const ScopedLockType lock (getLock()); const ElementType* e = data.elements.getData(); - const ElementType* const end = e + numUsed; + const ElementType* const end_ = e + numUsed; - for (; e != end; ++e) + for (; e != end_; ++e) if (elementToLookFor == *e) return true; @@ -668,11 +668,11 @@ public: const ScopedLockType lock (getLock()); int start = 0; - int end = numUsed; + int end_ = numUsed; for (;;) { - if (start >= end) + if (start >= end_) { return -1; } @@ -682,14 +682,14 @@ public: } else { - const int halfway = (start + end) >> 1; + const int halfway = (start + end_) >> 1; if (halfway == start) return -1; else if (comparator.compareElements (elementToLookFor, data.elements [halfway]) >= 0) start = halfway; else - end = halfway; + end_ = halfway; } } } diff --git a/src/containers/juce_HashMap.h b/src/containers/juce_HashMap.h index ed29a4b85b..5fae8eef5b 100644 --- a/src/containers/juce_HashMap.h +++ b/src/containers/juce_HashMap.h @@ -108,7 +108,7 @@ public: will be the "upperLimit" parameter that is passed to your generateHash() function. The number of hash slots will grow automatically if necessary, or it can be remapped manually using remapTable(). */ - HashMap (const int numberOfSlots = defaultHashTableSize) + explicit HashMap (const int numberOfSlots = defaultHashTableSize) : totalNumItems (0) { slots.insertMultiple (0, nullptr, numberOfSlots); diff --git a/src/containers/juce_OwnedArray.h b/src/containers/juce_OwnedArray.h index d504ad564f..8092dbfcb0 100644 --- a/src/containers/juce_OwnedArray.h +++ b/src/containers/juce_OwnedArray.h @@ -185,9 +185,9 @@ public: { const ScopedLockType lock (getLock()); ObjectClass* const* e = data.elements.getData(); - ObjectClass* const* const end = e + numUsed; + ObjectClass* const* const end_ = e + numUsed; - for (; e != end; ++e) + for (; e != end_; ++e) if (objectToLookFor == *e) return static_cast (e - data.elements.getData()); @@ -203,9 +203,9 @@ public: { const ScopedLockType lock (getLock()); ObjectClass* const* e = data.elements.getData(); - ObjectClass* const* const end = e + numUsed; + ObjectClass* const* const end_ = e + numUsed; - for (; e != end; ++e) + for (; e != end_; ++e) if (objectToLookFor == *e) return true; @@ -463,11 +463,11 @@ public: const ScopedLockType lock (getLock()); int start = 0; - int end = numUsed; + int end_ = numUsed; for (;;) { - if (start >= end) + if (start >= end_) { return -1; } @@ -477,14 +477,14 @@ public: } else { - const int halfway = (start + end) >> 1; + const int halfway = (start + end_) >> 1; if (halfway == start) return -1; else if (comparator.compareElements (objectToLookFor, data.elements [halfway]) >= 0) start = halfway; else - end = halfway; + end_ = halfway; } } } diff --git a/src/containers/juce_ReferenceCountedArray.h b/src/containers/juce_ReferenceCountedArray.h index 74895a5430..f46770d858 100644 --- a/src/containers/juce_ReferenceCountedArray.h +++ b/src/containers/juce_ReferenceCountedArray.h @@ -198,9 +198,9 @@ public: { const ScopedLockType lock (getLock()); ObjectClass** e = data.elements.getData(); - ObjectClass** const end = e + numUsed; + ObjectClass** const end_ = e + numUsed; - while (e != end) + while (e != end_) { if (objectToLookFor == *e) return static_cast (e - data.elements.getData()); @@ -220,9 +220,9 @@ public: { const ScopedLockType lock (getLock()); ObjectClass** e = data.elements.getData(); - ObjectClass** const end = e + numUsed; + ObjectClass** const end_ = e + numUsed; - while (e != end) + while (e != end_) { if (objectToLookFor == *e) return true; @@ -529,12 +529,12 @@ public: const ScopedLockType lock (getLock()); const int start = jlimit (0, numUsed, startIndex); - const int end = jlimit (0, numUsed, startIndex + numberToRemove); + const int end_ = jlimit (0, numUsed, startIndex + numberToRemove); - if (end > start) + if (end_ > start) { int i; - for (i = start; i < end; ++i) + for (i = start; i < end_; ++i) { if (data.elements[i] != nullptr) { @@ -543,9 +543,9 @@ public: } } - const int rangeSize = end - start; + const int rangeSize = end_ - start; ObjectClass** e = data.elements + start; - i = numUsed - end; + i = numUsed - end_; numUsed -= rangeSize; while (--i >= 0) diff --git a/src/containers/juce_SortedSet.h b/src/containers/juce_SortedSet.h index 3345a385d4..1bf6201340 100644 --- a/src/containers/juce_SortedSet.h +++ b/src/containers/juce_SortedSet.h @@ -270,11 +270,11 @@ public: const ScopedLockType lock (getLock()); int start = 0; - int end = numUsed; + int end_ = numUsed; for (;;) { - if (start >= end) + if (start >= end_) { return -1; } @@ -284,12 +284,12 @@ public: } else { - const int halfway = (start + end) >> 1; + const int halfway = (start + end_) >> 1; if (halfway == start) return -1; else if (elementToLookFor < data.elements [halfway]) - end = halfway; + end_ = halfway; else start = halfway; } @@ -306,11 +306,11 @@ public: const ScopedLockType lock (getLock()); int start = 0; - int end = numUsed; + int end_ = numUsed; for (;;) { - if (start >= end) + if (start >= end_) { return false; } @@ -320,12 +320,12 @@ public: } else { - const int halfway = (start + end) >> 1; + const int halfway = (start + end_) >> 1; if (halfway == start) return false; else if (elementToLookFor < data.elements [halfway]) - end = halfway; + end_ = halfway; else start = halfway; } @@ -343,13 +343,13 @@ public: const ScopedLockType lock (getLock()); int start = 0; - int end = numUsed; + int end_ = numUsed; for (;;) { - if (start >= end) + if (start >= end_) { - jassert (start <= end); + jassert (start <= end_); insertInternal (start, newElement); break; } @@ -359,7 +359,7 @@ public: } else { - const int halfway = (start + end) >> 1; + const int halfway = (start + end_) >> 1; if (halfway == start) { @@ -371,7 +371,7 @@ public: break; } else if (newElement < data.elements [halfway]) - end = halfway; + end_ = halfway; else start = halfway; } diff --git a/src/containers/juce_Variant.cpp b/src/containers/juce_Variant.cpp index 3c59f34d7e..d006ea94fb 100644 --- a/src/containers/juce_Variant.cpp +++ b/src/containers/juce_Variant.cpp @@ -565,9 +565,9 @@ Array* var::convertToArray() return array; } -void var::append (const var& value) +void var::append (const var& n) { - convertToArray()->add (value); + convertToArray()->add (n); } void var::remove (const int index) @@ -578,9 +578,9 @@ void var::remove (const int index) array->remove (index); } -void var::insert (const int index, const var& value) +void var::insert (const int index, const var& n) { - convertToArray()->insert (index, value); + convertToArray()->insert (index, n); } void var::resize (const int numArrayElementsWanted) @@ -588,10 +588,10 @@ void var::resize (const int numArrayElementsWanted) convertToArray()->resize (numArrayElementsWanted); } -int var::indexOf (const var& value) const +int var::indexOf (const var& n) const { const Array* const array = getArray(); - return array != nullptr ? array->indexOf (value) : -1; + return array != nullptr ? array->indexOf (n) : -1; } //============================================================================== diff --git a/src/containers/juce_Variant.h b/src/containers/juce_Variant.h index d182457675..4510fe0535 100644 --- a/src/containers/juce_Variant.h +++ b/src/containers/juce_Variant.h @@ -44,7 +44,10 @@ any kind of ReferenceCountedObject. The var class is intended to act like the kind of values used in dynamic scripting languages. - @see DynamicObject + You can save/load var objects either in a small, proprietary binary format + using writeToStream()/readFromStream(), or as JSON by using the JSON class. + + @see JSON, DynamicObject */ class JUCE_API var { @@ -208,12 +211,14 @@ public: //============================================================================== /** Writes a binary representation of this value to a stream. The data can be read back later using readFromStream(). + @see JSON */ void writeToStream (OutputStream& output) const; /** Reads back a stored binary representation of a value. The data in the stream must have been written using writeToStream(), or this will have unpredictable results. + @see JSON */ static var readFromStream (InputStream& input); diff --git a/src/events/juce_Timer.cpp b/src/events/juce_Timer.cpp index 2b1913d987..968261a03d 100644 --- a/src/events/juce_Timer.cpp +++ b/src/events/juce_Timer.cpp @@ -65,7 +65,7 @@ public: void run() { uint32 lastTime = Time::getMillisecondCounter(); - Message::Ptr message (new Message()); + Message::Ptr messageToSend (new Message()); while (! threadShouldExit()) { @@ -92,7 +92,7 @@ public: */ if (callbackNeeded.compareAndSetBool (1, 0)) { - postMessage (message); + postMessage (messageToSend); /* Sometimes our message can get discarded by the OS (e.g. when running as an RTAS when the app has a modal loop), so this is how long to wait before assuming the diff --git a/src/gui/components/buttons/juce_ShapeButton.cpp b/src/gui/components/buttons/juce_ShapeButton.cpp index 4a6b1d3951..f0fb0c017c 100644 --- a/src/gui/components/buttons/juce_ShapeButton.cpp +++ b/src/gui/components/buttons/juce_ShapeButton.cpp @@ -77,15 +77,15 @@ void ShapeButton::setShape (const Path& newShape, if (resizeNowToFitThisShape) { - Rectangle bounds (shape.getBounds()); + Rectangle newBounds (shape.getBounds()); if (hasShadow) - bounds.expand (4.0f, 4.0f); + newBounds.expand (4.0f, 4.0f); - shape.applyTransform (AffineTransform::translation (-bounds.getX(), -bounds.getY())); + shape.applyTransform (AffineTransform::translation (-newBounds.getX(), -newBounds.getY())); - setSize (1 + (int) (bounds.getWidth() + outlineWidth), - 1 + (int) (bounds.getHeight() + outlineWidth)); + setSize (1 + (int) (newBounds.getWidth() + outlineWidth), + 1 + (int) (newBounds.getHeight() + outlineWidth)); } } diff --git a/src/gui/components/controls/juce_ImageComponent.cpp b/src/gui/components/controls/juce_ImageComponent.cpp index 713a639148..0e7c453e6d 100644 --- a/src/gui/components/controls/juce_ImageComponent.cpp +++ b/src/gui/components/controls/juce_ImageComponent.cpp @@ -31,8 +31,8 @@ BEGIN_JUCE_NAMESPACE //============================================================================== -ImageComponent::ImageComponent (const String& componentName) - : Component (componentName), +ImageComponent::ImageComponent (const String& name) + : Component (name), placement (RectanglePlacement::centred) { } diff --git a/src/gui/components/controls/juce_Label.cpp b/src/gui/components/controls/juce_Label.cpp index 8ce3300bb9..06b5f51932 100644 --- a/src/gui/components/controls/juce_Label.cpp +++ b/src/gui/components/controls/juce_Label.cpp @@ -34,9 +34,9 @@ BEGIN_JUCE_NAMESPACE //============================================================================== -Label::Label (const String& componentName, +Label::Label (const String& name, const String& labelText) - : Component (componentName), + : Component (name), textValue (labelText), lastTextValue (labelText), font (15.0f), diff --git a/src/gui/components/controls/juce_TextEditor.cpp b/src/gui/components/controls/juce_TextEditor.cpp index df949528e0..46874a6fcb 100644 --- a/src/gui/components/controls/juce_TextEditor.cpp +++ b/src/gui/components/controls/juce_TextEditor.cpp @@ -1715,9 +1715,9 @@ void TextEditor::drawContent (Graphics& g) } } - for (int i = underlinedSections.size(); --i >= 0;) + for (int j = underlinedSections.size(); --j >= 0;) { - const Range& underlinedSection = underlinedSections.getReference (i); + const Range& underlinedSection = underlinedSections.getReference (j); Iterator i2 (sections, wordWrapWidth, passwordCharacter); diff --git a/src/gui/components/controls/juce_TreeView.cpp b/src/gui/components/controls/juce_TreeView.cpp index 64527f4932..2df44d6150 100644 --- a/src/gui/components/controls/juce_TreeView.cpp +++ b/src/gui/components/controls/juce_TreeView.cpp @@ -459,8 +459,8 @@ private: //============================================================================== -TreeView::TreeView (const String& componentName) - : Component (componentName), +TreeView::TreeView (const String& name) + : Component (name), rootItem (nullptr), indentSize (24), defaultOpenness (false), diff --git a/src/gui/components/juce_ModalComponentManager.cpp b/src/gui/components/juce_ModalComponentManager.cpp index 83b7b8033e..53c195e8e7 100644 --- a/src/gui/components/juce_ModalComponentManager.cpp +++ b/src/gui/components/juce_ModalComponentManager.cpp @@ -200,7 +200,7 @@ void ModalComponentManager::handleAsyncUpdate() if (! item->isActive) { - ScopedPointer item (stack.removeAndReturn (i)); + ScopedPointer deleter (stack.removeAndReturn (i)); for (int j = item->callbacks.size(); --j >= 0;) item->callbacks.getUnchecked(j)->modalStateFinished (item->returnValue); diff --git a/src/gui/components/keyboard/juce_KeyMappingEditorComponent.cpp b/src/gui/components/keyboard/juce_KeyMappingEditorComponent.cpp index 95b299854e..c453da78e2 100644 --- a/src/gui/components/keyboard/juce_KeyMappingEditorComponent.cpp +++ b/src/gui/components/keyboard/juce_KeyMappingEditorComponent.cpp @@ -385,7 +385,7 @@ public: void changeListenerCallback (ChangeBroadcaster*) { - const OpennessRestorer openness (*this); + const OpennessRestorer opennessRestorer (*this); clearSubItems(); const StringArray categories (owner.getMappings().getCommandManager()->getCommandCategories()); diff --git a/src/gui/components/layout/juce_GroupComponent.cpp b/src/gui/components/layout/juce_GroupComponent.cpp index 854d8f7112..e256c687d1 100644 --- a/src/gui/components/layout/juce_GroupComponent.cpp +++ b/src/gui/components/layout/juce_GroupComponent.cpp @@ -32,9 +32,9 @@ BEGIN_JUCE_NAMESPACE //============================================================================== -GroupComponent::GroupComponent (const String& componentName, +GroupComponent::GroupComponent (const String& name, const String& labelText) - : Component (componentName), + : Component (name), text (labelText), justification (Justification::left) { diff --git a/src/gui/components/layout/juce_ResizableBorderComponent.cpp b/src/gui/components/layout/juce_ResizableBorderComponent.cpp index d664ae857c..ec8f88b7a9 100644 --- a/src/gui/components/layout/juce_ResizableBorderComponent.cpp +++ b/src/gui/components/layout/juce_ResizableBorderComponent.cpp @@ -150,11 +150,11 @@ void ResizableBorderComponent::mouseDrag (const MouseEvent& e) return; } - const Rectangle bounds (mouseZone.resizeRectangleBy (originalBounds, e.getOffsetFromDragStart())); + const Rectangle newBounds (mouseZone.resizeRectangleBy (originalBounds, e.getOffsetFromDragStart())); if (constrainer != nullptr) { - constrainer->setBoundsForComponent (component, bounds, + constrainer->setBoundsForComponent (component, newBounds, mouseZone.isDraggingTopEdge(), mouseZone.isDraggingLeftEdge(), mouseZone.isDraggingBottomEdge(), @@ -162,12 +162,12 @@ void ResizableBorderComponent::mouseDrag (const MouseEvent& e) } else { - Component::Positioner* const positioner = component->getPositioner(); + Component::Positioner* const pos = component->getPositioner(); - if (positioner != nullptr) - positioner->applyNewBounds (bounds); + if (pos != nullptr) + pos->applyNewBounds (newBounds); else - component->setBounds (bounds); + component->setBounds (newBounds); } } diff --git a/src/gui/components/layout/juce_ResizableCornerComponent.cpp b/src/gui/components/layout/juce_ResizableCornerComponent.cpp index 4555090cba..81d0d06660 100644 --- a/src/gui/components/layout/juce_ResizableCornerComponent.cpp +++ b/src/gui/components/layout/juce_ResizableCornerComponent.cpp @@ -87,10 +87,10 @@ void ResizableCornerComponent::mouseDrag (const MouseEvent& e) } else { - Component::Positioner* const positioner = component->getPositioner(); + Component::Positioner* const pos = component->getPositioner(); - if (positioner != nullptr) - positioner->applyNewBounds (r); + if (pos != nullptr) + pos->applyNewBounds (r); else component->setBounds (r); } diff --git a/src/gui/components/layout/juce_ResizableEdgeComponent.cpp b/src/gui/components/layout/juce_ResizableEdgeComponent.cpp index d082325a45..674900221a 100644 --- a/src/gui/components/layout/juce_ResizableEdgeComponent.cpp +++ b/src/gui/components/layout/juce_ResizableEdgeComponent.cpp @@ -82,20 +82,20 @@ void ResizableEdgeComponent::mouseDrag (const MouseEvent& e) return; } - Rectangle bounds (originalBounds); + Rectangle newBounds (originalBounds); switch (edge) { - case leftEdge: bounds.setLeft (jmin (bounds.getRight(), bounds.getX() + e.getDistanceFromDragStartX())); break; - case rightEdge: bounds.setWidth (jmax (0, bounds.getWidth() + e.getDistanceFromDragStartX())); break; - case topEdge: bounds.setTop (jmin (bounds.getBottom(), bounds.getY() + e.getDistanceFromDragStartY())); break; - case bottomEdge: bounds.setHeight (jmax (0, bounds.getHeight() + e.getDistanceFromDragStartY())); break; + case leftEdge: newBounds.setLeft (jmin (newBounds.getRight(), newBounds.getX() + e.getDistanceFromDragStartX())); break; + case rightEdge: newBounds.setWidth (jmax (0, newBounds.getWidth() + e.getDistanceFromDragStartX())); break; + case topEdge: newBounds.setTop (jmin (newBounds.getBottom(), newBounds.getY() + e.getDistanceFromDragStartY())); break; + case bottomEdge: newBounds.setHeight (jmax (0, newBounds.getHeight() + e.getDistanceFromDragStartY())); break; default: jassertfalse; break; } if (constrainer != nullptr) { - constrainer->setBoundsForComponent (component, bounds, + constrainer->setBoundsForComponent (component, newBounds, edge == topEdge, edge == leftEdge, edge == bottomEdge, @@ -103,12 +103,12 @@ void ResizableEdgeComponent::mouseDrag (const MouseEvent& e) } else { - Component::Positioner* const positioner = component->getPositioner(); + Component::Positioner* const pos = component->getPositioner(); - if (positioner != nullptr) - positioner->applyNewBounds (bounds); + if (pos != nullptr) + pos->applyNewBounds (newBounds); else - component->setBounds (bounds); + component->setBounds (newBounds); } } diff --git a/src/gui/components/layout/juce_Viewport.cpp b/src/gui/components/layout/juce_Viewport.cpp index dc1e8aa94d..baf49b36ef 100644 --- a/src/gui/components/layout/juce_Viewport.cpp +++ b/src/gui/components/layout/juce_Viewport.cpp @@ -32,8 +32,8 @@ BEGIN_JUCE_NAMESPACE //============================================================================== -Viewport::Viewport (const String& componentName) - : Component (componentName), +Viewport::Viewport (const String& name) + : Component (name), scrollBarThickness (0), singleStepX (16), singleStepY (16), diff --git a/src/gui/components/positioning/juce_RelativeCoordinatePositioner.cpp b/src/gui/components/positioning/juce_RelativeCoordinatePositioner.cpp index 66b8da36c3..1733228381 100644 --- a/src/gui/components/positioning/juce_RelativeCoordinatePositioner.cpp +++ b/src/gui/components/positioning/juce_RelativeCoordinatePositioner.cpp @@ -220,10 +220,10 @@ void RelativeCoordinatePositionerBase::componentChildrenChanged (Component& chan apply(); } -void RelativeCoordinatePositionerBase::componentBeingDeleted (Component& component) +void RelativeCoordinatePositionerBase::componentBeingDeleted (Component& comp) { - jassert (sourceComponents.contains (&component)); - sourceComponents.removeValue (&component); + jassert (sourceComponents.contains (&comp)); + sourceComponents.removeValue (&comp); registeredOk = false; } diff --git a/src/gui/components/positioning/juce_RelativeRectangle.cpp b/src/gui/components/positioning/juce_RelativeRectangle.cpp index 3f41700362..34f6e4004f 100644 --- a/src/gui/components/positioning/juce_RelativeRectangle.cpp +++ b/src/gui/components/positioning/juce_RelativeRectangle.cpp @@ -147,8 +147,8 @@ const Rectangle RelativeRectangle::resolve (const Expression::Scope* scop { if (scope == nullptr) { - RelativeRectangleLocalScope scope (*this); - return resolve (&scope); + RelativeRectangleLocalScope defaultScope (*this); + return resolve (&defaultScope); } else { diff --git a/src/gui/components/windows/juce_CallOutBox.cpp b/src/gui/components/windows/juce_CallOutBox.cpp index 1146db704d..2986240250 100644 --- a/src/gui/components/windows/juce_CallOutBox.cpp +++ b/src/gui/components/windows/juce_CallOutBox.cpp @@ -36,17 +36,17 @@ BEGIN_JUCE_NAMESPACE //============================================================================== CallOutBox::CallOutBox (Component& contentComponent, Component& componentToPointTo, - Component* const parentComponent) + Component* const parent) : borderSpace (20), arrowSize (16.0f), content (contentComponent) { addAndMakeVisible (&content); - if (parentComponent != nullptr) + if (parent != nullptr) { - parentComponent->addChildComponent (this); + parent->addChildComponent (this); - updatePosition (parentComponent->getLocalArea (&componentToPointTo, componentToPointTo.getLocalBounds()), - parentComponent->getLocalBounds()); + updatePosition (parent->getLocalArea (&componentToPointTo, componentToPointTo.getLocalBounds()), + parent->getLocalBounds()); setVisible (true); } @@ -155,12 +155,12 @@ void CallOutBox::updatePosition (const Rectangle& newAreaToPointTo, const R targetArea = newAreaToPointTo; availableArea = newAreaToFitIn; - Rectangle bounds (0, 0, - content.getWidth() + borderSpace * 2, - content.getHeight() + borderSpace * 2); + Rectangle newBounds (0, 0, + content.getWidth() + borderSpace * 2, + content.getHeight() + borderSpace * 2); - const int hw = bounds.getWidth() / 2; - const int hh = bounds.getHeight() / 2; + const int hw = newBounds.getWidth() / 2; + const int hh = newBounds.getHeight() / 2; const float hwReduced = (float) (hw - borderSpace * 3); const float hhReduced = (float) (hh - borderSpace * 3); const float arrowIndent = borderSpace - arrowSize; @@ -195,12 +195,12 @@ void CallOutBox::updatePosition (const Rectangle& newAreaToPointTo, const R nearest = distanceFromCentre; targetPoint = targets[i]; - bounds.setPosition ((int) (centre.getX() - hw), - (int) (centre.getY() - hh)); + newBounds.setPosition ((int) (centre.getX() - hw), + (int) (centre.getY() - hh)); } } - setBounds (bounds); + setBounds (newBounds); } void CallOutBox::refreshPath() diff --git a/src/gui/components/windows/juce_DialogWindow.cpp b/src/gui/components/windows/juce_DialogWindow.cpp index 81752f2073..7d5085ff51 100644 --- a/src/gui/components/windows/juce_DialogWindow.cpp +++ b/src/gui/components/windows/juce_DialogWindow.cpp @@ -65,18 +65,18 @@ class TempDialogWindow : public DialogWindow { public: TempDialogWindow (const String& title, - Component* contentComponent, + Component* contentComponent_, Component* componentToCentreAround, const Colour& colour, - const bool escapeKeyTriggersCloseButton, + const bool escapeKeyTriggersCloseButton_, const bool shouldBeResizable, const bool useBottomRightCornerResizer) - : DialogWindow (title, colour, escapeKeyTriggersCloseButton, true) + : DialogWindow (title, colour, escapeKeyTriggersCloseButton_, true) { if (! JUCEApplication::isStandaloneApp()) setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level - setContentNonOwned (contentComponent, true); + setContentNonOwned (contentComponent_, true); centreAroundComponent (componentToCentreAround, getWidth(), getHeight()); setResizable (shouldBeResizable, useBottomRightCornerResizer); } diff --git a/src/gui/components/windows/juce_ResizableWindow.cpp b/src/gui/components/windows/juce_ResizableWindow.cpp index 33cca46a02..c97026fbcf 100644 --- a/src/gui/components/windows/juce_ResizableWindow.cpp +++ b/src/gui/components/windows/juce_ResizableWindow.cpp @@ -83,13 +83,13 @@ ResizableWindow::~ResizableWindow() jassert (getNumChildComponents() == 0); } -void ResizableWindow::initialise (const bool addToDesktop) +void ResizableWindow::initialise (const bool shouldAddToDesktop) { defaultConstrainer.setMinimumOnscreenAmounts (0x10000, 16, 24, 16); lastNonFullScreenPos.setBounds (50, 50, 256, 256); - if (addToDesktop) + if (shouldAddToDesktop) Component::addToDesktop (ResizableWindow::getDesktopWindowStyleFlags()); } @@ -349,12 +349,12 @@ void ResizableWindow::setConstrainer (ComponentBoundsConstrainer* newConstrainer } } -void ResizableWindow::setBoundsConstrained (const Rectangle& bounds) +void ResizableWindow::setBoundsConstrained (const Rectangle& newBounds) { if (constrainer != nullptr) - constrainer->setBoundsForComponent (this, bounds, false, false, false, false); + constrainer->setBoundsForComponent (this, newBounds, false, false, false, false); else - setBounds (bounds); + setBounds (newBounds); } //============================================================================== diff --git a/src/gui/components/windows/juce_TooltipWindow.cpp b/src/gui/components/windows/juce_TooltipWindow.cpp index d2bcf8a64e..4b5b2cb9b9 100644 --- a/src/gui/components/windows/juce_TooltipWindow.cpp +++ b/src/gui/components/windows/juce_TooltipWindow.cpp @@ -37,7 +37,7 @@ BEGIN_JUCE_NAMESPACE //============================================================================== -TooltipWindow::TooltipWindow (Component* const parentComponent, +TooltipWindow::TooltipWindow (Component* const parent_, const int millisecondsBeforeTipAppears_) : Component ("tooltip"), millisecondsBeforeTipAppears (millisecondsBeforeTipAppears_), @@ -52,8 +52,8 @@ TooltipWindow::TooltipWindow (Component* const parentComponent, setAlwaysOnTop (true); setOpaque (true); - if (parentComponent != nullptr) - parentComponent->addChildComponent (this); + if (parent_ != nullptr) + parent_->addChildComponent (this); } TooltipWindow::~TooltipWindow() diff --git a/src/gui/graphics/drawables/juce_DrawableComposite.cpp b/src/gui/graphics/drawables/juce_DrawableComposite.cpp index 0b3de87ea3..a65d19f67f 100644 --- a/src/gui/graphics/drawables/juce_DrawableComposite.cpp +++ b/src/gui/graphics/drawables/juce_DrawableComposite.cpp @@ -146,11 +146,11 @@ void DrawableComposite::resetContentAreaAndBoundingBoxToFitChildren() resetBoundingBoxToContentArea(); } -bool DrawableComposite::registerCoordinates (RelativeCoordinatePositionerBase& positioner) +bool DrawableComposite::registerCoordinates (RelativeCoordinatePositionerBase& pos) { - bool ok = positioner.addPoint (bounds.topLeft); - ok = positioner.addPoint (bounds.topRight) && ok; - return positioner.addPoint (bounds.bottomLeft) && ok; + bool ok = pos.addPoint (bounds.topLeft); + ok = pos.addPoint (bounds.topRight) && ok; + return pos.addPoint (bounds.bottomLeft) && ok; } void DrawableComposite::recalculateCoordinates (Expression::Scope* scope) diff --git a/src/gui/graphics/drawables/juce_DrawableImage.cpp b/src/gui/graphics/drawables/juce_DrawableImage.cpp index eb7cf84a69..0c1a718760 100644 --- a/src/gui/graphics/drawables/juce_DrawableImage.cpp +++ b/src/gui/graphics/drawables/juce_DrawableImage.cpp @@ -98,11 +98,11 @@ void DrawableImage::setBoundingBox (const RelativeParallelogram& newBounds) } //============================================================================== -bool DrawableImage::registerCoordinates (RelativeCoordinatePositionerBase& positioner) +bool DrawableImage::registerCoordinates (RelativeCoordinatePositionerBase& pos) { - bool ok = positioner.addPoint (bounds.topLeft); - ok = positioner.addPoint (bounds.topRight) && ok; - return positioner.addPoint (bounds.bottomLeft) && ok; + bool ok = pos.addPoint (bounds.topLeft); + ok = pos.addPoint (bounds.topRight) && ok; + return pos.addPoint (bounds.bottomLeft) && ok; } void DrawableImage::recalculateCoordinates (Expression::Scope* scope) diff --git a/src/gui/graphics/drawables/juce_DrawablePath.cpp b/src/gui/graphics/drawables/juce_DrawablePath.cpp index a34826ff1b..d8c8280e2b 100644 --- a/src/gui/graphics/drawables/juce_DrawablePath.cpp +++ b/src/gui/graphics/drawables/juce_DrawablePath.cpp @@ -210,16 +210,15 @@ void DrawablePath::ValueTreeWrapper::writeTo (RelativePointPath& relativePath) c for (int j = 0; j < numCps; ++j) points[j] = e.getControlPoint (j); - const Identifier type (e.getType()); - RelativePointPath::ElementBase* newElement = 0; - - if (type == Element::startSubPathElement) newElement = new RelativePointPath::StartSubPath (points[0]); - else if (type == Element::closeSubPathElement) newElement = new RelativePointPath::CloseSubPath(); - else if (type == Element::lineToElement) newElement = new RelativePointPath::LineTo (points[0]); - else if (type == Element::quadraticToElement) newElement = new RelativePointPath::QuadraticTo (points[0], points[1]); - else if (type == Element::cubicToElement) newElement = new RelativePointPath::CubicTo (points[0], points[1], points[2]); - else jassertfalse; + const Identifier t (e.getType()); + + if (t == Element::startSubPathElement) newElement = new RelativePointPath::StartSubPath (points[0]); + else if (t == Element::closeSubPathElement) newElement = new RelativePointPath::CloseSubPath(); + else if (t == Element::lineToElement) newElement = new RelativePointPath::LineTo (points[0]); + else if (t == Element::quadraticToElement) newElement = new RelativePointPath::QuadraticTo (points[0], points[1]); + else if (t == Element::cubicToElement) newElement = new RelativePointPath::CubicTo (points[0], points[1], points[2]); + else jassertfalse; relativePath.addElement (newElement); } diff --git a/src/gui/graphics/drawables/juce_DrawableRectangle.cpp b/src/gui/graphics/drawables/juce_DrawableRectangle.cpp index bcb5133996..0fe1fb9b9d 100644 --- a/src/gui/graphics/drawables/juce_DrawableRectangle.cpp +++ b/src/gui/graphics/drawables/juce_DrawableRectangle.cpp @@ -87,12 +87,12 @@ void DrawableRectangle::rebuildPath() } } -bool DrawableRectangle::registerCoordinates (RelativeCoordinatePositionerBase& positioner) +bool DrawableRectangle::registerCoordinates (RelativeCoordinatePositionerBase& pos) { - bool ok = positioner.addPoint (bounds.topLeft); - ok = positioner.addPoint (bounds.topRight) && ok; - ok = positioner.addPoint (bounds.bottomLeft) && ok; - return positioner.addPoint (cornerSize) && ok; + bool ok = pos.addPoint (bounds.topLeft); + ok = pos.addPoint (bounds.topRight) && ok; + ok = pos.addPoint (bounds.bottomLeft) && ok; + return pos.addPoint (cornerSize) && ok; } void DrawableRectangle::recalculateCoordinates (Expression::Scope* scope) diff --git a/src/gui/graphics/drawables/juce_DrawableShape.cpp b/src/gui/graphics/drawables/juce_DrawableShape.cpp index 72a6430258..ed04a6dd56 100644 --- a/src/gui/graphics/drawables/juce_DrawableShape.cpp +++ b/src/gui/graphics/drawables/juce_DrawableShape.cpp @@ -101,17 +101,17 @@ void DrawableShape::setStrokeFill (const FillType& newFill) } void DrawableShape::setFillInternal (RelativeFillType& fill, const RelativeFillType& newFill, - ScopedPointer& positioner) + ScopedPointer& pos) { if (fill != newFill) { fill = newFill; - positioner = nullptr; + pos = nullptr; if (fill.isDynamic()) { - positioner = new RelativePositioner (*this, fill, true); - positioner->apply(); + pos = new RelativePositioner (*this, fill, true); + pos->apply(); } else { diff --git a/src/gui/graphics/drawables/juce_DrawableText.cpp b/src/gui/graphics/drawables/juce_DrawableText.cpp index d4e4ea6925..7acf346e7c 100644 --- a/src/gui/graphics/drawables/juce_DrawableText.cpp +++ b/src/gui/graphics/drawables/juce_DrawableText.cpp @@ -130,12 +130,12 @@ void DrawableText::refreshBounds() } } -bool DrawableText::registerCoordinates (RelativeCoordinatePositionerBase& positioner) +bool DrawableText::registerCoordinates (RelativeCoordinatePositionerBase& pos) { - bool ok = positioner.addPoint (bounds.topLeft); - ok = positioner.addPoint (bounds.topRight) && ok; - ok = positioner.addPoint (bounds.bottomLeft) && ok; - return positioner.addPoint (fontSizeControlPoint) && ok; + bool ok = pos.addPoint (bounds.topLeft); + ok = pos.addPoint (bounds.topRight) && ok; + ok = pos.addPoint (bounds.bottomLeft) && ok; + return pos.addPoint (fontSizeControlPoint) && ok; } void DrawableText::recalculateCoordinates (Expression::Scope* scope) diff --git a/src/gui/graphics/imaging/image_file_formats/juce_GIFLoader.cpp b/src/gui/graphics/imaging/image_file_formats/juce_GIFLoader.cpp index 75a2c03f09..cc7b21f960 100644 --- a/src/gui/graphics/imaging/image_file_formats/juce_GIFLoader.cpp +++ b/src/gui/graphics/imaging/image_file_formats/juce_GIFLoader.cpp @@ -315,9 +315,9 @@ private: return code; } - int getCode (const int codeSize_, const bool initialise) + int getCode (const int codeSize_, const bool shouldInitialise) { - if (initialise) + if (shouldInitialise) { currentBit = 0; lastBit = 0; diff --git a/src/maths/juce_Expression.cpp b/src/maths/juce_Expression.cpp index cb0e2c7d53..1afe443011 100644 --- a/src/maths/juce_Expression.cpp +++ b/src/maths/juce_Expression.cpp @@ -1056,9 +1056,9 @@ Expression Expression::withRenamedSymbol (const Expression::Symbol& oldSymbol, c return e; } -bool Expression::referencesSymbol (const Expression::Symbol& symbol, const Scope& scope) const +bool Expression::referencesSymbol (const Expression::Symbol& symbolToCheck, const Scope& scope) const { - Helpers::SymbolCheckVisitor visitor (symbol); + Helpers::SymbolCheckVisitor visitor (symbolToCheck); try { diff --git a/src/native/mac/juce_mac_Fonts.mm b/src/native/mac/juce_mac_Fonts.mm index d7288d5cf2..6771c87b28 100644 --- a/src/native/mac/juce_mac_Fonts.mm +++ b/src/native/mac/juce_mac_Fonts.mm @@ -51,9 +51,9 @@ public: unitsToHeightScaleFactor (0.0f) { JUCE_AUTORELEASEPOOL - CFStringRef name = PlatformUtilities::juceStringToCFString (font.getTypefaceName()); - ctFontRef = CTFontCreateWithName (name, 1024, nullptr); - CFRelease (name); + CFStringRef cfName = PlatformUtilities::juceStringToCFString (font.getTypefaceName()); + ctFontRef = CTFontCreateWithName (cfName, 1024, nullptr); + CFRelease (cfName); if (ctFontRef != nullptr) { @@ -61,7 +61,7 @@ public: if (font.isItalic()) { - CTFontRef newFont = CTFontCreateCopyWithSymbolicTraits (ctFontRef, 0.0, nullptr, + CTFontRef newFont = CTFontCreateCopyWithSymbolicTraits (ctFontRef, 0.0f, nullptr, kCTFontItalicTrait, kCTFontItalicTrait); if (newFont != nullptr) @@ -77,7 +77,7 @@ public: if (font.isBold()) { - CTFontRef newFont = CTFontCreateCopyWithSymbolicTraits (ctFontRef, 0.0, nullptr, + CTFontRef newFont = CTFontCreateCopyWithSymbolicTraits (ctFontRef, 0.0f, nullptr, kCTFontBoldTrait, kCTFontBoldTrait); if (newFont != nullptr) { diff --git a/src/text/juce_JSON.cpp b/src/text/juce_JSON.cpp index 6bcb644412..265c0c7766 100644 --- a/src/text/juce_JSON.cpp +++ b/src/text/juce_JSON.cpp @@ -156,6 +156,7 @@ private: { DynamicObject* const resultObject = new DynamicObject(); result = resultObject; + NamedValueSet& resultProperties = resultObject->getProperties(); for (;;) { @@ -185,17 +186,17 @@ private: t = t.findEndOfWhitespace(); oldT = t; - const juce_wchar c = t.getAndAdvance(); - if (c != ':') + const juce_wchar c2 = t.getAndAdvance(); + if (c2 != ':') return createFail ("Expected ':', but found", &oldT); - var propertyValue; - Result r (parseAny (t, propertyValue)); + resultProperties.set (propertyName, var::null); + var* propertyValue = resultProperties.getVarPointer (propertyName); - if (r.failed()) - return r; + Result r2 (parseAny (t, *propertyValue)); - resultObject->setProperty (propertyName, propertyValue); + if (r2.failed()) + return r2; t = t.findEndOfWhitespace(); oldT = t; @@ -528,5 +529,123 @@ void JSON::writeToStream (OutputStream& output, const var& data, const bool allO JSONFormatter::write (output, data, 0, allOnOneLine); } +//============================================================================== +//============================================================================== +#if JUCE_UNIT_TESTS + +#include "../utilities/juce_UnitTest.h" +#include "../maths/juce_Random.h" + + +class JSONTests : public UnitTest +{ +public: + JSONTests() : UnitTest ("JSON") {} + + static String createRandomWideCharString (Random& r) + { + juce_wchar buffer[40] = { 0 }; + + for (int i = 0; i < numElementsInArray (buffer) - 1; ++i) + { + if (r.nextBool()) + { + do + { + buffer[i] = (juce_wchar) (1 + r.nextInt (0x10ffff - 1)); + } + while (! CharPointer_UTF16::canRepresent (buffer[i])); + } + else + buffer[i] = (juce_wchar) (1 + r.nextInt (0xff)); + } + + return CharPointer_UTF32 (buffer); + } + + static String createRandomIdentifier (Random& r) + { + char buffer[30] = { 0 }; + + for (int i = 0; i < numElementsInArray (buffer) - 1; ++i) + { + static const char chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-:"; + buffer[i] = chars [r.nextInt (sizeof (chars) - 1)]; + } + + return CharPointer_ASCII (buffer); + } + + static var createRandomVar (Random& r, int depth) + { + switch (r.nextInt (depth > 3 ? 6 : 8)) + { + case 0: return var::null; + case 1: return r.nextInt(); + case 2: return r.nextInt64(); + case 3: return r.nextBool(); + case 4: return r.nextDouble(); + case 5: return createRandomWideCharString (r); + + case 6: + { + var v (createRandomVar (r, depth + 1)); + + for (int i = 1 + r.nextInt (30); --i >= 0;) + v.append (createRandomVar (r, depth + 1)); + + return v; + } + + case 7: + { + DynamicObject* o = new DynamicObject(); + + for (int i = r.nextInt (30); --i >= 0;) + o->setProperty (createRandomIdentifier (r), createRandomVar (r, depth + 1)); + + return o; + } + + default: + return var::null; + } + } + + void runTest() + { + beginTest ("JSON"); + Random r; + r.setSeedRandomly(); + + expect (JSON::parse (String::empty) == var::null); + expect (JSON::parse ("{}").isObject()); + expect (JSON::parse ("[]").isArray()); + expect (JSON::parse ("1234").isInt()); + expect (JSON::parse ("12345678901234").isInt64()); + expect (JSON::parse ("1.123e3").isDouble()); + expect (JSON::parse ("-1234").isInt()); + expect (JSON::parse ("-12345678901234").isInt64()); + expect (JSON::parse ("-1.123e3").isDouble()); + + for (int i = 100; --i >= 0;) + { + var v; + + if (i > 0) + v = createRandomVar (r, 0); + + const bool oneLine = r.nextBool(); + String asString (JSON::toString (v, oneLine)); + var parsed = JSON::parse (asString); + String parsedString (JSON::toString (parsed, oneLine)); + expect (asString.isNotEmpty() && parsedString == asString); + } + } +}; + +static JSONTests JSONUnitTests; + +#endif END_JUCE_NAMESPACE