TBool CMMFSwCodecUtility::RampAudio(CMMFDataBuffer* aBuffer) { TInt i=0; TInt length = aBuffer->Data().Length()>>1; TInt16* sample = REINTERPRET_CAST(TInt16*,&aBuffer->Data()[0]); TInt64 theResult(0); while ((i < length) && (iRampIncr < iRampSamples)) { theResult = sample[i]; theResult *= iRampIncr; theResult /= iRampSamples; sample[i] = STATIC_CAST(TInt16, I64LOW(theResult) ); if ((iChannels == 1) || (!iSkip)) { iRampIncr++; } iSkip = !iSkip; i++; } if (iRampIncr < iRampSamples) return ETrue; else return EFalse; }
void ElemMessage::execute(StylesheetExecutionContext& executionContext) const { ElemTemplateElement::execute(executionContext); StylesheetExecutionContext::GetAndReleaseCachedString theResult(executionContext); const XalanDOMString& theString = childrenToString( executionContext, theResult.get()); const LocatorType* const theLocator = getLocator(); executionContext.message( theString, executionContext.getCurrentNode(), theLocator); if (m_terminate == true) { if (theLocator != 0) { throw ElemMessageTerminateException(*theLocator, theString); } else { throw ElemMessageTerminateException(theString); } } }
void TestStringResults( XPathFactory& theXPathFactory, XPathProcessor& theXPathProcessor, XPathEnvSupport& theXPathEnvSupport, DOMSupport& theDOMSupport, PrintWriter& thePrintWriter, XPathExecutionContext& theExecutionContext) { assert(sizeof(theStringTestInput) == sizeof(theStringTestExpectedOutput)); MemoryManagerType& theMemoryManager = theExecutionContext.getMemoryManager(); for(int i = 0; theStringTestInput[i] != 0; i++) { try { XPath* const theXPath = theXPathFactory.create(); XPathConstructionContextDefault theXPathConstructionContext(theMemoryManager); const XPathGuard theGuard( theXPathFactory, theXPath); XalanDOMString theInputString(theMemoryManager); XalanDOMString theResult(theMemoryManager); const ElementPrefixResolverProxy thePrefixResolver( 0, theXPathEnvSupport, theDOMSupport); const NodeRefList theDummyNodeList(theMemoryManager); TestStringResult( theXPathProcessor, *theXPath, theXPathConstructionContext, TranscodeFromLocalCodePage(theStringTestInput[i], theInputString), thePrintWriter, TranscodeFromLocalCodePage(theStringTestExpectedOutput[i], theResult), 0, thePrefixResolver, theDummyNodeList, theExecutionContext); } catch(...) { thePrintWriter.print("Exception caught evaluating XPath \""); thePrintWriter.print(theStringTestInput[i]); thePrintWriter.println(); } } }
GetCachedNodeList clone() const { assert(m_xpathExecutionContext != 0); GetCachedNodeList theResult(*m_xpathExecutionContext); *theResult = *m_mutableNodeRefList; return theResult; }
BorrowReturnMutableNodeRefList clone() const { assert(m_xpathExecutionContext != 0); BorrowReturnMutableNodeRefList theResult(*m_xpathExecutionContext); *theResult = *m_mutableNodeRefList; return theResult; }
XObjectPtr FunctionSubstringBefore::execute( XPathExecutionContext& executionContext, XalanNode* /* context */, const XObjectPtr arg1, const XObjectPtr arg2, const LocatorType* /* locator */) const { assert(arg1.null() == false && arg2.null() == false); const XalanDOMString& theFirstString = arg1->str(); const XalanDOMString::size_type theFirstStringLength = length(theFirstString); if (theFirstStringLength == 0) { return createEmptyString(executionContext); } else { const XalanDOMString& theSecondString = arg2->str(); const XalanDOMString::size_type theSecondStringLength = length(theSecondString); if (theSecondStringLength == 0) { return createEmptyString(executionContext); } else { const XalanDOMString::size_type theIndex = indexOf(theFirstString, theSecondString); if (theIndex == theFirstStringLength) { return createEmptyString(executionContext); } else { XPathExecutionContext::GetAndReleaseCachedString theResult(executionContext); XalanDOMString& theString = theResult.get(); theString.assign( toCharArray(theFirstString), theIndex); // Create a string of the appropriate length... return executionContext.getXObjectFactory().createString(theResult); } } } }
/** * Determine the fully qualified URI for a string. * * @param urlString string to qualify * @param base base location for URI * @return auto pointer to fully qualified URI */ static URLAutoPtrType getURLFromString( const XalanDOMString& urlString, const XalanDOMString& base, MemoryManagerType& theManager) { XalanDOMString theResult(theManager); getURLStringFromString(urlString, base, theResult); return getURLFromString(theResult, theManager); }
void ExtensionNSHandler::setElements(const XalanDOMString& elemNames) { if (elemNames.empty() == false) { StringTokenizer st(elemNames, s_tokenDelimiterCharacters, false); XalanDOMString theResult(m_elements.getMemoryManager()); while (st.hasMoreTokens() == true) { st.nextToken(theResult); m_elements.insert(theResult); // just stick it in there basically } m_componentDescLoaded = true; } }
XObjectPtr FunctionSubstring::execute( XPathExecutionContext& executionContext, XalanNode* /* context */, const XObjectPtr arg1, const XObjectPtr arg2, const XObjectPtr arg3, const LocatorType* /* locator */) const { assert(arg1.null() == false && arg2.null() == false); const XalanDOMString& theSourceString = arg1->str(); const XalanDOMString::size_type theSourceStringLength = length(theSourceString); if (theSourceStringLength == 0) { return createEmptyString(executionContext); } else { // Get the value of the second argument... const double theSecondArgValue = DoubleSupport::round(arg2->num()); // XPath indexes from 1, so this is the first XPath index.... const XalanDOMString::size_type theStartIndex = getStartIndex(theSecondArgValue, theSourceStringLength); if (theStartIndex >= theSourceStringLength) { return createEmptyString(executionContext); } else { const double theTotal = getTotal(theSourceStringLength, theSecondArgValue, arg3); if (DoubleSupport::isNaN(theSecondArgValue) == true || DoubleSupport::isNaN(theTotal) == true || DoubleSupport::isNegativeInfinity(theTotal) == true || theTotal == 0.0 || theTotal < double(theStartIndex)) { return createEmptyString(executionContext); } else { const XalanDOMString::size_type theSubstringLength = getSubstringLength( theSourceStringLength, theStartIndex, theTotal); XPathExecutionContext::GetAndReleaseCachedString theResult(executionContext); XalanDOMString& theString = theResult.get(); assign( theString, toCharArray(theSourceString) + theStartIndex, theSubstringLength); return executionContext.getXObjectFactory().createString(theResult); } } } }
XObjectPtr FunctionSubstringAfter::execute( XPathExecutionContext& executionContext, XalanNode* /* context */, const XObjectPtr arg1, const XObjectPtr arg2, const LocatorType* /* locator */) const { assert(arg1.null() == false && arg2.null() == false); const XalanDOMString& theFirstString = arg1->str(); const XalanDOMString::size_type theFirstStringLength = length(theFirstString); if (theFirstStringLength == 0) { return createEmptyString(executionContext); } else { const XalanDOMString& theSecondString = arg2->str(); const XalanDOMString::size_type theSecondStringLength = length(theSecondString); if (theSecondStringLength == 0) { return arg1; } else { const XalanDOMString::size_type theIndex = indexOf(theFirstString, theSecondString); if (theIndex == theFirstStringLength) { return createEmptyString(executionContext); } else { const XalanDOMString::size_type theSecondStringLength = length(theSecondString); // Find the first character, which will be the offset of the index of the // beginning of the second string, plus the length of the second string. const XalanDOMChar* const theFirstCharacter = toCharArray(theFirstString) + theIndex + theSecondStringLength; // The remaining length is just the opposite -- the length of the string, // minus the index, minus the length of the second string. const XalanDOMString::size_type theSubstringLength = theFirstStringLength - theIndex - theSecondStringLength; XPathExecutionContext::GetAndReleaseCachedString theResult(executionContext); XalanDOMString& theString = theResult.get(); assign( theString, theFirstCharacter, theSubstringLength); return executionContext.getXObjectFactory().createString(theResult); } } } }
bool TestPredicateResult( XPathProcessor& theXPathProcessor, XPathEnvSupport& theXPathEnvSupport, DOMSupport& theDOMSupport, XMLParserLiaison& theLiaison, XPathFactory& theXPathFactory, const XalanDOMString& theXMLFileURL, const XalanDOMString& theXSLFileURL, PrintWriter& thePrintWriter, XPathExecutionContext& theExecutionContext) { bool fError = false; XalanDocument* const theXMLDocument = ParseXML(theLiaison, theXMLFileURL); MemoryManagerType& theMemoryManager = theExecutionContext.getMemoryManager(); if (theXMLDocument != 0) { XalanDOMString theContextNodeMatchPattern(theMemoryManager); XalanDOMString theXPathString(theMemoryManager); if (GetXSLInput(theLiaison, theXSLFileURL, theContextNodeMatchPattern, theXPathString, theMemoryManager) == true) { XalanNode* const theContextNode = FindContextNode(theXPathProcessor, theXPathEnvSupport, theDOMSupport, theXPathFactory, theXMLDocument, theContextNodeMatchPattern, thePrintWriter, theExecutionContext); if (theContextNode != 0) { XalanElement* const theNamespaceContext = 0; ElementPrefixResolverProxy thePrefixResolver(theNamespaceContext, theXPathEnvSupport, theDOMSupport); NodeRefList theContextNodeList(theMemoryManager); XPath* const theXPath1 = theXPathFactory.create(); XPathConstructionContextDefault theXPathConstructionContext(theMemoryManager); XPathGuard theGuard1(theXPathFactory, theXPath1); XalanDOMString theResult(theMemoryManager); theXPathProcessor.initXPath(*theXPath1, theXPathConstructionContext, TranscodeFromLocalCodePage("following-sibling::*", theResult), thePrefixResolver); XPath* const theXPath2 = theXPathFactory.create(); XPathGuard theGuard2(theXPathFactory, theXPath2); theXPathProcessor.initXPath(*theXPath2, theXPathConstructionContext, TranscodeFromLocalCodePage("descendant::*", theResult), thePrefixResolver); bool fDump = false; if (fDump == true) { thePrintWriter.println(); thePrintWriter.println(); theXPath1->getExpression().dumpOpCodeMap(thePrintWriter); thePrintWriter.println(); theXPath1->getExpression().dumpTokenQueue(thePrintWriter); thePrintWriter.println(); thePrintWriter.println(); theXPath2->getExpression().dumpOpCodeMap(thePrintWriter); thePrintWriter.println(); theXPath2->getExpression().dumpTokenQueue(thePrintWriter); thePrintWriter.println(); thePrintWriter.println(); } XalanNode* theContextNode = theXMLDocument->getFirstChild()->getFirstChild(); for( ; theContextNode != 0; theContextNode = theContextNode->getNextSibling()) { if (theContextNode->getNodeType() != XalanNode::ELEMENT_NODE) { continue; } const XObjectPtr theResult1 = theXPath1->execute(theExecutionContext); try { assert(theResult1.null() == false); const NodeRefListBase& theResultList = theResult1->nodeset(); const unsigned int theLength = theResultList.getLength(); thePrintWriter.print("theResult1->str() == \""); thePrintWriter.print(theResult1->str()); thePrintWriter.print("\""); thePrintWriter.println(); if (theLength > 0) { for (unsigned int i = 0; i < theLength; i++) { thePrintWriter.print(theResultList.item(i)->getNodeName()); thePrintWriter.println(); } } } catch(...) { thePrintWriter.print("Execution of XPath "); thePrintWriter.print(theXPathString); thePrintWriter.println(" failed!"); } const XObjectPtr theResult2 = theXPath2->execute(theExecutionContext); try { assert(theResult2.null() == false); const NodeRefListBase& theResultList = theResult2->nodeset(); const int theLength = theResultList.getLength(); thePrintWriter.print("theResult2->str() == \""); thePrintWriter.print(theResult2->str()); thePrintWriter.print("\""); thePrintWriter.println(); if (theLength > 0) { for (int i = 0; i < theLength; i++) { thePrintWriter.print(theResultList.item(i)->getNodeName()); thePrintWriter.println(); } } } catch(...) { thePrintWriter.print("Execution of XPath "); thePrintWriter.print(theXPathString); thePrintWriter.println(" failed!"); } if (theResult1->equals(*theResult2, theExecutionContext) == true) { thePrintWriter.print("theResult1 is equal to theResult2"); thePrintWriter.println(); thePrintWriter.print("theContextNode->getNodeName() == \""); thePrintWriter.print(theContextNode->getNodeName()); thePrintWriter.print("\" theContextNode->getNodeValue() == \""); thePrintWriter.print(theContextNode->getNodeValue()); thePrintWriter.println("\""); } } } } } return fError; }