You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@locus.apache.org on 2000/08/04 23:30:52 UTC
cvs commit: xml-xalan/c/src/XPath XPath.cpp XPath.hpp XPathExpression.cpp XPathFunctionTable.cpp XPathFunctionTable.hpp XPathProcessorImpl.cpp XPathProcessorImpl.hpp
dbertoni 00/08/04 14:30:52
Modified: c/src/XPath XPath.cpp XPath.hpp XPathExpression.cpp
XPathFunctionTable.cpp XPathFunctionTable.hpp
XPathProcessorImpl.cpp XPathProcessorImpl.hpp
Log:
Encode number of arguments for function in the op map. Added a facility to uninstall a function from the function table.
Revision Changes Path
1.24 +12 -0 xml-xalan/c/src/XPath/XPath.cpp
Index: XPath.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPath.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- XPath.cpp 2000/07/28 22:01:56 1.23
+++ XPath.cpp 2000/08/04 21:30:46 1.24
@@ -139,6 +139,13 @@
+bool
+XPath::uninstallFunction(const XalanDOMString& funcName)
+{
+ return s_functions.UninstallFunction(funcName);
+}
+
+
XLocator*
XPath::createXLocatorHandler() const
{
@@ -1413,6 +1420,11 @@
// This is actually the position in the token queue of the
// string that contains the name of the function.
const int funcID = m_expression.m_opMap[opPos];
+
+ opPos++;
+
+ // Number of args is next...
+ const int argCount = m_expression.m_opMap[opPos];
opPos++;
1.13 +9 -0 xml-xalan/c/src/XPath/XPath.hpp
Index: XPath.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPath.hpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- XPath.hpp 2000/07/14 16:55:55 1.12
+++ XPath.hpp 2000/08/04 21:30:46 1.13
@@ -354,6 +354,15 @@
const Function& func);
/**
+ * Remove a named function from the function table.
+ *
+ * @param funcName name of function
+ * @return true if the function was found and removed.
+ */
+ static bool
+ uninstallFunction(const XalanDOMString& funcName);
+
+ /**
* Whether the named function is installed in the function table.
*
* @param name of function
1.11 +1 -1 xml-xalan/c/src/XPath/XPathExpression.cpp
Index: XPathExpression.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExpression.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- XPathExpression.cpp 2000/07/21 19:50:03 1.10
+++ XPathExpression.cpp 2000/08/04 21:30:46 1.11
@@ -759,7 +759,7 @@
theMap[eOP_NUMBERLIT] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_ARGUMENT] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_EXTFUNCTION] = 3 + s__opCodeMapLengthIndex;
- theMap[eOP_FUNCTION] = 2 + s__opCodeMapLengthIndex;
+ theMap[eOP_FUNCTION] = 3 + s__opCodeMapLengthIndex;
theMap[eOP_LOCATIONPATH] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_PREDICATE] = 1 + s__opCodeMapLengthIndex;
theMap[eNODETYPE_COMMENT] = 1;
1.8 +34 -1 xml-xalan/c/src/XPath/XPathFunctionTable.cpp
Index: XPathFunctionTable.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathFunctionTable.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XPathFunctionTable.cpp 2000/07/27 20:35:23 1.7
+++ XPathFunctionTable.cpp 2000/08/04 21:30:46 1.8
@@ -116,7 +116,7 @@
assert(length(theFunctionName) != 0);
// See if a function of that name is already installed...
- const FunctionNameIndexMapType::iterator i =
+ const FunctionNameIndexMapType::const_iterator i =
m_FunctionNameIndex.find(theFunctionName);
if (i != m_FunctionNameIndex.end())
@@ -135,6 +135,39 @@
m_FunctionCollection.push_back(theFunction.clone());
m_FunctionNameIndex[theFunctionName] = theIndex;
+ }
+}
+
+
+
+bool
+XPathFunctionTable::UninstallFunction(const XalanDOMString& theFunctionName)
+{
+ assert(length(theFunctionName) != 0);
+
+ // See if a function of that name is installed...
+ const FunctionNameIndexMapType::iterator i =
+ m_FunctionNameIndex.find(theFunctionName);
+
+ if (i == m_FunctionNameIndex.end())
+ {
+ return false;
+ }
+ else
+ {
+ assert(CollectionType::size_type(i->second) < m_FunctionCollection.size());
+
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::find;
+#endif
+
+ // Delete the function...
+ delete m_FunctionCollection[i->second];
+
+ // Erase it from the table...
+ m_FunctionCollection.erase(&m_FunctionCollection[i->second]);
+
+ return true;
}
}
1.7 +8 -0 xml-xalan/c/src/XPath/XPathFunctionTable.hpp
Index: XPathFunctionTable.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathFunctionTable.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XPathFunctionTable.hpp 2000/07/27 20:35:23 1.6
+++ XPathFunctionTable.hpp 2000/08/04 21:30:46 1.7
@@ -231,6 +231,14 @@
const XalanDOMString& theFunctionName,
const Function& theFunction);
+ /**
+ * Remove a named function from the function table.
+ *
+ * @param theFunctionName name of function
+ * @return true if the function was found and removed.
+ */
+ bool
+ UninstallFunction(const XalanDOMString& theFunctionName);
/**
* Whether a named function is in the function table.
1.17 +49 -25 xml-xalan/c/src/XPath/XPathProcessorImpl.cpp
Index: XPathProcessorImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathProcessorImpl.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- XPathProcessorImpl.cpp 2000/07/27 20:35:23 1.16
+++ XPathProcessorImpl.cpp 2000/08/04 21:30:47 1.17
@@ -1604,6 +1604,42 @@
+int
+XPathProcessorImpl::FunctionCallArguments()
+{
+ int argCount = 0;
+
+ consumeExpected('(');
+
+ while(tokenIs(')') == false)
+ {
+ if(tokenIs(',') == true)
+ {
+ error("Found ',' but no preceding argument!");
+ }
+
+ Argument();
+
+ ++argCount;
+
+ if(tokenIs(')') == false)
+ {
+
+ consumeExpected(',');
+
+ if(tokenIs(')') == true)
+ {
+ error("Found ',' but no following argument!");
+ }
+ }
+ }
+
+ consumeExpected(')');
+
+ return argCount;
+}
+
+
void
XPathProcessorImpl::FunctionCall()
{
@@ -1625,11 +1661,13 @@
theArgs[1] = m_expression->getTokenPosition() - 1;
- nextToken();
-
m_expression->setOpCodeArgs(XPathExpression::eOP_EXTFUNCTION,
opPos,
theArgs);
+
+ nextToken();
+
+ FunctionCallArguments();
}
else
{
@@ -1664,7 +1702,10 @@
int theFunctionID =
XPath::getFunctionTable().nameToID(m_token);
- XPathExpression::OpCodeMapValueVectorType theArgs(1, theFunctionID);
+ XPathExpression::OpCodeMapValueVectorType theArgs(2);
+
+ theArgs[0] = theFunctionID;
+ theArgs[1] = 0;
m_expression->appendOpCode(XPathExpression::eOP_FUNCTION,
theArgs);
@@ -1672,32 +1713,15 @@
}
nextToken();
- }
-
- consumeExpected('(');
-
- while(tokenIs(')') == false)
- {
- if(tokenIs(',') == true)
- {
- error("Found ',' but no preceding argument!");
- }
- Argument();
+ // Get the arguments, and the argument count...
+ const int argCount = FunctionCallArguments();
- if(tokenIs(')') == false)
- {
-
- consumeExpected(',');
+ assert(m_expression->m_opMap[opPos + 3] == 0);
- if(tokenIs(')') == true)
- {
- error("Found ',' but no following argument!");
- }
- }
+ // update the arg count in the op map...
+ m_expression->m_opMap[opPos + 3] = argCount;
}
-
- consumeExpected(')');
// Terminate for safety.
m_expression->appendOpCode(XPathExpression::eENDOP);
1.6 +3 -0 xml-xalan/c/src/XPath/XPathProcessorImpl.hpp
Index: XPathProcessorImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathProcessorImpl.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XPathProcessorImpl.hpp 2000/05/03 21:21:17 1.5
+++ XPathProcessorImpl.hpp 2000/08/04 21:30:47 1.6
@@ -738,6 +738,9 @@
private:
+ int
+ FunctionCallArguments();
+
static void
initializeKeywordsTable();