LCOV - code coverage report
Current view: directory - content/xslt/src/xpath - txUnionExpr.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 38 0 0.0 %
Date: 2012-06-02 Functions: 7 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is TransforMiiX XSLT processor code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * The MITRE Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1999
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Keith Visco <kvisco@ziplink.net> (Original Author)
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      27                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #include "txExpr.h"
      40                 : #include "txIXPathContext.h"
      41                 : #include "txNodeSet.h"
      42                 : 
      43                 :   //-------------/
      44                 :  //- UnionExpr -/
      45                 : //-------------/
      46                 : 
      47                 :     //-----------------------------/
      48                 :   //- Virtual methods from Expr -/
      49                 : //-----------------------------/
      50                 : 
      51                 : /**
      52                 :  * Evaluates this Expr based on the given context node and processor state
      53                 :  * @param context the context node for evaluation of this Expr
      54                 :  * @param ps the ContextState containing the stack information needed
      55                 :  * for evaluation
      56                 :  * @return the result of the evaluation
      57                 : **/
      58                 : nsresult
      59               0 : UnionExpr::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
      60                 : {
      61               0 :     *aResult = nsnull;
      62               0 :     nsRefPtr<txNodeSet> nodes;
      63               0 :     nsresult rv = aContext->recycler()->getNodeSet(getter_AddRefs(nodes));
      64               0 :     NS_ENSURE_SUCCESS(rv, rv);
      65                 : 
      66               0 :     PRUint32 i, len = mExpressions.Length();
      67               0 :     for (i = 0; i < len; ++i) {
      68               0 :         nsRefPtr<txAExprResult> exprResult;
      69               0 :         rv = mExpressions[i]->evaluate(aContext, getter_AddRefs(exprResult));
      70               0 :         NS_ENSURE_SUCCESS(rv, rv);
      71                 : 
      72               0 :         if (exprResult->getResultType() != txAExprResult::NODESET) {
      73                 :             //XXX ErrorReport: report nonnodeset error
      74               0 :             return NS_ERROR_XSLT_NODESET_EXPECTED;
      75                 :         }
      76                 : 
      77               0 :         nsRefPtr<txNodeSet> resultSet, ownedSet;
      78                 :         resultSet = static_cast<txNodeSet*>
      79               0 :                                (static_cast<txAExprResult*>(exprResult));
      80               0 :         exprResult = nsnull;
      81               0 :         rv = aContext->recycler()->
      82               0 :             getNonSharedNodeSet(resultSet, getter_AddRefs(ownedSet));
      83               0 :         NS_ENSURE_SUCCESS(rv, rv);
      84                 : 
      85               0 :         rv = nodes->addAndTransfer(ownedSet);
      86               0 :         NS_ENSURE_SUCCESS(rv, rv);
      87                 :     }
      88                 : 
      89               0 :     *aResult = nodes;
      90               0 :     NS_ADDREF(*aResult);
      91                 : 
      92               0 :     return NS_OK;
      93                 : } //-- evaluate
      94                 : 
      95                 : Expr::ExprType
      96               0 : UnionExpr::getType()
      97                 : {
      98               0 :   return UNION_EXPR;
      99                 : }
     100                 : 
     101               0 : TX_IMPL_EXPR_STUBS_LIST(UnionExpr, NODESET_RESULT, mExpressions)
     102                 : 
     103                 : bool
     104               0 : UnionExpr::isSensitiveTo(ContextSensitivity aContext)
     105                 : {
     106               0 :     PRUint32 i, len = mExpressions.Length();
     107               0 :     for (i = 0; i < len; ++i) {
     108               0 :         if (mExpressions[i]->isSensitiveTo(aContext)) {
     109               0 :             return true;
     110                 :         }
     111                 :     }
     112                 : 
     113               0 :     return false;
     114                 : }
     115                 : 
     116                 : #ifdef TX_TO_STRING
     117                 : void
     118               0 : UnionExpr::toString(nsAString& dest)
     119                 : {
     120                 :     PRUint32 i;
     121               0 :     for (i = 0; i < mExpressions.Length(); ++i) {
     122               0 :         if (i > 0)
     123               0 :             dest.AppendLiteral(" | ");
     124               0 :         mExpressions[i]->toString(dest);
     125                 :     }
     126               0 : }
     127                 : #endif

Generated by: LCOV version 1.7