From ea9a2c095d34be633ac1425d2944ddbf97031680 Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Sat, 1 Jan 2011 12:45:48 +0000 Subject: [PATCH] Fixes for 64-bit AUs and NamedValueSet. --- .../wrapper/AU/juce_AU_Wrapper.mm | 2 +- juce_amalgamated.cpp | 5 +- juce_amalgamated.h | 17 +- src/containers/juce_LinkedListPointer.h | 12 +- src/containers/juce_NamedValueSet.cpp | 431 +++++++++--------- src/gui/components/layout/juce_MarkerList.h | 5 +- 6 files changed, 240 insertions(+), 232 deletions(-) diff --git a/extras/audio plugins/wrapper/AU/juce_AU_Wrapper.mm b/extras/audio plugins/wrapper/AU/juce_AU_Wrapper.mm index 28b293d101..b6b7d2dc57 100644 --- a/extras/audio plugins/wrapper/AU/juce_AU_Wrapper.mm +++ b/extras/audio plugins/wrapper/AU/juce_AU_Wrapper.mm @@ -41,7 +41,7 @@ #define BUILD_AU_CARBON_UI 1 #endif -#if JUCE_64BIT +#ifdef __LP64__ #undef BUILD_AU_CARBON_UI // (not possible in a 64-bit build) #endif diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index b6c13839ae..2034bd3bd6 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -4566,12 +4566,13 @@ const var NamedValueSet::getValueAt (const int index) const void NamedValueSet::setFromXmlAttributes (const XmlElement& xml) { - LinkedListPointer::Appender appender (values.getLast()); + clear(); + LinkedListPointer::Appender appender (values); const int numAtts = xml.getNumAttributes(); // xxx inefficient - should write an att iterator.. for (int i = 0; i < numAtts; ++i) - set (xml.getAttributeName (i), var (xml.getAttributeValue (i))); + appender.append (new NamedValue (xml.getAttributeName (i), var (xml.getAttributeValue (i)))); } void NamedValueSet::copyToXmlAttributes (XmlElement& xml) const diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 8a2e014a1a..72932e04ae 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -6412,12 +6412,14 @@ public: */ ObjectType* removeNext() throw() { - if (item == 0) - return 0; - ObjectType* const oldItem = item; - oldItem->nextListItem = 0; - item = item->nextListItem; + + if (oldItem != 0) + { + item = oldItem->nextListItem; + oldItem->nextListItem = 0; + } + return oldItem; } @@ -54042,6 +54044,7 @@ public: public: ValueTreeWrapper (const ValueTree& state); + ValueTree& getState() throw() { return state; } int getNumMarkers() const; const ValueTree getMarkerState (int index) const; const ValueTree getMarkerState (const String& name) const; @@ -54053,10 +54056,10 @@ public: void applyTo (MarkerList& markerList); void readFrom (const MarkerList& markerList, UndoManager* undoManager); + static const Identifier markerTag, nameProperty, posProperty; + private: ValueTree state; - - static const Identifier markerTag, nameProperty, posProperty; }; private: diff --git a/src/containers/juce_LinkedListPointer.h b/src/containers/juce_LinkedListPointer.h index 507e022ded..09b683f524 100644 --- a/src/containers/juce_LinkedListPointer.h +++ b/src/containers/juce_LinkedListPointer.h @@ -237,12 +237,14 @@ public: */ ObjectType* removeNext() throw() { - if (item == 0) - return 0; - ObjectType* const oldItem = item; - oldItem->nextListItem = 0; - item = item->nextListItem; + + if (oldItem != 0) + { + item = oldItem->nextListItem; + oldItem->nextListItem = 0; + } + return oldItem; } diff --git a/src/containers/juce_NamedValueSet.cpp b/src/containers/juce_NamedValueSet.cpp index c282c5591c..45794e2dd2 100644 --- a/src/containers/juce_NamedValueSet.cpp +++ b/src/containers/juce_NamedValueSet.cpp @@ -1,215 +1,216 @@ -/* - ============================================================================== - - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-10 by Raw Material Software Ltd. - - ------------------------------------------------------------------------------ - - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. - - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - ------------------------------------------------------------------------------ - - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. - - ============================================================================== -*/ - -#include "../core/juce_StandardHeader.h" - -BEGIN_JUCE_NAMESPACE - -#include "juce_NamedValueSet.h" -#include "../text/juce_XmlElement.h" - - -//============================================================================== -NamedValueSet::NamedValue::NamedValue() throw() -{ -} - -inline NamedValueSet::NamedValue::NamedValue (const Identifier& name_, const var& value_) - : name (name_), value (value_) -{ -} - -bool NamedValueSet::NamedValue::operator== (const NamedValueSet::NamedValue& other) const throw() -{ - return name == other.name && value == other.value; -} - -//============================================================================== -NamedValueSet::NamedValueSet() throw() -{ -} - -NamedValueSet::NamedValueSet (const NamedValueSet& other) -{ - values.addCopyOfList (other.values); -} - -NamedValueSet& NamedValueSet::operator= (const NamedValueSet& other) -{ - clear(); - values.addCopyOfList (other.values); - return *this; -} - -NamedValueSet::~NamedValueSet() -{ - clear(); -} - -void NamedValueSet::clear() -{ - values.deleteAll(); -} - -bool NamedValueSet::operator== (const NamedValueSet& other) const -{ - const NamedValue* i1 = values; - const NamedValue* i2 = other.values; - - while (i1 != 0 && i2 != 0) - { - if (! (*i1 == *i2)) - return false; - - i1 = i1->nextListItem; - i2 = i2->nextListItem; - } - - return true; -} - -bool NamedValueSet::operator!= (const NamedValueSet& other) const -{ - return ! operator== (other); -} - -int NamedValueSet::size() const throw() -{ - return values.size(); -} - -const var& NamedValueSet::operator[] (const Identifier& name) const -{ - for (NamedValue* i = values; i != 0; i = i->nextListItem) - if (i->name == name) - return i->value; - - return var::null; -} - -const var NamedValueSet::getWithDefault (const Identifier& name, const var& defaultReturnValue) const -{ - const var* v = getVarPointer (name); - return v != 0 ? *v : defaultReturnValue; -} - -var* NamedValueSet::getVarPointer (const Identifier& name) const -{ - for (NamedValue* i = values; i != 0; i = i->nextListItem) - if (i->name == name) - return &(i->value); - - return 0; -} - -bool NamedValueSet::set (const Identifier& name, const var& newValue) -{ - LinkedListPointer* i = &values; - - while (i->get() != 0) - { - NamedValue* const v = i->get(); - - if (v->name == name) - { - if (v->value == newValue) - return false; - - v->value = newValue; - return true; - } - - i = &(v->nextListItem); - } - - i->insertNext (new NamedValue (name, newValue)); - return true; -} - -bool NamedValueSet::contains (const Identifier& name) const -{ - return getVarPointer (name) != 0; -} - -bool NamedValueSet::remove (const Identifier& name) -{ - LinkedListPointer* i = &values; - - for (;;) - { - NamedValue* const v = i->get(); - - if (v == 0) - break; - - if (v->name == name) - { - delete i->removeNext(); - return true; - } - - i = &(v->nextListItem); - } - - return false; -} - -const Identifier NamedValueSet::getName (const int index) const -{ - const NamedValue* const v = values[index]; - jassert (v != 0); - return v->name; -} - -const var NamedValueSet::getValueAt (const int index) const -{ - const NamedValue* const v = values[index]; - jassert (v != 0); - return v->value; -} - -void NamedValueSet::setFromXmlAttributes (const XmlElement& xml) -{ - LinkedListPointer::Appender appender (values.getLast()); - - const int numAtts = xml.getNumAttributes(); // xxx inefficient - should write an att iterator.. - - for (int i = 0; i < numAtts; ++i) - set (xml.getAttributeName (i), var (xml.getAttributeValue (i))); -} - -void NamedValueSet::copyToXmlAttributes (XmlElement& xml) const -{ - for (NamedValue* i = values; i != 0; i = i->nextListItem) - { - jassert (! i->value.isObject()); // DynamicObjects can't be stored as XML! - - xml.setAttribute (i->name.toString(), - i->value.toString()); - } -} - - -END_JUCE_NAMESPACE +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-10 by Raw Material Software Ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the GNU General + Public License (Version 2), as published by the Free Software Foundation. + A copy of the license is included in the JUCE distribution, or can be found + online at www.gnu.org/licenses. + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.rawmaterialsoftware.com/juce for more information. + + ============================================================================== +*/ + +#include "../core/juce_StandardHeader.h" + +BEGIN_JUCE_NAMESPACE + +#include "juce_NamedValueSet.h" +#include "../text/juce_XmlElement.h" + + +//============================================================================== +NamedValueSet::NamedValue::NamedValue() throw() +{ +} + +inline NamedValueSet::NamedValue::NamedValue (const Identifier& name_, const var& value_) + : name (name_), value (value_) +{ +} + +bool NamedValueSet::NamedValue::operator== (const NamedValueSet::NamedValue& other) const throw() +{ + return name == other.name && value == other.value; +} + +//============================================================================== +NamedValueSet::NamedValueSet() throw() +{ +} + +NamedValueSet::NamedValueSet (const NamedValueSet& other) +{ + values.addCopyOfList (other.values); +} + +NamedValueSet& NamedValueSet::operator= (const NamedValueSet& other) +{ + clear(); + values.addCopyOfList (other.values); + return *this; +} + +NamedValueSet::~NamedValueSet() +{ + clear(); +} + +void NamedValueSet::clear() +{ + values.deleteAll(); +} + +bool NamedValueSet::operator== (const NamedValueSet& other) const +{ + const NamedValue* i1 = values; + const NamedValue* i2 = other.values; + + while (i1 != 0 && i2 != 0) + { + if (! (*i1 == *i2)) + return false; + + i1 = i1->nextListItem; + i2 = i2->nextListItem; + } + + return true; +} + +bool NamedValueSet::operator!= (const NamedValueSet& other) const +{ + return ! operator== (other); +} + +int NamedValueSet::size() const throw() +{ + return values.size(); +} + +const var& NamedValueSet::operator[] (const Identifier& name) const +{ + for (NamedValue* i = values; i != 0; i = i->nextListItem) + if (i->name == name) + return i->value; + + return var::null; +} + +const var NamedValueSet::getWithDefault (const Identifier& name, const var& defaultReturnValue) const +{ + const var* v = getVarPointer (name); + return v != 0 ? *v : defaultReturnValue; +} + +var* NamedValueSet::getVarPointer (const Identifier& name) const +{ + for (NamedValue* i = values; i != 0; i = i->nextListItem) + if (i->name == name) + return &(i->value); + + return 0; +} + +bool NamedValueSet::set (const Identifier& name, const var& newValue) +{ + LinkedListPointer* i = &values; + + while (i->get() != 0) + { + NamedValue* const v = i->get(); + + if (v->name == name) + { + if (v->value == newValue) + return false; + + v->value = newValue; + return true; + } + + i = &(v->nextListItem); + } + + i->insertNext (new NamedValue (name, newValue)); + return true; +} + +bool NamedValueSet::contains (const Identifier& name) const +{ + return getVarPointer (name) != 0; +} + +bool NamedValueSet::remove (const Identifier& name) +{ + LinkedListPointer* i = &values; + + for (;;) + { + NamedValue* const v = i->get(); + + if (v == 0) + break; + + if (v->name == name) + { + delete i->removeNext(); + return true; + } + + i = &(v->nextListItem); + } + + return false; +} + +const Identifier NamedValueSet::getName (const int index) const +{ + const NamedValue* const v = values[index]; + jassert (v != 0); + return v->name; +} + +const var NamedValueSet::getValueAt (const int index) const +{ + const NamedValue* const v = values[index]; + jassert (v != 0); + return v->value; +} + +void NamedValueSet::setFromXmlAttributes (const XmlElement& xml) +{ + clear(); + LinkedListPointer::Appender appender (values); + + const int numAtts = xml.getNumAttributes(); // xxx inefficient - should write an att iterator.. + + for (int i = 0; i < numAtts; ++i) + appender.append (new NamedValue (xml.getAttributeName (i), var (xml.getAttributeValue (i)))); +} + +void NamedValueSet::copyToXmlAttributes (XmlElement& xml) const +{ + for (NamedValue* i = values; i != 0; i = i->nextListItem) + { + jassert (! i->value.isObject()); // DynamicObjects can't be stored as XML! + + xml.setAttribute (i->name.toString(), + i->value.toString()); + } +} + + +END_JUCE_NAMESPACE diff --git a/src/gui/components/layout/juce_MarkerList.h b/src/gui/components/layout/juce_MarkerList.h index 6082840883..b11b933e81 100644 --- a/src/gui/components/layout/juce_MarkerList.h +++ b/src/gui/components/layout/juce_MarkerList.h @@ -112,6 +112,7 @@ public: public: ValueTreeWrapper (const ValueTree& state); + ValueTree& getState() throw() { return state; } int getNumMarkers() const; const ValueTree getMarkerState (int index) const; const ValueTree getMarkerState (const String& name) const; @@ -123,10 +124,10 @@ public: void applyTo (MarkerList& markerList); void readFrom (const MarkerList& markerList, UndoManager* undoManager); + static const Identifier markerTag, nameProperty, posProperty; + private: ValueTree state; - - static const Identifier markerTag, nameProperty, posProperty; }; private: