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/14 18:34:08 UTC
cvs commit: xml-xalan/c/src/XPath FunctionDefaultStringArgument.hpp FunctionID.hpp FunctionNamespaceURI.hpp FunctionNumber.hpp SimpleNodeLocator.cpp XNodeSet.cpp XNodeSet.hpp XObjectFactory.hpp XObjectFactoryDefault.cpp XObjectFactoryDefault.hpp XPath.cpp XPath.hpp XPathExecutionContext.hpp XPathExecutionContextDefault.cpp XPathExecutionContextDefault.hpp XPathFunctionTable.hpp XSpan.cpp XSpan.hpp
dbertoni 00/08/14 09:34:07
Modified: c/src/XPath FunctionDefaultStringArgument.hpp FunctionID.hpp
FunctionNamespaceURI.hpp FunctionNumber.hpp
SimpleNodeLocator.cpp XNodeSet.cpp XNodeSet.hpp
XObjectFactory.hpp XObjectFactoryDefault.cpp
XObjectFactoryDefault.hpp XPath.cpp XPath.hpp
XPathExecutionContext.hpp
XPathExecutionContextDefault.cpp
XPathExecutionContextDefault.hpp
XPathFunctionTable.hpp XSpan.cpp XSpan.hpp
Log:
Changes for reusing node lists.
Revision Changes Path
1.7 +1 -1 xml-xalan/c/src/XPath/FunctionDefaultStringArgument.hpp
Index: FunctionDefaultStringArgument.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionDefaultStringArgument.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FunctionDefaultStringArgument.hpp 2000/07/12 21:46:50 1.6
+++ FunctionDefaultStringArgument.hpp 2000/08/14 16:33:54 1.7
@@ -125,7 +125,7 @@
// A node set that contains the context node.
XObjectGuard theArg(executionContext.getXObjectFactory(),
- executionContext.getXObjectFactory().createNodeSet(context));
+ executionContext.createNodeSet(context));
// Now, get the string from the XObject.
return theArg->str();
1.11 +4 -5 xml-xalan/c/src/XPath/FunctionID.hpp
Index: FunctionID.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionID.hpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- FunctionID.hpp 2000/08/10 18:37:29 1.10
+++ FunctionID.hpp 2000/08/14 16:33:54 1.11
@@ -145,12 +145,11 @@
context->getOwnerDocument();
assert(theDocContext != 0);
+ typedef XPathExecutionContext::BorrowReturnMutableNodeRefList BorrowReturnMutableNodeRefList;
+
// This list will hold the nodes we find.
-#if !defined(XALAN_NO_NAMESPACES)
- using std::auto_ptr;
-#endif
- auto_ptr<MutableNodeRefList> theNodeList(executionContext.createMutableNodeRefList());
+ BorrowReturnMutableNodeRefList theNodeList(executionContext);
// If there is no context, we cannot continue.
if(0 == theDocContext)
@@ -199,7 +198,7 @@
}
}
- return executionContext.getXObjectFactory().createNodeSet(theNodeList.release());
+ return executionContext.getXObjectFactory().createNodeSet(theNodeList);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
1.6 +1 -1 xml-xalan/c/src/XPath/FunctionNamespaceURI.hpp
Index: FunctionNamespaceURI.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionNamespaceURI.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FunctionNamespaceURI.hpp 2000/07/12 21:46:50 1.5
+++ FunctionNamespaceURI.hpp 2000/08/14 16:33:54 1.6
@@ -130,7 +130,7 @@
// An XObject that contains the context node.
XObjectGuard theXObject(executionContext.getXObjectFactory(),
- executionContext.getXObjectFactory().createNodeSet(*context));
+ executionContext.createNodeSet(*context));
theNamespace = getNamespaceFromNodeSet(*theXObject.get(),
1.6 +1 -1 xml-xalan/c/src/XPath/FunctionNumber.hpp
Index: FunctionNumber.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionNumber.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FunctionNumber.hpp 2000/07/12 21:46:51 1.5
+++ FunctionNumber.hpp 2000/08/14 16:33:54 1.6
@@ -127,7 +127,7 @@
// An XObject that contains the context node.
XObjectGuard theXObject(executionContext.getXObjectFactory(),
- executionContext.getXObjectFactory().createNodeSet(*context));
+ executionContext.createNodeSet(*context));
// Get the numeric value of the theXObject...
theValue = theXObject->num();
1.21 +6 -7 xml-xalan/c/src/XPath/SimpleNodeLocator.cpp
Index: SimpleNodeLocator.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/SimpleNodeLocator.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- SimpleNodeLocator.cpp 2000/08/10 18:37:31 1.20
+++ SimpleNodeLocator.cpp 2000/08/14 16:33:55 1.21
@@ -116,6 +116,7 @@
int /* opPos */,
const ConnectArgsVectorType& connectArgs)
{
+#if 0
assert(connectArgs.size() > 0 && connectArgs.size() < 3);
XObjectFactory& theFactory =
@@ -124,7 +125,6 @@
XObjectGuard results(theFactory,
theFactory.createNodeSet(executionContext.createMutableNodeRefList()));
-#if 0
const XPathExpression& currentExpression =
xpath.getExpression();
@@ -198,9 +198,10 @@
{
executionContext.warn("No files matched the file specification!");
}
+ return results.release();
#endif
- return results.release();
+ return 0;
}
@@ -212,15 +213,13 @@
XalanNode& context,
int opPos)
{
-#if !defined(XALAN_NO_NAMESPACES)
- using std::auto_ptr;
-#endif
+ typedef XPathExecutionContext::BorrowReturnMutableNodeRefList BorrowReturnMutableNodeRefList;
- auto_ptr<MutableNodeRefList> mnl(executionContext.createMutableNodeRefList());
+ BorrowReturnMutableNodeRefList mnl(executionContext);
step(xpath, executionContext, &context, opPos + 2, *mnl.get());
- return executionContext.getXObjectFactory().createNodeSet(mnl.release());
+ return executionContext.getXObjectFactory().createNodeSet(mnl);
}
1.13 +3 -31 xml-xalan/c/src/XPath/XNodeSet.cpp
Index: XNodeSet.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XNodeSet.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- XNodeSet.cpp 2000/08/10 18:37:33 1.12
+++ XNodeSet.cpp 2000/08/14 16:33:55 1.13
@@ -75,49 +75,21 @@
-XNodeSet::XNodeSet(NodeRefListBase* value) :
+XNodeSet::XNodeSet(BorrowReturnMutableNodeRefList& value) :
XObject(),
- m_value(value == 0 ? new NodeRefList : value),
+ m_value(value),
m_cachedStringValue(),
m_cachedNumberValue(0.0),
m_resultTreeFrag()
{
- assert(value != 0);
}
-MutableNodeRefList*
-createNodeListWithNode(XalanNode* node)
-{
-#if !defined(XALAN_NO_NAMESPACES)
- using std::auto_ptr;
-#endif
-
- auto_ptr<MutableNodeRefList> resultNodeList(new MutableNodeRefList);
-
- resultNodeList->addNode(node);
-
- return resultNodeList.release();
-}
-
-
-
-XNodeSet::XNodeSet(XalanNode& value) :
- XObject(),
- m_value(createNodeListWithNode(&value)),
- m_resultTreeFrag(),
- m_cachedStringValue(),
- m_cachedNumberValue(0.0)
-{
-}
-
-
-
XNodeSet::XNodeSet(const XNodeSet& source,
bool deepClone) :
XObject(source),
- m_value(source.m_value->clone()),
+ m_value(source.m_value.clone()),
m_resultTreeFrag(source.m_resultTreeFrag.get() == 0 ?
0 :
source.m_resultTreeFrag->clone(deepClone)),
1.13 +10 -12 xml-xalan/c/src/XPath/XNodeSet.hpp
Index: XNodeSet.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XNodeSet.hpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- XNodeSet.hpp 2000/08/10 18:37:33 1.12
+++ XNodeSet.hpp 2000/08/14 16:33:55 1.13
@@ -73,6 +73,10 @@
+#include <XPath/XPathExecutionContext.hpp>
+
+
+
class XalanNode;
@@ -84,19 +88,14 @@
{
public:
+ typedef XPathExecutionContext::BorrowReturnMutableNodeRefList BorrowReturnMutableNodeRefList;
+
/**
* Create an XNodeSet from a node list.
*
* @param value Pointer to source node list. The XNodeSet will adopt the pointer.
- */
- XNodeSet(NodeRefListBase* value);
-
- /**
- * Create an XNodeSet from a node.
- *
- * @param value source node
*/
- XNodeSet(XalanNode& value);
+ XNodeSet(BorrowReturnMutableNodeRefList& value);
/**
* Create an XNodeSet from another.
@@ -155,13 +154,12 @@
// Data members...
-#if defined(XALAN_NO_NAMESPACES)
- auto_ptr<NodeRefListBase> m_value;
+ const BorrowReturnMutableNodeRefList m_value;
+
+#if defined(XALAN_NO_NAMESPACES)
mutable auto_ptr<ResultTreeFragBase> m_resultTreeFrag;
#else
- std::auto_ptr<NodeRefListBase> m_value;
-
mutable std::auto_ptr<ResultTreeFragBase> m_resultTreeFrag;
#endif
1.10 +7 -28 xml-xalan/c/src/XPath/XObjectFactory.hpp
Index: XObjectFactory.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XObjectFactory.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- XObjectFactory.hpp 2000/08/10 18:37:36 1.9
+++ XObjectFactory.hpp 2000/08/14 16:33:56 1.10
@@ -71,6 +71,7 @@
#include <XPath/XObject.hpp>
+#include <XPath/XPathExecutionContext.hpp>
@@ -89,6 +90,8 @@
{
public:
+ typedef XPathExecutionContext::BorrowReturnMutableNodeRefList BorrowReturnMutableNodeRefList;
+
XObjectFactory();
virtual
@@ -144,21 +147,9 @@
* @return pointer to new object
*/
virtual XObject*
- createNodeSet(
- NodeRefListBase* theValue,
- bool fOptimize = true) = 0;
-
- /**
- * Create a node set XObject from a DOM node.
- *
- * @param theValue value used to create object
- * @param fOptimize not used
- * @return pointer to new object
- */
- virtual XObject*
createNodeSet(
- XalanNode& theValue,
- bool fOptimize = true) = 0;
+ BorrowReturnMutableNodeRefList& theValue,
+ bool fOptimize = true) = 0;
/**
* Create a null XObject.
@@ -227,21 +218,9 @@
* @return pointer to new object
*/
virtual XObject*
- createSpan(
- NodeRefListBase* theValue,
- bool fOptimize = true) = 0;
-
- /**
- * Create a span XObject from a DOM node.
- *
- * @param theValue value used to create object
- * @param fOptimize not used
- * @return pointer to new object
- */
- virtual XObject*
createSpan(
- XalanNode& theValue,
- bool fOptimize = true) = 0;
+ BorrowReturnMutableNodeRefList& theValue,
+ bool fOptimize = true) = 0;
/**
*
1.13 +5 -41 xml-xalan/c/src/XPath/XObjectFactoryDefault.cpp
Index: XObjectFactoryDefault.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XObjectFactoryDefault.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- XObjectFactoryDefault.cpp 2000/08/10 18:37:37 1.12
+++ XObjectFactoryDefault.cpp 2000/08/14 16:33:56 1.13
@@ -197,10 +197,10 @@
XObject*
XObjectFactoryDefault::createNodeSet(
- NodeRefListBase* value,
- bool /* fOptimize */)
+ BorrowReturnMutableNodeRefList& theValue,
+ bool /* fOptimize */)
{
- XNodeSet* const theXNodeSet = new XNodeSet(value);
+ XNodeSet* const theXNodeSet = new XNodeSet(theValue);
m_xobjects.insert(theXNodeSet);
@@ -214,24 +214,6 @@
XObject*
-XObjectFactoryDefault::createNodeSet(
- XalanNode& value,
- bool /* fOptimize */)
-{
- XNodeSet* const theXNodeSet = new XNodeSet(value);
-
- m_xobjects.insert(theXNodeSet);
-
-#if !defined(NDEBUG)
- ++m_totalNodeSetInstanceCount;
-#endif
-
- return theXNodeSet;
-}
-
-
-
-XObject*
XObjectFactoryDefault::createNull(bool fOptimize)
{
if (fOptimize == true)
@@ -327,27 +309,9 @@
XObject*
-XObjectFactoryDefault::createSpan(
- NodeRefListBase* theValue,
- bool /* fOptimize */)
-{
- XSpan* const theXSpan = new XSpan(theValue);
-
- m_xobjects.insert(theXSpan);
-
-#if !defined(NDEBUG)
- ++m_totalSpanInstanceCount;
-#endif
-
- return theXSpan;
-}
-
-
-
-XObject*
XObjectFactoryDefault::createSpan(
- XalanNode& theValue,
- bool /* fOptimize */)
+ BorrowReturnMutableNodeRefList& theValue,
+ bool /* fOptimize */)
{
XSpan* const theXSpan = new XSpan(theValue);
1.10 +4 -14 xml-xalan/c/src/XPath/XObjectFactoryDefault.hpp
Index: XObjectFactoryDefault.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XObjectFactoryDefault.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- XObjectFactoryDefault.hpp 2000/08/10 18:37:37 1.9
+++ XObjectFactoryDefault.hpp 2000/08/14 16:33:56 1.10
@@ -110,15 +110,10 @@
virtual XObject*
createNodeSet(
- NodeRefListBase* value,
- bool fOptimize = true);
+ BorrowReturnMutableNodeRefList& theValue,
+ bool fOptimize = true);
virtual XObject*
- createNodeSet(
- XalanNode& value,
- bool fOptimize = true);
-
- virtual XObject*
createNull(bool fOptimize = true);
virtual XObject*
@@ -142,14 +137,9 @@
bool fOptimize = true);
virtual XObject*
- createSpan(
- NodeRefListBase* value,
- bool fOptimize = true);
-
- virtual XObject*
createSpan(
- XalanNode& value,
- bool fOptimize = true);
+ BorrowReturnMutableNodeRefList& theValue,
+ bool fOptimize = true);
#if defined(XALAN_NO_NAMESPACES)
typedef set<const XObject*> CollectionType;
1.26 +3 -5 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.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- XPath.cpp 2000/08/10 18:37:38 1.25
+++ XPath.cpp 2000/08/14 16:33:57 1.26
@@ -1122,11 +1122,9 @@
{
opPos += 2;
-#if !defined(XALAN_NO_NAMESPACES)
- using std::auto_ptr;
-#endif
+ typedef XPathExecutionContext::BorrowReturnMutableNodeRefList BorrowReturnMutableNodeRefList;
- auto_ptr<MutableNodeRefList> resultNodeList(executionContext.createMutableNodeRefList());
+ BorrowReturnMutableNodeRefList resultNodeList(executionContext);
XObjectFactory& theFactory = executionContext.getXObjectFactory();
@@ -1146,7 +1144,7 @@
opPos = nextOpPos;
}
- return theFactory.createNodeSet(resultNodeList.release());
+ return theFactory.createNodeSet(resultNodeList);
}
1.15 +5 -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.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- XPath.hpp 2000/08/10 18:37:38 1.14
+++ XPath.hpp 2000/08/14 16:33:57 1.15
@@ -415,6 +415,11 @@
}
#endif
+ static void
+ destroyTable()
+ {
+ s_functions.DestroyTable();
+ }
protected:
/**
1.19 +40 -2 xml-xalan/c/src/XPath/XPathExecutionContext.hpp
Index: XPathExecutionContext.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExecutionContext.hpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- XPathExecutionContext.hpp 2000/08/10 18:37:38 1.18
+++ XPathExecutionContext.hpp 2000/08/14 16:33:57 1.19
@@ -165,6 +165,16 @@
getXObjectFactory() const = 0;
/**
+ * Convenience function for creating a node set with
+ * the supplied node as the only member.
+ *
+ * @param node The node queried
+ * @return a pointer to the XObject instance.
+ */
+ virtual XObject*
+ createNodeSet(XalanNode& theNode) = 0;
+
+ /**
* Tell if the node is ignorable whitespace. This should be in the DOM.
* Return false if the parser doesn't handle this.
*
@@ -451,9 +461,31 @@
assert(m_mutableNodeRefList != 0);
}
+ // N.B. Non-const copy constructor semantics (like std::auto_ptr)
+ BorrowReturnMutableNodeRefList(const BorrowReturnMutableNodeRefList& theSource) :
+ m_xpathExecutionContext(theSource.m_xpathExecutionContext),
+ m_mutableNodeRefList(theSource.m_mutableNodeRefList)
+ {
+ assert(m_mutableNodeRefList != 0);
+
+ ((BorrowReturnMutableNodeRefList&)theSource).m_mutableNodeRefList = 0;
+ }
+
+// BorrowReturnMutableNodeRefList(const BorrowReturnMutableNodeRefList& theSource) :
+// m_xpathExecutionContext(theSource.m_xpathExecutionContext),
+// m_mutableNodeRefList(theSource.m_mutableNodeRefList)
+// {
+// assert(m_mutableNodeRefList != 0);
+
+// theSource.m_mutableNodeRefList = 0;
+// }
+
~BorrowReturnMutableNodeRefList()
{
- m_xpathExecutionContext.returnMutableNodeRefList(m_mutableNodeRefList);
+ if (m_mutableNodeRefList != 0)
+ {
+ m_xpathExecutionContext.returnMutableNodeRefList(m_mutableNodeRefList);
+ }
}
MutableNodeRefList&
@@ -463,9 +495,15 @@
}
MutableNodeRefList*
- operator->() const
+ get() const
{
return m_mutableNodeRefList;
+ }
+
+ MutableNodeRefList*
+ operator->() const
+ {
+ return get();
}
BorrowReturnMutableNodeRefList
1.17 +13 -0 xml-xalan/c/src/XPath/XPathExecutionContextDefault.cpp
Index: XPathExecutionContextDefault.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExecutionContextDefault.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- XPathExecutionContextDefault.cpp 2000/08/11 15:16:42 1.16
+++ XPathExecutionContextDefault.cpp 2000/08/14 16:33:58 1.17
@@ -153,6 +153,19 @@
+XObject*
+XPathExecutionContextDefault::createNodeSet(XalanNode& theNode)
+{
+ // This list will hold the node...
+ BorrowReturnMutableNodeRefList theNodeList(*this);
+
+ theNodeList->addNode(&theNode);
+
+ return m_xobjectFactory.createNodeSet(theNodeList);
+}
+
+
+
bool
XPathExecutionContextDefault::isIgnorableWhitespace(const XalanText& node) const
{
1.18 +3 -0 xml-xalan/c/src/XPath/XPathExecutionContextDefault.hpp
Index: XPathExecutionContextDefault.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExecutionContextDefault.hpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- XPathExecutionContextDefault.hpp 2000/08/11 15:16:42 1.17
+++ XPathExecutionContextDefault.hpp 2000/08/14 16:33:58 1.18
@@ -131,6 +131,9 @@
virtual XObjectFactory&
getXObjectFactory() const;
+ virtual XObject*
+ createNodeSet(XalanNode& theNode);
+
virtual bool
isIgnorableWhitespace(const XalanText& node) const;
1.9 +3 -3 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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XPathFunctionTable.hpp 2000/08/07 19:51:49 1.8
+++ XPathFunctionTable.hpp 2000/08/14 16:33:58 1.9
@@ -305,13 +305,13 @@
}
#endif
+ void
+ DestroyTable();
+
protected:
void
CreateTable();
-
- void
- DestroyTable();
private:
1.7 +1 -10 xml-xalan/c/src/XPath/XSpan.cpp
Index: XSpan.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XSpan.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XSpan.cpp 2000/08/10 18:37:40 1.6
+++ XSpan.cpp 2000/08/14 16:33:59 1.7
@@ -58,16 +58,7 @@
-XSpan::XSpan(NodeRefListBase* value) :
- XNodeSet(value),
- m_start(-1),
- m_end(-1)
-{
-}
-
-
-
-XSpan::XSpan(XalanNode& value) :
+XSpan::XSpan(BorrowReturnMutableNodeRefList& value) :
XNodeSet(value),
m_start(-1),
m_end(-1)
1.8 +1 -8 xml-xalan/c/src/XPath/XSpan.hpp
Index: XSpan.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XSpan.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XSpan.hpp 2000/08/10 18:37:40 1.7
+++ XSpan.hpp 2000/08/14 16:33:59 1.8
@@ -78,14 +78,7 @@
*
* @param value source node list. The instance will adopt the value instance.
*/
- XSpan(NodeRefListBase* value);
-
- /**
- * Construct an XSpan object from a DOM node.
- *
- * @param value source node
- */
- XSpan(XalanNode& value);
+ XSpan(BorrowReturnMutableNodeRefList& value);
XSpan(const XSpan& source);