diff --git a/extensions/transformiix/source/xpath/AdditiveExpr.cpp b/extensions/transformiix/source/xpath/AdditiveExpr.cpp index d191551ef01..58931d2b3af 100644 --- a/extensions/transformiix/source/xpath/AdditiveExpr.cpp +++ b/extensions/transformiix/source/xpath/AdditiveExpr.cpp @@ -38,13 +38,16 @@ /** * Creates a new AdditiveExpr using the given operator **/ -AdditiveExpr::AdditiveExpr(nsAutoPtr aLeftExpr, - nsAutoPtr aRightExpr, short aOp) - : op(aOp), - leftExpr(aLeftExpr), - rightExpr(aRightExpr) -{ -} +AdditiveExpr::AdditiveExpr(Expr* leftExpr, Expr* rightExpr, short op) { + this->op = op; + this->leftExpr = leftExpr; + this->rightExpr = rightExpr; +} //-- AdditiveExpr + +AdditiveExpr::~AdditiveExpr() { + delete leftExpr; + delete rightExpr; +} //-- ~AdditiveExpr /** * Evaluates this Expr based on the given context node and processor state diff --git a/extensions/transformiix/source/xpath/AttributeValueTemplate.cpp b/extensions/transformiix/source/xpath/AttributeValueTemplate.cpp index 5b16b49e33e..ae04266b9e9 100644 --- a/extensions/transformiix/source/xpath/AttributeValueTemplate.cpp +++ b/extensions/transformiix/source/xpath/AttributeValueTemplate.cpp @@ -31,6 +31,11 @@ #include "ExprResult.h" #include "txIXPathContext.h" +/** + * Create a new AttributeValueTemplate +**/ +AttributeValueTemplate::AttributeValueTemplate() {}; + /** * Default destructor **/ @@ -44,15 +49,8 @@ AttributeValueTemplate::~AttributeValueTemplate() { /** * Adds the given Expr to this AttributeValueTemplate **/ -nsresult -AttributeValueTemplate::addExpr(nsAutoPtr aExpr) -{ - nsresult rv = expressions.add(aExpr); - NS_ENSURE_SUCCESS(rv, rv); - - aExpr.forget(); - - return NS_OK; +void AttributeValueTemplate::addExpr(Expr* expr) { + if (expr) expressions.add(expr); } //-- addExpr /** diff --git a/extensions/transformiix/source/xpath/BooleanExpr.cpp b/extensions/transformiix/source/xpath/BooleanExpr.cpp index 836a7b3253f..a6071f6474f 100644 --- a/extensions/transformiix/source/xpath/BooleanExpr.cpp +++ b/extensions/transformiix/source/xpath/BooleanExpr.cpp @@ -41,12 +41,15 @@ /** * Creates a new BooleanExpr using the given operator **/ -BooleanExpr::BooleanExpr(nsAutoPtr aLeftExpr, - nsAutoPtr aRightExpr, short aOp) - : op(aOp), - leftExpr(aLeftExpr), - rightExpr(aRightExpr) -{ +BooleanExpr::BooleanExpr(Expr* leftExpr, Expr* rightExpr, short op) { + this->op = op; + this->leftExpr = leftExpr; + this->rightExpr = rightExpr; +} //-- BooleanExpr + +BooleanExpr::~BooleanExpr() { + delete leftExpr; + delete rightExpr; } //-- ~BooleanExpr /** diff --git a/extensions/transformiix/source/xpath/Expr.h b/extensions/transformiix/source/xpath/Expr.h index 23b517c26a1..e703b12276a 100644 --- a/extensions/transformiix/source/xpath/Expr.h +++ b/extensions/transformiix/source/xpath/Expr.h @@ -119,7 +119,7 @@ public: * Adds the given parameter to this FunctionCall's parameter list * @param expr the Expr to add to this FunctionCall's parameter list **/ - nsresult addParam(nsAutoPtr aExpr); + nsresult addParam(Expr* aExpr); /** * Check if the number of parameters falls within a range. @@ -140,6 +140,8 @@ protected: txList params; + FunctionCall(); + /* * Evaluates the given Expression and converts its result to a String. * The value is appended to the given destination String @@ -177,12 +179,15 @@ protected: class AttributeValueTemplate: public Expr { public: + + AttributeValueTemplate(); + virtual ~AttributeValueTemplate(); /** * Adds the given Expr to this AttributeValueTemplate **/ - nsresult addExpr(nsAutoPtr expr); + void addExpr(Expr* expr); TX_DECL_EXPR; @@ -227,8 +232,11 @@ public: txNameTest(nsIAtom* aPrefix, nsIAtom* aLocalName, PRInt32 aNSID, Node::NodeType aNodeType); + ~txNameTest(); + TX_DECL_NODE_TEST; +private: nsCOMPtr mPrefix; nsCOMPtr mLocalName; PRInt32 mNamespace; @@ -253,6 +261,8 @@ public: */ txNodeTypeTest(NodeType aNodeType); + ~txNodeTypeTest(); + /* * Sets the name of the node to match. Only availible for pi nodes */ @@ -272,6 +282,11 @@ private: class PredicateList { public: + + /** + * Creates a new PredicateList + **/ + PredicateList(); /** * Destructor, will delete all Expressions in the list, so remove * any you may need @@ -282,7 +297,7 @@ public: * Adds the given Expr to the list * @param expr the Expr to add to the list **/ - nsresult add(nsAutoPtr aExpr); + void add(Expr* expr); nsresult evaluatePredicates(NodeSet* aNodes, txIMatchContext* aContext); @@ -358,12 +373,17 @@ public: * Creates a new FilterExpr using the given Expr * @param expr the Expr to use for evaluation **/ - FilterExpr(nsAutoPtr aExpr); + FilterExpr(Expr* aExpr); + + /** + * Destructor, will delete all predicates and the given Expr + **/ + virtual ~FilterExpr(); TX_DECL_EXPR; private: - nsAutoPtr expr; + Expr* expr; }; //-- FilterExpr @@ -393,15 +413,15 @@ public: //-- LF, changed from static const short to enum enum _AdditiveExprType { ADDITION = 1, SUBTRACTION }; - AdditiveExpr(nsAutoPtr aLeftExpr, nsAutoPtr aRightExpr, - short aOp); + AdditiveExpr(Expr* leftExpr, Expr* rightExpr, short op); + ~AdditiveExpr(); TX_DECL_EXPR; private: short op; - nsAutoPtr leftExpr; - nsAutoPtr rightExpr; + Expr* leftExpr; + Expr* rightExpr; }; //-- AdditiveExpr /** @@ -411,12 +431,13 @@ class UnaryExpr : public Expr { public: - UnaryExpr(nsAutoPtr aExpr); + UnaryExpr(Expr* expr); + ~UnaryExpr(); TX_DECL_EXPR; private: - nsAutoPtr expr; + Expr* expr; }; //-- UnaryExpr /** @@ -430,15 +451,15 @@ public: //-- BooleanExpr Types enum _BooleanExprType { AND = 1, OR }; - BooleanExpr(nsAutoPtr aLeftExpr, nsAutoPtr aRightExpr, - short aOp); + BooleanExpr(Expr* leftExpr, Expr* rightExpr, short op); + ~BooleanExpr(); TX_DECL_EXPR; private: short op; - nsAutoPtr leftExpr; - nsAutoPtr rightExpr; + Expr* leftExpr; + Expr* rightExpr; }; //-- BooleanExpr /** @@ -457,15 +478,15 @@ public: //-- LF, changed from static const short to enum enum _MultiplicativeExprType { DIVIDE = 1, MULTIPLY, MODULUS }; - MultiplicativeExpr(nsAutoPtr aLeftExpr, nsAutoPtr aRightExpr, - short aOp); + MultiplicativeExpr(Expr* leftExpr, Expr* rightExpr, short op); + ~MultiplicativeExpr(); TX_DECL_EXPR; private: short op; - nsAutoPtr leftExpr; - nsAutoPtr rightExpr; + Expr* leftExpr; + Expr* rightExpr; }; //-- MultiplicativeExpr /** @@ -490,8 +511,7 @@ public: GREATER_OR_EQUAL }; - RelationalExpr(nsAutoPtr aLeftExpr, nsAutoPtr aRightExpr, - RelationalExprType aOp); + RelationalExpr(Expr* aLeftExpr, Expr* aRightExpr, RelationalExprType aOp); TX_DECL_EXPR; @@ -513,6 +533,7 @@ class VariableRefExpr : public Expr { public: VariableRefExpr(nsIAtom* aPrefix, nsIAtom* aLocalName, PRInt32 aNSID); + ~VariableRefExpr(); TX_DECL_EXPR; @@ -534,6 +555,11 @@ public: //-- LF, changed from static const short to enum enum PathOperator { RELATIVE_OP, DESCENDANT_OP }; + /** + * Creates a new PathExpr + **/ + PathExpr(); + /** * Destructor, will delete all Expressions **/ @@ -543,13 +569,13 @@ public: * Adds the Expr to this PathExpr * @param expr the Expr to add to this PathExpr **/ - nsresult addExpr(nsAutoPtr aExpr, PathOperator aPathOp); + void addExpr(Expr* expr, PathOperator pathOp); TX_DECL_EXPR; private: struct PathExprItem { - nsAutoPtr expr; + Expr* expr; PathOperator pathOp; }; @@ -593,6 +619,11 @@ class UnionExpr : public Expr { public: + /** + * Creates a new UnionExpr + **/ + UnionExpr(); + /** * Destructor, will delete all Path Expressions **/ @@ -602,7 +633,7 @@ public: * Adds the PathExpr to this UnionExpr * @param expr the Expr to add to this UnionExpr **/ - nsresult addExpr(nsAutoPtr aExpr); + void addExpr(Expr* expr); TX_DECL_EXPR; diff --git a/extensions/transformiix/source/xpath/FilterExpr.cpp b/extensions/transformiix/source/xpath/FilterExpr.cpp index a0f33a26660..9f77dc58056 100644 --- a/extensions/transformiix/source/xpath/FilterExpr.cpp +++ b/extensions/transformiix/source/xpath/FilterExpr.cpp @@ -35,11 +35,17 @@ * Creates a new FilterExpr using the given Expr * @param expr the Expr to use for evaluation **/ -FilterExpr::FilterExpr(nsAutoPtr aExpr) - : expr(aExpr) -{ +FilterExpr::FilterExpr(Expr* expr) : PredicateList() { + this->expr = expr; } //-- FilterExpr +/** + * Destroys this FilterExpr, all predicates and the expr will be deleted +**/ +FilterExpr::~FilterExpr() { + delete expr; +} //-- ~FilterExpr + //-----------------------------/ //- Virtual methods from Expr -/ //-----------------------------/ diff --git a/extensions/transformiix/source/xpath/FunctionCall.cpp b/extensions/transformiix/source/xpath/FunctionCall.cpp index f5f4714fa31..f8d75c52fae 100644 --- a/extensions/transformiix/source/xpath/FunctionCall.cpp +++ b/extensions/transformiix/source/xpath/FunctionCall.cpp @@ -33,6 +33,10 @@ * This class represents a FunctionCall as defined by the XSL Working Draft **/ +FunctionCall::FunctionCall() +{ +} + /** * Destructor **/ @@ -52,14 +56,10 @@ FunctionCall::~FunctionCall() * Adds the given parameter to this FunctionCall's parameter list * @param expr the Expr to add to this FunctionCall's parameter list **/ -nsresult -FunctionCall::addParam(nsAutoPtr aExpr) +nsresult FunctionCall::addParam(Expr* aExpr) { - nsresult rv = params.add(aExpr); - NS_ENSURE_SUCCESS(rv, rv); - - aExpr.forget(); - + if (aExpr) + params.add(aExpr); return NS_OK; } //-- addParam diff --git a/extensions/transformiix/source/xpath/MultiplicativeExpr.cpp b/extensions/transformiix/source/xpath/MultiplicativeExpr.cpp index 7118bcf7b6c..1618a77c4c3 100644 --- a/extensions/transformiix/source/xpath/MultiplicativeExpr.cpp +++ b/extensions/transformiix/source/xpath/MultiplicativeExpr.cpp @@ -44,13 +44,16 @@ /** * Creates a new MultiplicativeExpr using the given operator **/ -MultiplicativeExpr::MultiplicativeExpr(nsAutoPtr aLeftExpr, - nsAutoPtr aRightExpr, short aOp) - : op(aOp), - leftExpr(aLeftExpr), - rightExpr(aRightExpr) -{ -} +MultiplicativeExpr::MultiplicativeExpr(Expr* leftExpr, Expr* rightExpr, short op) { + this->op = op; + this->leftExpr = leftExpr; + this->rightExpr = rightExpr; +} //-- MultiplicativeExpr + +MultiplicativeExpr::~MultiplicativeExpr() { + delete leftExpr; + delete rightExpr; +} //-- ~MultiplicativeExpr /** * Evaluates this Expr based on the given context node and processor state diff --git a/extensions/transformiix/source/xpath/PathExpr.cpp b/extensions/transformiix/source/xpath/PathExpr.cpp index faca90b4103..27c6fc538d6 100644 --- a/extensions/transformiix/source/xpath/PathExpr.cpp +++ b/extensions/transformiix/source/xpath/PathExpr.cpp @@ -41,6 +41,14 @@ //- PathExpr -/ //------------/ +/** + * Creates a new PathExpr +**/ +PathExpr::PathExpr() +{ + //-- do nothing +} + /** * Destructor, will delete all Expressions **/ @@ -49,6 +57,7 @@ PathExpr::~PathExpr() txListIterator iter(&expressions); while (iter.hasNext()) { PathExprItem* pxi = (PathExprItem*)iter.next(); + delete pxi->expr; delete pxi; } } //-- ~PathExpr @@ -57,20 +66,21 @@ PathExpr::~PathExpr() * Adds the Expr to this PathExpr * @param expr the Expr to add to this PathExpr **/ -nsresult -PathExpr::addExpr(nsAutoPtr aExpr, PathOperator aPathOp) +void PathExpr::addExpr(Expr* expr, PathOperator pathOp) { - NS_ASSERTION(expressions.getLength() > 0 || aPathOp == RELATIVE_OP, + NS_ASSERTION(expressions.getLength() > 0 || pathOp == RELATIVE_OP, "First step has to be relative in PathExpr"); - nsAutoPtr pxi(new PathExprItem); - NS_ENSURE_TRUE(pxi, NS_ERROR_OUT_OF_MEMORY); - - pxi->expr = aExpr; - pxi->pathOp = aPathOp; - nsresult rv = expressions.add(pxi); - NS_ENSURE_SUCCESS(rv, rv); - - return NS_OK; + if (expr) { + PathExprItem* pxi = new PathExprItem; + if (!pxi) { + // XXX ErrorReport: out of memory + NS_ASSERTION(0, "out of memory"); + return; + } + pxi->expr = expr; + pxi->pathOp = pathOp; + expressions.add(pxi); + } } //-- addPattenExpr //-----------------------------/ diff --git a/extensions/transformiix/source/xpath/PredicateList.cpp b/extensions/transformiix/source/xpath/PredicateList.cpp index 00c02598349..51e92963e95 100644 --- a/extensions/transformiix/source/xpath/PredicateList.cpp +++ b/extensions/transformiix/source/xpath/PredicateList.cpp @@ -32,6 +32,10 @@ * for use with Step and Filter Expressions */ +PredicateList::PredicateList() +{ +} // PredicateList + /* * Destructor, will delete all Expressions in the list */ @@ -47,15 +51,9 @@ PredicateList::~PredicateList() * Adds the given Expr to the list * @param expr the Expr to add to the list */ -nsresult -PredicateList::add(nsAutoPtr aExpr) +void PredicateList::add(Expr* expr) { - nsresult rv = predicates.add(aExpr); - NS_ENSURE_SUCCESS(rv, rv); - - aExpr.forget(); - - return NS_OK; + predicates.add(expr); } // add nsresult diff --git a/extensions/transformiix/source/xpath/RelationalExpr.cpp b/extensions/transformiix/source/xpath/RelationalExpr.cpp index ecad2ea00c6..1f45fbdf7a2 100644 --- a/extensions/transformiix/source/xpath/RelationalExpr.cpp +++ b/extensions/transformiix/source/xpath/RelationalExpr.cpp @@ -32,12 +32,9 @@ #include "XMLDOMUtils.h" #include "txIXPathContext.h" -RelationalExpr::RelationalExpr(nsAutoPtr aLeftExpr, - nsAutoPtr aRightExpr, +RelationalExpr::RelationalExpr(Expr* aLeftExpr, Expr* aRightExpr, RelationalExprType aOp) - : mLeftExpr(aLeftExpr), - mRightExpr(aRightExpr), - mOp(aOp) + : mLeftExpr(aLeftExpr), mRightExpr(aRightExpr), mOp(aOp) { } diff --git a/extensions/transformiix/source/xpath/UnaryExpr.cpp b/extensions/transformiix/source/xpath/UnaryExpr.cpp index 0c035fd93e2..2b659847233 100644 --- a/extensions/transformiix/source/xpath/UnaryExpr.cpp +++ b/extensions/transformiix/source/xpath/UnaryExpr.cpp @@ -27,9 +27,14 @@ #include "ExprResult.h" #include "txIXPathContext.h" -UnaryExpr::UnaryExpr(nsAutoPtr aExpr) - : expr(aExpr) +UnaryExpr::UnaryExpr(Expr* expr) { + this->expr = expr; +} + +UnaryExpr::~UnaryExpr() +{ + delete expr; } /* diff --git a/extensions/transformiix/source/xpath/UnionExpr.cpp b/extensions/transformiix/source/xpath/UnionExpr.cpp index 11d37c93bc5..12153e62529 100644 --- a/extensions/transformiix/source/xpath/UnionExpr.cpp +++ b/extensions/transformiix/source/xpath/UnionExpr.cpp @@ -32,6 +32,13 @@ //-------------/ +/** + * Creates a new UnionExpr +**/ +UnionExpr::UnionExpr() { + //-- do nothing +} + /** * Destructor, will delete all Path Expressions **/ @@ -46,15 +53,9 @@ UnionExpr::~UnionExpr() { * Adds the Expr to this UnionExpr * @param expr the Expr to add to this UnionExpr **/ -nsresult -UnionExpr::addExpr(nsAutoPtr aExpr) -{ - nsresult rv = expressions.add(aExpr); - NS_ENSURE_SUCCESS(rv, rv); - - aExpr.forget(); - - return NS_OK; +void UnionExpr::addExpr(Expr* expr) { + if (expr) + expressions.add(expr); } //-- addExpr //-----------------------------/ diff --git a/extensions/transformiix/source/xpath/VariableRefExpr.cpp b/extensions/transformiix/source/xpath/VariableRefExpr.cpp index 1e9cea6bddb..828f9da1974 100644 --- a/extensions/transformiix/source/xpath/VariableRefExpr.cpp +++ b/extensions/transformiix/source/xpath/VariableRefExpr.cpp @@ -44,6 +44,13 @@ VariableRefExpr::VariableRefExpr(nsIAtom* aPrefix, nsIAtom* aLocalName, mPrefix = 0; } +/* + * Release the local name atom + */ +VariableRefExpr::~VariableRefExpr() +{ +} + /** * Evaluates this Expr based on the given context node and processor state * @param context the context node for evaluation of this Expr diff --git a/extensions/transformiix/source/xpath/txNameTest.cpp b/extensions/transformiix/source/xpath/txNameTest.cpp index c54c73adf65..bff91f825b3 100644 --- a/extensions/transformiix/source/xpath/txNameTest.cpp +++ b/extensions/transformiix/source/xpath/txNameTest.cpp @@ -37,6 +37,10 @@ txNameTest::txNameTest(nsIAtom* aPrefix, nsIAtom* aLocalName, PRInt32 aNSID, NS_ASSERTION(aLocalName, "txNameTest without a local name?"); } +txNameTest::~txNameTest() +{ +} + /* * Determines whether this txNodeTest matches the given node */ diff --git a/extensions/transformiix/source/xpath/txNodeTypeTest.cpp b/extensions/transformiix/source/xpath/txNodeTypeTest.cpp index 06e39d39258..76e8fd5132b 100644 --- a/extensions/transformiix/source/xpath/txNodeTypeTest.cpp +++ b/extensions/transformiix/source/xpath/txNodeTypeTest.cpp @@ -35,6 +35,10 @@ txNodeTypeTest::txNodeTypeTest(NodeType aNodeType) { } +txNodeTypeTest::~txNodeTypeTest() +{ +} + void txNodeTypeTest::setNodeName(const nsAString& aName) { mNodeName = do_GetAtom(aName); diff --git a/extensions/transformiix/source/xslt/txXSLTPatterns.cpp b/extensions/transformiix/source/xslt/txXSLTPatterns.cpp index 4f9ee84a55c..62067d1be0e 100644 --- a/extensions/transformiix/source/xslt/txXSLTPatterns.cpp +++ b/extensions/transformiix/source/xslt/txXSLTPatterns.cpp @@ -459,6 +459,11 @@ void txKeyPattern::toString(nsAString& aDest) * a txPattern to hold the NodeTest and the Predicates of a StepPattern */ +txStepPattern::~txStepPattern() +{ + delete mNodeTest; +} + MBool txStepPattern::matches(Node* aNode, txIMatchContext* aContext) { NS_ASSERTION(mNodeTest && aNode, "Internal error"); diff --git a/extensions/transformiix/source/xslt/txXSLTPatterns.h b/extensions/transformiix/source/xslt/txXSLTPatterns.h index 56e4f5e013f..3b06d7b37dc 100644 --- a/extensions/transformiix/source/xslt/txXSLTPatterns.h +++ b/extensions/transformiix/source/xslt/txXSLTPatterns.h @@ -131,7 +131,12 @@ private: { } - nsAutoPtr pattern; + ~Step() + { + delete pattern; + } + + txPattern* pattern; MBool isChild; }; @@ -193,9 +198,12 @@ public: { } + ~txStepPattern(); + TX_DECL_PATTERN; - nsAutoPtr mNodeTest; +private: + txNodeTest* mNodeTest; MBool mIsAttr; };