1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

DynamicObject: Update signature of clone to return unique_ptr

This commit is contained in:
reuk 2023-08-17 14:43:55 +01:00
parent 679a33d657
commit 6420ab31b6
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C
5 changed files with 34 additions and 7 deletions

View file

@ -87,11 +87,11 @@ void DynamicObject::cloneAllProperties()
*v = v->clone();
}
DynamicObject::Ptr DynamicObject::clone()
std::unique_ptr<DynamicObject> DynamicObject::clone() const
{
Ptr d (new DynamicObject (*this));
d->cloneAllProperties();
return d;
auto result = std::make_unique<DynamicObject> (*this);
result->cloneAllProperties();
return result;
}
void DynamicObject::writeAsJSON (OutputStream& out, const int indentLevel, const bool allOnOneLine, int maximumDecimalPlaces)

View file

@ -107,7 +107,7 @@ public:
with a (deep) copy of all of its properties. Subclasses can override this to
implement their own custom copy routines.
*/
virtual Ptr clone();
virtual std::unique_ptr<DynamicObject> clone() const;
//==============================================================================
/** Writes this object to a text stream in JSON format.

View file

@ -314,7 +314,7 @@ struct var::VariantType
static var objectClone (const var& original)
{
if (auto* d = original.getDynamicObject())
return d->clone().get();
return d->clone().release();
jassertfalse; // can only clone DynamicObjects!
return {};

View file

@ -833,7 +833,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
tb.parseFunctionParamsAndBody (*this);
}
DynamicObject::Ptr clone() override { return *new FunctionObject (*this); }
std::unique_ptr<DynamicObject> clone() const override { return std::make_unique<FunctionObject> (*this); }
void writeAsJSON (OutputStream& out, int /*indentLevel*/, bool /*allOnOneLine*/, int /*maximumDecimalPlaces*/) override
{