diff --git a/source/backend/plugin/CarlaPluginBridge.cpp b/source/backend/plugin/CarlaPluginBridge.cpp index 4ca33784f..5b29acd42 100644 --- a/source/backend/plugin/CarlaPluginBridge.cpp +++ b/source/backend/plugin/CarlaPluginBridge.cpp @@ -17,6 +17,7 @@ #include #include "extra/Base64.hpp" +#include "extra/ScopedPointer.hpp" #include "extra/Time.hpp" #include "water/files/File.h" diff --git a/source/modules/water/containers/HashMap.h b/source/modules/water/containers/HashMap.h index 847f55d6d..6e8f0ab2d 100644 --- a/source/modules/water/containers/HashMap.h +++ b/source/modules/water/containers/HashMap.h @@ -29,7 +29,7 @@ #include "Array.h" #include "../text/String.h" -#include "extra/ScopedPointer.hpp" +#include namespace water { @@ -141,7 +141,7 @@ public: while (h != nullptr) { - const ScopedPointer deleter (h); + const std::unique_ptr deleter (h); h = h->nextEntry; } @@ -262,7 +262,7 @@ public: { if (entry->value == valueToRemove) { - const ScopedPointer deleter (entry); + const std::unique_ptr deleter (entry); entry = entry->nextEntry; diff --git a/source/modules/water/containers/OwnedArray.h b/source/modules/water/containers/OwnedArray.h index 9c3aa4a0c..c347a401f 100644 --- a/source/modules/water/containers/OwnedArray.h +++ b/source/modules/water/containers/OwnedArray.h @@ -28,7 +28,7 @@ #include "ArrayAllocationBase.h" -#include "extra/ScopedPointer.hpp" +#include namespace water { @@ -372,7 +372,7 @@ public: { if (indexToChange >= 0) { - ScopedPointer toDelete; + std::unique_ptr toDelete; { if (indexToChange < numUsed) @@ -536,14 +536,14 @@ public: */ void remove (const size_t indexToRemove, bool deleteObject = true) { - ScopedPointer toDelete; + std::unique_ptr toDelete; if (indexToRemove < numUsed) { ObjectClass** const e = data.elements + indexToRemove; if (deleteObject) - toDelete = *e; + toDelete.reset(*e); --numUsed; const size_t numToShift = numUsed - indexToRemove; diff --git a/source/modules/water/files/DirectoryIterator.cpp b/source/modules/water/files/DirectoryIterator.cpp index 1b616cc35..02c5a103b 100644 --- a/source/modules/water/files/DirectoryIterator.cpp +++ b/source/modules/water/files/DirectoryIterator.cpp @@ -99,8 +99,8 @@ bool DirectoryIterator::next (bool* const isDirResult, int64* const fileSize, bo if (isDirectory) { if (isRecursive) - subIterator = new DirectoryIterator (File::createFileWithoutCheckingPath (path + filename), - true, wildCard, whatToLookFor); + subIterator.reset(new DirectoryIterator (File::createFileWithoutCheckingPath (path + filename), + true, wildCard, whatToLookFor)); matches = (whatToLookFor & File::findDirectories) != 0; } diff --git a/source/modules/water/files/DirectoryIterator.h b/source/modules/water/files/DirectoryIterator.h index 27cca126e..575e3f0ff 100644 --- a/source/modules/water/files/DirectoryIterator.h +++ b/source/modules/water/files/DirectoryIterator.h @@ -29,7 +29,7 @@ #include "File.h" #include "../text/StringArray.h" -#include "extra/ScopedPointer.hpp" +#include namespace water { @@ -123,7 +123,7 @@ private: private: friend class DirectoryIterator; - ScopedPointer pimpl; + std::unique_ptr pimpl; CARLA_DECLARE_NON_COPYABLE (NativeIterator) }; @@ -136,7 +136,7 @@ private: const int whatToLookFor; const bool isRecursive; bool hasBeenAdvanced; - ScopedPointer subIterator; + std::unique_ptr subIterator; File currentFile; static StringArray parseWildcards (const String& pattern); diff --git a/source/modules/water/files/File.cpp b/source/modules/water/files/File.cpp index c71b05bfb..9ec0496d1 100644 --- a/source/modules/water/files/File.cpp +++ b/source/modules/water/files/File.cpp @@ -714,7 +714,7 @@ File File::withFileExtension (const char* const newExtension) const //============================================================================== FileInputStream* File::createInputStream() const { - ScopedPointer fin (new FileInputStream (*this)); + std::unique_ptr fin (new FileInputStream (*this)); if (fin->openedOk()) return fin.release(); @@ -724,7 +724,7 @@ FileInputStream* File::createInputStream() const FileOutputStream* File::createOutputStream (const size_t bufferSize) const { - ScopedPointer out (new FileOutputStream (*this, bufferSize)); + std::unique_ptr out (new FileOutputStream (*this, bufferSize)); return out->failedToOpen() ? nullptr : out.release(); diff --git a/source/modules/water/files/TemporaryFile.h b/source/modules/water/files/TemporaryFile.h index 33d59b92d..fcd8d9ceb 100644 --- a/source/modules/water/files/TemporaryFile.h +++ b/source/modules/water/files/TemporaryFile.h @@ -3,7 +3,7 @@ This file is part of the Water library. Copyright (c) 2016 ROLI Ltd. - Copyright (C) 2017-2022 Filipe Coelho + Copyright (C) 2017-2025 Filipe Coelho Permission is granted to use this software under the terms of the ISC license http://www.isc.org/downloads/software-support-policy/isc-license/ @@ -26,7 +26,6 @@ #ifndef WATER_TEMPORARYFILE_H_INCLUDED #define WATER_TEMPORARYFILE_H_INCLUDED -#include "TemporaryFile.h" #include "File.h" namespace water { @@ -49,7 +48,7 @@ namespace water { TemporaryFile temp (myTargetFile); // create a stream to the temporary file, and write some data to it... - ScopedPointer out (temp.getFile().createOutputStream()); + std::unique_ptr out (temp.getFile().createOutputStream()); if (out != nullptr) { diff --git a/source/modules/water/memory/SharedResourcePointer.h b/source/modules/water/memory/SharedResourcePointer.h index c52158461..0b977a5e4 100644 --- a/source/modules/water/memory/SharedResourcePointer.h +++ b/source/modules/water/memory/SharedResourcePointer.h @@ -29,7 +29,7 @@ #include "ReferenceCountedObject.h" #include "../threads/SpinLock.h" -#include "extra/ScopedPointer.hpp" +#include namespace water { @@ -123,7 +123,7 @@ public: const SpinLock::ScopedLockType sl (holder.lock); if (--(holder.refCount) == 0) - holder.sharedInstance = nullptr; + holder.sharedInstance.reset(); } /** Returns the shared object. */ @@ -144,7 +144,7 @@ private: struct SharedObjectHolder : public ReferenceCountedObject { SpinLock lock; - ScopedPointer sharedInstance; + std::unique_ptr sharedInstance; int refCount; }; @@ -162,9 +162,9 @@ private: const SpinLock::ScopedLockType sl (holder.lock); if (++(holder.refCount) == 1) - holder.sharedInstance = new SharedObjectType(); + holder.sharedInstance.reset(new SharedObjectType()); - sharedObject = holder.sharedInstance; + sharedObject = holder.sharedInstance.get(); } void initialise_v2(const char* const v1, const char* const v2) @@ -173,9 +173,9 @@ private: const SpinLock::ScopedLockType sl (holder.lock); if (++(holder.refCount) == 1) - holder.sharedInstance = new SharedObjectType(v1, v2); + holder.sharedInstance.reset(new SharedObjectType(v1, v2)); - sharedObject = holder.sharedInstance; + sharedObject = holder.sharedInstance.get(); } // There's no need to assign to a SharedResourcePointer because every diff --git a/source/modules/water/processors/AudioProcessorGraph.h b/source/modules/water/processors/AudioProcessorGraph.h index 31c674def..8a1a38d5f 100644 --- a/source/modules/water/processors/AudioProcessorGraph.h +++ b/source/modules/water/processors/AudioProcessorGraph.h @@ -69,7 +69,7 @@ public: const uint32 nodeId; /** The actual processor object that this node represents. */ - AudioProcessor* getProcessor() const noexcept { return processor; } + AudioProcessor* getProcessor() const noexcept { return processor.get(); } /** Custom properties for Carla usage. */ struct Properties { @@ -112,7 +112,7 @@ public: //============================================================================== friend class AudioProcessorGraph; - const ScopedPointer processor; + const std::unique_ptr processor; bool isPrepared; Node (uint32 nodeId, AudioProcessor*) noexcept; @@ -405,7 +405,7 @@ private: friend class AudioGraphIOProcessor; struct AudioProcessorGraphBufferHelpers; - ScopedPointer audioAndCVBuffers; + std::unique_ptr audioAndCVBuffers; MidiBuffer* currentMidiInputBuffer; MidiBuffer currentMidiOutputBuffer; diff --git a/source/modules/water/threads/ChildProcess.cpp b/source/modules/water/threads/ChildProcess.cpp index 057a20d9d..0d1536453 100644 --- a/source/modules/water/threads/ChildProcess.cpp +++ b/source/modules/water/threads/ChildProcess.cpp @@ -330,7 +330,7 @@ uint32 ChildProcess::getPID() const noexcept #ifdef CARLA_OS_WIN bool ChildProcess::start (const String& command, Type) { - activeProcess = new ActiveProcess (command); + activeProcess.reset(new ActiveProcess (command)); if (! activeProcess->ok) activeProcess = nullptr; @@ -370,7 +370,7 @@ bool ChildProcess::start (const StringArray& args, const Type type) if (args.size() == 0) return false; - activeProcess = new ActiveProcess (args, type); + activeProcess.reset(new ActiveProcess (args, type)); if (activeProcess->childPID == 0) activeProcess = nullptr; diff --git a/source/modules/water/threads/ChildProcess.h b/source/modules/water/threads/ChildProcess.h index 79857d316..9c8f463aa 100644 --- a/source/modules/water/threads/ChildProcess.h +++ b/source/modules/water/threads/ChildProcess.h @@ -28,7 +28,7 @@ #include "../text/StringArray.h" -#include "extra/ScopedPointer.hpp" +#include namespace water { @@ -103,7 +103,7 @@ public: private: //============================================================================== class ActiveProcess; - ScopedPointer activeProcess; + std::unique_ptr activeProcess; CARLA_DECLARE_NON_COPYABLE (ChildProcess) }; diff --git a/source/modules/water/xml/XmlDocument.cpp b/source/modules/water/xml/XmlDocument.cpp index a325ded97..f87f8380a 100644 --- a/source/modules/water/xml/XmlDocument.cpp +++ b/source/modules/water/xml/XmlDocument.cpp @@ -70,7 +70,7 @@ XmlElement* XmlDocument::parse (const String& xmlData) void XmlDocument::setInputSource (FileInputSource* const newSource) noexcept { - inputSource = newSource; + inputSource.reset(newSource); } void XmlDocument::setEmptyTextElementsIgnored (const bool shouldBeIgnored) noexcept @@ -121,7 +121,7 @@ XmlElement* XmlDocument::getDocumentElement (const bool onlyReadOuterDocumentEle { if (originalText.isEmpty() && inputSource != nullptr) { - ScopedPointer in (inputSource->createInputStream()); + std::unique_ptr in (inputSource->createInputStream()); if (in != nullptr) { @@ -160,7 +160,7 @@ String XmlDocument::getFileContents (const String& filename) const { if (inputSource != nullptr) { - const ScopedPointer in (inputSource->createInputStreamFor (filename.trim().unquoted())); + std::unique_ptr in (inputSource->createInputStreamFor (filename.trim().unquoted())); if (in != nullptr) return in->readEntireStreamAsString(); @@ -206,7 +206,7 @@ XmlElement* XmlDocument::parseDocumentElement (CharPointer_UTF8 textToParse, { lastError.clear(); - ScopedPointer result (readNextElement (! onlyReadOuterDocumentElement)); + std::unique_ptr result (readNextElement (! onlyReadOuterDocumentElement)); if (! errorOccurred) return result.release(); diff --git a/source/modules/water/xml/XmlDocument.h b/source/modules/water/xml/XmlDocument.h index b0dff9107..b931f2004 100644 --- a/source/modules/water/xml/XmlDocument.h +++ b/source/modules/water/xml/XmlDocument.h @@ -28,7 +28,7 @@ #include "../text/StringArray.h" -#include "extra/ScopedPointer.hpp" +#include namespace water { @@ -43,9 +43,9 @@ namespace water { @code XmlDocument myDocument (File ("myfile.xml")); - ScopedPointer mainElement (myDocument.getDocumentElement()); + std::unique_ptr mainElement (myDocument.getDocumentElement()); - if (mainElement == nullptr) + if (mainElement.get() == nullptr) { String error = myDocument.getLastParseError(); } @@ -59,7 +59,7 @@ namespace water { Or you can use the static helper methods for quick parsing.. @code - ScopedPointer xml (XmlDocument::parse (myXmlFile)); + std::unique_ptr xml (XmlDocument::parse (myXmlFile)); if (xml != nullptr && xml->hasTagName ("foobar")) { @@ -158,7 +158,7 @@ private: String lastError, dtdText; StringArray tokenisedDTD; bool needToLoadDTD, ignoreEmptyTextElements; - DISTRHO_NAMESPACE::ScopedPointer inputSource; + std::unique_ptr inputSource; XmlElement* parseDocumentElement (CharPointer_UTF8, bool outer); void setLastError (const String&, bool carryOn);