mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-28 02:30:05 +00:00
More ScopedPointer/unique_ptr compatibility work
This commit is contained in:
parent
48a5fbd333
commit
1a60fa9765
80 changed files with 404 additions and 368 deletions
|
|
@ -411,7 +411,7 @@ public:
|
|||
{
|
||||
toDelete.reset (data.elements[indexToChange]);
|
||||
|
||||
if (toDelete == newObject)
|
||||
if (toDelete.get() == newObject)
|
||||
toDelete.release();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -389,7 +389,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
|
|||
|
||||
struct DotOperator : public Expression
|
||||
{
|
||||
DotOperator (const CodeLocation& l, ExpPtr& p, const Identifier& c) noexcept : Expression (l), parent (p), child (c) {}
|
||||
DotOperator (const CodeLocation& l, ExpPtr& p, const Identifier& c) noexcept : Expression (l), parent (p.release()), child (c) {}
|
||||
|
||||
var getResult (const Scope& s) const override
|
||||
{
|
||||
|
|
@ -478,7 +478,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
|
|||
struct BinaryOperatorBase : public Expression
|
||||
{
|
||||
BinaryOperatorBase (const CodeLocation& l, ExpPtr& a, ExpPtr& b, TokenType op) noexcept
|
||||
: Expression (l), lhs (a), rhs (b), operation (op) {}
|
||||
: Expression (l), lhs (a.release()), rhs (b.release()), operation (op) {}
|
||||
|
||||
ExpPtr lhs, rhs;
|
||||
TokenType operation;
|
||||
|
|
@ -674,7 +674,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
|
|||
|
||||
struct Assignment : public Expression
|
||||
{
|
||||
Assignment (const CodeLocation& l, ExpPtr& dest, ExpPtr& source) noexcept : Expression (l), target (dest), newValue (source) {}
|
||||
Assignment (const CodeLocation& l, ExpPtr& dest, ExpPtr& source) noexcept : Expression (l), target (dest.release()), newValue (source.release()) {}
|
||||
|
||||
var getResult (const Scope& s) const override
|
||||
{
|
||||
|
|
@ -1080,7 +1080,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
|
|||
}
|
||||
|
||||
match (TokenTypes::closeParen);
|
||||
fo.body = parseBlock();
|
||||
fo.body.reset (parseBlock());
|
||||
}
|
||||
|
||||
Expression* parseExpression()
|
||||
|
|
@ -1270,7 +1270,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
|
|||
Expression* parseFunctionCall (FunctionCall* call, ExpPtr& function)
|
||||
{
|
||||
ScopedPointer<FunctionCall> s (call);
|
||||
s->object = function;
|
||||
s->object.reset (function.release());
|
||||
match (TokenTypes::openParen);
|
||||
|
||||
while (currentType != TokenTypes::closeParen)
|
||||
|
|
@ -1296,7 +1296,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
|
|||
if (matchIf (TokenTypes::openBracket))
|
||||
{
|
||||
ScopedPointer<ArraySubscript> s (new ArraySubscript (location));
|
||||
s->object = input;
|
||||
s->object.reset (input.release());
|
||||
s->index.reset (parseExpression());
|
||||
match (TokenTypes::closeBracket);
|
||||
return parseSuffixes (s.release());
|
||||
|
|
@ -1505,7 +1505,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
|
|||
Expression* parseTernaryOperator (ExpPtr& condition)
|
||||
{
|
||||
ScopedPointer<ConditionalOp> e (new ConditionalOp (location));
|
||||
e->condition = condition;
|
||||
e->condition.reset (condition.release());
|
||||
e->trueBranch.reset (parseExpression());
|
||||
match (TokenTypes::colon);
|
||||
e->falseBranch.reset (parseExpression());
|
||||
|
|
|
|||
|
|
@ -1023,22 +1023,22 @@ Expression Expression::adjustedToGiveNewResult (const double targetValue, const
|
|||
{
|
||||
ScopedPointer<Term> newTerm (term->clone());
|
||||
|
||||
Helpers::Constant* termToAdjust = Helpers::findTermToAdjust (newTerm, true);
|
||||
Helpers::Constant* termToAdjust = Helpers::findTermToAdjust (newTerm.get(), true);
|
||||
|
||||
if (termToAdjust == nullptr)
|
||||
termToAdjust = Helpers::findTermToAdjust (newTerm, false);
|
||||
termToAdjust = Helpers::findTermToAdjust (newTerm.get(), false);
|
||||
|
||||
if (termToAdjust == nullptr)
|
||||
{
|
||||
newTerm = new Helpers::Add (newTerm.release(), new Helpers::Constant (0, false));
|
||||
termToAdjust = Helpers::findTermToAdjust (newTerm, false);
|
||||
newTerm.reset (new Helpers::Add (newTerm.release(), new Helpers::Constant (0, false)));
|
||||
termToAdjust = Helpers::findTermToAdjust (newTerm.get(), false);
|
||||
}
|
||||
|
||||
jassert (termToAdjust != nullptr);
|
||||
|
||||
if (const Term* parent = Helpers::findDestinationFor (newTerm, termToAdjust))
|
||||
if (const Term* parent = Helpers::findDestinationFor (newTerm.get(), termToAdjust))
|
||||
{
|
||||
if (const Helpers::TermPtr reverseTerm = parent->createTermToEvaluateInput (scope, termToAdjust, targetValue, newTerm))
|
||||
if (Helpers::TermPtr reverseTerm = parent->createTermToEvaluateInput (scope, termToAdjust, targetValue, newTerm.get()))
|
||||
termToAdjust->value = Expression (reverseTerm).evaluate (scope);
|
||||
else
|
||||
return Expression (targetValue);
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ namespace FunctionTestsHelpers
|
|||
|
||||
FunctionObject (const FunctionObject& other)
|
||||
{
|
||||
bigData = new BigData (*other.bigData);
|
||||
bigData.reset (new BigData (*other.bigData));
|
||||
}
|
||||
|
||||
int operator()(int i) const { return bigData->sum() + i; }
|
||||
|
|
|
|||
|
|
@ -1118,7 +1118,7 @@ private:
|
|||
[req addValue: juceStringToNS (value) forHTTPHeaderField: juceStringToNS (key)];
|
||||
}
|
||||
|
||||
connection = new URLConnectionState (req, numRedirectsToFollow);
|
||||
connection.reset (new URLConnectionState (req, numRedirectsToFollow));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1257,7 +1257,7 @@ bool ChildProcess::start (const StringArray& args, int streamFlags)
|
|||
if (args.size() == 0)
|
||||
return false;
|
||||
|
||||
activeProcess = new ActiveProcess (args, streamFlags);
|
||||
activeProcess.reset (new ActiveProcess (args, streamFlags));
|
||||
|
||||
if (activeProcess->childPID == 0)
|
||||
activeProcess.reset();
|
||||
|
|
|
|||
|
|
@ -118,9 +118,11 @@ URL::DownloadTask* URL::DownloadTask::createFallbackDownloader (const URL& urlTo
|
|||
const size_t bufferSize = 0x8000;
|
||||
targetFileToUse.deleteFile();
|
||||
|
||||
if (ScopedPointer<FileOutputStream> outputStream = targetFileToUse.createOutputStream (bufferSize))
|
||||
ScopedPointer<FileOutputStream> outputStream (targetFileToUse.createOutputStream (bufferSize));
|
||||
|
||||
if (outputStream != nullptr)
|
||||
{
|
||||
ScopedPointer<WebInputStream> stream = new WebInputStream (urlToUse, usePostRequest);
|
||||
ScopedPointer<WebInputStream> stream (new WebInputStream (urlToUse, usePostRequest));
|
||||
stream->withExtraHeaders (extraHeadersToUse);
|
||||
|
||||
if (stream->connect (nullptr))
|
||||
|
|
@ -650,10 +652,9 @@ InputStream* URL::createInputStream (const bool usePostCommand,
|
|||
|
||||
ScopedPointer<WebInputStream> wi (new WebInputStream (*this, usePostCommand));
|
||||
|
||||
struct ProgressCallbackCaller : WebInputStream::Listener
|
||||
struct ProgressCallbackCaller : public WebInputStream::Listener
|
||||
{
|
||||
ProgressCallbackCaller (OpenStreamProgressCallback* const progressCallbackToUse,
|
||||
void* const progressCallbackContextToUse)
|
||||
ProgressCallbackCaller (OpenStreamProgressCallback* progressCallbackToUse, void* progressCallbackContextToUse)
|
||||
: callback (progressCallbackToUse), data (progressCallbackContextToUse)
|
||||
{}
|
||||
|
||||
|
|
@ -670,7 +671,7 @@ InputStream* URL::createInputStream (const bool usePostCommand,
|
|||
ProgressCallbackCaller& operator= (const ProgressCallbackCaller&) { jassertfalse; return *this; }
|
||||
};
|
||||
|
||||
ScopedPointer<ProgressCallbackCaller> callbackCaller =
|
||||
ScopedPointer<ProgressCallbackCaller> callbackCaller
|
||||
(progressCallback != nullptr ? new ProgressCallbackCaller (progressCallback, progressCallbackContext) : nullptr);
|
||||
|
||||
if (headers.isNotEmpty())
|
||||
|
|
@ -684,7 +685,7 @@ InputStream* URL::createInputStream (const bool usePostCommand,
|
|||
|
||||
wi->withNumRedirectsToFollow (numRedirectsToFollow);
|
||||
|
||||
bool success = wi->connect (callbackCaller);
|
||||
bool success = wi->connect (callbackCaller.get());
|
||||
|
||||
if (statusCode != nullptr)
|
||||
*statusCode = wi->getStatusCode();
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ LocalisedStrings& LocalisedStrings::operator= (const LocalisedStrings& other)
|
|||
languageName = other.languageName;
|
||||
countryCodes = other.countryCodes;
|
||||
translations = other.translations;
|
||||
fallback = createCopyIfNotNull (other.fallback.get());
|
||||
fallback.reset (createCopyIfNotNull (other.fallback.get()));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -171,19 +171,19 @@ void LocalisedStrings::addStrings (const LocalisedStrings& other)
|
|||
|
||||
void LocalisedStrings::setFallback (LocalisedStrings* f)
|
||||
{
|
||||
fallback = f;
|
||||
fallback.reset (f);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void LocalisedStrings::setCurrentMappings (LocalisedStrings* newTranslations)
|
||||
{
|
||||
const SpinLock::ScopedLockType sl (currentMappingsLock);
|
||||
currentMappings = newTranslations;
|
||||
currentMappings.reset (newTranslations);
|
||||
}
|
||||
|
||||
LocalisedStrings* LocalisedStrings::getCurrentMappings()
|
||||
{
|
||||
return currentMappings;
|
||||
return currentMappings.get();
|
||||
}
|
||||
|
||||
String LocalisedStrings::translateWithCurrentMappings (const String& text) { return juce::translate (text); }
|
||||
|
|
|
|||
|
|
@ -40,25 +40,25 @@ XmlElement* XmlDocument::parse (const String& xmlData)
|
|||
return doc.getDocumentElement();
|
||||
}
|
||||
|
||||
void XmlDocument::setInputSource (InputSource* const newSource) noexcept
|
||||
void XmlDocument::setInputSource (InputSource* newSource) noexcept
|
||||
{
|
||||
inputSource = newSource;
|
||||
inputSource.reset (newSource);
|
||||
}
|
||||
|
||||
void XmlDocument::setEmptyTextElementsIgnored (const bool shouldBeIgnored) noexcept
|
||||
void XmlDocument::setEmptyTextElementsIgnored (bool shouldBeIgnored) noexcept
|
||||
{
|
||||
ignoreEmptyTextElements = shouldBeIgnored;
|
||||
}
|
||||
|
||||
namespace XmlIdentifierChars
|
||||
{
|
||||
static bool isIdentifierCharSlow (const juce_wchar c) noexcept
|
||||
static bool isIdentifierCharSlow (juce_wchar c) noexcept
|
||||
{
|
||||
return CharacterFunctions::isLetterOrDigit (c)
|
||||
|| c == '_' || c == '-' || c == ':' || c == '.';
|
||||
}
|
||||
|
||||
static bool isIdentifierChar (const juce_wchar c) noexcept
|
||||
static bool isIdentifierChar (juce_wchar c) noexcept
|
||||
{
|
||||
static const uint32 legalChars[] = { 0, 0x7ff6000, 0x87fffffe, 0x7fffffe, 0 };
|
||||
|
||||
|
|
@ -93,7 +93,9 @@ XmlElement* XmlDocument::getDocumentElement (const bool onlyReadOuterDocumentEle
|
|||
{
|
||||
if (originalText.isEmpty() && inputSource != nullptr)
|
||||
{
|
||||
if (ScopedPointer<InputStream> in = inputSource->createInputStream())
|
||||
ScopedPointer<InputStream> in (inputSource->createInputStream());
|
||||
|
||||
if (in != nullptr)
|
||||
{
|
||||
MemoryOutputStream data;
|
||||
data.writeFromInputStream (*in, onlyReadOuterDocumentElement ? 8192 : -1);
|
||||
|
|
@ -141,8 +143,12 @@ void XmlDocument::setLastError (const String& desc, const bool carryOn)
|
|||
String XmlDocument::getFileContents (const String& filename) const
|
||||
{
|
||||
if (inputSource != nullptr)
|
||||
if (ScopedPointer<InputStream> in = inputSource->createInputStreamFor (filename.trim().unquoted()))
|
||||
{
|
||||
ScopedPointer<InputStream> in (inputSource->createInputStreamFor (filename.trim().unquoted()));
|
||||
|
||||
if (in != nullptr)
|
||||
return in->readEntireStreamAsString();
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ bool GZIPDecompressorInputStream::setPosition (int64 newPos)
|
|||
isEof = false;
|
||||
activeBufferSize = 0;
|
||||
currentPos = 0;
|
||||
helper = new GZIPDecompressHelper (format);
|
||||
helper.reset (new GZIPDecompressHelper (format));
|
||||
|
||||
sourceStream->setPosition (originalSourcePos);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,7 +128,8 @@ struct ZipFile::ZipInputStream : public InputStream
|
|||
{
|
||||
if (zf.inputSource != nullptr)
|
||||
{
|
||||
inputStream = streamToDelete = file.inputSource->createInputStream();
|
||||
streamToDelete.reset (file.inputSource->createInputStream());
|
||||
inputStream = streamToDelete.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -223,7 +224,7 @@ ZipFile::ZipFile (InputStream* stream, bool deleteStreamWhenDestroyed)
|
|||
: inputStream (stream)
|
||||
{
|
||||
if (deleteStreamWhenDestroyed)
|
||||
streamToDelete = inputStream;
|
||||
streamToDelete.reset (inputStream);
|
||||
|
||||
init();
|
||||
}
|
||||
|
|
@ -339,7 +340,7 @@ void ZipFile::init()
|
|||
if (inputSource != nullptr)
|
||||
{
|
||||
in = inputSource->createInputStream();
|
||||
toDelete = in;
|
||||
toDelete.reset (in);
|
||||
}
|
||||
|
||||
if (in != nullptr)
|
||||
|
|
@ -516,7 +517,7 @@ private:
|
|||
{
|
||||
if (stream == nullptr)
|
||||
{
|
||||
stream = file.createInputStream();
|
||||
stream.reset (file.createInputStream());
|
||||
|
||||
if (stream == nullptr)
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue