diff --git a/extras/Introjucer/Source/Project/jucer_Project.cpp b/extras/Introjucer/Source/Project/jucer_Project.cpp index 574a36f844..37a25aa825 100644 --- a/extras/Introjucer/Source/Project/jucer_Project.cpp +++ b/extras/Introjucer/Source/Project/jucer_Project.cpp @@ -535,7 +535,7 @@ void Project::findAllImageItems (OwnedArray& 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)) { diff --git a/extras/Introjucer/Source/Project/jucer_Project.h b/extras/Introjucer/Source/Project/jucer_Project.h index bda65620f0..63ab508479 100644 --- a/extras/Introjucer/Source/Project/jucer_Project.h +++ b/extras/Introjucer/Source/Project/jucer_Project.h @@ -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(); diff --git a/extras/browser plugins/wrapper/juce_ActiveX_GlueCode.cpp b/extras/browser plugins/wrapper/juce_ActiveX_GlueCode.cpp index ce0446b537..8c2324ba7e 100644 --- a/extras/browser plugins/wrapper/juce_ActiveX_GlueCode.cpp +++ b/extras/browser plugins/wrapper/juce_ActiveX_GlueCode.cpp @@ -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) diff --git a/src/audio/midi/juce_MidiBuffer.cpp b/src/audio/midi/juce_MidiBuffer.cpp index 4d83643c3e..0a29fa0050 100644 --- a/src/audio/midi/juce_MidiBuffer.cpp +++ b/src/audio/midi/juce_MidiBuffer.cpp @@ -59,7 +59,7 @@ MidiBuffer& MidiBuffer::operator= (const MidiBuffer& other) throw() void MidiBuffer::swapWith (MidiBuffer& other) throw() { data.swapWith (other.data); - swapVariables (bytesUsed, other.bytesUsed); + std::swap (bytesUsed, other.bytesUsed); } MidiBuffer::~MidiBuffer() diff --git a/src/containers/juce_ArrayAllocationBase.h b/src/containers/juce_ArrayAllocationBase.h index 8da908e5d8..2fe345ca1c 100644 --- a/src/containers/juce_ArrayAllocationBase.h +++ b/src/containers/juce_ArrayAllocationBase.h @@ -105,7 +105,7 @@ public: void swapWith (ArrayAllocationBase & other) throw() { elements.swapWith (other.elements); - swapVariables (numAllocated, other.numAllocated); + std::swap (numAllocated, other.numAllocated); } //============================================================================== diff --git a/src/containers/juce_ElementComparator.h b/src/containers/juce_ElementComparator.h index 158b932349..f976c40c77 100644 --- a/src/containers/juce_ElementComparator.h +++ b/src/containers/juce_ElementComparator.h @@ -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) { diff --git a/src/containers/juce_HashMap.h b/src/containers/juce_HashMap.h index 3b2d331c3b..325ef9d2a8 100644 --- a/src/containers/juce_HashMap.h +++ b/src/containers/juce_HashMap.h @@ -321,7 +321,7 @@ public: const ScopedLockType lock2 (otherHashMap.getLock()); slots.swapWithArray (otherHashMap.slots); - swapVariables (totalNumItems, otherHashMap.totalNumItems); + std::swap (totalNumItems, otherHashMap.totalNumItems); } //============================================================================== diff --git a/src/containers/juce_Variant.cpp b/src/containers/juce_Variant.cpp index 1acd732142..c282be9d29 100644 --- a/src/containers/juce_Variant.cpp +++ b/src/containers/juce_Variant.cpp @@ -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; } diff --git a/src/cryptography/juce_BlowFish.cpp b/src/cryptography/juce_BlowFish.cpp index 2731ff4623..a0d5a4b756 100644 --- a/src/cryptography/juce_BlowFish.cpp +++ b/src/cryptography/juce_BlowFish.cpp @@ -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]; diff --git a/src/gui/components/controls/juce_Slider.cpp b/src/gui/components/controls/juce_Slider.cpp index eb58d0a8ed..170cae3d0a 100644 --- a/src/gui/components/controls/juce_Slider.cpp +++ b/src/gui/components/controls/juce_Slider.cpp @@ -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); diff --git a/src/gui/components/controls/juce_TreeView.cpp b/src/gui/components/controls/juce_TreeView.cpp index dc01ed081d..dfeab48b6c 100644 --- a/src/gui/components/controls/juce_TreeView.cpp +++ b/src/gui/components/controls/juce_TreeView.cpp @@ -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); diff --git a/src/gui/components/layout/juce_TabbedButtonBar.cpp b/src/gui/components/layout/juce_TabbedButtonBar.cpp index a8cd801022..58b391b71e 100644 --- a/src/gui/components/layout/juce_TabbedButtonBar.cpp +++ b/src/gui/components/layout/juce_TabbedButtonBar.cpp @@ -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; diff --git a/src/gui/components/lookandfeel/juce_LookAndFeel.cpp b/src/gui/components/lookandfeel/juce_LookAndFeel.cpp index 311691aaac..288e0b072a 100644 --- a/src/gui/components/lookandfeel/juce_LookAndFeel.cpp +++ b/src/gui/components/lookandfeel/juce_LookAndFeel.cpp @@ -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; diff --git a/src/gui/components/lookandfeel/juce_OldSchoolLookAndFeel.cpp b/src/gui/components/lookandfeel/juce_OldSchoolLookAndFeel.cpp index cb8db7d95a..b9cca3f071 100644 --- a/src/gui/components/lookandfeel/juce_OldSchoolLookAndFeel.cpp +++ b/src/gui/components/lookandfeel/juce_OldSchoolLookAndFeel.cpp @@ -604,7 +604,7 @@ void OldSchoolLookAndFeel::positionDocumentWindowButtons (DocumentWindow&, } if (positionTitleBarButtonsOnLeft) - swapVariables (minimiseButton, maximiseButton); + std::swap (minimiseButton, maximiseButton); if (maximiseButton != 0) { diff --git a/src/gui/components/positioning/juce_RelativePointPath.cpp b/src/gui/components/positioning/juce_RelativePointPath.cpp index d52716a6ba..e89379477f 100644 --- a/src/gui/components/positioning/juce_RelativePointPath.cpp +++ b/src/gui/components/positioning/juce_RelativePointPath.cpp @@ -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 diff --git a/src/gui/components/special/juce_MidiKeyboardComponent.cpp b/src/gui/components/special/juce_MidiKeyboardComponent.cpp index 81c2546c34..e9cd414280 100644 --- a/src/gui/components/special/juce_MidiKeyboardComponent.cpp +++ b/src/gui/components/special/juce_MidiKeyboardComponent.cpp @@ -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); diff --git a/src/gui/graphics/contexts/juce_EdgeTable.cpp b/src/gui/graphics/contexts/juce_EdgeTable.cpp index dae2b08de7..ea6d214152 100644 --- a/src/gui/graphics/contexts/juce_EdgeTable.cpp +++ b/src/gui/graphics/contexts/juce_EdgeTable.cpp @@ -73,7 +73,7 @@ EdgeTable::EdgeTable (const Rectangle& bounds_, if (y1 > y2) { - swapVariables (y1, y2); + std::swap (y1, y2); direction = 1; } diff --git a/src/maths/juce_BigInteger.cpp b/src/maths/juce_BigInteger.cpp index cdba6f2ae1..a07ed810fd 100644 --- a/src/maths/juce_BigInteger.cpp +++ b/src/maths/juce_BigInteger.cpp @@ -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; } diff --git a/src/maths/juce_Expression.cpp b/src/maths/juce_Expression.cpp index cfb91ceeef..08ccd2e356 100644 --- a/src/maths/juce_Expression.cpp +++ b/src/maths/juce_Expression.cpp @@ -28,7 +28,7 @@ BEGIN_JUCE_NAMESPACE #include "juce_Expression.h" -#include "../containers/juce_ReferenceCountedArray.h" +#include "../memory/juce_HeapBlock.h" //============================================================================== diff --git a/src/maths/juce_MathsFunctions.h b/src/maths/juce_MathsFunctions.h index df31ae945b..8814d9072f 100644 --- a/src/maths/juce_MathsFunctions.h +++ b/src/maths/juce_MathsFunctions.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 inline void swapVariables (Type& variable1, Type& variable2) { - const Type tempVal = variable1; - variable1 = variable2; - variable2 = tempVal; + std::swap (variable1, variable2); } #if JUCE_VC6 diff --git a/src/memory/juce_HeapBlock.h b/src/memory/juce_HeapBlock.h index c056c839fa..43d4c61aea 100644 --- a/src/memory/juce_HeapBlock.h +++ b/src/memory/juce_HeapBlock.h @@ -227,7 +227,7 @@ public: */ void swapWith (HeapBlock & other) throw() { - swapVariables (data, other.data); + std::swap (data, other.data); } /** This fills the block with zeros, up to the number of elements specified. diff --git a/src/memory/juce_MemoryBlock.cpp b/src/memory/juce_MemoryBlock.cpp index 0bb018bf17..87eac6e80c 100644 --- a/src/memory/juce_MemoryBlock.cpp +++ b/src/memory/juce_MemoryBlock.cpp @@ -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); } diff --git a/src/memory/juce_OptionalScopedPointer.h b/src/memory/juce_OptionalScopedPointer.h index 29bd28f7de..7bc2e029d5 100644 --- a/src/memory/juce_OptionalScopedPointer.h +++ b/src/memory/juce_OptionalScopedPointer.h @@ -134,7 +134,7 @@ public: void swapWith (OptionalScopedPointer& other) throw() { object.swapWith (other.object); - swapVariables (shouldDelete, other.shouldDelete); + std::swap (shouldDelete, other.shouldDelete); } private: diff --git a/src/memory/juce_ScopedPointer.h b/src/memory/juce_ScopedPointer.h index b2b1dfad13..b7cf3667be 100644 --- a/src/memory/juce_ScopedPointer.h +++ b/src/memory/juce_ScopedPointer.h @@ -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: diff --git a/src/native/windows/juce_win32_Midi.cpp b/src/native/windows/juce_win32_Midi.cpp index 3abc4c73a6..a43bbbe4ef 100644 --- a/src/native/windows/juce_win32_Midi.cpp +++ b/src/native/windows/juce_win32_Midi.cpp @@ -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++; diff --git a/src/text/juce_LocalisedStrings.h b/src/text/juce_LocalisedStrings.h index dba046d08a..7ad5e75b9a 100644 --- a/src/text/juce_LocalisedStrings.h +++ b/src/text/juce_LocalisedStrings.h @@ -37,8 +37,8 @@ @see LocalisedStrings */ -#define TRANS(stringLiteral) \ - LocalisedStrings::translateWithCurrentMappings (stringLiteral) +#define TRANS(stringLiteral) \ + JUCE_NAMESPACE::LocalisedStrings::translateWithCurrentMappings (stringLiteral) diff --git a/src/text/juce_String.cpp b/src/text/juce_String.cpp index 6a33cc4057..7acc2ad11c 100644 --- a/src/text/juce_String.cpp +++ b/src/text/juce_String.cpp @@ -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()