Browse Source

Replace some usage of ScopedPointer with std::unique_ptr

Signed-off-by: falkTX <falktx@falktx.com>
pull/1975/merge
falkTX 2 months ago
parent
commit
3f9b70572d
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
13 changed files with 40 additions and 40 deletions
  1. +1
    -0
      source/backend/plugin/CarlaPluginBridge.cpp
  2. +3
    -3
      source/modules/water/containers/HashMap.h
  3. +4
    -4
      source/modules/water/containers/OwnedArray.h
  4. +2
    -2
      source/modules/water/files/DirectoryIterator.cpp
  5. +3
    -3
      source/modules/water/files/DirectoryIterator.h
  6. +2
    -2
      source/modules/water/files/File.cpp
  7. +2
    -3
      source/modules/water/files/TemporaryFile.h
  8. +7
    -7
      source/modules/water/memory/SharedResourcePointer.h
  9. +3
    -3
      source/modules/water/processors/AudioProcessorGraph.h
  10. +2
    -2
      source/modules/water/threads/ChildProcess.cpp
  11. +2
    -2
      source/modules/water/threads/ChildProcess.h
  12. +4
    -4
      source/modules/water/xml/XmlDocument.cpp
  13. +5
    -5
      source/modules/water/xml/XmlDocument.h

+ 1
- 0
source/backend/plugin/CarlaPluginBridge.cpp View File

@@ -17,6 +17,7 @@
#include <ctime>

#include "extra/Base64.hpp"
#include "extra/ScopedPointer.hpp"
#include "extra/Time.hpp"

#include "water/files/File.h"


+ 3
- 3
source/modules/water/containers/HashMap.h View File

@@ -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;


+ 4
- 4
source/modules/water/containers/OwnedArray.h View File

@@ -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;


+ 2
- 2
source/modules/water/files/DirectoryIterator.cpp View File

@@ -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;
}


+ 3
- 3
source/modules/water/files/DirectoryIterator.h View File

@@ -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);


+ 2
- 2
source/modules/water/files/File.cpp View File

@@ -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();


+ 2
- 3
source/modules/water/files/TemporaryFile.h View File

@@ -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)
{


+ 7
- 7
source/modules/water/memory/SharedResourcePointer.h View File

@@ -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


+ 3
- 3
source/modules/water/processors/AudioProcessorGraph.h View File

@@ -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;


+ 2
- 2
source/modules/water/threads/ChildProcess.cpp View File

@@ -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;


+ 2
- 2
source/modules/water/threads/ChildProcess.h View File

@@ -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)
};


+ 4
- 4
source/modules/water/xml/XmlDocument.cpp View File

@@ -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();


+ 5
- 5
source/modules/water/xml/XmlDocument.h View File

@@ -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);


Loading…
Cancel
Save