mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
A couple of minor fixes, and changed code to use std::swap instead of swapVariables()
This commit is contained in:
parent
1fb8929c55
commit
904e1aba45
27 changed files with 65 additions and 61 deletions
|
|
@ -535,7 +535,7 @@ void Project::findAllImageItems (OwnedArray<Project::Item>& items)
|
|||
|
||||
//==============================================================================
|
||||
Project::Item::Item (Project& project_, const ValueTree& node_)
|
||||
: project (project_), node (node_)
|
||||
: project (&project_), node (node_)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -544,6 +544,13 @@ Project::Item::Item (const Item& other)
|
|||
{
|
||||
}
|
||||
|
||||
Project::Item& Project::Item::operator= (const Project::Item& other)
|
||||
{
|
||||
project = other.project;
|
||||
node = other.node;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Project::Item::~Item()
|
||||
{
|
||||
}
|
||||
|
|
@ -571,7 +578,7 @@ Project::Item Project::Item::findItemWithID (const String& targetId) const
|
|||
}
|
||||
}
|
||||
|
||||
return Item (project, ValueTree::invalid);
|
||||
return Item (*project, ValueTree::invalid);
|
||||
}
|
||||
|
||||
bool Project::Item::canContain (const Item& child) const
|
||||
|
|
@ -614,7 +621,7 @@ Value Project::Item::getShouldAddToResourceValue() const
|
|||
const File Project::Item::getFile() const
|
||||
{
|
||||
if (isFile())
|
||||
return project.resolveFilename (node [Ids::file].toString());
|
||||
return project->resolveFilename (node [Ids::file].toString());
|
||||
else
|
||||
return File::nonexistent;
|
||||
}
|
||||
|
|
@ -622,7 +629,7 @@ const File Project::Item::getFile() const
|
|||
void Project::Item::setFile (const File& file)
|
||||
{
|
||||
jassert (isFile());
|
||||
node.setProperty (Ids::file, project.getRelativePathForFile (file), getUndoManager());
|
||||
node.setProperty (Ids::file, project->getRelativePathForFile (file), getUndoManager());
|
||||
node.setProperty (Ids::name, file.getFileName(), getUndoManager());
|
||||
|
||||
jassert (getFile() == file);
|
||||
|
|
@ -658,7 +665,7 @@ Project::Item Project::Item::findItemForFile (const File& file) const
|
|||
}
|
||||
}
|
||||
|
||||
return Item (project, ValueTree::invalid);
|
||||
return Item (*project, ValueTree::invalid);
|
||||
}
|
||||
|
||||
const File Project::Item::determineGroupFolder() const
|
||||
|
|
@ -684,7 +691,7 @@ const File Project::Item::determineGroupFolder() const
|
|||
}
|
||||
else
|
||||
{
|
||||
f = project.getFile().getParentDirectory();
|
||||
f = project->getFile().getParentDirectory();
|
||||
|
||||
if (f.getChildFile ("Source").isDirectory())
|
||||
f = f.getChildFile ("Source");
|
||||
|
|
@ -729,7 +736,7 @@ Project::Item Project::Item::getParent() const
|
|||
if (isMainGroup() || ! isGroup())
|
||||
return *this;
|
||||
|
||||
return Item (project, node.getParent());
|
||||
return Item (*project, node.getParent());
|
||||
}
|
||||
|
||||
struct ItemSorter
|
||||
|
|
@ -753,7 +760,7 @@ bool Project::Item::addFile (const File& file, int insertIndex)
|
|||
|
||||
if (file.isDirectory())
|
||||
{
|
||||
Item group (project.createNewGroup());
|
||||
Item group (project->createNewGroup());
|
||||
group.getName() = file.getFileNameWithoutExtension();
|
||||
|
||||
jassert (canContain (group));
|
||||
|
|
@ -764,7 +771,7 @@ bool Project::Item::addFile (const File& file, int insertIndex)
|
|||
DirectoryIterator iter (file, false, "*", File::findFilesAndDirectories);
|
||||
while (iter.next())
|
||||
{
|
||||
if (! project.getMainGroup().findItemForFile (iter.getFile()).isValid())
|
||||
if (! project->getMainGroup().findItemForFile (iter.getFile()).isValid())
|
||||
group.addFile (iter.getFile(), -1);
|
||||
}
|
||||
|
||||
|
|
@ -772,9 +779,9 @@ bool Project::Item::addFile (const File& file, int insertIndex)
|
|||
}
|
||||
else if (file.existsAsFile())
|
||||
{
|
||||
if (! project.getMainGroup().findItemForFile (file).isValid())
|
||||
if (! project->getMainGroup().findItemForFile (file).isValid())
|
||||
{
|
||||
Item item (project.createNewItem (file));
|
||||
Item item (project->createNewItem (file));
|
||||
|
||||
if (canContain (item))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -156,6 +156,7 @@ public:
|
|||
//==============================================================================
|
||||
Item (Project& project, const ValueTree& itemNode);
|
||||
Item (const Item& other);
|
||||
Item& operator= (const Item& other);
|
||||
~Item();
|
||||
|
||||
void initialiseNodeValues();
|
||||
|
|
@ -164,8 +165,8 @@ public:
|
|||
bool isValid() const { return node.isValid(); }
|
||||
const ValueTree& getNode() const throw() { return node; }
|
||||
ValueTree& getNode() throw() { return node; }
|
||||
Project& getProject() const throw() { return project; }
|
||||
bool operator== (const Item& other) const { return node == other.node && &project == &other.project; }
|
||||
Project& getProject() const throw() { return *project; }
|
||||
bool operator== (const Item& other) const { return node == other.node && project == other.project; }
|
||||
bool operator!= (const Item& other) const { return ! operator== (other); }
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -194,7 +195,7 @@ public:
|
|||
//==============================================================================
|
||||
bool canContain (const Item& child) const;
|
||||
int getNumChildren() const { return node.getNumChildren(); }
|
||||
Item getChild (int index) const { return Item (project, node.getChild (index)); }
|
||||
Item getChild (int index) const { return Item (*project, node.getChild (index)); }
|
||||
void addChild (const Item& newChild, int insertIndex);
|
||||
bool addFile (const File& file, int insertIndex);
|
||||
void removeItemFromProject();
|
||||
|
|
@ -207,11 +208,10 @@ public:
|
|||
|
||||
private:
|
||||
//==============================================================================
|
||||
Project& project;
|
||||
Project* project;
|
||||
ValueTree node;
|
||||
|
||||
UndoManager* getUndoManager() const { return project.getUndoManagerFor (node); }
|
||||
Item& operator= (const Item&);
|
||||
UndoManager* getUndoManager() const { return project->getUndoManagerFor (node); }
|
||||
};
|
||||
|
||||
Item getMainGroup();
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ public:
|
|||
for (int j = numArgs; --j >= 0;)
|
||||
args.add (variantTojuceVar (pDispParams->rgvarg[j]));
|
||||
|
||||
result = v.invoke (memberId, args.getRawDataPointer(), numArgs);
|
||||
result = v.invoke (memberId, numArgs == 0 ? 0 : args.getRawDataPointer(), numArgs);
|
||||
}
|
||||
|
||||
if (pVarResult != 0)
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ MidiBuffer& MidiBuffer::operator= (const MidiBuffer& other) throw()
|
|||
void MidiBuffer::swapWith (MidiBuffer& other) throw()
|
||||
{
|
||||
data.swapWith (other.data);
|
||||
swapVariables <int> (bytesUsed, other.bytesUsed);
|
||||
std::swap (bytesUsed, other.bytesUsed);
|
||||
}
|
||||
|
||||
MidiBuffer::~MidiBuffer()
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ public:
|
|||
void swapWith (ArrayAllocationBase <ElementType, TypeOfCriticalSectionToUse>& other) throw()
|
||||
{
|
||||
elements.swapWith (other.elements);
|
||||
swapVariables (numAllocated, other.numAllocated);
|
||||
std::swap (numAllocated, other.numAllocated);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ static void sortArray (ElementComparator& comparator,
|
|||
{
|
||||
if (comparator.compareElements (array[i], array [i + 1]) > 0)
|
||||
{
|
||||
swapVariables (array[i], array[i + 1]);
|
||||
std::swap (array[i], array[i + 1]);
|
||||
|
||||
if (i > firstElement)
|
||||
i -= 2;
|
||||
|
|
@ -101,14 +101,14 @@ static void sortArray (ElementComparator& comparator,
|
|||
if (comparator.compareElements (array[k], array [maxIndex]) > 0)
|
||||
maxIndex = k;
|
||||
|
||||
swapVariables (array[j], array[maxIndex]);
|
||||
std::swap (array[j], array[maxIndex]);
|
||||
--j;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const int mid = firstElement + (size >> 1);
|
||||
swapVariables (array[mid], array[firstElement]);
|
||||
std::swap (array[mid], array[firstElement]);
|
||||
|
||||
int i = firstElement;
|
||||
int j = lastElement + 1;
|
||||
|
|
@ -126,10 +126,10 @@ static void sortArray (ElementComparator& comparator,
|
|||
if (j < i)
|
||||
break;
|
||||
|
||||
swapVariables (array[i], array[j]);
|
||||
std::swap (array[i], array[j]);
|
||||
}
|
||||
|
||||
swapVariables (array[j], array[firstElement]);
|
||||
std::swap (array[j], array[firstElement]);
|
||||
|
||||
if (j - 1 - firstElement >= lastElement - i)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ public:
|
|||
const ScopedLockType lock2 (otherHashMap.getLock());
|
||||
|
||||
slots.swapWithArray (otherHashMap.slots);
|
||||
swapVariables (totalNumItems, otherHashMap.totalNumItems);
|
||||
std::swap (totalNumItems, otherHashMap.totalNumItems);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -373,8 +373,8 @@ DynamicObject* var::getObject() const { return type->toObject (value);
|
|||
//==============================================================================
|
||||
void var::swapWith (var& other) throw()
|
||||
{
|
||||
swapVariables (type, other.type);
|
||||
swapVariables (value, other.value);
|
||||
std::swap (type, other.type);
|
||||
std::swap (value, other.value);
|
||||
}
|
||||
|
||||
var& var::operator= (const var& newValue) { type->cleanUp (value); type = newValue.type; type->createCopy (value, newValue.value); return *this; }
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ void BlowFish::encrypt (uint32& data1, uint32& data2) const throw()
|
|||
{
|
||||
l ^= p[i];
|
||||
r ^= F(l);
|
||||
swapVariables (l, r);
|
||||
std::swap (l, r);
|
||||
}
|
||||
|
||||
data1 = r ^ p[17];
|
||||
|
|
@ -274,7 +274,7 @@ void BlowFish::decrypt (uint32& data1, uint32& data2) const throw()
|
|||
{
|
||||
l ^= p[i];
|
||||
r ^= F(l);
|
||||
swapVariables (l, r);
|
||||
std::swap (l, r);
|
||||
}
|
||||
|
||||
data1 = r ^ p[0];
|
||||
|
|
|
|||
|
|
@ -603,7 +603,7 @@ void Slider::setMinAndMaxValues (double newMinValue, double newMaxValue, bool se
|
|||
|| style == ThreeValueHorizontal || style == ThreeValueVertical);
|
||||
|
||||
if (newMaxValue < newMinValue)
|
||||
swapVariables (newMaxValue, newMinValue);
|
||||
std::swap (newMaxValue, newMinValue);
|
||||
|
||||
newMinValue = constrainedValue (newMinValue);
|
||||
newMaxValue = constrainedValue (newMaxValue);
|
||||
|
|
|
|||
|
|
@ -363,13 +363,13 @@ private:
|
|||
int rowStart = firstSelected->getRowNumberInTree();
|
||||
int rowEnd = lastSelected->getRowNumberInTree();
|
||||
if (rowStart > rowEnd)
|
||||
swapVariables (rowStart, rowEnd);
|
||||
std::swap (rowStart, rowEnd);
|
||||
|
||||
int ourRow = item->getRowNumberInTree();
|
||||
int otherEnd = ourRow < rowEnd ? rowStart : rowEnd;
|
||||
|
||||
if (ourRow > otherEnd)
|
||||
swapVariables (ourRow, otherEnd);
|
||||
std::swap (ourRow, otherEnd);
|
||||
|
||||
for (int i = ourRow; i <= otherEnd; ++i)
|
||||
owner.getItemOnRow (i)->setSelected (true, false);
|
||||
|
|
|
|||
|
|
@ -339,7 +339,7 @@ void TabbedButtonBar::resized()
|
|||
int length = getHeight();
|
||||
|
||||
if (orientation == TabsAtTop || orientation == TabsAtBottom)
|
||||
swapVariables (depth, length);
|
||||
std::swap (depth, length);
|
||||
|
||||
const int overlap = getLookAndFeel().getTabButtonOverlap (depth)
|
||||
+ getLookAndFeel().getTabButtonSpaceAroundImage() * 2;
|
||||
|
|
|
|||
|
|
@ -2053,7 +2053,7 @@ void LookAndFeel::positionDocumentWindowButtons (DocumentWindow&,
|
|||
}
|
||||
|
||||
if (positionTitleBarButtonsOnLeft)
|
||||
swapVariables (minimiseButton, maximiseButton);
|
||||
std::swap (minimiseButton, maximiseButton);
|
||||
|
||||
if (maximiseButton != 0)
|
||||
{
|
||||
|
|
@ -2194,7 +2194,7 @@ void LookAndFeel::createTabButtonShape (Path& p,
|
|||
if (orientation == TabbedButtonBar::TabsAtLeft
|
||||
|| orientation == TabbedButtonBar::TabsAtRight)
|
||||
{
|
||||
swapVariables (length, depth);
|
||||
std::swap (length, depth);
|
||||
}
|
||||
|
||||
const float indent = (float) getTabButtonOverlap ((int) depth);
|
||||
|
|
@ -2282,7 +2282,7 @@ void LookAndFeel::drawTabButtonText (Graphics& g,
|
|||
if (orientation == TabbedButtonBar::TabsAtLeft
|
||||
|| orientation == TabbedButtonBar::TabsAtRight)
|
||||
{
|
||||
swapVariables (length, depth);
|
||||
std::swap (length, depth);
|
||||
}
|
||||
|
||||
Font font (depth * 0.6f);
|
||||
|
|
@ -2353,7 +2353,7 @@ void LookAndFeel::drawTabButton (Graphics& g,
|
|||
if (orientation == TabbedButtonBar::TabsAtLeft
|
||||
|| orientation == TabbedButtonBar::TabsAtRight)
|
||||
{
|
||||
swapVariables (length, depth);
|
||||
std::swap (length, depth);
|
||||
}
|
||||
|
||||
Path tabShape;
|
||||
|
|
|
|||
|
|
@ -604,7 +604,7 @@ void OldSchoolLookAndFeel::positionDocumentWindowButtons (DocumentWindow&,
|
|||
}
|
||||
|
||||
if (positionTitleBarButtonsOnLeft)
|
||||
swapVariables (minimiseButton, maximiseButton);
|
||||
std::swap (minimiseButton, maximiseButton);
|
||||
|
||||
if (maximiseButton != 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -105,8 +105,8 @@ bool RelativePointPath::operator!= (const RelativePointPath& other) const throw(
|
|||
void RelativePointPath::swapWith (RelativePointPath& other) throw()
|
||||
{
|
||||
elements.swapWithArray (other.elements);
|
||||
swapVariables (usesNonZeroWinding, other.usesNonZeroWinding);
|
||||
swapVariables (containsDynamicPoints, other.containsDynamicPoints);
|
||||
std::swap (usesNonZeroWinding, other.usesNonZeroWinding);
|
||||
std::swap (containsDynamicPoints, other.containsDynamicPoints);
|
||||
}
|
||||
|
||||
void RelativePointPath::createPath (Path& path, Expression::Scope* scope) const
|
||||
|
|
|
|||
|
|
@ -580,7 +580,7 @@ void MidiKeyboardComponent::resized()
|
|||
if (w > 0 && h > 0)
|
||||
{
|
||||
if (orientation != horizontalKeyboard)
|
||||
swapVariables (w, h);
|
||||
std::swap (w, h);
|
||||
|
||||
blackNoteLength = roundToInt (h * 0.7f);
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ EdgeTable::EdgeTable (const Rectangle<int>& bounds_,
|
|||
|
||||
if (y1 > y2)
|
||||
{
|
||||
swapVariables (y1, y2);
|
||||
std::swap (y1, y2);
|
||||
direction = 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,9 +92,9 @@ BigInteger::~BigInteger()
|
|||
void BigInteger::swapWith (BigInteger& other) throw()
|
||||
{
|
||||
values.swapWith (other.values);
|
||||
swapVariables (numValues, other.numValues);
|
||||
swapVariables (highestBit, other.highestBit);
|
||||
swapVariables (negative, other.negative);
|
||||
std::swap (numValues, other.numValues);
|
||||
std::swap (highestBit, other.highestBit);
|
||||
std::swap (negative, other.negative);
|
||||
}
|
||||
|
||||
BigInteger& BigInteger::operator= (const BigInteger& other)
|
||||
|
|
@ -786,7 +786,7 @@ const BigInteger BigInteger::simpleGCD (BigInteger* m, BigInteger* n)
|
|||
while (! m->isZero())
|
||||
{
|
||||
if (n->compareAbsolute (*m) > 0)
|
||||
swapVariables (m, n);
|
||||
std::swap (m, n);
|
||||
|
||||
*m -= *n;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
#include "juce_Expression.h"
|
||||
#include "../containers/juce_ReferenceCountedArray.h"
|
||||
#include "../memory/juce_HeapBlock.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -254,14 +254,11 @@ inline bool isPositiveAndNotGreaterThan (const int valueToTest, const int upperL
|
|||
#endif
|
||||
|
||||
//==============================================================================
|
||||
/** Handy function to swap two values over.
|
||||
*/
|
||||
/** Handy function to swap two values. */
|
||||
template <typename Type>
|
||||
inline void swapVariables (Type& variable1, Type& variable2)
|
||||
{
|
||||
const Type tempVal = variable1;
|
||||
variable1 = variable2;
|
||||
variable2 = tempVal;
|
||||
std::swap (variable1, variable2);
|
||||
}
|
||||
|
||||
#if JUCE_VC6
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ public:
|
|||
*/
|
||||
void swapWith (HeapBlock <ElementType>& other) throw()
|
||||
{
|
||||
swapVariables (data, other.data);
|
||||
std::swap (data, other.data);
|
||||
}
|
||||
|
||||
/** This fills the block with zeros, up to the number of elements specified.
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ void MemoryBlock::ensureSize (const size_t minimumSize, const bool initialiseToZ
|
|||
|
||||
void MemoryBlock::swapWith (MemoryBlock& other) throw()
|
||||
{
|
||||
swapVariables (size, other.size);
|
||||
std::swap (size, other.size);
|
||||
data.swapWith (other.data);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ public:
|
|||
void swapWith (OptionalScopedPointer<ObjectType>& other) throw()
|
||||
{
|
||||
object.swapWith (other.object);
|
||||
swapVariables (shouldDelete, other.shouldDelete);
|
||||
std::swap (shouldDelete, other.shouldDelete);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ public:
|
|||
// this happens, you must have done something dodgy!
|
||||
jassert (object != other.object);
|
||||
|
||||
swapVariables (object, other.object);
|
||||
std::swap (object, other.object);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -400,7 +400,7 @@ MidiOutput* MidiOutput::openDevice (int index)
|
|||
{
|
||||
MidiOutHandle* const han = MidiOutHandle::activeHandles.getUnchecked(i);
|
||||
|
||||
if (han != 0 && han->deviceId == deviceId)
|
||||
if (han->deviceId == deviceId)
|
||||
{
|
||||
han->refCount++;
|
||||
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@
|
|||
|
||||
@see LocalisedStrings
|
||||
*/
|
||||
#define TRANS(stringLiteral) \
|
||||
LocalisedStrings::translateWithCurrentMappings (stringLiteral)
|
||||
#define TRANS(stringLiteral) \
|
||||
JUCE_NAMESPACE::LocalisedStrings::translateWithCurrentMappings (stringLiteral)
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ String::String (const String& other) throw()
|
|||
|
||||
void String::swapWith (String& other) throw()
|
||||
{
|
||||
swapVariables (text, other.text);
|
||||
std::swap (text, other.text);
|
||||
}
|
||||
|
||||
String& String::operator= (const String& other) throw()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue