Signed-off-by: falkTX <falktx@falktx.com>pull/1975/merge
| @@ -17,6 +17,7 @@ | |||
| #include <ctime> | |||
| #include "extra/Base64.hpp" | |||
| #include "extra/ScopedPointer.hpp" | |||
| #include "extra/Time.hpp" | |||
| #include "water/files/File.h" | |||
| @@ -29,7 +29,7 @@ | |||
| #include "Array.h" | |||
| #include "../text/String.h" | |||
| #include "extra/ScopedPointer.hpp" | |||
| #include <memory> | |||
| namespace water { | |||
| @@ -141,7 +141,7 @@ public: | |||
| while (h != nullptr) | |||
| { | |||
| const ScopedPointer<HashEntry> deleter (h); | |||
| const std::unique_ptr<HashEntry> deleter (h); | |||
| h = h->nextEntry; | |||
| } | |||
| @@ -262,7 +262,7 @@ public: | |||
| { | |||
| if (entry->value == valueToRemove) | |||
| { | |||
| const ScopedPointer<HashEntry> deleter (entry); | |||
| const std::unique_ptr<HashEntry> deleter (entry); | |||
| entry = entry->nextEntry; | |||
| @@ -28,7 +28,7 @@ | |||
| #include "ArrayAllocationBase.h" | |||
| #include "extra/ScopedPointer.hpp" | |||
| #include <memory> | |||
| namespace water { | |||
| @@ -372,7 +372,7 @@ public: | |||
| { | |||
| if (indexToChange >= 0) | |||
| { | |||
| ScopedPointer<ObjectClass> toDelete; | |||
| std::unique_ptr<ObjectClass> toDelete; | |||
| { | |||
| if (indexToChange < numUsed) | |||
| @@ -536,14 +536,14 @@ public: | |||
| */ | |||
| void remove (const size_t indexToRemove, bool deleteObject = true) | |||
| { | |||
| ScopedPointer<ObjectClass> toDelete; | |||
| std::unique_ptr<ObjectClass> toDelete; | |||
| if (indexToRemove < numUsed) | |||
| { | |||
| ObjectClass** const e = data.elements + indexToRemove; | |||
| if (deleteObject) | |||
| toDelete = *e; | |||
| toDelete.reset(*e); | |||
| --numUsed; | |||
| const size_t numToShift = numUsed - indexToRemove; | |||
| @@ -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; | |||
| } | |||
| @@ -29,7 +29,7 @@ | |||
| #include "File.h" | |||
| #include "../text/StringArray.h" | |||
| #include "extra/ScopedPointer.hpp" | |||
| #include <memory> | |||
| namespace water { | |||
| @@ -123,7 +123,7 @@ private: | |||
| private: | |||
| friend class DirectoryIterator; | |||
| ScopedPointer<Pimpl> pimpl; | |||
| std::unique_ptr<Pimpl> pimpl; | |||
| CARLA_DECLARE_NON_COPYABLE (NativeIterator) | |||
| }; | |||
| @@ -136,7 +136,7 @@ private: | |||
| const int whatToLookFor; | |||
| const bool isRecursive; | |||
| bool hasBeenAdvanced; | |||
| ScopedPointer<DirectoryIterator> subIterator; | |||
| std::unique_ptr<DirectoryIterator> subIterator; | |||
| File currentFile; | |||
| static StringArray parseWildcards (const String& pattern); | |||
| @@ -714,7 +714,7 @@ File File::withFileExtension (const char* const newExtension) const | |||
| //============================================================================== | |||
| FileInputStream* File::createInputStream() const | |||
| { | |||
| ScopedPointer<FileInputStream> fin (new FileInputStream (*this)); | |||
| std::unique_ptr<FileInputStream> 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<FileOutputStream> out (new FileOutputStream (*this, bufferSize)); | |||
| std::unique_ptr<FileOutputStream> out (new FileOutputStream (*this, bufferSize)); | |||
| return out->failedToOpen() ? nullptr | |||
| : out.release(); | |||
| @@ -3,7 +3,7 @@ | |||
| This file is part of the Water library. | |||
| Copyright (c) 2016 ROLI Ltd. | |||
| Copyright (C) 2017-2022 Filipe Coelho <falktx@falktx.com> | |||
| Copyright (C) 2017-2025 Filipe Coelho <falktx@falktx.com> | |||
| 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<FileOutputStream> out (temp.getFile().createOutputStream()); | |||
| std::unique_ptr<FileOutputStream> out (temp.getFile().createOutputStream()); | |||
| if (out != nullptr) | |||
| { | |||
| @@ -29,7 +29,7 @@ | |||
| #include "ReferenceCountedObject.h" | |||
| #include "../threads/SpinLock.h" | |||
| #include "extra/ScopedPointer.hpp" | |||
| #include <memory> | |||
| 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<SharedObjectType> sharedInstance; | |||
| std::unique_ptr<SharedObjectType> 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 | |||
| @@ -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<AudioProcessor> processor; | |||
| const std::unique_ptr<AudioProcessor> processor; | |||
| bool isPrepared; | |||
| Node (uint32 nodeId, AudioProcessor*) noexcept; | |||
| @@ -405,7 +405,7 @@ private: | |||
| friend class AudioGraphIOProcessor; | |||
| struct AudioProcessorGraphBufferHelpers; | |||
| ScopedPointer<AudioProcessorGraphBufferHelpers> audioAndCVBuffers; | |||
| std::unique_ptr<AudioProcessorGraphBufferHelpers> audioAndCVBuffers; | |||
| MidiBuffer* currentMidiInputBuffer; | |||
| MidiBuffer currentMidiOutputBuffer; | |||
| @@ -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; | |||
| @@ -28,7 +28,7 @@ | |||
| #include "../text/StringArray.h" | |||
| #include "extra/ScopedPointer.hpp" | |||
| #include <memory> | |||
| namespace water { | |||
| @@ -103,7 +103,7 @@ public: | |||
| private: | |||
| //============================================================================== | |||
| class ActiveProcess; | |||
| ScopedPointer<ActiveProcess> activeProcess; | |||
| std::unique_ptr<ActiveProcess> activeProcess; | |||
| CARLA_DECLARE_NON_COPYABLE (ChildProcess) | |||
| }; | |||
| @@ -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<InputStream> in (inputSource->createInputStream()); | |||
| std::unique_ptr<InputStream> in (inputSource->createInputStream()); | |||
| if (in != nullptr) | |||
| { | |||
| @@ -160,7 +160,7 @@ String XmlDocument::getFileContents (const String& filename) const | |||
| { | |||
| if (inputSource != nullptr) | |||
| { | |||
| const ScopedPointer<InputStream> in (inputSource->createInputStreamFor (filename.trim().unquoted())); | |||
| std::unique_ptr<InputStream> 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<XmlElement> result (readNextElement (! onlyReadOuterDocumentElement)); | |||
| std::unique_ptr<XmlElement> result (readNextElement (! onlyReadOuterDocumentElement)); | |||
| if (! errorOccurred) | |||
| return result.release(); | |||
| @@ -28,7 +28,7 @@ | |||
| #include "../text/StringArray.h" | |||
| #include "extra/ScopedPointer.hpp" | |||
| #include <memory> | |||
| namespace water { | |||
| @@ -43,9 +43,9 @@ namespace water { | |||
| @code | |||
| XmlDocument myDocument (File ("myfile.xml")); | |||
| ScopedPointer<XmlElement> mainElement (myDocument.getDocumentElement()); | |||
| std::unique_ptr<XmlElement> 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<XmlElement> xml (XmlDocument::parse (myXmlFile)); | |||
| std::unique_ptr<XmlElement> 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<FileInputSource> inputSource; | |||
| std::unique_ptr<FileInputSource> inputSource; | |||
| XmlElement* parseDocumentElement (CharPointer_UTF8, bool outer); | |||
| void setLastError (const String&, bool carryOn); | |||