| @@ -269,10 +269,10 @@ struct LicenseThread : NetWorkerThread | |||||
| if (productKey.isNotEmpty()) | if (productKey.isNotEmpty()) | ||||
| { | { | ||||
| DynamicObject::Ptr redeamObject = new DynamicObject(); | |||||
| redeamObject->setProperty (serialIdentifier, productKey); | |||||
| DynamicObject::Ptr redeemObject (new DynamicObject()); | |||||
| redeemObject->setProperty (serialIdentifier, productKey); | |||||
| String postData (JSON::toString (var (redeamObject.get()))); | |||||
| String postData (JSON::toString (var (redeemObject.get()))); | |||||
| std::unique_ptr<WebInputStream> shared (getSharedWebInputStream (URL ("https://api.roli.com/api/v1/user/products").withPOSTData (postData), | std::unique_ptr<WebInputStream> shared (getSharedWebInputStream (URL ("https://api.roli.com/api/v1/user/products").withPOSTData (postData), | ||||
| true)); | true)); | ||||
| @@ -295,12 +295,12 @@ struct LicenseThread : NetWorkerThread | |||||
| if (chosenLicenseType.isNotEmpty()) | if (chosenLicenseType.isNotEmpty()) | ||||
| { | { | ||||
| // redeem the license | // redeem the license | ||||
| DynamicObject::Ptr jsonLicenseObject = new DynamicObject(); | |||||
| DynamicObject::Ptr jsonLicenseObject (new DynamicObject()); | |||||
| jsonLicenseObject->setProperty (projucerLicenseTypeIdentifier, chosenLicenseType); | jsonLicenseObject->setProperty (projucerLicenseTypeIdentifier, chosenLicenseType); | ||||
| jsonLicenseObject->setProperty (versionIdentifier, 5); | jsonLicenseObject->setProperty (versionIdentifier, 5); | ||||
| DynamicObject::Ptr jsonLicenseRequest = new DynamicObject(); | |||||
| DynamicObject::Ptr jsonLicenseRequest (new DynamicObject()); | |||||
| jsonLicenseRequest->setProperty (licenseIdentifier, var (jsonLicenseObject.get())); | jsonLicenseRequest->setProperty (licenseIdentifier, var (jsonLicenseObject.get())); | ||||
| jsonLicenseRequest->setProperty (searchInternalIdentifier, "com.roli.projucer"); | jsonLicenseRequest->setProperty (searchInternalIdentifier, "com.roli.projucer"); | ||||
| jsonLicenseRequest->setProperty (licenseTypeIdentifier, "software"); | jsonLicenseRequest->setProperty (licenseTypeIdentifier, "software"); | ||||
| @@ -119,7 +119,7 @@ struct ChildProcessCache | |||||
| { | { | ||||
| for (auto& p : processes) | for (auto& p : processes) | ||||
| if (&(p->project) == &project) | if (&(p->project) == &project) | ||||
| return p; | |||||
| return *p; | |||||
| return {}; | return {}; | ||||
| } | } | ||||
| @@ -132,7 +132,7 @@ struct ChildProcessCache | |||||
| auto p = new CompileEngineChildProcess (project); | auto p = new CompileEngineChildProcess (project); | ||||
| tellNewProcessAboutExistingEditors (*p); | tellNewProcessAboutExistingEditors (*p); | ||||
| processes.add (p); | processes.add (p); | ||||
| return p; | |||||
| return *p; | |||||
| } | } | ||||
| static void tellNewProcessAboutExistingEditors (CompileEngineChildProcess& process) | static void tellNewProcessAboutExistingEditors (CompileEngineChildProcess& process) | ||||
| @@ -355,7 +355,7 @@ protected: | |||||
| BuildConfiguration::Ptr createBuildConfig (const ValueTree& v) const override | BuildConfiguration::Ptr createBuildConfig (const ValueTree& v) const override | ||||
| { | { | ||||
| return new AndroidBuildConfiguration (project, v, *this); | |||||
| return *new AndroidBuildConfiguration (project, v, *this); | |||||
| } | } | ||||
| private: | private: | ||||
| @@ -49,7 +49,7 @@ protected: | |||||
| BuildConfiguration::Ptr createBuildConfig (const ValueTree& tree) const override | BuildConfiguration::Ptr createBuildConfig (const ValueTree& tree) const override | ||||
| { | { | ||||
| return new CLionBuildConfiguration (project, tree, *this); | |||||
| return *new CLionBuildConfiguration (project, tree, *this); | |||||
| } | } | ||||
| public: | public: | ||||
| @@ -235,7 +235,7 @@ private: | |||||
| BuildConfiguration::Ptr createBuildConfig (const ValueTree& tree) const override | BuildConfiguration::Ptr createBuildConfig (const ValueTree& tree) const override | ||||
| { | { | ||||
| return new CodeBlocksBuildConfiguration (project, tree, *this); | |||||
| return *new CodeBlocksBuildConfiguration (project, tree, *this); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -1517,7 +1517,7 @@ protected: | |||||
| BuildConfiguration::Ptr createBuildConfig (const ValueTree& v) const override | BuildConfiguration::Ptr createBuildConfig (const ValueTree& v) const override | ||||
| { | { | ||||
| return new MSVCBuildConfiguration (project, v, *this); | |||||
| return *new MSVCBuildConfiguration (project, v, *this); | |||||
| } | } | ||||
| StringArray getHeaderSearchPaths (const BuildConfiguration& config) const | StringArray getHeaderSearchPaths (const BuildConfiguration& config) const | ||||
| @@ -78,7 +78,7 @@ protected: | |||||
| BuildConfiguration::Ptr createBuildConfig (const ValueTree& tree) const override | BuildConfiguration::Ptr createBuildConfig (const ValueTree& tree) const override | ||||
| { | { | ||||
| return new MakeBuildConfiguration (project, tree, *this); | |||||
| return *new MakeBuildConfiguration (project, tree, *this); | |||||
| } | } | ||||
| public: | public: | ||||
| @@ -625,7 +625,7 @@ protected: | |||||
| BuildConfiguration::Ptr createBuildConfig (const ValueTree& v) const override | BuildConfiguration::Ptr createBuildConfig (const ValueTree& v) const override | ||||
| { | { | ||||
| return new XcodeBuildConfiguration (project, v, iOS, *this); | |||||
| return *new XcodeBuildConfiguration (project, v, iOS, *this); | |||||
| } | } | ||||
| public: | public: | ||||
| @@ -3078,7 +3078,7 @@ private: | |||||
| for (auto& type : getiOSAppIconTypes()) | for (auto& type : getiOSAppIconTypes()) | ||||
| { | { | ||||
| DynamicObject::Ptr d = new DynamicObject(); | |||||
| DynamicObject::Ptr d (new DynamicObject()); | |||||
| d->setProperty ("idiom", type.idiom); | d->setProperty ("idiom", type.idiom); | ||||
| d->setProperty ("size", type.sizeString); | d->setProperty ("size", type.sizeString); | ||||
| d->setProperty ("filename", type.filename); | d->setProperty ("filename", type.filename); | ||||
| @@ -3146,7 +3146,7 @@ private: | |||||
| for (auto& type : getiOSLaunchImageTypes()) | for (auto& type : getiOSLaunchImageTypes()) | ||||
| { | { | ||||
| DynamicObject::Ptr d = new DynamicObject(); | |||||
| DynamicObject::Ptr d (new DynamicObject()); | |||||
| d->setProperty ("orientation", type.orientation); | d->setProperty ("orientation", type.orientation); | ||||
| d->setProperty ("idiom", type.idiom); | d->setProperty ("idiom", type.idiom); | ||||
| d->setProperty ("extent", type.extent); | d->setProperty ("extent", type.extent); | ||||
| @@ -686,7 +686,7 @@ struct RenderSequenceBuilder | |||||
| if (numOuts == 0) | if (numOuts == 0) | ||||
| totalLatency = maxLatency; | totalLatency = maxLatency; | ||||
| sequence.addProcessOp (&node, audioChannelsToUse, totalChans, midiBufferToUse); | |||||
| sequence.addProcessOp (node, audioChannelsToUse, totalChans, midiBufferToUse); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -1318,7 +1318,7 @@ struct PhysicalTopologySource::Internal | |||||
| bi->rotation = 0; | bi->rotation = 0; | ||||
| } | } | ||||
| layoutNeighbours (block, topology, block->uid, visited); | |||||
| layoutNeighbours (*block, topology, block->uid, visited); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -1327,7 +1327,7 @@ struct PhysicalTopologySource::Internal | |||||
| { | { | ||||
| for (auto& block : topology.blocks) | for (auto& block : topology.blocks) | ||||
| if (block->uid == uid) | if (block->uid == uid) | ||||
| return block; | |||||
| return *block; | |||||
| return {}; | return {}; | ||||
| } | } | ||||
| @@ -178,7 +178,7 @@ public: | |||||
| */ | */ | ||||
| inline ObjectClassPtr operator[] (int index) const noexcept | inline ObjectClassPtr operator[] (int index) const noexcept | ||||
| { | { | ||||
| return getObjectPointer (index); | |||||
| return ObjectClassPtr (getObjectPointer (index)); | |||||
| } | } | ||||
| /** Returns a pointer to the object at this index in the array, without checking | /** Returns a pointer to the object at this index in the array, without checking | ||||
| @@ -189,7 +189,7 @@ public: | |||||
| */ | */ | ||||
| inline ObjectClassPtr getUnchecked (int index) const noexcept | inline ObjectClassPtr getUnchecked (int index) const noexcept | ||||
| { | { | ||||
| return getObjectPointerUnchecked (index); | |||||
| return ObjectClassPtr (getObjectPointerUnchecked (index)); | |||||
| } | } | ||||
| /** Returns a raw pointer to the object at this index in the array. | /** Returns a raw pointer to the object at this index in the array. | ||||
| @@ -253,7 +253,7 @@ public: | |||||
| if (numUsed > 0) | if (numUsed > 0) | ||||
| { | { | ||||
| jassert (data.elements != nullptr); | jassert (data.elements != nullptr); | ||||
| return data.elements[numUsed - 1]; | |||||
| return ObjectClassPtr (data.elements[numUsed - 1]); | |||||
| } | } | ||||
| return {}; | return {}; | ||||
| @@ -81,13 +81,13 @@ struct JavascriptEngine::RootObject : public DynamicObject | |||||
| void execute (const String& code) | void execute (const String& code) | ||||
| { | { | ||||
| ExpressionTreeBuilder tb (code); | ExpressionTreeBuilder tb (code); | ||||
| std::unique_ptr<BlockStatement> (tb.parseStatementList())->perform (Scope (nullptr, this, this), nullptr); | |||||
| std::unique_ptr<BlockStatement> (tb.parseStatementList())->perform (Scope ({}, *this, *this), nullptr); | |||||
| } | } | ||||
| var evaluate (const String& code) | var evaluate (const String& code) | ||||
| { | { | ||||
| ExpressionTreeBuilder tb (code); | ExpressionTreeBuilder tb (code); | ||||
| return ExpPtr (tb.parseExpression())->getResult (Scope (nullptr, this, this)); | |||||
| return ExpPtr (tb.parseExpression())->getResult (Scope ({}, *this, *this)); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -210,7 +210,7 @@ struct JavascriptEngine::RootObject : public DynamicObject | |||||
| for (int i = 0; i < props.size(); ++i) | for (int i = 0; i < props.size(); ++i) | ||||
| if (auto* o = props.getValueAt (i).getDynamicObject()) | if (auto* o = props.getValueAt (i).getDynamicObject()) | ||||
| if (Scope (this, root, o).findAndInvokeMethod (function, args, result)) | |||||
| if (Scope (this, *root, *o).findAndInvokeMethod (function, args, result)) | |||||
| return true; | return true; | ||||
| return false; | return false; | ||||
| @@ -833,7 +833,7 @@ struct JavascriptEngine::RootObject : public DynamicObject | |||||
| tb.parseFunctionParamsAndBody (*this); | tb.parseFunctionParamsAndBody (*this); | ||||
| } | } | ||||
| DynamicObject::Ptr clone() override { return new FunctionObject (*this); } | |||||
| DynamicObject::Ptr clone() override { return *new FunctionObject (*this); } | |||||
| void writeAsJSON (OutputStream& out, int /*indentLevel*/, bool /*allOnOneLine*/, int /*maximumDecimalPlaces*/) override | void writeAsJSON (OutputStream& out, int /*indentLevel*/, bool /*allOnOneLine*/, int /*maximumDecimalPlaces*/) override | ||||
| { | { | ||||
| @@ -1875,7 +1875,7 @@ var JavascriptEngine::callFunction (const Identifier& function, const var::Nativ | |||||
| { | { | ||||
| prepareTimeout(); | prepareTimeout(); | ||||
| if (result != nullptr) *result = Result::ok(); | if (result != nullptr) *result = Result::ok(); | ||||
| RootObject::Scope ({}, root, root).findAndInvokeMethod (function, args, returnVal); | |||||
| RootObject::Scope ({}, *root, *root).findAndInvokeMethod (function, args, returnVal); | |||||
| } | } | ||||
| catch (String& error) | catch (String& error) | ||||
| { | { | ||||
| @@ -1894,8 +1894,9 @@ var JavascriptEngine::callFunctionObject (DynamicObject* objectScope, const var& | |||||
| { | { | ||||
| prepareTimeout(); | prepareTimeout(); | ||||
| if (result != nullptr) *result = Result::ok(); | if (result != nullptr) *result = Result::ok(); | ||||
| RootObject::Scope rootScope ({}, root, root); | |||||
| RootObject::Scope (&rootScope, root, objectScope).invokeMethod (functionObject, args, returnVal); | |||||
| RootObject::Scope rootScope ({}, *root, *root); | |||||
| RootObject::Scope (&rootScope, *root, DynamicObject::Ptr (objectScope)) | |||||
| .invokeMethod (functionObject, args, returnVal); | |||||
| } | } | ||||
| catch (String& error) | catch (String& error) | ||||
| { | { | ||||
| @@ -112,9 +112,9 @@ struct Expression::Helpers | |||||
| Type getType() const noexcept { return constantType; } | Type getType() const noexcept { return constantType; } | ||||
| Term* clone() const { return new Constant (value, isResolutionTarget); } | Term* clone() const { return new Constant (value, isResolutionTarget); } | ||||
| TermPtr resolve (const Scope&, int) { return this; } | |||||
| TermPtr resolve (const Scope&, int) { return *this; } | |||||
| double toDouble() const { return value; } | double toDouble() const { return value; } | ||||
| TermPtr negated() { return new Constant (-value, isResolutionTarget); } | |||||
| TermPtr negated() { return *new Constant (-value, isResolutionTarget); } | |||||
| String toString() const | String toString() const | ||||
| { | { | ||||
| @@ -152,15 +152,15 @@ struct Expression::Helpers | |||||
| TermPtr resolve (const Scope& scope, int recursionDepth) | TermPtr resolve (const Scope& scope, int recursionDepth) | ||||
| { | { | ||||
| return new Constant (performFunction (left ->resolve (scope, recursionDepth)->toDouble(), | |||||
| right->resolve (scope, recursionDepth)->toDouble()), false); | |||||
| return *new Constant (performFunction (left ->resolve (scope, recursionDepth)->toDouble(), | |||||
| right->resolve (scope, recursionDepth)->toDouble()), false); | |||||
| } | } | ||||
| String toString() const | String toString() const | ||||
| { | { | ||||
| String s; | String s; | ||||
| const int ourPrecendence = getOperatorPrecedence(); | |||||
| auto ourPrecendence = getOperatorPrecedence(); | |||||
| if (left->getOperatorPrecedence() > ourPrecendence) | if (left->getOperatorPrecedence() > ourPrecendence) | ||||
| s << '(' << left->toString() << ')'; | s << '(' << left->toString() << ')'; | ||||
| else | else | ||||
| @@ -188,7 +188,7 @@ struct Expression::Helpers | |||||
| if (auto dest = findDestinationFor (topLevelTerm, this)) | if (auto dest = findDestinationFor (topLevelTerm, this)) | ||||
| return dest->createTermToEvaluateInput (scope, this, overallTarget, topLevelTerm); | return dest->createTermToEvaluateInput (scope, this, overallTarget, topLevelTerm); | ||||
| return new Constant (overallTarget, false); | |||||
| return *new Constant (overallTarget, false); | |||||
| } | } | ||||
| }; | }; | ||||
| @@ -261,7 +261,7 @@ struct Expression::Helpers | |||||
| result = scope.evaluateFunction (functionName, nullptr, 0); | result = scope.evaluateFunction (functionName, nullptr, 0); | ||||
| } | } | ||||
| return new Constant (result, false); | |||||
| return *new Constant (result, false); | |||||
| } | } | ||||
| int getInputIndexFor (const Term* possibleInput) const | int getInputIndexFor (const Term* possibleInput) const | ||||
| @@ -300,7 +300,7 @@ struct Expression::Helpers | |||||
| class DotOperator : public BinaryTerm | class DotOperator : public BinaryTerm | ||||
| { | { | ||||
| public: | public: | ||||
| DotOperator (SymbolTerm* const l, TermPtr r) : BinaryTerm (l, r) {} | |||||
| DotOperator (SymbolTerm* l, TermPtr r) : BinaryTerm (TermPtr (l), r) {} | |||||
| TermPtr resolve (const Scope& scope, int recursionDepth) | TermPtr resolve (const Scope& scope, int recursionDepth) | ||||
| { | { | ||||
| @@ -311,7 +311,7 @@ struct Expression::Helpers | |||||
| return visitor.output; | return visitor.output; | ||||
| } | } | ||||
| Term* clone() const { return new DotOperator (getSymbol(), right.get()); } | |||||
| Term* clone() const { return new DotOperator (getSymbol(), *right); } | |||||
| String getName() const { return "."; } | String getName() const { return "."; } | ||||
| int getOperatorPrecedence() const { return 1; } | int getOperatorPrecedence() const { return 1; } | ||||
| void writeOperator (String& dest) const { dest << '.'; } | void writeOperator (String& dest) const { dest << '.'; } | ||||
| @@ -414,11 +414,11 @@ struct Expression::Helpers | |||||
| int getInputIndexFor (const Term* possibleInput) const { return possibleInput == input ? 0 : -1; } | int getInputIndexFor (const Term* possibleInput) const { return possibleInput == input ? 0 : -1; } | ||||
| int getNumInputs() const { return 1; } | int getNumInputs() const { return 1; } | ||||
| Term* getInput (int index) const { return index == 0 ? input.get() : nullptr; } | Term* getInput (int index) const { return index == 0 ? input.get() : nullptr; } | ||||
| Term* clone() const { return new Negate (input->clone()); } | |||||
| Term* clone() const { return new Negate (*input->clone()); } | |||||
| TermPtr resolve (const Scope& scope, int recursionDepth) | TermPtr resolve (const Scope& scope, int recursionDepth) | ||||
| { | { | ||||
| return new Constant (-input->resolve (scope, recursionDepth)->toDouble(), false); | |||||
| return *new Constant (-input->resolve (scope, recursionDepth)->toDouble(), false); | |||||
| } | } | ||||
| String getName() const { return "-"; } | String getName() const { return "-"; } | ||||
| @@ -431,8 +431,8 @@ struct Expression::Helpers | |||||
| const Term* const dest = findDestinationFor (topLevelTerm, this); | const Term* const dest = findDestinationFor (topLevelTerm, this); | ||||
| return new Negate (dest == nullptr ? new Constant (overallTarget, false) | |||||
| : dest->createTermToEvaluateInput (scope, this, overallTarget, topLevelTerm)); | |||||
| return *new Negate (dest == nullptr ? TermPtr (*new Constant (overallTarget, false)) | |||||
| : dest->createTermToEvaluateInput (scope, this, overallTarget, topLevelTerm)); | |||||
| } | } | ||||
| String toString() const | String toString() const | ||||
| @@ -453,7 +453,7 @@ struct Expression::Helpers | |||||
| public: | public: | ||||
| Add (TermPtr l, TermPtr r) : BinaryTerm (l, r) {} | Add (TermPtr l, TermPtr r) : BinaryTerm (l, r) {} | ||||
| Term* clone() const { return new Add (left->clone(), right->clone()); } | |||||
| Term* clone() const { return new Add (*left->clone(), *right->clone()); } | |||||
| double performFunction (double lhs, double rhs) const { return lhs + rhs; } | double performFunction (double lhs, double rhs) const { return lhs + rhs; } | ||||
| int getOperatorPrecedence() const { return 3; } | int getOperatorPrecedence() const { return 3; } | ||||
| String getName() const { return "+"; } | String getName() const { return "+"; } | ||||
| @@ -462,7 +462,7 @@ struct Expression::Helpers | |||||
| TermPtr createTermToEvaluateInput (const Scope& scope, const Term* input, double overallTarget, Term* topLevelTerm) const | TermPtr createTermToEvaluateInput (const Scope& scope, const Term* input, double overallTarget, Term* topLevelTerm) const | ||||
| { | { | ||||
| if (auto newDest = createDestinationTerm (scope, input, overallTarget, topLevelTerm)) | if (auto newDest = createDestinationTerm (scope, input, overallTarget, topLevelTerm)) | ||||
| return new Subtract (newDest, (input == left ? right : left)->clone()); | |||||
| return *new Subtract (newDest, *(input == left ? right : left)->clone()); | |||||
| return {}; | return {}; | ||||
| } | } | ||||
| @@ -477,7 +477,7 @@ struct Expression::Helpers | |||||
| public: | public: | ||||
| Subtract (TermPtr l, TermPtr r) : BinaryTerm (l, r) {} | Subtract (TermPtr l, TermPtr r) : BinaryTerm (l, r) {} | ||||
| Term* clone() const { return new Subtract (left->clone(), right->clone()); } | |||||
| Term* clone() const { return new Subtract (*left->clone(), *right->clone()); } | |||||
| double performFunction (double lhs, double rhs) const { return lhs - rhs; } | double performFunction (double lhs, double rhs) const { return lhs - rhs; } | ||||
| int getOperatorPrecedence() const { return 3; } | int getOperatorPrecedence() const { return 3; } | ||||
| String getName() const { return "-"; } | String getName() const { return "-"; } | ||||
| @@ -488,9 +488,9 @@ struct Expression::Helpers | |||||
| if (auto newDest = createDestinationTerm (scope, input, overallTarget, topLevelTerm)) | if (auto newDest = createDestinationTerm (scope, input, overallTarget, topLevelTerm)) | ||||
| { | { | ||||
| if (input == left) | if (input == left) | ||||
| return new Add (newDest, right->clone()); | |||||
| return *new Add (*newDest, *right->clone()); | |||||
| return new Subtract (left->clone(), newDest); | |||||
| return *new Subtract (*left->clone(), *newDest); | |||||
| } | } | ||||
| return {}; | return {}; | ||||
| @@ -506,7 +506,7 @@ struct Expression::Helpers | |||||
| public: | public: | ||||
| Multiply (TermPtr l, TermPtr r) : BinaryTerm (l, r) {} | Multiply (TermPtr l, TermPtr r) : BinaryTerm (l, r) {} | ||||
| Term* clone() const { return new Multiply (left->clone(), right->clone()); } | |||||
| Term* clone() const { return new Multiply (*left->clone(), *right->clone()); } | |||||
| double performFunction (double lhs, double rhs) const { return lhs * rhs; } | double performFunction (double lhs, double rhs) const { return lhs * rhs; } | ||||
| String getName() const { return "*"; } | String getName() const { return "*"; } | ||||
| void writeOperator (String& dest) const { dest << " * "; } | void writeOperator (String& dest) const { dest << " * "; } | ||||
| @@ -515,7 +515,7 @@ struct Expression::Helpers | |||||
| TermPtr createTermToEvaluateInput (const Scope& scope, const Term* input, double overallTarget, Term* topLevelTerm) const | TermPtr createTermToEvaluateInput (const Scope& scope, const Term* input, double overallTarget, Term* topLevelTerm) const | ||||
| { | { | ||||
| if (auto newDest = createDestinationTerm (scope, input, overallTarget, topLevelTerm)) | if (auto newDest = createDestinationTerm (scope, input, overallTarget, topLevelTerm)) | ||||
| return new Divide (newDest, (input == left ? right : left)->clone()); | |||||
| return *new Divide (newDest, *(input == left ? right : left)->clone()); | |||||
| return {}; | return {}; | ||||
| } | } | ||||
| @@ -529,7 +529,7 @@ struct Expression::Helpers | |||||
| public: | public: | ||||
| Divide (TermPtr l, TermPtr r) : BinaryTerm (l, r) {} | Divide (TermPtr l, TermPtr r) : BinaryTerm (l, r) {} | ||||
| Term* clone() const { return new Divide (left->clone(), right->clone()); } | |||||
| Term* clone() const { return new Divide (*left->clone(), *right->clone()); } | |||||
| double performFunction (double lhs, double rhs) const { return lhs / rhs; } | double performFunction (double lhs, double rhs) const { return lhs / rhs; } | ||||
| String getName() const { return "/"; } | String getName() const { return "/"; } | ||||
| void writeOperator (String& dest) const { dest << " / "; } | void writeOperator (String& dest) const { dest << " / "; } | ||||
| @@ -537,14 +537,15 @@ struct Expression::Helpers | |||||
| TermPtr createTermToEvaluateInput (const Scope& scope, const Term* input, double overallTarget, Term* topLevelTerm) const | TermPtr createTermToEvaluateInput (const Scope& scope, const Term* input, double overallTarget, Term* topLevelTerm) const | ||||
| { | { | ||||
| const TermPtr newDest (createDestinationTerm (scope, input, overallTarget, topLevelTerm)); | |||||
| auto newDest = createDestinationTerm (scope, input, overallTarget, topLevelTerm); | |||||
| if (newDest == nullptr) | if (newDest == nullptr) | ||||
| return {}; | return {}; | ||||
| if (input == left) | if (input == left) | ||||
| return new Multiply (newDest, right->clone()); | |||||
| return *new Multiply (*newDest, *right->clone()); | |||||
| return new Divide (left->clone(), newDest); | |||||
| return *new Divide (*left->clone(), *newDest); | |||||
| } | } | ||||
| JUCE_DECLARE_NON_COPYABLE (Divide) | JUCE_DECLARE_NON_COPYABLE (Divide) | ||||
| @@ -598,11 +599,8 @@ struct Expression::Helpers | |||||
| } | } | ||||
| for (int i = 0; i < numIns; ++i) | for (int i = 0; i < numIns; ++i) | ||||
| { | |||||
| Constant* const c = findTermToAdjust (term->getInput (i), mustBeFlagged); | |||||
| if (c != nullptr) | |||||
| if (auto c = findTermToAdjust (term->getInput (i), mustBeFlagged)) | |||||
| return c; | return c; | ||||
| } | |||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| @@ -659,9 +657,9 @@ struct Expression::Helpers | |||||
| TermPtr readUpToComma() | TermPtr readUpToComma() | ||||
| { | { | ||||
| if (text.isEmpty()) | if (text.isEmpty()) | ||||
| return new Constant (0.0, false); | |||||
| return *new Constant (0.0, false); | |||||
| const TermPtr e (readExpression()); | |||||
| auto e = readExpression(); | |||||
| if (e == nullptr || ((! readOperator (",")) && ! text.isEmpty())) | if (e == nullptr || ((! readOperator (",")) && ! text.isEmpty())) | ||||
| return parseError ("Syntax error: \"" + String (text) + "\""); | return parseError ("Syntax error: \"" + String (text) + "\""); | ||||
| @@ -674,12 +672,12 @@ struct Expression::Helpers | |||||
| private: | private: | ||||
| String::CharPointerType& text; | String::CharPointerType& text; | ||||
| Term* parseError (const String& message) | |||||
| TermPtr parseError (const String& message) | |||||
| { | { | ||||
| if (error.isEmpty()) | if (error.isEmpty()) | ||||
| error = message; | error = message; | ||||
| return nullptr; | |||||
| return {}; | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -774,20 +772,20 @@ struct Expression::Helpers | |||||
| TermPtr readExpression() | TermPtr readExpression() | ||||
| { | { | ||||
| TermPtr lhs (readMultiplyOrDivideExpression()); | |||||
| auto lhs = readMultiplyOrDivideExpression(); | |||||
| char opType; | char opType; | ||||
| while (lhs != nullptr && readOperator ("+-", &opType)) | while (lhs != nullptr && readOperator ("+-", &opType)) | ||||
| { | { | ||||
| TermPtr rhs (readMultiplyOrDivideExpression()); | |||||
| auto rhs = readMultiplyOrDivideExpression(); | |||||
| if (rhs == nullptr) | if (rhs == nullptr) | ||||
| return parseError ("Expected expression after \"" + String::charToString ((juce_wchar) (uint8) opType) + "\""); | return parseError ("Expected expression after \"" + String::charToString ((juce_wchar) (uint8) opType) + "\""); | ||||
| if (opType == '+') | if (opType == '+') | ||||
| lhs = new Add (lhs, rhs); | |||||
| lhs = *new Add (lhs, rhs); | |||||
| else | else | ||||
| lhs = new Subtract (lhs, rhs); | |||||
| lhs = *new Subtract (lhs, rhs); | |||||
| } | } | ||||
| return lhs; | return lhs; | ||||
| @@ -795,9 +793,9 @@ struct Expression::Helpers | |||||
| TermPtr readMultiplyOrDivideExpression() | TermPtr readMultiplyOrDivideExpression() | ||||
| { | { | ||||
| TermPtr lhs (readUnaryExpression()); | |||||
| auto lhs = readUnaryExpression(); | |||||
| char opType; | char opType; | ||||
| while (lhs != nullptr && readOperator ("*/", &opType)) | while (lhs != nullptr && readOperator ("*/", &opType)) | ||||
| { | { | ||||
| TermPtr rhs (readUnaryExpression()); | TermPtr rhs (readUnaryExpression()); | ||||
| @@ -806,9 +804,9 @@ struct Expression::Helpers | |||||
| return parseError ("Expected expression after \"" + String::charToString ((juce_wchar) (uint8) opType) + "\""); | return parseError ("Expected expression after \"" + String::charToString ((juce_wchar) (uint8) opType) + "\""); | ||||
| if (opType == '*') | if (opType == '*') | ||||
| lhs = new Multiply (lhs, rhs); | |||||
| lhs = *new Multiply (lhs, rhs); | |||||
| else | else | ||||
| lhs = new Divide (lhs, rhs); | |||||
| lhs = *new Divide (lhs, rhs); | |||||
| } | } | ||||
| return lhs; | return lhs; | ||||
| @@ -835,12 +833,10 @@ struct Expression::Helpers | |||||
| TermPtr readPrimaryExpression() | TermPtr readPrimaryExpression() | ||||
| { | { | ||||
| TermPtr e (readParenthesisedExpression()); | |||||
| if (e != nullptr) | |||||
| if (auto e = readParenthesisedExpression()) | |||||
| return e; | return e; | ||||
| e = readNumber(); | |||||
| if (e != nullptr) | |||||
| if (auto e = readNumber()) | |||||
| return e; | return e; | ||||
| return readSymbolOrFunction(); | return readSymbolOrFunction(); | ||||
| @@ -848,20 +844,21 @@ struct Expression::Helpers | |||||
| TermPtr readSymbolOrFunction() | TermPtr readSymbolOrFunction() | ||||
| { | { | ||||
| String identifier; | |||||
| String identifier; | |||||
| if (readIdentifier (identifier)) | if (readIdentifier (identifier)) | ||||
| { | { | ||||
| if (readOperator ("(")) // method call... | if (readOperator ("(")) // method call... | ||||
| { | { | ||||
| Function* const f = new Function (identifier); | |||||
| auto f = new Function (identifier); | |||||
| std::unique_ptr<Term> func (f); // (can't use std::unique_ptr<Function> in MSVC) | std::unique_ptr<Term> func (f); // (can't use std::unique_ptr<Function> in MSVC) | ||||
| TermPtr param (readExpression()); | |||||
| auto param = readExpression(); | |||||
| if (param == nullptr) | if (param == nullptr) | ||||
| { | { | ||||
| if (readOperator (")")) | if (readOperator (")")) | ||||
| return func.release(); | |||||
| return TermPtr (func.release()); | |||||
| return parseError ("Expected parameters after \"" + identifier + " (\""); | return parseError ("Expected parameters after \"" + identifier + " (\""); | ||||
| } | } | ||||
| @@ -879,7 +876,7 @@ struct Expression::Helpers | |||||
| } | } | ||||
| if (readOperator (")")) | if (readOperator (")")) | ||||
| return func.release(); | |||||
| return TermPtr (func.release()); | |||||
| return parseError ("Expected \")\""); | return parseError ("Expected \")\""); | ||||
| } | } | ||||
| @@ -894,12 +891,12 @@ struct Expression::Helpers | |||||
| if (identifier == "this") | if (identifier == "this") | ||||
| return rhs; | return rhs; | ||||
| return new DotOperator (new SymbolTerm (identifier), rhs); | |||||
| return *new DotOperator (new SymbolTerm (identifier), rhs); | |||||
| } | } | ||||
| // just a symbol.. | // just a symbol.. | ||||
| jassert (identifier.trim() == identifier); | jassert (identifier.trim() == identifier); | ||||
| return new SymbolTerm (identifier); | |||||
| return *new SymbolTerm (identifier); | |||||
| } | } | ||||
| return {}; | return {}; | ||||
| @@ -910,7 +907,8 @@ struct Expression::Helpers | |||||
| if (! readOperator ("(")) | if (! readOperator ("(")) | ||||
| return {}; | return {}; | ||||
| const TermPtr e (readExpression()); | |||||
| auto e = readExpression(); | |||||
| if (e == nullptr || ! readOperator (")")) | if (e == nullptr || ! readOperator (")")) | ||||
| return {}; | return {}; | ||||
| @@ -1020,14 +1018,14 @@ Expression Expression::adjustedToGiveNewResult (const double targetValue, const | |||||
| { | { | ||||
| std::unique_ptr<Term> newTerm (term->clone()); | std::unique_ptr<Term> newTerm (term->clone()); | ||||
| Helpers::Constant* termToAdjust = Helpers::findTermToAdjust (newTerm.get(), true); | |||||
| auto termToAdjust = Helpers::findTermToAdjust (newTerm.get(), true); | |||||
| if (termToAdjust == nullptr) | if (termToAdjust == nullptr) | ||||
| termToAdjust = Helpers::findTermToAdjust (newTerm.get(), false); | termToAdjust = Helpers::findTermToAdjust (newTerm.get(), false); | ||||
| if (termToAdjust == nullptr) | if (termToAdjust == nullptr) | ||||
| { | { | ||||
| newTerm.reset (new Helpers::Add (newTerm.release(), new Helpers::Constant (0, false))); | |||||
| newTerm.reset (new Helpers::Add (*newTerm.release(), *new Helpers::Constant (0, false))); | |||||
| termToAdjust = Helpers::findTermToAdjust (newTerm.get(), false); | termToAdjust = Helpers::findTermToAdjust (newTerm.get(), false); | ||||
| } | } | ||||
| @@ -1095,7 +1093,7 @@ Expression Expression::getInput (int index) const { return Expression (ter | |||||
| //============================================================================== | //============================================================================== | ||||
| ReferenceCountedObjectPtr<Expression::Term> Expression::Term::negated() | ReferenceCountedObjectPtr<Expression::Term> Expression::Term::negated() | ||||
| { | { | ||||
| return new Helpers::Negate (this); | |||||
| return *new Helpers::Negate (*this); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -260,6 +260,15 @@ public: | |||||
| incIfNotNull (refCountedObject); | incIfNotNull (refCountedObject); | ||||
| } | } | ||||
| /** Creates a pointer to an object. | |||||
| This will increment the object's reference-count. | |||||
| */ | |||||
| ReferenceCountedObjectPtr (ReferencedType& refCountedObject) noexcept | |||||
| : referencedObject (&refCountedObject) | |||||
| { | |||||
| refCountedObject.incReferenceCount(); | |||||
| } | |||||
| /** Copies another pointer. | /** Copies another pointer. | ||||
| This will increment the object's reference-count. | This will increment the object's reference-count. | ||||
| */ | */ | ||||
| @@ -310,19 +319,40 @@ public: | |||||
| The reference count of the old object is decremented, and it might be | The reference count of the old object is decremented, and it might be | ||||
| deleted if it hits zero. The new object's count is incremented. | deleted if it hits zero. The new object's count is incremented. | ||||
| */ | */ | ||||
| ReferenceCountedObjectPtr& operator= (ReferencedType* newObject) | |||||
| { | |||||
| if (referencedObject != newObject) | |||||
| { | |||||
| incIfNotNull (newObject); | |||||
| auto* oldObject = referencedObject; | |||||
| referencedObject = newObject; | |||||
| decIfNotNull (oldObject); | |||||
| } | |||||
| return *this; | |||||
| } | |||||
| ReferenceCountedObjectPtr& operator= (ReferencedType* newObject) | |||||
| { | |||||
| if (newObject != nullptr) | |||||
| return operator= (*newObject); | |||||
| reset(); | |||||
| return *this; | |||||
| } | |||||
| /** Changes this pointer to point at a different object. | |||||
| The reference count of the old object is decremented, and it might be | |||||
| deleted if it hits zero. The new object's count is incremented. | |||||
| */ | |||||
| ReferenceCountedObjectPtr& operator= (ReferencedType& newObject) | |||||
| { | |||||
| if (referencedObject != &newObject) | |||||
| { | |||||
| newObject.incReferenceCount(); | |||||
| auto* oldObject = referencedObject; | |||||
| referencedObject = &newObject; | |||||
| decIfNotNull (oldObject); | |||||
| } | |||||
| return *this; | |||||
| } | |||||
| /** Resets this pointer to a null pointer. */ | |||||
| ReferenceCountedObjectPtr& operator= (decltype (nullptr)) | |||||
| { | |||||
| reset(); | |||||
| return *this; | |||||
| } | |||||
| /** Takes-over the object from another pointer. */ | /** Takes-over the object from another pointer. */ | ||||
| ReferenceCountedObjectPtr& operator= (ReferenceCountedObjectPtr&& other) noexcept | ReferenceCountedObjectPtr& operator= (ReferenceCountedObjectPtr&& other) noexcept | ||||
| { | { | ||||
| @@ -335,8 +365,8 @@ public: | |||||
| object to be deleted when the ref-count hits zero. | object to be deleted when the ref-count hits zero. | ||||
| */ | */ | ||||
| ~ReferenceCountedObjectPtr() | ~ReferenceCountedObjectPtr() | ||||
| { | |||||
| decIfNotNull (referencedObject); | |||||
| { | |||||
| reset(); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -344,6 +374,12 @@ public: | |||||
| The pointer returned may be null, of course. | The pointer returned may be null, of course. | ||||
| */ | */ | ||||
| ReferencedType* get() const noexcept { return referencedObject; } | ReferencedType* get() const noexcept { return referencedObject; } | ||||
| /** Resets this object to a null pointer. */ | |||||
| void reset() noexcept | |||||
| { | |||||
| decIfNotNull (referencedObject); | |||||
| } | |||||
| // the -> operator is called on the referenced object | // the -> operator is called on the referenced object | ||||
| ReferencedType* operator->() const noexcept | ReferencedType* operator->() const noexcept | ||||
| @@ -170,7 +170,7 @@ public: | |||||
| { | { | ||||
| if (sharedPointer == nullptr) | if (sharedPointer == nullptr) | ||||
| { | { | ||||
| sharedPointer = new SharedPointer (object); | |||||
| sharedPointer = *new SharedPointer (object); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -149,7 +149,7 @@ static var nsObjectToVar (NSObject* array); | |||||
| static var nsDictionaryToVar (NSDictionary* dictionary) | static var nsDictionaryToVar (NSDictionary* dictionary) | ||||
| { | { | ||||
| DynamicObject::Ptr dynamicObject = new DynamicObject(); | |||||
| DynamicObject::Ptr dynamicObject (new DynamicObject()); | |||||
| for (NSString* key in dictionary) | for (NSString* key in dictionary) | ||||
| dynamicObject->setProperty (nsStringToJuce (key), nsObjectToVar (dictionary[key])); | dynamicObject->setProperty (nsStringToJuce (key), nsObjectToVar (dictionary[key])); | ||||
| @@ -60,9 +60,9 @@ public: | |||||
| } | } | ||||
| } | } | ||||
| SharedObject* getRoot() noexcept | |||||
| SharedObject& getRoot() noexcept | |||||
| { | { | ||||
| return parent == nullptr ? this : parent->getRoot(); | |||||
| return parent == nullptr ? *this : parent->getRoot(); | |||||
| } | } | ||||
| template <typename Function> | template <typename Function> | ||||
| @@ -97,31 +97,31 @@ public: | |||||
| void sendPropertyChangeMessage (const Identifier& property, ValueTree::Listener* listenerToExclude = nullptr) | void sendPropertyChangeMessage (const Identifier& property, ValueTree::Listener* listenerToExclude = nullptr) | ||||
| { | { | ||||
| ValueTree tree (this); | |||||
| ValueTree tree (*this); | |||||
| callListenersForAllParents (listenerToExclude, [&] (Listener& l) { l.valueTreePropertyChanged (tree, property); }); | callListenersForAllParents (listenerToExclude, [&] (Listener& l) { l.valueTreePropertyChanged (tree, property); }); | ||||
| } | } | ||||
| void sendChildAddedMessage (ValueTree child) | void sendChildAddedMessage (ValueTree child) | ||||
| { | { | ||||
| ValueTree tree (this); | |||||
| ValueTree tree (*this); | |||||
| callListenersForAllParents (nullptr, [&] (Listener& l) { l.valueTreeChildAdded (tree, child); }); | callListenersForAllParents (nullptr, [&] (Listener& l) { l.valueTreeChildAdded (tree, child); }); | ||||
| } | } | ||||
| void sendChildRemovedMessage (ValueTree child, int index) | void sendChildRemovedMessage (ValueTree child, int index) | ||||
| { | { | ||||
| ValueTree tree (this); | |||||
| ValueTree tree (*this); | |||||
| callListenersForAllParents (nullptr, [=, &tree, &child] (Listener& l) { l.valueTreeChildRemoved (tree, child, index); }); | callListenersForAllParents (nullptr, [=, &tree, &child] (Listener& l) { l.valueTreeChildRemoved (tree, child, index); }); | ||||
| } | } | ||||
| void sendChildOrderChangedMessage (int oldIndex, int newIndex) | void sendChildOrderChangedMessage (int oldIndex, int newIndex) | ||||
| { | { | ||||
| ValueTree tree (this); | |||||
| ValueTree tree (*this); | |||||
| callListenersForAllParents (nullptr, [=, &tree] (Listener& l) { l.valueTreeChildOrderChanged (tree, oldIndex, newIndex); }); | callListenersForAllParents (nullptr, [=, &tree] (Listener& l) { l.valueTreeChildOrderChanged (tree, oldIndex, newIndex); }); | ||||
| } | } | ||||
| void sendParentChangeMessage() | void sendParentChangeMessage() | ||||
| { | { | ||||
| ValueTree tree (this); | |||||
| ValueTree tree (*this); | |||||
| for (int j = children.size(); --j >= 0;) | for (int j = children.size(); --j >= 0;) | ||||
| if (auto* child = children.getObjectPointer (j)) | if (auto* child = children.getObjectPointer (j)) | ||||
| @@ -143,12 +143,12 @@ public: | |||||
| if (auto* existingValue = properties.getVarPointer (name)) | if (auto* existingValue = properties.getVarPointer (name)) | ||||
| { | { | ||||
| if (*existingValue != newValue) | if (*existingValue != newValue) | ||||
| undoManager->perform (new SetPropertyAction (this, name, newValue, *existingValue, | |||||
| undoManager->perform (new SetPropertyAction (*this, name, newValue, *existingValue, | |||||
| false, false, listenerToExclude)); | false, false, listenerToExclude)); | ||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| undoManager->perform (new SetPropertyAction (this, name, newValue, {}, | |||||
| undoManager->perform (new SetPropertyAction (*this, name, newValue, {}, | |||||
| true, false, listenerToExclude)); | true, false, listenerToExclude)); | ||||
| } | } | ||||
| } | } | ||||
| @@ -169,7 +169,7 @@ public: | |||||
| else | else | ||||
| { | { | ||||
| if (properties.contains (name)) | if (properties.contains (name)) | ||||
| undoManager->perform (new SetPropertyAction (this, name, {}, properties [name], false, true)); | |||||
| undoManager->perform (new SetPropertyAction (*this, name, {}, properties [name], false, true)); | |||||
| } | } | ||||
| } | } | ||||
| @@ -187,7 +187,7 @@ public: | |||||
| else | else | ||||
| { | { | ||||
| for (int i = properties.size(); --i >= 0;) | for (int i = properties.size(); --i >= 0;) | ||||
| undoManager->perform (new SetPropertyAction (this, properties.getName(i), {}, | |||||
| undoManager->perform (new SetPropertyAction (*this, properties.getName(i), {}, | |||||
| properties.getValueAt(i), false, true)); | properties.getValueAt(i), false, true)); | ||||
| } | } | ||||
| } | } | ||||
| @@ -206,7 +206,7 @@ public: | |||||
| { | { | ||||
| for (auto* s : children) | for (auto* s : children) | ||||
| if (s->type == typeToMatch) | if (s->type == typeToMatch) | ||||
| return ValueTree (s); | |||||
| return ValueTree (*s); | |||||
| return {}; | return {}; | ||||
| } | } | ||||
| @@ -215,18 +215,18 @@ public: | |||||
| { | { | ||||
| for (auto* s : children) | for (auto* s : children) | ||||
| if (s->type == typeToMatch) | if (s->type == typeToMatch) | ||||
| return ValueTree (s); | |||||
| return ValueTree (*s); | |||||
| auto newObject = new SharedObject (typeToMatch); | auto newObject = new SharedObject (typeToMatch); | ||||
| addChild (newObject, -1, undoManager); | addChild (newObject, -1, undoManager); | ||||
| return ValueTree (newObject); | |||||
| return ValueTree (*newObject); | |||||
| } | } | ||||
| ValueTree getChildWithProperty (const Identifier& propertyName, const var& propertyValue) const | ValueTree getChildWithProperty (const Identifier& propertyName, const var& propertyValue) const | ||||
| { | { | ||||
| for (auto* s : children) | for (auto* s : children) | ||||
| if (s->properties[propertyName] == propertyValue) | if (s->properties[propertyName] == propertyValue) | ||||
| return ValueTree (s); | |||||
| return ValueTree (*s); | |||||
| return {}; | return {}; | ||||
| } | } | ||||
| @@ -266,7 +266,7 @@ public: | |||||
| { | { | ||||
| children.insert (index, child); | children.insert (index, child); | ||||
| child->parent = this; | child->parent = this; | ||||
| sendChildAddedMessage (ValueTree (child)); | |||||
| sendChildAddedMessage (ValueTree (*child)); | |||||
| child->sendParentChangeMessage(); | child->sendParentChangeMessage(); | ||||
| } | } | ||||
| else | else | ||||
| @@ -274,7 +274,7 @@ public: | |||||
| if (! isPositiveAndBelow (index, children.size())) | if (! isPositiveAndBelow (index, children.size())) | ||||
| index = children.size(); | index = children.size(); | ||||
| undoManager->perform (new AddOrRemoveChildAction (this, index, child)); | |||||
| undoManager->perform (new AddOrRemoveChildAction (*this, index, child)); | |||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| @@ -288,7 +288,7 @@ public: | |||||
| void removeChild (int childIndex, UndoManager* undoManager) | void removeChild (int childIndex, UndoManager* undoManager) | ||||
| { | { | ||||
| if (Ptr child = children.getObjectPointer (childIndex)) | |||||
| if (auto child = Ptr (children.getObjectPointer (childIndex))) | |||||
| { | { | ||||
| if (undoManager == nullptr) | if (undoManager == nullptr) | ||||
| { | { | ||||
| @@ -299,7 +299,7 @@ public: | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| undoManager->perform (new AddOrRemoveChildAction (this, childIndex, nullptr)); | |||||
| undoManager->perform (new AddOrRemoveChildAction (*this, childIndex, {})); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -328,7 +328,7 @@ public: | |||||
| if (! isPositiveAndBelow (newIndex, children.size())) | if (! isPositiveAndBelow (newIndex, children.size())) | ||||
| newIndex = children.size() - 1; | newIndex = children.size() - 1; | ||||
| undoManager->perform (new MoveChildAction (this, currentIndex, newIndex)); | |||||
| undoManager->perform (new MoveChildAction (*this, currentIndex, newIndex)); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -389,12 +389,12 @@ public: | |||||
| } | } | ||||
| output.writeCompressedInt (children.size()); | output.writeCompressedInt (children.size()); | ||||
| for (int i = 0; i < children.size(); ++i) | |||||
| writeObjectToStream (output, children.getObjectPointerUnchecked(i)); | |||||
| for (auto* c : children) | |||||
| writeObjectToStream (output, c); | |||||
| } | } | ||||
| static void writeObjectToStream (OutputStream& output, const Ptr& object) | |||||
| static void writeObjectToStream (OutputStream& output, const SharedObject* object) | |||||
| { | { | ||||
| if (object != nullptr) | if (object != nullptr) | ||||
| { | { | ||||
| @@ -455,7 +455,7 @@ public: | |||||
| if (auto* next = dynamic_cast<SetPropertyAction*> (nextAction)) | if (auto* next = dynamic_cast<SetPropertyAction*> (nextAction)) | ||||
| if (next->target == target && next->name == name | if (next->target == target && next->name == name | ||||
| && ! (next->isAddingNewProperty || next->isDeletingProperty)) | && ! (next->isAddingNewProperty || next->isDeletingProperty)) | ||||
| return new SetPropertyAction (target, name, next->newValue, oldValue, false, false); | |||||
| return new SetPropertyAction (*target, name, next->newValue, oldValue, false, false); | |||||
| } | } | ||||
| return nullptr; | return nullptr; | ||||
| @@ -598,11 +598,9 @@ ValueTree::ValueTree (const Identifier& type, | |||||
| addChild (tree, -1, nullptr); | addChild (tree, -1, nullptr); | ||||
| } | } | ||||
| ValueTree::ValueTree (ReferenceCountedObjectPtr<SharedObject> so) noexcept | |||||
| : object (static_cast<ReferenceCountedObjectPtr<SharedObject>&&> (so)) | |||||
| { | |||||
| } | |||||
| ValueTree::ValueTree (SharedObject::Ptr so) noexcept : object (static_cast<SharedObject::Ptr&&> (so)) {} | |||||
| ValueTree::ValueTree (SharedObject& so) noexcept : object (so) {} | |||||
| ValueTree::ValueTree (const ValueTree& other) noexcept : object (other.object) | ValueTree::ValueTree (const ValueTree& other) noexcept : object (other.object) | ||||
| { | { | ||||
| } | } | ||||
| @@ -663,8 +661,11 @@ bool ValueTree::isEquivalentTo (const ValueTree& other) const | |||||
| } | } | ||||
| ValueTree ValueTree::createCopy() const | ValueTree ValueTree::createCopy() const | ||||
| { | |||||
| return ValueTree (createCopyIfNotNull (object.get())); | |||||
| { | |||||
| if (object != nullptr) | |||||
| return ValueTree (*new SharedObject (*object)); | |||||
| return {}; | |||||
| } | } | ||||
| void ValueTree::copyPropertiesFrom (const ValueTree& source, UndoManager* undoManager) | void ValueTree::copyPropertiesFrom (const ValueTree& source, UndoManager* undoManager) | ||||
| @@ -700,24 +701,30 @@ Identifier ValueTree::getType() const noexcept | |||||
| } | } | ||||
| ValueTree ValueTree::getParent() const noexcept | ValueTree ValueTree::getParent() const noexcept | ||||
| { | |||||
| return ValueTree (object != nullptr ? object->parent | |||||
| : static_cast<SharedObject*> (nullptr)); | |||||
| { | |||||
| if (object != nullptr) | |||||
| if (auto p = object->parent) | |||||
| return ValueTree (*p); | |||||
| return {}; | |||||
| } | } | ||||
| ValueTree ValueTree::getRoot() const noexcept | ValueTree ValueTree::getRoot() const noexcept | ||||
| { | { | ||||
| return ValueTree (object != nullptr ? object->getRoot() | |||||
| : static_cast<SharedObject*> (nullptr)); | |||||
| if (object != nullptr) | |||||
| return ValueTree (object->getRoot()); | |||||
| return {}; | |||||
| } | } | ||||
| ValueTree ValueTree::getSibling (int delta) const noexcept | ValueTree ValueTree::getSibling (int delta) const noexcept | ||||
| { | { | ||||
| if (object == nullptr || object->parent == nullptr) | |||||
| return {}; | |||||
| auto index = object->parent->indexOf (*this) + delta; | |||||
| return ValueTree (object->parent->children.getObjectPointer (index)); | |||||
| if (object == nullptr) | |||||
| if (auto p = object->parent) | |||||
| if (auto c = p->children.getObjectPointer (p->indexOf (*this) + delta)) | |||||
| return ValueTree (*c); | |||||
| return {}; | |||||
| } | } | ||||
| static const var& getNullVarRef() noexcept | static const var& getNullVarRef() noexcept | ||||
| @@ -848,9 +855,12 @@ int ValueTree::getNumChildren() const noexcept | |||||
| } | } | ||||
| ValueTree ValueTree::getChild (int index) const | ValueTree ValueTree::getChild (int index) const | ||||
| { | |||||
| return ValueTree (object != nullptr ? object->children.getObjectPointer (index) | |||||
| : static_cast<SharedObject*> (nullptr)); | |||||
| { | |||||
| if (object != nullptr) | |||||
| if (auto c = object->children.getObjectPointer (index)) | |||||
| return ValueTree (*c); | |||||
| return {}; | |||||
| } | } | ||||
| ValueTree::Iterator::Iterator (const ValueTree& v, bool isEnd) noexcept | ValueTree::Iterator::Iterator (const ValueTree& v, bool isEnd) noexcept | ||||
| @@ -871,7 +881,7 @@ bool ValueTree::Iterator::operator!= (const Iterator& other) const noexcept | |||||
| ValueTree ValueTree::Iterator::operator*() const | ValueTree ValueTree::Iterator::operator*() const | ||||
| { | { | ||||
| return ValueTree (*static_cast<SharedObject**> (internal)); | |||||
| return ValueTree (SharedObject::Ptr (*static_cast<SharedObject**> (internal))); | |||||
| } | } | ||||
| ValueTree::Iterator ValueTree::begin() const noexcept { return Iterator (*this, false); } | ValueTree::Iterator ValueTree::begin() const noexcept { return Iterator (*this, false); } | ||||
| @@ -944,8 +954,11 @@ void ValueTree::createListOfChildren (OwnedArray<ValueTree>& list) const | |||||
| { | { | ||||
| jassert (object != nullptr); | jassert (object != nullptr); | ||||
| for (auto* o : object->children) | |||||
| list.add (new ValueTree (o)); | |||||
| for (auto* o : object->children) | |||||
| { | |||||
| jassert (o != nullptr); | |||||
| list.add (new ValueTree (*o)); | |||||
| } | |||||
| } | } | ||||
| void ValueTree::reorderChildren (const OwnedArray<ValueTree>& newOrder, UndoManager* undoManager) | void ValueTree::reorderChildren (const OwnedArray<ValueTree>& newOrder, UndoManager* undoManager) | ||||
| @@ -1017,7 +1030,7 @@ String ValueTree::toXmlString() const | |||||
| //============================================================================== | //============================================================================== | ||||
| void ValueTree::writeToStream (OutputStream& output) const | void ValueTree::writeToStream (OutputStream& output) const | ||||
| { | { | ||||
| SharedObject::writeObjectToStream (output, object); | |||||
| SharedObject::writeObjectToStream (output, object.get()); | |||||
| } | } | ||||
| ValueTree ValueTree::readFromStream (InputStream& input) | ValueTree ValueTree::readFromStream (InputStream& input) | ||||
| @@ -632,7 +632,8 @@ private: | |||||
| void createListOfChildren (OwnedArray<ValueTree>&) const; | void createListOfChildren (OwnedArray<ValueTree>&) const; | ||||
| void reorderChildren (const OwnedArray<ValueTree>&, UndoManager*); | void reorderChildren (const OwnedArray<ValueTree>&, UndoManager*); | ||||
| explicit ValueTree (ReferenceCountedObjectPtr<SharedObject>) noexcept; | |||||
| explicit ValueTree (ReferenceCountedObjectPtr<SharedObject>) noexcept; | |||||
| explicit ValueTree (SharedObject&) noexcept; | |||||
| }; | }; | ||||
| } // namespace juce | } // namespace juce | ||||
| @@ -60,7 +60,7 @@ typename FIR::Coefficients<FloatType>::Ptr | |||||
| WindowingFunction<FloatType> theWindow (order + 1, type, false, beta); | WindowingFunction<FloatType> theWindow (order + 1, type, false, beta); | ||||
| theWindow.multiplyWithWindowingTable (c, order + 1); | theWindow.multiplyWithWindowingTable (c, order + 1); | ||||
| return result; | |||||
| return *result; | |||||
| } | } | ||||
| template <typename FloatType> | template <typename FloatType> | ||||
| @@ -121,7 +121,7 @@ typename FIR::Coefficients<FloatType>::Ptr | |||||
| } | } | ||||
| } | } | ||||
| return result; | |||||
| return *result; | |||||
| } | } | ||||
| template <typename FloatType> | template <typename FloatType> | ||||
| @@ -231,7 +231,7 @@ typename FIR::Coefficients<FloatType>::Ptr | |||||
| } | } | ||||
| } | } | ||||
| return result; | |||||
| return *result; | |||||
| } | } | ||||
| template <typename FloatType> | template <typename FloatType> | ||||
| @@ -290,7 +290,7 @@ typename FIR::Coefficients<FloatType>::Ptr | |||||
| c[2 * n + 1] = static_cast<FloatType> (0.5); | c[2 * n + 1] = static_cast<FloatType> (0.5); | ||||
| return result; | |||||
| return *result; | |||||
| } | } | ||||
| template <typename FloatType> | template <typename FloatType> | ||||
| @@ -178,7 +178,7 @@ class FIRFilterTest : public UnitTest | |||||
| AudioBlock<NumericType> fir (firBlock, 1, static_cast<size_t> (size)); | AudioBlock<NumericType> fir (firBlock, 1, static_cast<size_t> (size)); | ||||
| fillRandom (random, fir.getChannelPointer (0), static_cast<size_t> (size)); | fillRandom (random, fir.getChannelPointer (0), static_cast<size_t> (size)); | ||||
| FIR::Filter<SampleType> filter (new FIR::Coefficients<NumericType> (fir.getChannelPointer (0), static_cast<size_t> (size))); | |||||
| FIR::Filter<SampleType> filter (*new FIR::Coefficients<NumericType> (fir.getChannelPointer (0), static_cast<size_t> (size))); | |||||
| ProcessSpec spec {0.0, n, 1}; | ProcessSpec spec {0.0, n, 1}; | ||||
| filter.prepare (spec); | filter.prepare (spec); | ||||
| @@ -99,7 +99,7 @@ typename IIR::Coefficients<NumericType>::Ptr IIR::Coefficients<NumericType>::mak | |||||
| auto n = std::tan (MathConstants<NumericType>::pi * frequency / static_cast<NumericType> (sampleRate)); | auto n = std::tan (MathConstants<NumericType>::pi * frequency / static_cast<NumericType> (sampleRate)); | ||||
| return new Coefficients (n, n, n + 1, n - 1); | |||||
| return *new Coefficients (n, n, n + 1, n - 1); | |||||
| } | } | ||||
| template <typename NumericType> | template <typename NumericType> | ||||
| @@ -111,7 +111,7 @@ typename IIR::Coefficients<NumericType>::Ptr IIR::Coefficients<NumericType>::mak | |||||
| auto n = std::tan (MathConstants<NumericType>::pi * frequency / static_cast<NumericType> (sampleRate)); | auto n = std::tan (MathConstants<NumericType>::pi * frequency / static_cast<NumericType> (sampleRate)); | ||||
| return new Coefficients (1, -1, n + 1, n - 1); | |||||
| return *new Coefficients (1, -1, n + 1, n - 1); | |||||
| } | } | ||||
| template <typename NumericType> | template <typename NumericType> | ||||
| @@ -123,7 +123,7 @@ typename IIR::Coefficients<NumericType>::Ptr IIR::Coefficients<NumericType>::mak | |||||
| auto n = std::tan (MathConstants<NumericType>::pi * frequency / static_cast<NumericType> (sampleRate)); | auto n = std::tan (MathConstants<NumericType>::pi * frequency / static_cast<NumericType> (sampleRate)); | ||||
| return new Coefficients (n - 1, n + 1, n + 1, n - 1); | |||||
| return *new Coefficients (n - 1, n + 1, n + 1, n - 1); | |||||
| } | } | ||||
| template <typename NumericType> | template <typename NumericType> | ||||
| @@ -147,9 +147,9 @@ typename IIR::Coefficients<NumericType>::Ptr IIR::Coefficients<NumericType>::mak | |||||
| auto invQ = 1 / Q; | auto invQ = 1 / Q; | ||||
| auto c1 = 1 / (1 + invQ * n + nSquared); | auto c1 = 1 / (1 + invQ * n + nSquared); | ||||
| return new Coefficients (c1, c1 * 2, c1, | |||||
| 1, c1 * 2 * (1 - nSquared), | |||||
| c1 * (1 - invQ * n + nSquared)); | |||||
| return *new Coefficients (c1, c1 * 2, c1, | |||||
| 1, c1 * 2 * (1 - nSquared), | |||||
| c1 * (1 - invQ * n + nSquared)); | |||||
| } | } | ||||
| template <typename NumericType> | template <typename NumericType> | ||||
| @@ -173,9 +173,9 @@ typename IIR::Coefficients<NumericType>::Ptr IIR::Coefficients<NumericType>::mak | |||||
| auto invQ = 1 / Q; | auto invQ = 1 / Q; | ||||
| auto c1 = 1 / (1 + invQ * n + nSquared); | auto c1 = 1 / (1 + invQ * n + nSquared); | ||||
| return new Coefficients (c1, c1 * -2, c1, | |||||
| 1, c1 * 2 * (nSquared - 1), | |||||
| c1 * (1 - invQ * n + nSquared)); | |||||
| return *new Coefficients (c1, c1 * -2, c1, | |||||
| 1, c1 * 2 * (nSquared - 1), | |||||
| c1 * (1 - invQ * n + nSquared)); | |||||
| } | } | ||||
| template <typename NumericType> | template <typename NumericType> | ||||
| @@ -199,10 +199,10 @@ typename IIR::Coefficients<NumericType>::Ptr IIR::Coefficients<NumericType>::mak | |||||
| auto invQ = 1 / Q; | auto invQ = 1 / Q; | ||||
| auto c1 = 1 / (1 + invQ * n + nSquared); | auto c1 = 1 / (1 + invQ * n + nSquared); | ||||
| return new Coefficients (c1 * n * invQ, 0, | |||||
| -c1 * n * invQ, 1, | |||||
| c1 * 2 * (1 - nSquared), | |||||
| c1 * (1 - invQ * n + nSquared)); | |||||
| return *new Coefficients (c1 * n * invQ, 0, | |||||
| -c1 * n * invQ, 1, | |||||
| c1 * 2 * (1 - nSquared), | |||||
| c1 * (1 - invQ * n + nSquared)); | |||||
| } | } | ||||
| template <typename NumericType> | template <typename NumericType> | ||||
| @@ -228,7 +228,7 @@ typename IIR::Coefficients<NumericType>::Ptr IIR::Coefficients<NumericType>::mak | |||||
| auto b0 = c1 * (1 + nSquared); | auto b0 = c1 * (1 + nSquared); | ||||
| auto b1 = 2 * c1 * (1 - nSquared); | auto b1 = 2 * c1 * (1 - nSquared); | ||||
| return new Coefficients (b0, b1, b0, 1, b1, c1 * (1 - n * invQ + nSquared)); | |||||
| return *new Coefficients (b0, b1, b0, 1, b1, c1 * (1 - n * invQ + nSquared)); | |||||
| } | } | ||||
| template <typename NumericType> | template <typename NumericType> | ||||
| @@ -254,7 +254,7 @@ typename IIR::Coefficients<NumericType>::Ptr IIR::Coefficients<NumericType>::mak | |||||
| auto b0 = c1 * (1 - n * invQ + nSquared); | auto b0 = c1 * (1 - n * invQ + nSquared); | ||||
| auto b1 = c1 * 2 * (1 - nSquared); | auto b1 = c1 * 2 * (1 - nSquared); | ||||
| return new Coefficients (b0, b1, 1, 1, b1, b0); | |||||
| return *new Coefficients (b0, b1, 1, 1, b1, b0); | |||||
| } | } | ||||
| template <typename NumericType> | template <typename NumericType> | ||||
| @@ -275,12 +275,12 @@ typename IIR::Coefficients<NumericType>::Ptr IIR::Coefficients<NumericType>::mak | |||||
| auto beta = std::sin (omega) * std::sqrt (A) / Q; | auto beta = std::sin (omega) * std::sqrt (A) / Q; | ||||
| auto aminus1TimesCoso = aminus1 * coso; | auto aminus1TimesCoso = aminus1 * coso; | ||||
| return new Coefficients (A * (aplus1 - aminus1TimesCoso + beta), | |||||
| A * 2 * (aminus1 - aplus1 * coso), | |||||
| A * (aplus1 - aminus1TimesCoso - beta), | |||||
| aplus1 + aminus1TimesCoso + beta, | |||||
| -2 * (aminus1 + aplus1 * coso), | |||||
| aplus1 + aminus1TimesCoso - beta); | |||||
| return *new Coefficients (A * (aplus1 - aminus1TimesCoso + beta), | |||||
| A * 2 * (aminus1 - aplus1 * coso), | |||||
| A * (aplus1 - aminus1TimesCoso - beta), | |||||
| aplus1 + aminus1TimesCoso + beta, | |||||
| -2 * (aminus1 + aplus1 * coso), | |||||
| aplus1 + aminus1TimesCoso - beta); | |||||
| } | } | ||||
| template <typename NumericType> | template <typename NumericType> | ||||
| @@ -301,12 +301,12 @@ typename IIR::Coefficients<NumericType>::Ptr IIR::Coefficients<NumericType>::mak | |||||
| auto beta = std::sin (omega) * std::sqrt (A) / Q; | auto beta = std::sin (omega) * std::sqrt (A) / Q; | ||||
| auto aminus1TimesCoso = aminus1 * coso; | auto aminus1TimesCoso = aminus1 * coso; | ||||
| return new Coefficients (A * (aplus1 + aminus1TimesCoso + beta), | |||||
| A * -2 * (aminus1 + aplus1 * coso), | |||||
| A * (aplus1 + aminus1TimesCoso - beta), | |||||
| aplus1 - aminus1TimesCoso + beta, | |||||
| 2 * (aminus1 - aplus1 * coso), | |||||
| aplus1 - aminus1TimesCoso - beta); | |||||
| return *new Coefficients (A * (aplus1 + aminus1TimesCoso + beta), | |||||
| A * -2 * (aminus1 + aplus1 * coso), | |||||
| A * (aplus1 + aminus1TimesCoso - beta), | |||||
| aplus1 - aminus1TimesCoso + beta, | |||||
| 2 * (aminus1 - aplus1 * coso), | |||||
| aplus1 - aminus1TimesCoso - beta); | |||||
| } | } | ||||
| template <typename NumericType> | template <typename NumericType> | ||||
| @@ -327,10 +327,10 @@ typename IIR::Coefficients<NumericType>::Ptr IIR::Coefficients<NumericType>::mak | |||||
| auto alphaTimesA = alpha * A; | auto alphaTimesA = alpha * A; | ||||
| auto alphaOverA = alpha / A; | auto alphaOverA = alpha / A; | ||||
| return new Coefficients (1 + alphaTimesA, c2, | |||||
| 1 - alphaTimesA, | |||||
| 1 + alphaOverA, c2, | |||||
| 1 - alphaOverA); | |||||
| return *new Coefficients (1 + alphaTimesA, c2, | |||||
| 1 - alphaTimesA, | |||||
| 1 + alphaOverA, c2, | |||||
| 1 - alphaOverA); | |||||
| } | } | ||||
| template <typename NumericType> | template <typename NumericType> | ||||
| @@ -43,7 +43,7 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| AsyncUpdater::AsyncUpdater() | AsyncUpdater::AsyncUpdater() | ||||
| { | { | ||||
| activeMessage = new AsyncUpdaterMessage (*this); | |||||
| activeMessage = *new AsyncUpdaterMessage (*this); | |||||
| } | } | ||||
| AsyncUpdater::~AsyncUpdater() | AsyncUpdater::~AsyncUpdater() | ||||
| @@ -294,7 +294,7 @@ bool MessageManager::Lock::tryAcquire (bool lockIsMandatory) const noexcept | |||||
| try | try | ||||
| { | { | ||||
| blockingMessage = new BlockingMessage (this); | |||||
| blockingMessage = *new BlockingMessage (this); | |||||
| } | } | ||||
| catch (...) | catch (...) | ||||
| { | { | ||||
| @@ -308,7 +308,7 @@ bool Font::operator!= (const Font& other) const noexcept | |||||
| void Font::dupeInternalIfShared() | void Font::dupeInternalIfShared() | ||||
| { | { | ||||
| if (font->getReferenceCount() > 1) | if (font->getReferenceCount() > 1) | ||||
| font = new SharedFontInternal (*font); | |||||
| font = *new SharedFontInternal (*font); | |||||
| } | } | ||||
| void Font::checkTypefaceSuitability() | void Font::checkTypefaceSuitability() | ||||
| @@ -118,7 +118,7 @@ Typeface::~Typeface() | |||||
| Typeface::Ptr Typeface::getFallbackTypeface() | Typeface::Ptr Typeface::getFallbackTypeface() | ||||
| { | { | ||||
| const Font fallbackFont (Font::getFallbackFontName(), Font::getFallbackFontStyle(), 10.0f); | const Font fallbackFont (Font::getFallbackFontName(), Font::getFallbackFontStyle(), 10.0f); | ||||
| return fallbackFont.getTypeface(); | |||||
| return Typeface::Ptr (fallbackFont.getTypeface()); | |||||
| } | } | ||||
| EdgeTable* Typeface::getEdgeTableForGlyph (int glyphNumber, const AffineTransform& transform, float fontHeight) | EdgeTable* Typeface::getEdgeTableForGlyph (int glyphNumber, const AffineTransform& transform, float fontHeight) | ||||
| @@ -140,9 +140,8 @@ EdgeTable* Typeface::getEdgeTableForGlyph (int glyphNumber, const AffineTransfor | |||||
| struct Typeface::HintingParams | struct Typeface::HintingParams | ||||
| { | { | ||||
| HintingParams (Typeface& t) | HintingParams (Typeface& t) | ||||
| : cachedSize (0), top (0), middle (0), bottom (0) | |||||
| { | { | ||||
| Font font (&t); | |||||
| Font font (t); | |||||
| font = font.withHeight ((float) standardHeight); | font = font.withHeight ((float) standardHeight); | ||||
| top = getAverageY (font, "BDEFPRTZOQ", true); | top = getAverageY (font, "BDEFPRTZOQ", true); | ||||
| @@ -209,7 +208,7 @@ private: | |||||
| float middle, upperScale, upperOffset, lowerScale, lowerOffset; | float middle, upperScale, upperOffset, lowerScale, lowerOffset; | ||||
| }; | }; | ||||
| float cachedSize; | |||||
| float cachedSize = 0; | |||||
| Scaling cachedScale; | Scaling cachedScale; | ||||
| static float getAverageY (const Font& font, const char* chars, bool getTop) | static float getAverageY (const Font& font, const char* chars, bool getTop) | ||||
| @@ -248,7 +247,7 @@ private: | |||||
| } | } | ||||
| enum { standardHeight = 100 }; | enum { standardHeight = 100 }; | ||||
| float top, middle, bottom; | |||||
| float top = 0, middle = 0, bottom = 0; | |||||
| }; | }; | ||||
| void Typeface::applyVerticalHintingTransform (float fontSize, Path& path) | void Typeface::applyVerticalHintingTransform (float fontSize, Path& path) | ||||
| @@ -93,7 +93,7 @@ public: | |||||
| LowLevelGraphicsContext* createLowLevelContext() override | LowLevelGraphicsContext* createLowLevelContext() override | ||||
| { | { | ||||
| sendDataChangeMessage(); | sendDataChangeMessage(); | ||||
| return new LowLevelGraphicsSoftwareRenderer (Image (this)); | |||||
| return new LowLevelGraphicsSoftwareRenderer (Image (*this)); | |||||
| } | } | ||||
| void initialiseBitmapData (Image::BitmapData& bitmap, int x, int y, Image::BitmapData::ReadWriteMode mode) override | void initialiseBitmapData (Image::BitmapData& bitmap, int x, int y, Image::BitmapData::ReadWriteMode mode) override | ||||
| @@ -109,9 +109,9 @@ public: | |||||
| ImagePixelData::Ptr clone() override | ImagePixelData::Ptr clone() override | ||||
| { | { | ||||
| SoftwarePixelData* s = new SoftwarePixelData (pixelFormat, width, height, false); | |||||
| auto s = new SoftwarePixelData (pixelFormat, width, height, false); | |||||
| memcpy (s->imageData, imageData, (size_t) lineStride * (size_t) height); | memcpy (s->imageData, imageData, (size_t) lineStride * (size_t) height); | ||||
| return s; | |||||
| return *s; | |||||
| } | } | ||||
| ImageType* createType() const override { return new SoftwareImageType(); } | ImageType* createType() const override { return new SoftwareImageType(); } | ||||
| @@ -128,7 +128,7 @@ SoftwareImageType::~SoftwareImageType() {} | |||||
| ImagePixelData::Ptr SoftwareImageType::create (Image::PixelFormat format, int width, int height, bool clearImage) const | ImagePixelData::Ptr SoftwareImageType::create (Image::PixelFormat format, int width, int height, bool clearImage) const | ||||
| { | { | ||||
| return new SoftwarePixelData (format, width, height, clearImage); | |||||
| return *new SoftwarePixelData (format, width, height, clearImage); | |||||
| } | } | ||||
| int SoftwareImageType::getTypeID() const | int SoftwareImageType::getTypeID() const | ||||
| @@ -187,10 +187,10 @@ public: | |||||
| { | { | ||||
| Graphics g (newImage); | Graphics g (newImage); | ||||
| g.drawImageAt (Image (this), 0, 0); | |||||
| g.drawImageAt (Image (*this), 0, 0); | |||||
| } | } | ||||
| return newImage.getPixelData(); | |||||
| return *newImage.getPixelData(); | |||||
| } | } | ||||
| ImageType* createType() const override { return sourceImage->createType(); } | ImageType* createType() const override { return sourceImage->createType(); } | ||||
| @@ -216,7 +216,7 @@ Image Image::getClippedImage (const Rectangle<int>& area) const | |||||
| if (validArea.isEmpty()) | if (validArea.isEmpty()) | ||||
| return {}; | return {}; | ||||
| return Image (new SubsectionPixelData (image, validArea)); | |||||
| return Image (*new SubsectionPixelData (image, validArea)); | |||||
| } | } | ||||
| @@ -216,7 +216,7 @@ private: | |||||
| { | { | ||||
| for (auto g : glyphs) | for (auto g : glyphs) | ||||
| if (g->glyph == glyphNumber && g->font == font) | if (g->glyph == glyphNumber && g->font == font) | ||||
| return g; | |||||
| return *g; | |||||
| return {}; | return {}; | ||||
| } | } | ||||
| @@ -232,8 +232,8 @@ private: | |||||
| misses = 0; | misses = 0; | ||||
| } | } | ||||
| if (auto* g = findLeastRecentlyUsedGlyph()) | |||||
| return g; | |||||
| if (auto g = findLeastRecentlyUsedGlyph()) | |||||
| return *g; | |||||
| addNewGlyphSlots (32); | addNewGlyphSlots (32); | ||||
| return glyphs.getLast(); | return glyphs.getLast(); | ||||
| @@ -1670,13 +1670,13 @@ struct ClipRegions | |||||
| using Ptr = typename Base::Ptr; | using Ptr = typename Base::Ptr; | ||||
| Ptr clone() const override { return new EdgeTableRegion (*this); } | |||||
| Ptr clone() const override { return *new EdgeTableRegion (*this); } | |||||
| Ptr applyClipTo (const Ptr& target) const override { return target->clipToEdgeTable (edgeTable); } | Ptr applyClipTo (const Ptr& target) const override { return target->clipToEdgeTable (edgeTable); } | ||||
| Ptr clipToRectangle (Rectangle<int> r) override | Ptr clipToRectangle (Rectangle<int> r) override | ||||
| { | { | ||||
| edgeTable.clipToRectangle (r); | edgeTable.clipToRectangle (r); | ||||
| return edgeTable.isEmpty() ? nullptr : this; | |||||
| return edgeTable.isEmpty() ? Ptr() : Ptr (*this); | |||||
| } | } | ||||
| Ptr clipToRectangleList (const RectangleList<int>& r) override | Ptr clipToRectangleList (const RectangleList<int>& r) override | ||||
| @@ -1687,26 +1687,26 @@ struct ClipRegions | |||||
| for (auto& i : inverse) | for (auto& i : inverse) | ||||
| edgeTable.excludeRectangle (i); | edgeTable.excludeRectangle (i); | ||||
| return edgeTable.isEmpty() ? nullptr : this; | |||||
| return edgeTable.isEmpty() ? Ptr() : Ptr (*this); | |||||
| } | } | ||||
| Ptr excludeClipRectangle (Rectangle<int> r) override | Ptr excludeClipRectangle (Rectangle<int> r) override | ||||
| { | { | ||||
| edgeTable.excludeRectangle (r); | edgeTable.excludeRectangle (r); | ||||
| return edgeTable.isEmpty() ? nullptr : this; | |||||
| return edgeTable.isEmpty() ? Ptr() : Ptr (*this); | |||||
| } | } | ||||
| Ptr clipToPath (const Path& p, const AffineTransform& transform) override | Ptr clipToPath (const Path& p, const AffineTransform& transform) override | ||||
| { | { | ||||
| EdgeTable et (edgeTable.getMaximumBounds(), p, transform); | EdgeTable et (edgeTable.getMaximumBounds(), p, transform); | ||||
| edgeTable.clipToEdgeTable (et); | edgeTable.clipToEdgeTable (et); | ||||
| return edgeTable.isEmpty() ? nullptr : this; | |||||
| return edgeTable.isEmpty() ? Ptr() : Ptr (*this); | |||||
| } | } | ||||
| Ptr clipToEdgeTable (const EdgeTable& et) override | Ptr clipToEdgeTable (const EdgeTable& et) override | ||||
| { | { | ||||
| edgeTable.clipToEdgeTable (et); | edgeTable.clipToEdgeTable (et); | ||||
| return edgeTable.isEmpty() ? nullptr : this; | |||||
| return edgeTable.isEmpty() ? Ptr() : Ptr (*this); | |||||
| } | } | ||||
| Ptr clipToImageAlpha (const Image& image, const AffineTransform& transform, Graphics::ResamplingQuality quality) override | Ptr clipToImageAlpha (const Image& image, const AffineTransform& transform, Graphics::ResamplingQuality quality) override | ||||
| @@ -1729,7 +1729,7 @@ struct ClipRegions | |||||
| else | else | ||||
| straightClipImage (srcData, imageX, imageY, (PixelAlpha*) 0); | straightClipImage (srcData, imageX, imageY, (PixelAlpha*) 0); | ||||
| return edgeTable.isEmpty() ? nullptr : this; | |||||
| return edgeTable.isEmpty() ? Ptr() : Ptr (*this); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1751,7 +1751,7 @@ struct ClipRegions | |||||
| transformedClipImage (srcData, transform, quality, (PixelAlpha*) 0); | transformedClipImage (srcData, transform, quality, (PixelAlpha*) 0); | ||||
| } | } | ||||
| return edgeTable.isEmpty() ? nullptr : this; | |||||
| return edgeTable.isEmpty() ? Ptr() : Ptr (*this); | |||||
| } | } | ||||
| void translate (Point<int> delta) override | void translate (Point<int> delta) override | ||||
| @@ -1851,25 +1851,25 @@ struct ClipRegions | |||||
| using Ptr = typename Base::Ptr; | using Ptr = typename Base::Ptr; | ||||
| Ptr clone() const override { return new RectangleListRegion (*this); } | |||||
| Ptr clone() const override { return *new RectangleListRegion (*this); } | |||||
| Ptr applyClipTo (const Ptr& target) const override { return target->clipToRectangleList (clip); } | Ptr applyClipTo (const Ptr& target) const override { return target->clipToRectangleList (clip); } | ||||
| Ptr clipToRectangle (Rectangle<int> r) override | Ptr clipToRectangle (Rectangle<int> r) override | ||||
| { | { | ||||
| clip.clipTo (r); | clip.clipTo (r); | ||||
| return clip.isEmpty() ? nullptr : this; | |||||
| return clip.isEmpty() ? Ptr() : Ptr (*this); | |||||
| } | } | ||||
| Ptr clipToRectangleList (const RectangleList<int>& r) override | Ptr clipToRectangleList (const RectangleList<int>& r) override | ||||
| { | { | ||||
| clip.clipTo (r); | clip.clipTo (r); | ||||
| return clip.isEmpty() ? nullptr : this; | |||||
| return clip.isEmpty() ? Ptr() : Ptr (*this); | |||||
| } | } | ||||
| Ptr excludeClipRectangle (Rectangle<int> r) override | Ptr excludeClipRectangle (Rectangle<int> r) override | ||||
| { | { | ||||
| clip.subtract (r); | clip.subtract (r); | ||||
| return clip.isEmpty() ? nullptr : this; | |||||
| return clip.isEmpty() ? Ptr() : Ptr (*this); | |||||
| } | } | ||||
| Ptr clipToPath (const Path& p, const AffineTransform& transform) override { return toEdgeTable()->clipToPath (p, transform); } | Ptr clipToPath (const Path& p, const AffineTransform& transform) override { return toEdgeTable()->clipToPath (p, transform); } | ||||
| @@ -2068,7 +2068,7 @@ struct ClipRegions | |||||
| JUCE_DECLARE_NON_COPYABLE (SubRectangleIteratorFloat) | JUCE_DECLARE_NON_COPYABLE (SubRectangleIteratorFloat) | ||||
| }; | }; | ||||
| Ptr toEdgeTable() const { return new EdgeTableRegion (clip); } | |||||
| Ptr toEdgeTable() const { return *new EdgeTableRegion (clip); } | |||||
| RectangleListRegion& operator= (const RectangleListRegion&); | RectangleListRegion& operator= (const RectangleListRegion&); | ||||
| }; | }; | ||||
| @@ -2267,7 +2267,7 @@ public: | |||||
| auto clipped = clip->getClipBounds().getIntersection (r); | auto clipped = clip->getClipBounds().getIntersection (r); | ||||
| if (! clipped.isEmpty()) | if (! clipped.isEmpty()) | ||||
| fillShape (new RectangleListRegionType (clipped), false); | |||||
| fillShape (*new RectangleListRegionType (clipped), false); | |||||
| } | } | ||||
| } | } | ||||
| @@ -2282,7 +2282,7 @@ public: | |||||
| auto clipped = clip->getClipBounds().toFloat().getIntersection (r); | auto clipped = clip->getClipBounds().toFloat().getIntersection (r); | ||||
| if (! clipped.isEmpty()) | if (! clipped.isEmpty()) | ||||
| fillShape (new EdgeTableRegionType (clipped), false); | |||||
| fillShape (*new EdgeTableRegionType (clipped), false); | |||||
| } | } | ||||
| } | } | ||||
| @@ -2336,7 +2336,7 @@ public: | |||||
| if (transform.isIdentity()) | if (transform.isIdentity()) | ||||
| { | { | ||||
| fillShape (new EdgeTableRegionType (list), false); | |||||
| fillShape (*new EdgeTableRegionType (list), false); | |||||
| } | } | ||||
| else if (! transform.isRotated) | else if (! transform.isRotated) | ||||
| { | { | ||||
| @@ -2347,7 +2347,7 @@ public: | |||||
| else | else | ||||
| transformed.transformAll (transform.getTransform()); | transformed.transformAll (transform.getTransform()); | ||||
| fillShape (new EdgeTableRegionType (transformed), false); | |||||
| fillShape (*new EdgeTableRegionType (transformed), false); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -2364,7 +2364,7 @@ public: | |||||
| auto clipRect = clip->getClipBounds(); | auto clipRect = clip->getClipBounds(); | ||||
| if (path.getBoundsTransformed (trans).getSmallestIntegerContainer().intersects (clipRect)) | if (path.getBoundsTransformed (trans).getSmallestIntegerContainer().intersects (clipRect)) | ||||
| fillShape (new EdgeTableRegionType (clipRect, path, trans), false); | |||||
| fillShape (*new EdgeTableRegionType (clipRect, path, trans), false); | |||||
| } | } | ||||
| } | } | ||||
| @@ -2383,7 +2383,7 @@ public: | |||||
| edgeTableClip->edgeTable.multiplyLevels (1.0f + 1.6f * brightness); | edgeTableClip->edgeTable.multiplyLevels (1.0f + 1.6f * brightness); | ||||
| } | } | ||||
| fillShape (edgeTableClip, false); | |||||
| fillShape (*edgeTableClip, false); | |||||
| } | } | ||||
| } | } | ||||
| @@ -2434,7 +2434,7 @@ public: | |||||
| area = area.getIntersection (getThis().getMaximumBounds()); | area = area.getIntersection (getThis().getMaximumBounds()); | ||||
| if (! area.isEmpty()) | if (! area.isEmpty()) | ||||
| if (auto c = clip->applyClipTo (new EdgeTableRegionType (area))) | |||||
| if (auto c = clip->applyClipTo (*new EdgeTableRegionType (area))) | |||||
| c->renderImageUntransformed (getThis(), sourceImage, alpha, tx, ty, false); | c->renderImageUntransformed (getThis(), sourceImage, alpha, tx, ty, false); | ||||
| } | } | ||||
| @@ -2609,7 +2609,7 @@ public: | |||||
| std::unique_ptr<EdgeTable> et (font.getTypeface()->getEdgeTableForGlyph (glyphNumber, t, fontHeight)); | std::unique_ptr<EdgeTable> et (font.getTypeface()->getEdgeTableForGlyph (glyphNumber, t, fontHeight)); | ||||
| if (et != nullptr) | if (et != nullptr) | ||||
| fillShape (new EdgeTableRegionType (*et), false); | |||||
| fillShape (*new EdgeTableRegionType (*et), false); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -78,7 +78,7 @@ public: | |||||
| { | { | ||||
| auto im = new CoreGraphicsImage (pixelFormat, width, height, false); | auto im = new CoreGraphicsImage (pixelFormat, width, height, false); | ||||
| memcpy (im->imageData, imageData, (size_t) (lineStride * height)); | memcpy (im->imageData, imageData, (size_t) (lineStride * height)); | ||||
| return im; | |||||
| return *im; | |||||
| } | } | ||||
| ImageType* createType() const override { return new NativeImageType(); } | ImageType* createType() const override { return new NativeImageType(); } | ||||
| @@ -162,7 +162,7 @@ private: | |||||
| ImagePixelData::Ptr NativeImageType::create (Image::PixelFormat format, int width, int height, bool clearImage) const | ImagePixelData::Ptr NativeImageType::create (Image::PixelFormat format, int width, int height, bool clearImage) const | ||||
| { | { | ||||
| return new CoreGraphicsImage (format == Image::RGB ? Image::ARGB : format, width, height, clearImage); | |||||
| return *new CoreGraphicsImage (format == Image::RGB ? Image::ARGB : format, width, height, clearImage); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -896,7 +896,7 @@ Image juce_createImageFromCIImage (CIImage* im, int w, int h) | |||||
| [cic drawImage: im inRect: CGRectMake (0, 0, w, h) fromRect: CGRectMake (0, 0, w, h)]; | [cic drawImage: im inRect: CGRectMake (0, 0, w, h) fromRect: CGRectMake (0, 0, w, h)]; | ||||
| CGContextFlush (cgImage->context); | CGContextFlush (cgImage->context); | ||||
| return Image (cgImage); | |||||
| return Image (*cgImage); | |||||
| } | } | ||||
| CGImageRef juce_createCoreGraphicsImage (const Image& juceImage, CGColorSpaceRef colourSpace, | CGImageRef juce_createCoreGraphicsImage (const Image& juceImage, CGColorSpaceRef colourSpace, | ||||
| @@ -788,8 +788,8 @@ StringArray Font::findAllTypefaceStyles (const String& family) | |||||
| //============================================================================== | //============================================================================== | ||||
| Typeface::Ptr Typeface::createSystemTypefaceFor (const Font& font) { return new OSXTypeface (font); } | |||||
| Typeface::Ptr Typeface::createSystemTypefaceFor (const void* data, size_t size) { return new OSXTypeface (data, size); } | |||||
| Typeface::Ptr Typeface::createSystemTypefaceFor (const Font& font) { return *new OSXTypeface (font); } | |||||
| Typeface::Ptr Typeface::createSystemTypefaceFor (const void* data, size_t size) { return *new OSXTypeface (data, size); } | |||||
| void Typeface::scanFolderForFonts (const File&) | void Typeface::scanFolderForFonts (const File&) | ||||
| { | { | ||||
| @@ -147,7 +147,7 @@ void LookAndFeel::setDefaultSansSerifTypefaceName (const String& newName) | |||||
| { | { | ||||
| if (defaultSans != newName) | if (defaultSans != newName) | ||||
| { | { | ||||
| defaultTypeface = {}; | |||||
| defaultTypeface.reset(); | |||||
| Typeface::clearTypefaceCache(); | Typeface::clearTypefaceCache(); | ||||
| defaultSans = newName; | defaultSans = newName; | ||||
| } | } | ||||
| @@ -77,7 +77,7 @@ struct ItemComponent : public Component | |||||
| : item (i), customComp (i.customComponent) | : item (i), customComp (i.customComponent) | ||||
| { | { | ||||
| if (item.isSectionHeader) | if (item.isSectionHeader) | ||||
| customComp = new HeaderItemComponent (item.text); | |||||
| customComp = *new HeaderItemComponent (item.text); | |||||
| if (customComp != nullptr) | if (customComp != nullptr) | ||||
| addAndMakeVisible (*customComp); | addAndMakeVisible (*customComp); | ||||
| @@ -589,16 +589,25 @@ public: | |||||
| void execute (OpenGLContext::AsyncWorker::Ptr workerToUse, bool shouldBlock, bool calledFromDestructor = false) | void execute (OpenGLContext::AsyncWorker::Ptr workerToUse, bool shouldBlock, bool calledFromDestructor = false) | ||||
| { | { | ||||
| if (calledFromDestructor || destroying.get() == 0) | if (calledFromDestructor || destroying.get() == 0) | ||||
| { | |||||
| BlockingWorker* blocker = (shouldBlock ? new BlockingWorker (static_cast<OpenGLContext::AsyncWorker::Ptr&&> (workerToUse)) : nullptr); | |||||
| OpenGLContext::AsyncWorker::Ptr worker = (blocker != nullptr ? blocker : static_cast<OpenGLContext::AsyncWorker::Ptr&&> (workerToUse)); | |||||
| workQueue.add (worker); | |||||
| messageManagerLock.abort(); | |||||
| context.triggerRepaint(); | |||||
| if (blocker != nullptr) | |||||
| blocker->block(); | |||||
| { | |||||
| if (shouldBlock) | |||||
| { | |||||
| auto blocker = new BlockingWorker (static_cast<OpenGLContext::AsyncWorker::Ptr&&> (workerToUse)); | |||||
| OpenGLContext::AsyncWorker::Ptr worker (*blocker); | |||||
| workQueue.add (worker); | |||||
| messageManagerLock.abort(); | |||||
| context.triggerRepaint(); | |||||
| blocker->block(); | |||||
| } | |||||
| else | |||||
| { | |||||
| workQueue.add (static_cast<OpenGLContext::AsyncWorker::Ptr&&> (workerToUse)); | |||||
| messageManagerLock.abort(); | |||||
| context.triggerRepaint(); | |||||
| } | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -111,10 +111,10 @@ struct CachedImageList : public ReferenceCountedObject, | |||||
| { | { | ||||
| TextureInfo t; | TextureInfo t; | ||||
| if (textureNeedsReloading) | |||||
| if (textureNeedsReloading && pixelData != nullptr) | |||||
| { | { | ||||
| textureNeedsReloading = false; | textureNeedsReloading = false; | ||||
| texture.loadImage (Image (pixelData)); | |||||
| texture.loadImage (Image (*pixelData)); | |||||
| } | } | ||||
| t.textureID = texture.getTextureID(); | t.textureID = texture.getTextureID(); | ||||
| @@ -1660,7 +1660,7 @@ struct SavedState : public RenderingHelpers::SavedStateBase<SavedState> | |||||
| const std::unique_ptr<EdgeTable> et (font.getTypeface()->getEdgeTableForGlyph (glyphNumber, t, fontHeight)); | const std::unique_ptr<EdgeTable> et (font.getTypeface()->getEdgeTableForGlyph (glyphNumber, t, fontHeight)); | ||||
| if (et != nullptr) | if (et != nullptr) | ||||
| fillShape (new EdgeTableRegionType (*et), false); | |||||
| fillShape (*new EdgeTableRegionType (*et), false); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -1844,8 +1844,9 @@ struct CustomProgram : public ReferenceCountedObject, | |||||
| static ReferenceCountedObjectPtr<CustomProgram> get (const String& hashName) | static ReferenceCountedObjectPtr<CustomProgram> get (const String& hashName) | ||||
| { | { | ||||
| if (auto* c = OpenGLContext::getCurrentContext()) | |||||
| return static_cast<CustomProgram*> (c->getAssociatedObject (hashName.toRawUTF8())); | |||||
| if (auto* c = OpenGLContext::getCurrentContext()) | |||||
| if (auto* o = c->getAssociatedObject (hashName.toRawUTF8())) | |||||
| return *static_cast<CustomProgram*> (o); | |||||
| return {}; | return {}; | ||||
| } | } | ||||
| @@ -53,11 +53,11 @@ public: | |||||
| ImagePixelData::Ptr clone() override | ImagePixelData::Ptr clone() override | ||||
| { | { | ||||
| Image newImage (new OpenGLFrameBufferImage (context, width, height)); | |||||
| Image newImage (*new OpenGLFrameBufferImage (context, width, height)); | |||||
| Graphics g (newImage); | Graphics g (newImage); | ||||
| g.drawImageAt (Image (this), 0, 0, false); | |||||
| g.drawImageAt (Image (*this), 0, 0, false); | |||||
| return newImage.getPixelData(); | |||||
| return ImagePixelData::Ptr (newImage.getPixelData()); | |||||
| } | } | ||||
| void initialiseBitmapData (Image::BitmapData& bitmapData, int x, int y, Image::BitmapData::ReadWriteMode mode) override | void initialiseBitmapData (Image::BitmapData& bitmapData, int x, int y, Image::BitmapData::ReadWriteMode mode) override | ||||
| @@ -193,7 +193,7 @@ ImagePixelData::Ptr OpenGLImageType::create (Image::PixelFormat, int width, int | |||||
| return ImagePixelData::Ptr(); | return ImagePixelData::Ptr(); | ||||
| im->frameBuffer.clear (Colours::transparentBlack); | im->frameBuffer.clear (Colours::transparentBlack); | ||||
| return im.release(); | |||||
| return *im.release(); | |||||
| } | } | ||||
| OpenGLFrameBuffer* OpenGLImageType::getFrameBufferFrom (const Image& image) | OpenGLFrameBuffer* OpenGLImageType::getFrameBufferFrom (const Image& image) | ||||