txErrorExpr.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "nsError.h"
  6. #include "txExpr.h"
  7. #include "nsString.h"
  8. #include "txIXPathContext.h"
  9. nsresult
  10. txErrorExpr::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
  11. {
  12. *aResult = nullptr;
  13. nsAutoString err(NS_LITERAL_STRING("Invalid expression evaluated"));
  14. #ifdef TX_TO_STRING
  15. err.AppendLiteral(": ");
  16. toString(err);
  17. #endif
  18. aContext->receiveError(err,
  19. NS_ERROR_XPATH_INVALID_EXPRESSION_EVALUATED);
  20. return NS_ERROR_XPATH_INVALID_EXPRESSION_EVALUATED;
  21. }
  22. TX_IMPL_EXPR_STUBS_0(txErrorExpr, ANY_RESULT)
  23. bool
  24. txErrorExpr::isSensitiveTo(ContextSensitivity aContext)
  25. {
  26. // It doesn't really matter what we return here, but it might
  27. // be a good idea to try to keep this as unoptimizable as possible
  28. return true;
  29. }
  30. #ifdef TX_TO_STRING
  31. void
  32. txErrorExpr::toString(nsAString& aStr)
  33. {
  34. aStr.Append(mStr);
  35. }
  36. #endif