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:
parent
679a33d657
commit
6420ab31b6
5 changed files with 34 additions and 7 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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 {};
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue