mhoyt 2004/10/13 20:14:08
Modified: c/Projects/Win32/VC6/AllInOne AllInOne.dsp
AllInOneWithICU.dsp
c/Projects/Win32/VC7.1/AllInOne AllInOne.vcproj
AllInOneWithICU.vcproj
c/src/xalanc/DOMSupport XalanNamespacesStack.hpp
c/src/xalanc/XPath XPathExecutionContextDefault.hpp
XalanQName.hpp
c/src/xalanc/XSLT OutputContextStack.hpp
StylesheetExecutionContextDefault.hpp
c/src/xalanc/XercesParserLiaison/Deprecated
XercesDocumentBridge.hpp
Added: c/src/xalanc/Include XalanDeque.hpp
Log:
Initial XalanDeque implementation and integration to support pluggable memory
management
Revision Changes Path
1.62 +4 -0 xml-xalan/c/Projects/Win32/VC6/AllInOne/AllInOne.dsp
Index: AllInOne.dsp
===================================================================
RCS file: /home/cvs/xml-xalan/c/Projects/Win32/VC6/AllInOne/AllInOne.dsp,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- AllInOne.dsp 12 Oct 2004 14:34:11 -0000 1.61
+++ AllInOne.dsp 14 Oct 2004 03:14:07 -0000 1.62
@@ -198,6 +198,10 @@
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\src\xalanc\Include\XalanDeque.hpp
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\src\xalanc\Include\XalanList.hpp
# End Source File
# Begin Source File
1.59 +4 -0
xml-xalan/c/Projects/Win32/VC6/AllInOne/AllInOneWithICU.dsp
Index: AllInOneWithICU.dsp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/Projects/Win32/VC6/AllInOne/AllInOneWithICU.dsp,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- AllInOneWithICU.dsp 12 Oct 2004 14:34:11 -0000 1.58
+++ AllInOneWithICU.dsp 14 Oct 2004 03:14:07 -0000 1.59
@@ -199,6 +199,10 @@
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\src\xalanc\Include\XalanDeque.hpp
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\src\xalanc\Include\XalanList.hpp
# End Source File
# Begin Source File
1.8 +3 -0 xml-xalan/c/Projects/Win32/VC7.1/AllInOne/AllInOne.vcproj
Index: AllInOne.vcproj
===================================================================
RCS file:
/home/cvs/xml-xalan/c/Projects/Win32/VC7.1/AllInOne/AllInOne.vcproj,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- AllInOne.vcproj 12 Oct 2004 14:43:32 -0000 1.7
+++ AllInOne.vcproj 14 Oct 2004 03:14:07 -0000 1.8
@@ -260,6 +260,9 @@
RelativePath="..\..\..\..\src\xalanc\Include\XalanAutoPtr.hpp">
</File>
<File
+
RelativePath="..\..\..\..\src\xalanc\Include\XalanDeque.hpp">
+ </File>
+ <File
RelativePath="..\..\..\..\src\xalanc\Include\XalanList.hpp">
</File>
<File
1.8 +3 -0
xml-xalan/c/Projects/Win32/VC7.1/AllInOne/AllInOneWithICU.vcproj
Index: AllInOneWithICU.vcproj
===================================================================
RCS file:
/home/cvs/xml-xalan/c/Projects/Win32/VC7.1/AllInOne/AllInOneWithICU.vcproj,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- AllInOneWithICU.vcproj 12 Oct 2004 14:43:32 -0000 1.7
+++ AllInOneWithICU.vcproj 14 Oct 2004 03:14:07 -0000 1.8
@@ -254,6 +254,9 @@
RelativePath="..\..\..\..\src\xalanc\Include\XalanAutoPtr.hpp">
</File>
<File
+
RelativePath="..\..\..\..\src\xalanc\Include\XalanDeque.hpp">
+ </File>
+ <File
RelativePath="..\..\..\..\src\xalanc\Include\XalanList.hpp">
</File>
<File
1.6 +3 -23
xml-xalan/c/src/xalanc/DOMSupport/XalanNamespacesStack.hpp
Index: XalanNamespacesStack.hpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/xalanc/DOMSupport/XalanNamespacesStack.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XalanNamespacesStack.hpp 31 Jul 2004 06:05:02 -0000 1.5
+++ XalanNamespacesStack.hpp 14 Oct 2004 03:14:08 -0000 1.6
@@ -23,11 +23,8 @@
-#include <deque>
-
-
-
#include <xalanc/Include/XalanVector.hpp>
+#include <xalanc/Include/XalanDeque.hpp>
@@ -86,11 +83,7 @@
typedef XalanNamespace value_type;
-#if defined(XALAN_NO_STD_NAMESPACE)
- typedef deque<value_type> NamespaceCollectionType;
-#else
- typedef std::deque<value_type> NamespaceCollectionType;
-#endif
+ typedef XalanDeque<value_type> NamespaceCollectionType;
typedef const XalanDOMString&
(value_type::*MemberFunctionType)() const;
@@ -220,21 +213,8 @@
typedef XalanNamespacesStackEntry value_type;
-#if defined(XALAN_NO_STD_NAMESPACE)
- typedef deque<value_type> NamespacesStackType;
-#if defined(XALAN_USE_DEQUE_FOR_VECTOR_BOOL)
- typedef deque<bool> BoolVectorType;
-#else
+ typedef XalanDeque<value_type> NamespacesStackType;
typedef XalanVector<bool> BoolVectorType;
-#endif
-#else
- typedef std::deque<value_type> NamespacesStackType;
-#if defined(XALAN_USE_DEQUE_FOR_VECTOR_BOOL)
- typedef std::deque<bool> BoolVectorType;
-#else
- typedef XalanVector<bool> BoolVectorType;
-#endif
-#endif
typedef NamespacesStackType::iterator
iterator;
typedef NamespacesStackType::reverse_iterator
reverse_iterator;
1.1 xml-xalan/c/src/xalanc/Include/XalanDeque.hpp
Index: XalanDeque.hpp
===================================================================
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author Matthew Hoyt ([EMAIL PROTECTED])
*/
#if !defined(XALANDEQUE_HEADER_GUARD_1357924680)
#define XALANDEQUE_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <xalanc/Include/PlatformDefinitions.hpp>
#include <xalanc/Include/XalanVector.hpp>
#include <xercesc/framework/MemoryManager.hpp>
XALAN_CPP_NAMESPACE_BEGIN
template <class Value>
struct XalanDequeIteratorTraits
{
typedef Value value_type;
typedef Value& reference;
typedef Value* pointer;
typedef const Value& const_reference;
};
template <class Value>
struct XalanDequeConstIteratorTraits
{
typedef Value value_type;
typedef const Value& reference;
typedef const Value* pointer;
typedef const Value& const_reference;
};
template <class XalanDequeTraits, class XalanDeque>
struct XalanDequeIterator
{
typedef size_t size_type;
typedef typename XalanDequeTraits::value_type value_type;
typedef typename XalanDequeTraits::reference reference;
typedef typename XalanDequeTraits::pointer pointer;
typedef typename XalanDequeTraits::const_reference const_reference;
typedef ptrdiff_t difference_type;
typedef XalanDequeIterator<XalanDequeIteratorTraits<value_type>,
XalanDeque> Iterator;
typedef XALAN_STD_QUALIFIER random_access_iterator_tag
iterator_category;
XalanDequeIterator(XalanDeque* deque,
size_type pos) :
m_deque(deque),
m_pos(pos)
{
}
XalanDequeIterator(const Iterator & iterator) :
m_deque(iterator.m_deque),
m_pos(iterator.m_pos)
{
}
XalanDequeIterator& operator=(const Iterator & iterator)
{
m_deque = iterator.m_deque;
m_pos = iterator.m_pos;
return *this;
}
XalanDequeIterator& operator++()
{
++m_pos;
return *this;
}
XalanDequeIterator& operator--()
{
--m_pos;
return *this;
}
pointer operator->()
{
return &(*m_deque[m_pos]);
}
reference operator*()
{
return (*m_deque)[m_pos];
}
const_reference operator*() const
{
return (*m_deque)[m_pos];
}
XalanDequeIterator operator+(difference_type difference) const
{
return XalanDequeIterator(m_deque, m_pos + difference);
}
XalanDequeIterator operator-(difference_type difference) const
{
return XalanDequeIterator(m_deque, m_pos - difference);
}
difference_type operator-(const XalanDequeIterator &theRhs) const
{
return m_pos - theRhs.m_pos;
}
bool operator==(const XalanDequeIterator & theRhs) const
{
return (theRhs.m_deque == m_deque)
&& theRhs.m_pos == m_pos;
}
bool operator!=(const XalanDequeIterator & theRhs) const
{
return !(theRhs == *this);
}
XalanDeque* m_deque;
size_type m_pos;
};
/**
* Xalan implementation of deque
*/
template <class Type>
class XalanDeque
{
public:
typedef XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager MemoryManagerType;
typedef size_t size_type;
typedef Type value_type;
typedef Type& reference;
typedef const Type& const_reference;
typedef XalanVector<Type> BlockType;
typedef XalanVector<BlockType*> BlockIndexType;
typedef XalanDequeIterator<XalanDequeIteratorTraits<value_type>,
XalanDeque> iterator;
typedef XalanDequeIterator<XalanDequeConstIteratorTraits<value_type>,
XalanDeque> const_iterator;
#if defined(XALAN_HAS_STD_ITERATORS)
typedef XALAN_STD_QUALIFIER reverse_iterator<iterator>
reverse_iterator_;
typedef XALAN_STD_QUALIFIER reverse_iterator<const_iterator>
const_reverse_iterator_;
#elif defined(XALAN_RW_NO_CLASS_PARTIAL_SPEC)
typedef XALAN_STD_QUALIFIER reverse_iterator<
iterator,
XALAN_STD_QUALIFIER random_access_iterator_tag,
value_type> reverse_iterator_;
typedef XALAN_STD_QUALIFIER reverse_iterator<
const_iterator,
XALAN_STD_QUALIFIER random_access_iterator_tag,
const value_type> const_reverse_iterator_;
#else
typedef XALAN_STD_QUALIFIER reverse_iterator<iterator, value_type>
reverse_iterator_;
typedef XALAN_STD_QUALIFIER reverse_iterator<const_iterator, value_type,
const_reference> const_reverse_iterator_;
#endif
typedef reverse_iterator_ reverse_iterator;
typedef const_reverse_iterator_ const_reverse_iterator;
XalanDeque(
size_type initialSize = 0,
MemoryManagerType* memoryManager = 0,
size_type blockSize = 10) :
m_memoryManager(memoryManager),
m_blockSize(blockSize),
m_blockIndex(memoryManager,
initialSize / m_blockSize + (initialSize % m_blockSize ==
0 ? 0 : 1))
{
XALAN_STD_QUALIFIER fill_n(XALAN_STD_QUALIFIER back_inserter(*this),
initialSize, value_type());
}
XalanDeque(const XalanDeque& theRhs) :
m_memoryManager(theRhs.m_memoryManager),
m_blockSize(theRhs.m_blockSize),
m_blockIndex(theRhs.m_memoryManager,
theRhs.size() / m_blockSize + (theRhs.size() %
m_blockSize == 0 ? 0 : 1))
{
XALAN_STD_QUALIFIER copy(theRhs.begin(), theRhs.end(),
XALAN_STD_QUALIFIER back_inserter(*this));
}
~XalanDeque()
{
clear();
BlockIndexType::iterator iter = m_freeBlockVector.begin();
while (iter != m_freeBlockVector.end())
{
(*iter)->~XalanVector<Type>();
deallocate(*iter);
++iter;
}
}
iterator begin()
{
return iterator(this, 0);
}
const_iterator begin() const
{
return const_iterator(const_cast<XalanDeque*>(this), 0);
}
iterator end()
{
return iterator(this, size());
}
const_iterator end() const
{
return const_iterator(const_cast<XalanDeque*>(this), size());
}
const_reverse_iterator rbegin() const
{
return const_reverse_iterator(end());
}
const_reverse_iterator rend() const
{
return const_reverse_iterator(begin());
}
bool empty() const
{
return m_blockIndex.empty();
}
size_type size() const
{
if (m_blockIndex.empty())
{
return 0;
}
else
{
return (m_blockIndex.size() - 1) * m_blockSize
+ m_blockIndex.back()->size();
}
}
value_type& back()
{
return m_blockIndex.back()->back();
}
value_type& operator[](size_type index)
{
BlockType & block = *(m_blockIndex[index / m_blockSize]);
return block[index % m_blockSize];
}
const value_type& operator[](size_type index) const
{
BlockType & block = *(m_blockIndex[index / m_blockSize]);
return block[index % m_blockSize];
}
void clear()
{
BlockIndexType::iterator iter = m_blockIndex.begin();
m_freeBlockVector.reserve(m_freeBlockVector.size() +
m_blockIndex.size());
while (iter != m_blockIndex.end())
{
(*iter)->clear();
m_freeBlockVector.push_back(*iter);
++iter;
}
m_blockIndex.clear();
}
void push_back(const value_type & value)
{
if (m_blockIndex.empty() ||
m_blockIndex.back()->size() >= m_blockSize)
{
m_blockIndex.push_back(getNewBlock());
}
m_blockIndex.back()->push_back(value);
}
void pop_back()
{
BlockType & lastBlock = *(m_blockIndex.back());
lastBlock.pop_back();
if (lastBlock.empty())
{
m_freeBlockVector.push_back(&lastBlock);
m_blockIndex.pop_back();
}
}
void resize(size_type newSize)
{
if (newSize > size())
{
for (size_type i = 0; i < newSize - size(); ++i)
{
push_back(value_type());
}
}
else
{
for (size_type i = 0; i < size() - newSize; ++i)
{
pop_back();
}
}
}
void swap(XalanDeque& theRhs)
{
MemoryManagerType* tempMemoryManager = m_memoryManager;
m_memoryManager = theRhs.m_memoryManager;
theRhs.m_memoryManager = tempMemoryManager;
theRhs.m_blockIndex.swap(m_blockIndex);
theRhs.m_freeBlockVector.swap(m_freeBlockVector);
}
const XalanDeque & operator=(const XalanDeque & theRhs)
{
clear();
XALAN_STD_QUALIFIER copy(theRhs.begin(), theRhs.end(),
XALAN_STD_QUALIFIER back_inserter(*this));
return *this;
}
protected:
BlockType* getNewBlock()
{
BlockType * newBlock;
if (m_freeBlockVector.empty())
{
newBlock = allocate(1);
new (&*newBlock) BlockType(m_memoryManager, m_blockSize);
}
else
{
newBlock = m_freeBlockVector.back();
m_freeBlockVector.pop_back();
}
assert (newBlock != 0);
return newBlock;
}
BlockType*
allocate(size_type size)
{
const size_type theBytesNeeded = size * sizeof(BlockType);
void* pointer = m_memoryManager == 0 ?
::operator new (theBytesNeeded) :
m_memoryManager->allocate(theBytesNeeded);
assert(pointer != 0);
return (BlockType*) pointer;
}
void
deallocate(BlockType* pointer)
{
if (m_memoryManager == 0)
{
::operator delete(pointer);
}
else
{
m_memoryManager->deallocate(pointer);
}
}
BlockIndexType m_blockIndex;
BlockIndexType m_freeBlockVector;
MemoryManagerType* m_memoryManager;
const size_type m_blockSize;
};
XALAN_CPP_NAMESPACE_END
#endif // XALANDEQUE_HEADER_GUARD_1357924680
1.10 +3 -11
xml-xalan/c/src/xalanc/XPath/XPathExecutionContextDefault.hpp
Index: XPathExecutionContextDefault.hpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/xalanc/XPath/XPathExecutionContextDefault.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- XPathExecutionContextDefault.hpp 13 Aug 2004 15:49:07 -0000 1.9
+++ XPathExecutionContextDefault.hpp 14 Oct 2004 03:14:08 -0000 1.10
@@ -23,11 +23,8 @@
-#include <deque>
-
-
-
#include <xalanc/Include/XalanObjectCache.hpp>
+#include <xalanc/Include/XalanVector.hpp>
@@ -69,13 +66,8 @@
{
public:
-#if defined(XALAN_NO_STD_NAMESPACE)
- typedef deque<XalanNode*>
CurrentNodeStackType;
- typedef deque<const NodeRefListBase*> ContextNodeListStackType;
-#else
- typedef std::deque<XalanNode*>
CurrentNodeStackType;
- typedef std::deque<const NodeRefListBase*>
ContextNodeListStackType;
-#endif
+ typedef XalanVector<XalanNode*>
CurrentNodeStackType;
+ typedef XalanVector<const NodeRefListBase*>
ContextNodeListStackType;
/**
* Construct an XPathExecutionContextDefault object
1.8 +3 -11 xml-xalan/c/src/xalanc/XPath/XalanQName.hpp
Index: XalanQName.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/xalanc/XPath/XalanQName.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XalanQName.hpp 17 Sep 2004 22:23:10 -0000 1.7
+++ XalanQName.hpp 14 Oct 2004 03:14:08 -0000 1.8
@@ -23,11 +23,8 @@
-#include <deque>
-
-
-
#include <xalanc/Include/XalanMap.hpp>
+#include <xalanc/Include/XalanDeque.hpp>
#include <xalanc/Include/STLHelper.hpp>
@@ -71,13 +68,8 @@
{
public:
-#if defined(XALAN_NO_STD_NAMESPACE)
- typedef deque<NameSpace>
NamespaceVectorType;
- typedef deque<NamespaceVectorType>
NamespacesStackType;
-#else
- typedef std::deque<NameSpace>
NamespaceVectorType;
- typedef std::deque<NamespaceVectorType> NamespacesStackType;
-#endif
+ typedef XalanDeque<NameSpace>
NamespaceVectorType;
+ typedef XalanDeque<NamespaceVectorType>
NamespacesStackType;
/**
* Construct an empty XalanQName.
1.5 +2 -6 xml-xalan/c/src/xalanc/XSLT/OutputContextStack.hpp
Index: OutputContextStack.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/OutputContextStack.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- OutputContextStack.hpp 26 Feb 2004 22:58:58 -0000 1.4
+++ OutputContextStack.hpp 14 Oct 2004 03:14:08 -0000 1.5
@@ -23,7 +23,7 @@
-#include <deque>
+#include <xalanc/Include/XalanDeque.hpp>
@@ -88,11 +88,7 @@
bool m_mustFlushPendingStartDocument;
};
-#if defined(XALAN_NO_STD_NAMESPACE)
- typedef deque<OutputContext> OutputContextStackType;
-#else
- typedef std::deque<OutputContext> OutputContextStackType;
-#endif
+ typedef XalanDeque<OutputContext>
OutputContextStackType;
typedef OutputContextStackType::size_type size_type;
1.32 +2 -3
xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.hpp
Index: StylesheetExecutionContextDefault.hpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.hpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- StylesheetExecutionContextDefault.hpp 12 Oct 2004 21:57:08 -0000
1.31
+++ StylesheetExecutionContextDefault.hpp 14 Oct 2004 03:14:08 -0000
1.32
@@ -24,7 +24,6 @@
#include <ctime>
-#include <deque>
#include <memory>
@@ -96,11 +95,11 @@
typedef XalanVector<PrintWriter*>
PrintWriterVectorType;
typedef XalanVector<XalanOutputStream*>
OutputStreamVectorType;
- typedef XALAN_STD_QUALIFIER deque<const ElemTemplateElement*>
ElementTemplateElementStackType;
+ typedef XalanVector<const ElemTemplateElement*>
ElementTemplateElementStackType;
typedef XalanSet<const KeyDeclaration*> KeyDeclarationSetType;
typedef XALAN_STD_QUALIFIER pair<const XPath*, ClockType>
XPathCacheEntry;
typedef XalanMap <XalanDOMString, XPathCacheEntry>
XPathCacheMapType;
- typedef XALAN_STD_QUALIFIER deque<const ElemTemplate*>
CurrentTemplateStackType;
+ typedef XalanVector<const ElemTemplate*>
CurrentTemplateStackType;
typedef Stylesheet::KeyTablesTableType
KeyTablesTableType;
typedef VariablesStack::ParamsVectorType
ParamsVectorType;
1.6 +3 -11
xml-xalan/c/src/xalanc/XercesParserLiaison/Deprecated/XercesDocumentBridge.hpp
Index: XercesDocumentBridge.hpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/xalanc/XercesParserLiaison/Deprecated/XercesDocumentBridge.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XercesDocumentBridge.hpp 30 Sep 2004 22:28:11 -0000 1.5
+++ XercesDocumentBridge.hpp 14 Oct 2004 03:14:08 -0000 1.6
@@ -22,11 +22,8 @@
-#include <deque>
-
-
-
#include <xalanc/Include/XalanVector.hpp>
+#include <xalanc/Include/XalanDeque.hpp>
@@ -331,15 +328,10 @@
void
buildBridgeNodes();
-#if defined(XALAN_NO_STD_NAMESPACE)
- typedef deque<XercesBridgeNavigator> NavigatorBridgeVectorType;
- typedef deque<XalanNode*> NodeVectorType;
-#else
- typedef std::deque<XercesBridgeNavigator>
NavigatorBridgeVectorType;
+ typedef XalanDeque<XercesBridgeNavigator>
NavigatorBridgeVectorType;
+ typedef XalanDeque<XalanNode*> NodeVectorType;
- typedef std::deque<XalanNode*> NodeVectorType;
-#endif
// Helper class to walk the tree and build everything...
class BuildBridgeTreeWalker : public XercesTreeWalker
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]