1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Cleaned up some obscure compiler warnings and added some JSON unit tests.

This commit is contained in:
Julian Storer 2011-06-12 19:52:58 +01:00
parent 796247483a
commit 2009753eac
41 changed files with 298 additions and 178 deletions

View file

@ -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)
{

View file

@ -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);

View file

@ -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();
}
}

View file

@ -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);

View file

@ -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))

View file

@ -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 <int> (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;
}
}
}

View file

@ -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);

View file

@ -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 <int> (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;
}
}
}

View file

@ -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 <int> (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)

View file

@ -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;
}

View file

@ -565,9 +565,9 @@ Array<var>* 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<var>* const array = getArray();
return array != nullptr ? array->indexOf (value) : -1;
return array != nullptr ? array->indexOf (n) : -1;
}
//==============================================================================

View file

@ -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);

View file

@ -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

View file

@ -77,15 +77,15 @@ void ShapeButton::setShape (const Path& newShape,
if (resizeNowToFitThisShape)
{
Rectangle<float> bounds (shape.getBounds());
Rectangle<float> 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));
}
}

View file

@ -31,8 +31,8 @@ BEGIN_JUCE_NAMESPACE
//==============================================================================
ImageComponent::ImageComponent (const String& componentName)
: Component (componentName),
ImageComponent::ImageComponent (const String& name)
: Component (name),
placement (RectanglePlacement::centred)
{
}

View file

@ -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),

View file

@ -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<int>& underlinedSection = underlinedSections.getReference (i);
const Range<int>& underlinedSection = underlinedSections.getReference (j);
Iterator i2 (sections, wordWrapWidth, passwordCharacter);

View file

@ -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),

View file

@ -200,7 +200,7 @@ void ModalComponentManager::handleAsyncUpdate()
if (! item->isActive)
{
ScopedPointer<ModalItem> item (stack.removeAndReturn (i));
ScopedPointer<ModalItem> deleter (stack.removeAndReturn (i));
for (int j = item->callbacks.size(); --j >= 0;)
item->callbacks.getUnchecked(j)->modalStateFinished (item->returnValue);

View file

@ -385,7 +385,7 @@ public:
void changeListenerCallback (ChangeBroadcaster*)
{
const OpennessRestorer openness (*this);
const OpennessRestorer opennessRestorer (*this);
clearSubItems();
const StringArray categories (owner.getMappings().getCommandManager()->getCommandCategories());

View file

@ -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)
{

View file

@ -150,11 +150,11 @@ void ResizableBorderComponent::mouseDrag (const MouseEvent& e)
return;
}
const Rectangle<int> bounds (mouseZone.resizeRectangleBy (originalBounds, e.getOffsetFromDragStart()));
const Rectangle<int> 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);
}
}

View file

@ -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);
}

View file

@ -82,20 +82,20 @@ void ResizableEdgeComponent::mouseDrag (const MouseEvent& e)
return;
}
Rectangle<int> bounds (originalBounds);
Rectangle<int> 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);
}
}

View file

@ -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),

View file

@ -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;
}

View file

@ -147,8 +147,8 @@ const Rectangle<float> RelativeRectangle::resolve (const Expression::Scope* scop
{
if (scope == nullptr)
{
RelativeRectangleLocalScope scope (*this);
return resolve (&scope);
RelativeRectangleLocalScope defaultScope (*this);
return resolve (&defaultScope);
}
else
{

View file

@ -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<int>& newAreaToPointTo, const R
targetArea = newAreaToPointTo;
availableArea = newAreaToFitIn;
Rectangle<int> bounds (0, 0,
content.getWidth() + borderSpace * 2,
content.getHeight() + borderSpace * 2);
Rectangle<int> 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<int>& 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()

View file

@ -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);
}

View file

@ -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<int>& bounds)
void ResizableWindow::setBoundsConstrained (const Rectangle<int>& 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);
}
//==============================================================================

View file

@ -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()

View file

@ -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)

View file

@ -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)

View file

@ -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;
const Identifier t (e.getType());
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;
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);
}

View file

@ -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)

View file

@ -101,17 +101,17 @@ void DrawableShape::setStrokeFill (const FillType& newFill)
}
void DrawableShape::setFillInternal (RelativeFillType& fill, const RelativeFillType& newFill,
ScopedPointer<RelativeCoordinatePositionerBase>& positioner)
ScopedPointer<RelativeCoordinatePositionerBase>& 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
{

View file

@ -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)

View file

@ -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;

View file

@ -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
{

View file

@ -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)
{

View file

@ -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