| @@ -269,10 +269,10 @@ struct LicenseThread : NetWorkerThread | |||
| 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), | |||
| true)); | |||
| @@ -295,12 +295,12 @@ struct LicenseThread : NetWorkerThread | |||
| if (chosenLicenseType.isNotEmpty()) | |||
| { | |||
| // redeem the license | |||
| DynamicObject::Ptr jsonLicenseObject = new DynamicObject(); | |||
| DynamicObject::Ptr jsonLicenseObject (new DynamicObject()); | |||
| jsonLicenseObject->setProperty (projucerLicenseTypeIdentifier, chosenLicenseType); | |||
| jsonLicenseObject->setProperty (versionIdentifier, 5); | |||
| DynamicObject::Ptr jsonLicenseRequest = new DynamicObject(); | |||
| DynamicObject::Ptr jsonLicenseRequest (new DynamicObject()); | |||
| jsonLicenseRequest->setProperty (licenseIdentifier, var (jsonLicenseObject.get())); | |||
| jsonLicenseRequest->setProperty (searchInternalIdentifier, "com.roli.projucer"); | |||
| jsonLicenseRequest->setProperty (licenseTypeIdentifier, "software"); | |||
| @@ -119,7 +119,7 @@ struct ChildProcessCache | |||
| { | |||
| for (auto& p : processes) | |||
| if (&(p->project) == &project) | |||
| return p; | |||
| return *p; | |||
| return {}; | |||
| } | |||
| @@ -132,7 +132,7 @@ struct ChildProcessCache | |||
| auto p = new CompileEngineChildProcess (project); | |||
| tellNewProcessAboutExistingEditors (*p); | |||
| processes.add (p); | |||
| return p; | |||
| return *p; | |||
| } | |||
| static void tellNewProcessAboutExistingEditors (CompileEngineChildProcess& process) | |||
| @@ -355,7 +355,7 @@ protected: | |||
| BuildConfiguration::Ptr createBuildConfig (const ValueTree& v) const override | |||
| { | |||
| return new AndroidBuildConfiguration (project, v, *this); | |||
| return *new AndroidBuildConfiguration (project, v, *this); | |||
| } | |||
| private: | |||
| @@ -49,7 +49,7 @@ protected: | |||
| BuildConfiguration::Ptr createBuildConfig (const ValueTree& tree) const override | |||
| { | |||
| return new CLionBuildConfiguration (project, tree, *this); | |||
| return *new CLionBuildConfiguration (project, tree, *this); | |||
| } | |||
| public: | |||
| @@ -235,7 +235,7 @@ private: | |||
| 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 | |||
| { | |||
| return new MSVCBuildConfiguration (project, v, *this); | |||
| return *new MSVCBuildConfiguration (project, v, *this); | |||
| } | |||
| StringArray getHeaderSearchPaths (const BuildConfiguration& config) const | |||
| @@ -78,7 +78,7 @@ protected: | |||
| BuildConfiguration::Ptr createBuildConfig (const ValueTree& tree) const override | |||
| { | |||
| return new MakeBuildConfiguration (project, tree, *this); | |||
| return *new MakeBuildConfiguration (project, tree, *this); | |||
| } | |||
| public: | |||
| @@ -625,7 +625,7 @@ protected: | |||
| BuildConfiguration::Ptr createBuildConfig (const ValueTree& v) const override | |||
| { | |||
| return new XcodeBuildConfiguration (project, v, iOS, *this); | |||
| return *new XcodeBuildConfiguration (project, v, iOS, *this); | |||
| } | |||
| public: | |||
| @@ -3078,7 +3078,7 @@ private: | |||
| for (auto& type : getiOSAppIconTypes()) | |||
| { | |||
| DynamicObject::Ptr d = new DynamicObject(); | |||
| DynamicObject::Ptr d (new DynamicObject()); | |||
| d->setProperty ("idiom", type.idiom); | |||
| d->setProperty ("size", type.sizeString); | |||
| d->setProperty ("filename", type.filename); | |||
| @@ -3146,7 +3146,7 @@ private: | |||
| for (auto& type : getiOSLaunchImageTypes()) | |||
| { | |||
| DynamicObject::Ptr d = new DynamicObject(); | |||
| DynamicObject::Ptr d (new DynamicObject()); | |||
| d->setProperty ("orientation", type.orientation); | |||
| d->setProperty ("idiom", type.idiom); | |||
| d->setProperty ("extent", type.extent); | |||
| @@ -686,7 +686,7 @@ struct RenderSequenceBuilder | |||
| if (numOuts == 0) | |||
| totalLatency = maxLatency; | |||
| sequence.addProcessOp (&node, audioChannelsToUse, totalChans, midiBufferToUse); | |||
| sequence.addProcessOp (node, audioChannelsToUse, totalChans, midiBufferToUse); | |||
| } | |||
| //============================================================================== | |||
| @@ -1318,7 +1318,7 @@ struct PhysicalTopologySource::Internal | |||
| 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) | |||
| if (block->uid == uid) | |||
| return block; | |||
| return *block; | |||
| return {}; | |||
| } | |||
| @@ -178,7 +178,7 @@ public: | |||
| */ | |||
| 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 | |||
| @@ -189,7 +189,7 @@ public: | |||
| */ | |||
| 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. | |||
| @@ -253,7 +253,7 @@ public: | |||
| if (numUsed > 0) | |||
| { | |||
| jassert (data.elements != nullptr); | |||
| return data.elements[numUsed - 1]; | |||
| return ObjectClassPtr (data.elements[numUsed - 1]); | |||
| } | |||
| return {}; | |||
| @@ -81,13 +81,13 @@ struct JavascriptEngine::RootObject : public DynamicObject | |||
| void execute (const String& 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) | |||
| { | |||
| 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) | |||
| 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 false; | |||
| @@ -833,7 +833,7 @@ struct JavascriptEngine::RootObject : public DynamicObject | |||
| 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 | |||
| { | |||
| @@ -1875,7 +1875,7 @@ var JavascriptEngine::callFunction (const Identifier& function, const var::Nativ | |||
| { | |||
| prepareTimeout(); | |||
| 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) | |||
| { | |||
| @@ -1894,8 +1894,9 @@ var JavascriptEngine::callFunctionObject (DynamicObject* objectScope, const var& | |||
| { | |||
| prepareTimeout(); | |||
| 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) | |||
| { | |||
| @@ -112,9 +112,9 @@ struct Expression::Helpers | |||
| Type getType() const noexcept { return constantType; } | |||
| 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; } | |||
| TermPtr negated() { return new Constant (-value, isResolutionTarget); } | |||
| TermPtr negated() { return *new Constant (-value, isResolutionTarget); } | |||
| String toString() const | |||
| { | |||
| @@ -152,15 +152,15 @@ struct Expression::Helpers | |||
| 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 s; | |||
| const int ourPrecendence = getOperatorPrecedence(); | |||
| auto ourPrecendence = getOperatorPrecedence(); | |||
| if (left->getOperatorPrecedence() > ourPrecendence) | |||
| s << '(' << left->toString() << ')'; | |||
| else | |||
| @@ -188,7 +188,7 @@ struct Expression::Helpers | |||
| if (auto dest = findDestinationFor (topLevelTerm, this)) | |||
| 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); | |||
| } | |||
| return new Constant (result, false); | |||
| return *new Constant (result, false); | |||
| } | |||
| int getInputIndexFor (const Term* possibleInput) const | |||
| @@ -300,7 +300,7 @@ struct Expression::Helpers | |||
| class DotOperator : public BinaryTerm | |||
| { | |||
| 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) | |||
| { | |||
| @@ -311,7 +311,7 @@ struct Expression::Helpers | |||
| return visitor.output; | |||
| } | |||
| Term* clone() const { return new DotOperator (getSymbol(), right.get()); } | |||
| Term* clone() const { return new DotOperator (getSymbol(), *right); } | |||
| String getName() const { return "."; } | |||
| int getOperatorPrecedence() const { return 1; } | |||
| 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 getNumInputs() const { return 1; } | |||
| 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) | |||
| { | |||
| return new Constant (-input->resolve (scope, recursionDepth)->toDouble(), false); | |||
| return *new Constant (-input->resolve (scope, recursionDepth)->toDouble(), false); | |||
| } | |||
| String getName() const { return "-"; } | |||
| @@ -431,8 +431,8 @@ struct Expression::Helpers | |||
| 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 | |||
| @@ -453,7 +453,7 @@ struct Expression::Helpers | |||
| public: | |||
| 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; } | |||
| int getOperatorPrecedence() const { return 3; } | |||
| String getName() const { return "+"; } | |||
| @@ -462,7 +462,7 @@ struct Expression::Helpers | |||
| TermPtr createTermToEvaluateInput (const Scope& scope, const Term* input, double overallTarget, Term* topLevelTerm) const | |||
| { | |||
| 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 {}; | |||
| } | |||
| @@ -477,7 +477,7 @@ struct Expression::Helpers | |||
| public: | |||
| 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; } | |||
| int getOperatorPrecedence() const { return 3; } | |||
| String getName() const { return "-"; } | |||
| @@ -488,9 +488,9 @@ struct Expression::Helpers | |||
| if (auto newDest = createDestinationTerm (scope, input, overallTarget, topLevelTerm)) | |||
| { | |||
| 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 {}; | |||
| @@ -506,7 +506,7 @@ struct Expression::Helpers | |||
| public: | |||
| 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; } | |||
| String getName() const { return "*"; } | |||
| 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 | |||
| { | |||
| 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 {}; | |||
| } | |||
| @@ -529,7 +529,7 @@ struct Expression::Helpers | |||
| public: | |||
| 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; } | |||
| String getName() const { return "/"; } | |||
| 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 | |||
| { | |||
| const TermPtr newDest (createDestinationTerm (scope, input, overallTarget, topLevelTerm)); | |||
| auto newDest = createDestinationTerm (scope, input, overallTarget, topLevelTerm); | |||
| if (newDest == nullptr) | |||
| return {}; | |||
| 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) | |||
| @@ -598,11 +599,8 @@ struct Expression::Helpers | |||
| } | |||
| 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 nullptr; | |||
| } | |||
| @@ -659,9 +657,9 @@ struct Expression::Helpers | |||
| TermPtr readUpToComma() | |||
| { | |||
| 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())) | |||
| return parseError ("Syntax error: \"" + String (text) + "\""); | |||
| @@ -674,12 +672,12 @@ struct Expression::Helpers | |||
| private: | |||
| String::CharPointerType& text; | |||
| Term* parseError (const String& message) | |||
| TermPtr parseError (const String& message) | |||
| { | |||
| if (error.isEmpty()) | |||
| error = message; | |||
| return nullptr; | |||
| return {}; | |||
| } | |||
| //============================================================================== | |||
| @@ -774,20 +772,20 @@ struct Expression::Helpers | |||
| TermPtr readExpression() | |||
| { | |||
| TermPtr lhs (readMultiplyOrDivideExpression()); | |||
| auto lhs = readMultiplyOrDivideExpression(); | |||
| char opType; | |||
| while (lhs != nullptr && readOperator ("+-", &opType)) | |||
| { | |||
| TermPtr rhs (readMultiplyOrDivideExpression()); | |||
| auto rhs = readMultiplyOrDivideExpression(); | |||
| if (rhs == nullptr) | |||
| return parseError ("Expected expression after \"" + String::charToString ((juce_wchar) (uint8) opType) + "\""); | |||
| if (opType == '+') | |||
| lhs = new Add (lhs, rhs); | |||
| lhs = *new Add (lhs, rhs); | |||
| else | |||
| lhs = new Subtract (lhs, rhs); | |||
| lhs = *new Subtract (lhs, rhs); | |||
| } | |||
| return lhs; | |||
| @@ -795,9 +793,9 @@ struct Expression::Helpers | |||
| TermPtr readMultiplyOrDivideExpression() | |||
| { | |||
| TermPtr lhs (readUnaryExpression()); | |||
| auto lhs = readUnaryExpression(); | |||
| char opType; | |||
| while (lhs != nullptr && readOperator ("*/", &opType)) | |||
| { | |||
| TermPtr rhs (readUnaryExpression()); | |||
| @@ -806,9 +804,9 @@ struct Expression::Helpers | |||
| return parseError ("Expected expression after \"" + String::charToString ((juce_wchar) (uint8) opType) + "\""); | |||
| if (opType == '*') | |||
| lhs = new Multiply (lhs, rhs); | |||
| lhs = *new Multiply (lhs, rhs); | |||
| else | |||
| lhs = new Divide (lhs, rhs); | |||
| lhs = *new Divide (lhs, rhs); | |||
| } | |||
| return lhs; | |||
| @@ -835,12 +833,10 @@ struct Expression::Helpers | |||
| TermPtr readPrimaryExpression() | |||
| { | |||
| TermPtr e (readParenthesisedExpression()); | |||
| if (e != nullptr) | |||
| if (auto e = readParenthesisedExpression()) | |||
| return e; | |||
| e = readNumber(); | |||
| if (e != nullptr) | |||
| if (auto e = readNumber()) | |||
| return e; | |||
| return readSymbolOrFunction(); | |||
| @@ -848,20 +844,21 @@ struct Expression::Helpers | |||
| TermPtr readSymbolOrFunction() | |||
| { | |||
| String identifier; | |||
| String identifier; | |||
| if (readIdentifier (identifier)) | |||
| { | |||
| 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) | |||
| TermPtr param (readExpression()); | |||
| auto param = readExpression(); | |||
| if (param == nullptr) | |||
| { | |||
| if (readOperator (")")) | |||
| return func.release(); | |||
| return TermPtr (func.release()); | |||
| return parseError ("Expected parameters after \"" + identifier + " (\""); | |||
| } | |||
| @@ -879,7 +876,7 @@ struct Expression::Helpers | |||
| } | |||
| if (readOperator (")")) | |||
| return func.release(); | |||
| return TermPtr (func.release()); | |||
| return parseError ("Expected \")\""); | |||
| } | |||
| @@ -894,12 +891,12 @@ struct Expression::Helpers | |||
| if (identifier == "this") | |||
| return rhs; | |||
| return new DotOperator (new SymbolTerm (identifier), rhs); | |||
| return *new DotOperator (new SymbolTerm (identifier), rhs); | |||
| } | |||
| // just a symbol.. | |||
| jassert (identifier.trim() == identifier); | |||
| return new SymbolTerm (identifier); | |||
| return *new SymbolTerm (identifier); | |||
| } | |||
| return {}; | |||
| @@ -910,7 +907,8 @@ struct Expression::Helpers | |||
| if (! readOperator ("(")) | |||
| return {}; | |||
| const TermPtr e (readExpression()); | |||
| auto e = readExpression(); | |||
| if (e == nullptr || ! readOperator (")")) | |||
| return {}; | |||
| @@ -1020,14 +1018,14 @@ Expression Expression::adjustedToGiveNewResult (const double targetValue, const | |||
| { | |||
| 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) | |||
| termToAdjust = Helpers::findTermToAdjust (newTerm.get(), false); | |||
| 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); | |||
| } | |||
| @@ -1095,7 +1093,7 @@ Expression Expression::getInput (int index) const { return Expression (ter | |||
| //============================================================================== | |||
| ReferenceCountedObjectPtr<Expression::Term> Expression::Term::negated() | |||
| { | |||
| return new Helpers::Negate (this); | |||
| return *new Helpers::Negate (*this); | |||
| } | |||
| //============================================================================== | |||
| @@ -260,6 +260,15 @@ public: | |||
| 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. | |||
| 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 | |||
| 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. */ | |||
| ReferenceCountedObjectPtr& operator= (ReferenceCountedObjectPtr&& other) noexcept | |||
| { | |||
| @@ -335,8 +365,8 @@ public: | |||
| object to be deleted when the ref-count hits zero. | |||
| */ | |||
| ~ReferenceCountedObjectPtr() | |||
| { | |||
| decIfNotNull (referencedObject); | |||
| { | |||
| reset(); | |||
| } | |||
| //============================================================================== | |||
| @@ -344,6 +374,12 @@ public: | |||
| The pointer returned may be null, of course. | |||
| */ | |||
| 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 | |||
| ReferencedType* operator->() const noexcept | |||
| @@ -170,7 +170,7 @@ public: | |||
| { | |||
| if (sharedPointer == nullptr) | |||
| { | |||
| sharedPointer = new SharedPointer (object); | |||
| sharedPointer = *new SharedPointer (object); | |||
| } | |||
| else | |||
| { | |||
| @@ -149,7 +149,7 @@ static var nsObjectToVar (NSObject* array); | |||
| static var nsDictionaryToVar (NSDictionary* dictionary) | |||
| { | |||
| DynamicObject::Ptr dynamicObject = new DynamicObject(); | |||
| DynamicObject::Ptr dynamicObject (new DynamicObject()); | |||
| for (NSString* key in dictionary) | |||
| 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> | |||
| @@ -97,31 +97,31 @@ public: | |||
| void sendPropertyChangeMessage (const Identifier& property, ValueTree::Listener* listenerToExclude = nullptr) | |||
| { | |||
| ValueTree tree (this); | |||
| ValueTree tree (*this); | |||
| callListenersForAllParents (listenerToExclude, [&] (Listener& l) { l.valueTreePropertyChanged (tree, property); }); | |||
| } | |||
| void sendChildAddedMessage (ValueTree child) | |||
| { | |||
| ValueTree tree (this); | |||
| ValueTree tree (*this); | |||
| callListenersForAllParents (nullptr, [&] (Listener& l) { l.valueTreeChildAdded (tree, child); }); | |||
| } | |||
| void sendChildRemovedMessage (ValueTree child, int index) | |||
| { | |||
| ValueTree tree (this); | |||
| ValueTree tree (*this); | |||
| callListenersForAllParents (nullptr, [=, &tree, &child] (Listener& l) { l.valueTreeChildRemoved (tree, child, index); }); | |||
| } | |||
| void sendChildOrderChangedMessage (int oldIndex, int newIndex) | |||
| { | |||
| ValueTree tree (this); | |||
| ValueTree tree (*this); | |||
| callListenersForAllParents (nullptr, [=, &tree] (Listener& l) { l.valueTreeChildOrderChanged (tree, oldIndex, newIndex); }); | |||
| } | |||
| void sendParentChangeMessage() | |||
| { | |||
| ValueTree tree (this); | |||
| ValueTree tree (*this); | |||
| for (int j = children.size(); --j >= 0;) | |||
| if (auto* child = children.getObjectPointer (j)) | |||
| @@ -143,12 +143,12 @@ public: | |||
| if (auto* existingValue = properties.getVarPointer (name)) | |||
| { | |||
| if (*existingValue != newValue) | |||
| undoManager->perform (new SetPropertyAction (this, name, newValue, *existingValue, | |||
| undoManager->perform (new SetPropertyAction (*this, name, newValue, *existingValue, | |||
| false, false, listenerToExclude)); | |||
| } | |||
| else | |||
| { | |||
| undoManager->perform (new SetPropertyAction (this, name, newValue, {}, | |||
| undoManager->perform (new SetPropertyAction (*this, name, newValue, {}, | |||
| true, false, listenerToExclude)); | |||
| } | |||
| } | |||
| @@ -169,7 +169,7 @@ public: | |||
| else | |||
| { | |||
| 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 | |||
| { | |||
| 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)); | |||
| } | |||
| } | |||
| @@ -206,7 +206,7 @@ public: | |||
| { | |||
| for (auto* s : children) | |||
| if (s->type == typeToMatch) | |||
| return ValueTree (s); | |||
| return ValueTree (*s); | |||
| return {}; | |||
| } | |||
| @@ -215,18 +215,18 @@ public: | |||
| { | |||
| for (auto* s : children) | |||
| if (s->type == typeToMatch) | |||
| return ValueTree (s); | |||
| return ValueTree (*s); | |||
| auto newObject = new SharedObject (typeToMatch); | |||
| addChild (newObject, -1, undoManager); | |||
| return ValueTree (newObject); | |||
| return ValueTree (*newObject); | |||
| } | |||
| ValueTree getChildWithProperty (const Identifier& propertyName, const var& propertyValue) const | |||
| { | |||
| for (auto* s : children) | |||
| if (s->properties[propertyName] == propertyValue) | |||
| return ValueTree (s); | |||
| return ValueTree (*s); | |||
| return {}; | |||
| } | |||
| @@ -266,7 +266,7 @@ public: | |||
| { | |||
| children.insert (index, child); | |||
| child->parent = this; | |||
| sendChildAddedMessage (ValueTree (child)); | |||
| sendChildAddedMessage (ValueTree (*child)); | |||
| child->sendParentChangeMessage(); | |||
| } | |||
| else | |||
| @@ -274,7 +274,7 @@ public: | |||
| if (! isPositiveAndBelow (index, children.size())) | |||
| index = children.size(); | |||
| undoManager->perform (new AddOrRemoveChildAction (this, index, child)); | |||
| undoManager->perform (new AddOrRemoveChildAction (*this, index, child)); | |||
| } | |||
| } | |||
| else | |||
| @@ -288,7 +288,7 @@ public: | |||
| void removeChild (int childIndex, UndoManager* undoManager) | |||
| { | |||
| if (Ptr child = children.getObjectPointer (childIndex)) | |||
| if (auto child = Ptr (children.getObjectPointer (childIndex))) | |||
| { | |||
| if (undoManager == nullptr) | |||
| { | |||
| @@ -299,7 +299,7 @@ public: | |||
| } | |||
| else | |||
| { | |||
| undoManager->perform (new AddOrRemoveChildAction (this, childIndex, nullptr)); | |||
| undoManager->perform (new AddOrRemoveChildAction (*this, childIndex, {})); | |||
| } | |||
| } | |||
| } | |||
| @@ -328,7 +328,7 @@ public: | |||
| if (! isPositiveAndBelow (newIndex, children.size())) | |||
| 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()); | |||
| 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) | |||
| { | |||
| @@ -455,7 +455,7 @@ public: | |||
| if (auto* next = dynamic_cast<SetPropertyAction*> (nextAction)) | |||
| if (next->target == target && next->name == name | |||
| && ! (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; | |||
| @@ -598,11 +598,9 @@ ValueTree::ValueTree (const Identifier& type, | |||
| 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) | |||
| { | |||
| } | |||
| @@ -663,8 +661,11 @@ bool ValueTree::isEquivalentTo (const ValueTree& other) 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) | |||
| @@ -700,24 +701,30 @@ Identifier ValueTree::getType() 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 | |||
| { | |||
| 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 | |||
| { | |||
| 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 | |||
| @@ -848,9 +855,12 @@ int ValueTree::getNumChildren() const noexcept | |||
| } | |||
| 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 | |||
| @@ -871,7 +881,7 @@ bool ValueTree::Iterator::operator!= (const Iterator& other) const noexcept | |||
| 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); } | |||
| @@ -944,8 +954,11 @@ void ValueTree::createListOfChildren (OwnedArray<ValueTree>& list) const | |||
| { | |||
| 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) | |||
| @@ -1017,7 +1030,7 @@ String ValueTree::toXmlString() const | |||
| //============================================================================== | |||
| void ValueTree::writeToStream (OutputStream& output) const | |||
| { | |||
| SharedObject::writeObjectToStream (output, object); | |||
| SharedObject::writeObjectToStream (output, object.get()); | |||
| } | |||
| ValueTree ValueTree::readFromStream (InputStream& input) | |||
| @@ -632,7 +632,8 @@ private: | |||
| void createListOfChildren (OwnedArray<ValueTree>&) const; | |||
| void reorderChildren (const OwnedArray<ValueTree>&, UndoManager*); | |||
| explicit ValueTree (ReferenceCountedObjectPtr<SharedObject>) noexcept; | |||
| explicit ValueTree (ReferenceCountedObjectPtr<SharedObject>) noexcept; | |||
| explicit ValueTree (SharedObject&) noexcept; | |||
| }; | |||
| } // namespace juce | |||
| @@ -60,7 +60,7 @@ typename FIR::Coefficients<FloatType>::Ptr | |||
| WindowingFunction<FloatType> theWindow (order + 1, type, false, beta); | |||
| theWindow.multiplyWithWindowingTable (c, order + 1); | |||
| return result; | |||
| return *result; | |||
| } | |||
| template <typename FloatType> | |||
| @@ -121,7 +121,7 @@ typename FIR::Coefficients<FloatType>::Ptr | |||
| } | |||
| } | |||
| return result; | |||
| return *result; | |||
| } | |||
| template <typename FloatType> | |||
| @@ -231,7 +231,7 @@ typename FIR::Coefficients<FloatType>::Ptr | |||
| } | |||
| } | |||
| return result; | |||
| return *result; | |||
| } | |||
| template <typename FloatType> | |||
| @@ -290,7 +290,7 @@ typename FIR::Coefficients<FloatType>::Ptr | |||
| c[2 * n + 1] = static_cast<FloatType> (0.5); | |||
| return result; | |||
| return *result; | |||
| } | |||
| template <typename FloatType> | |||
| @@ -178,7 +178,7 @@ class FIRFilterTest : public UnitTest | |||
| AudioBlock<NumericType> fir (firBlock, 1, 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}; | |||
| 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)); | |||
| return new Coefficients (n, n, n + 1, n - 1); | |||
| return *new Coefficients (n, n, n + 1, n - 1); | |||
| } | |||
| 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)); | |||
| return new Coefficients (1, -1, n + 1, n - 1); | |||
| return *new Coefficients (1, -1, n + 1, n - 1); | |||
| } | |||
| 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)); | |||
| 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> | |||
| @@ -147,9 +147,9 @@ typename IIR::Coefficients<NumericType>::Ptr IIR::Coefficients<NumericType>::mak | |||
| auto invQ = 1 / Q; | |||
| 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> | |||
| @@ -173,9 +173,9 @@ typename IIR::Coefficients<NumericType>::Ptr IIR::Coefficients<NumericType>::mak | |||
| auto invQ = 1 / Q; | |||
| 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> | |||
| @@ -199,10 +199,10 @@ typename IIR::Coefficients<NumericType>::Ptr IIR::Coefficients<NumericType>::mak | |||
| auto invQ = 1 / Q; | |||
| 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> | |||
| @@ -228,7 +228,7 @@ typename IIR::Coefficients<NumericType>::Ptr IIR::Coefficients<NumericType>::mak | |||
| auto b0 = 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> | |||
| @@ -254,7 +254,7 @@ typename IIR::Coefficients<NumericType>::Ptr IIR::Coefficients<NumericType>::mak | |||
| auto b0 = c1 * (1 - n * invQ + 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> | |||
| @@ -275,12 +275,12 @@ typename IIR::Coefficients<NumericType>::Ptr IIR::Coefficients<NumericType>::mak | |||
| auto beta = std::sin (omega) * std::sqrt (A) / Q; | |||
| 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> | |||
| @@ -301,12 +301,12 @@ typename IIR::Coefficients<NumericType>::Ptr IIR::Coefficients<NumericType>::mak | |||
| auto beta = std::sin (omega) * std::sqrt (A) / Q; | |||
| 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> | |||
| @@ -327,10 +327,10 @@ typename IIR::Coefficients<NumericType>::Ptr IIR::Coefficients<NumericType>::mak | |||
| auto alphaTimesA = 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> | |||
| @@ -43,7 +43,7 @@ public: | |||
| //============================================================================== | |||
| AsyncUpdater::AsyncUpdater() | |||
| { | |||
| activeMessage = new AsyncUpdaterMessage (*this); | |||
| activeMessage = *new AsyncUpdaterMessage (*this); | |||
| } | |||
| AsyncUpdater::~AsyncUpdater() | |||
| @@ -294,7 +294,7 @@ bool MessageManager::Lock::tryAcquire (bool lockIsMandatory) const noexcept | |||
| try | |||
| { | |||
| blockingMessage = new BlockingMessage (this); | |||
| blockingMessage = *new BlockingMessage (this); | |||
| } | |||
| catch (...) | |||
| { | |||
| @@ -308,7 +308,7 @@ bool Font::operator!= (const Font& other) const noexcept | |||
| void Font::dupeInternalIfShared() | |||
| { | |||
| if (font->getReferenceCount() > 1) | |||
| font = new SharedFontInternal (*font); | |||
| font = *new SharedFontInternal (*font); | |||
| } | |||
| void Font::checkTypefaceSuitability() | |||
| @@ -118,7 +118,7 @@ Typeface::~Typeface() | |||
| Typeface::Ptr Typeface::getFallbackTypeface() | |||
| { | |||
| 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) | |||
| @@ -140,9 +140,8 @@ EdgeTable* Typeface::getEdgeTableForGlyph (int glyphNumber, const AffineTransfor | |||
| struct Typeface::HintingParams | |||
| { | |||
| HintingParams (Typeface& t) | |||
| : cachedSize (0), top (0), middle (0), bottom (0) | |||
| { | |||
| Font font (&t); | |||
| Font font (t); | |||
| font = font.withHeight ((float) standardHeight); | |||
| top = getAverageY (font, "BDEFPRTZOQ", true); | |||
| @@ -209,7 +208,7 @@ private: | |||
| float middle, upperScale, upperOffset, lowerScale, lowerOffset; | |||
| }; | |||
| float cachedSize; | |||
| float cachedSize = 0; | |||
| Scaling cachedScale; | |||
| static float getAverageY (const Font& font, const char* chars, bool getTop) | |||
| @@ -248,7 +247,7 @@ private: | |||
| } | |||
| enum { standardHeight = 100 }; | |||
| float top, middle, bottom; | |||
| float top = 0, middle = 0, bottom = 0; | |||
| }; | |||
| void Typeface::applyVerticalHintingTransform (float fontSize, Path& path) | |||
| @@ -93,7 +93,7 @@ public: | |||
| LowLevelGraphicsContext* createLowLevelContext() override | |||
| { | |||
| 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 | |||
| @@ -109,9 +109,9 @@ public: | |||
| 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); | |||
| return s; | |||
| return *s; | |||
| } | |||
| 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 | |||
| { | |||
| return new SoftwarePixelData (format, width, height, clearImage); | |||
| return *new SoftwarePixelData (format, width, height, clearImage); | |||
| } | |||
| int SoftwareImageType::getTypeID() const | |||
| @@ -187,10 +187,10 @@ public: | |||
| { | |||
| 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(); } | |||
| @@ -216,7 +216,7 @@ Image Image::getClippedImage (const Rectangle<int>& area) const | |||
| if (validArea.isEmpty()) | |||
| return {}; | |||
| return Image (new SubsectionPixelData (image, validArea)); | |||
| return Image (*new SubsectionPixelData (image, validArea)); | |||
| } | |||
| @@ -216,7 +216,7 @@ private: | |||
| { | |||
| for (auto g : glyphs) | |||
| if (g->glyph == glyphNumber && g->font == font) | |||
| return g; | |||
| return *g; | |||
| return {}; | |||
| } | |||
| @@ -232,8 +232,8 @@ private: | |||
| misses = 0; | |||
| } | |||
| if (auto* g = findLeastRecentlyUsedGlyph()) | |||
| return g; | |||
| if (auto g = findLeastRecentlyUsedGlyph()) | |||
| return *g; | |||
| addNewGlyphSlots (32); | |||
| return glyphs.getLast(); | |||
| @@ -1670,13 +1670,13 @@ struct ClipRegions | |||
| 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 clipToRectangle (Rectangle<int> r) override | |||
| { | |||
| edgeTable.clipToRectangle (r); | |||
| return edgeTable.isEmpty() ? nullptr : this; | |||
| return edgeTable.isEmpty() ? Ptr() : Ptr (*this); | |||
| } | |||
| Ptr clipToRectangleList (const RectangleList<int>& r) override | |||
| @@ -1687,26 +1687,26 @@ struct ClipRegions | |||
| for (auto& i : inverse) | |||
| edgeTable.excludeRectangle (i); | |||
| return edgeTable.isEmpty() ? nullptr : this; | |||
| return edgeTable.isEmpty() ? Ptr() : Ptr (*this); | |||
| } | |||
| Ptr excludeClipRectangle (Rectangle<int> r) override | |||
| { | |||
| edgeTable.excludeRectangle (r); | |||
| return edgeTable.isEmpty() ? nullptr : this; | |||
| return edgeTable.isEmpty() ? Ptr() : Ptr (*this); | |||
| } | |||
| Ptr clipToPath (const Path& p, const AffineTransform& transform) override | |||
| { | |||
| EdgeTable et (edgeTable.getMaximumBounds(), p, transform); | |||
| edgeTable.clipToEdgeTable (et); | |||
| return edgeTable.isEmpty() ? nullptr : this; | |||
| return edgeTable.isEmpty() ? Ptr() : Ptr (*this); | |||
| } | |||
| Ptr clipToEdgeTable (const EdgeTable& et) override | |||
| { | |||
| 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 | |||
| @@ -1729,7 +1729,7 @@ struct ClipRegions | |||
| else | |||
| 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); | |||
| } | |||
| return edgeTable.isEmpty() ? nullptr : this; | |||
| return edgeTable.isEmpty() ? Ptr() : Ptr (*this); | |||
| } | |||
| void translate (Point<int> delta) override | |||
| @@ -1851,25 +1851,25 @@ struct ClipRegions | |||
| 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 clipToRectangle (Rectangle<int> r) override | |||
| { | |||
| clip.clipTo (r); | |||
| return clip.isEmpty() ? nullptr : this; | |||
| return clip.isEmpty() ? Ptr() : Ptr (*this); | |||
| } | |||
| Ptr clipToRectangleList (const RectangleList<int>& r) override | |||
| { | |||
| clip.clipTo (r); | |||
| return clip.isEmpty() ? nullptr : this; | |||
| return clip.isEmpty() ? Ptr() : Ptr (*this); | |||
| } | |||
| Ptr excludeClipRectangle (Rectangle<int> r) override | |||
| { | |||
| 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); } | |||
| @@ -2068,7 +2068,7 @@ struct ClipRegions | |||
| JUCE_DECLARE_NON_COPYABLE (SubRectangleIteratorFloat) | |||
| }; | |||
| Ptr toEdgeTable() const { return new EdgeTableRegion (clip); } | |||
| Ptr toEdgeTable() const { return *new EdgeTableRegion (clip); } | |||
| RectangleListRegion& operator= (const RectangleListRegion&); | |||
| }; | |||
| @@ -2267,7 +2267,7 @@ public: | |||
| auto clipped = clip->getClipBounds().getIntersection (r); | |||
| 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); | |||
| if (! clipped.isEmpty()) | |||
| fillShape (new EdgeTableRegionType (clipped), false); | |||
| fillShape (*new EdgeTableRegionType (clipped), false); | |||
| } | |||
| } | |||
| @@ -2336,7 +2336,7 @@ public: | |||
| if (transform.isIdentity()) | |||
| { | |||
| fillShape (new EdgeTableRegionType (list), false); | |||
| fillShape (*new EdgeTableRegionType (list), false); | |||
| } | |||
| else if (! transform.isRotated) | |||
| { | |||
| @@ -2347,7 +2347,7 @@ public: | |||
| else | |||
| transformed.transformAll (transform.getTransform()); | |||
| fillShape (new EdgeTableRegionType (transformed), false); | |||
| fillShape (*new EdgeTableRegionType (transformed), false); | |||
| } | |||
| else | |||
| { | |||
| @@ -2364,7 +2364,7 @@ public: | |||
| auto clipRect = clip->getClipBounds(); | |||
| 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); | |||
| } | |||
| fillShape (edgeTableClip, false); | |||
| fillShape (*edgeTableClip, false); | |||
| } | |||
| } | |||
| @@ -2434,7 +2434,7 @@ public: | |||
| area = area.getIntersection (getThis().getMaximumBounds()); | |||
| 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); | |||
| } | |||
| @@ -2609,7 +2609,7 @@ public: | |||
| std::unique_ptr<EdgeTable> et (font.getTypeface()->getEdgeTableForGlyph (glyphNumber, t, fontHeight)); | |||
| 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); | |||
| memcpy (im->imageData, imageData, (size_t) (lineStride * height)); | |||
| return im; | |||
| return *im; | |||
| } | |||
| 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 | |||
| { | |||
| 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)]; | |||
| CGContextFlush (cgImage->context); | |||
| return Image (cgImage); | |||
| return Image (*cgImage); | |||
| } | |||
| 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&) | |||
| { | |||
| @@ -147,7 +147,7 @@ void LookAndFeel::setDefaultSansSerifTypefaceName (const String& newName) | |||
| { | |||
| if (defaultSans != newName) | |||
| { | |||
| defaultTypeface = {}; | |||
| defaultTypeface.reset(); | |||
| Typeface::clearTypefaceCache(); | |||
| defaultSans = newName; | |||
| } | |||
| @@ -77,7 +77,7 @@ struct ItemComponent : public Component | |||
| : item (i), customComp (i.customComponent) | |||
| { | |||
| if (item.isSectionHeader) | |||
| customComp = new HeaderItemComponent (item.text); | |||
| customComp = *new HeaderItemComponent (item.text); | |||
| if (customComp != nullptr) | |||
| addAndMakeVisible (*customComp); | |||
| @@ -589,16 +589,25 @@ public: | |||
| void execute (OpenGLContext::AsyncWorker::Ptr workerToUse, bool shouldBlock, bool calledFromDestructor = false) | |||
| { | |||
| 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 | |||
| { | |||
| @@ -111,10 +111,10 @@ struct CachedImageList : public ReferenceCountedObject, | |||
| { | |||
| TextureInfo t; | |||
| if (textureNeedsReloading) | |||
| if (textureNeedsReloading && pixelData != nullptr) | |||
| { | |||
| textureNeedsReloading = false; | |||
| texture.loadImage (Image (pixelData)); | |||
| texture.loadImage (Image (*pixelData)); | |||
| } | |||
| 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)); | |||
| 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) | |||
| { | |||
| 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 {}; | |||
| } | |||
| @@ -53,11 +53,11 @@ public: | |||
| ImagePixelData::Ptr clone() override | |||
| { | |||
| Image newImage (new OpenGLFrameBufferImage (context, width, height)); | |||
| Image newImage (*new OpenGLFrameBufferImage (context, width, height)); | |||
| 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 | |||
| @@ -193,7 +193,7 @@ ImagePixelData::Ptr OpenGLImageType::create (Image::PixelFormat, int width, int | |||
| return ImagePixelData::Ptr(); | |||
| im->frameBuffer.clear (Colours::transparentBlack); | |||
| return im.release(); | |||
| return *im.release(); | |||
| } | |||
| OpenGLFrameBuffer* OpenGLImageType::getFrameBufferFrom (const Image& image) | |||