You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ne...@apache.org on 2003/09/16 20:30:54 UTC
cvs commit: xml-xerces/c/src/xercesc/dom/deprecated DOMParser.cpp
neilg 2003/09/16 11:30:54
Modified: c/src/xercesc/framework XMLGrammarPool.hpp
c/src/xercesc/internal XMLGrammarPoolImpl.cpp
XMLGrammarPoolImpl.hpp
c/src/xercesc/validators/common GrammarResolver.cpp
GrammarResolver.hpp
c/src/xercesc/parsers AbstractDOMParser.cpp SAXParser.cpp
SAX2XMLReaderImpl.cpp
c/src/xercesc/dom/deprecated DOMParser.cpp
Log:
make Grammar pool be responsible for creating and owning URI string pools. This is one more step towards having grammars be independent of the parsers involved in their creation
Revision Changes Path
1.4 +20 -6 xml-xerces/c/src/xercesc/framework/XMLGrammarPool.hpp
Index: XMLGrammarPool.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/XMLGrammarPool.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XMLGrammarPool.hpp 2 Sep 2003 08:59:02 -0000 1.3
+++ XMLGrammarPool.hpp 16 Sep 2003 18:30:54 -0000 1.4
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.4 2003/09/16 18:30:54 neilg
+ * make Grammar pool be responsible for creating and owning URI string pools. This is one more step towards having grammars be independent of the parsers involved in their creation
+ *
* Revision 1.3 2003/09/02 08:59:02 gareth
* Added API to get enumerator of grammars.
*
@@ -73,8 +76,8 @@
#define XMLGRAMMARPOOL_HPP
#include <xercesc/util/PlatformUtils.hpp>
-#include <xercesc/util/XMemory.hpp>
#include <xercesc/util/RefHashTableOf.hpp>
+#include <xercesc/util/XMemory.hpp>
XERCES_CPP_NAMESPACE_BEGIN
@@ -85,6 +88,7 @@
class SchemaGrammar;
class XMLDTDDescription;
class XMLSchemaDescription;
+class XMLStringPool;
class XMLPARSER_EXPORT XMLGrammarPool : public XMemory
{
@@ -151,17 +155,19 @@
virtual void clear() = 0;
/**
- * lookPool
+ * lockPool
*
- * The grammar pool is looked and accessed exclusively by the looking thread
+ * When this method is called by the application, the
+ * grammar pool should stop adding new grammars to the cache.
*
*/
virtual void lockPool() = 0;
/**
- * lookPool
+ * unlockPool
*
- * The grammar pool is accessible by multi threads
+ * After this method has been called, the grammar pool implementation
+ * should return to its default behaviour when cacheGrammars(...) is called.
*
*/
virtual void unlockPool() = 0;
@@ -194,6 +200,7 @@
*
*/
virtual XMLSchemaDescription* createSchemaDescription(const XMLCh* const targetNamespace) = 0;
+
//@}
// -----------------------------------------------------------------------
@@ -210,6 +217,13 @@
return fMemMgr;
}
+ /**
+ * Return an XMLStringPool for use by validation routines.
+ * Implementations should not create a string pool on each call to this
+ * method, but should maintain one string pool for all grammars
+ * for which this pool is responsible.
+ */
+ virtual XMLStringPool *getURIStringPool() = 0;
//@}
protected :
1.5 +12 -1 xml-xerces/c/src/xercesc/internal/XMLGrammarPoolImpl.cpp
Index: XMLGrammarPoolImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLGrammarPoolImpl.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XMLGrammarPoolImpl.cpp 2 Sep 2003 08:59:02 -0000 1.4
+++ XMLGrammarPoolImpl.cpp 16 Sep 2003 18:30:54 -0000 1.5
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.5 2003/09/16 18:30:54 neilg
+ * make Grammar pool be responsible for creating and owning URI string pools. This is one more step towards having grammars be independent of the parsers involved in their creation
+ *
* Revision 1.4 2003/09/02 08:59:02 gareth
* Added API to get enumerator of grammars.
*
@@ -92,13 +95,16 @@
XMLGrammarPoolImpl::~XMLGrammarPoolImpl()
{
delete fGrammarRegistry;
+ delete fStringPool;
}
XMLGrammarPoolImpl::XMLGrammarPoolImpl(MemoryManager* const memMgr)
:XMLGrammarPool(memMgr)
,fGrammarRegistry(0)
+,fStringPool(0)
{
fGrammarRegistry = new (memMgr) RefHashTableOf<Grammar>(29, true, memMgr);
+ fStringPool = new (memMgr) XMLStringPool(109, memMgr);
}
// -----------------------------------------------------------------------
@@ -180,6 +186,11 @@
XMLSchemaDescription* XMLGrammarPoolImpl::createSchemaDescription(const XMLCh* const targetNamespace)
{
return new (getMemoryManager()) XMLSchemaDescriptionImpl(targetNamespace, getMemoryManager());
+}
+
+inline XMLStringPool *XMLGrammarPoolImpl::getURIStringPool()
+{
+ return fStringPool;
}
XERCES_CPP_NAMESPACE_END
1.5 +27 -5 xml-xerces/c/src/xercesc/internal/XMLGrammarPoolImpl.hpp
Index: XMLGrammarPoolImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLGrammarPoolImpl.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XMLGrammarPoolImpl.hpp 2 Sep 2003 08:59:02 -0000 1.4
+++ XMLGrammarPoolImpl.hpp 16 Sep 2003 18:30:54 -0000 1.5
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.5 2003/09/16 18:30:54 neilg
+ * make Grammar pool be responsible for creating and owning URI string pools. This is one more step towards having grammars be independent of the parsers involved in their creation
+ *
* Revision 1.4 2003/09/02 08:59:02 gareth
* Added API to get enumerator of grammars.
*
@@ -146,17 +149,19 @@
virtual void clear();
/**
- * lookPool
+ * lockPool
*
- * The grammar pool is looked and accessed exclusively by the looking thread
+ * When this method is called by the application, the
+ * grammar pool should stop adding new grammars to the cache.
*
*/
virtual void lockPool();
/**
- * lookPool
+ * unlockPool
*
- * The grammar pool is accessible by multi threads
+ * After this method has been called, the grammar pool implementation
+ * should return to its default behaviour when cacheGrammars(...) is called.
*
*/
virtual void unlockPool();
@@ -191,6 +196,20 @@
virtual XMLSchemaDescription* createSchemaDescription(const XMLCh* const targetNamespace);
//@}
+ // -----------------------------------------------------------------------
+ /** @name Getter */
+ // -----------------------------------------------------------------------
+ //@{
+
+ /**
+ * Return an XMLStringPool for use by validation routines.
+ * Implementations should not create a string pool on each call to this
+ * method, but should maintain one string pool for all grammars
+ * for which this pool is responsible.
+ */
+ virtual XMLStringPool *getURIStringPool();
+
+ // @}
private:
// -----------------------------------------------------------------------
/** name Unimplemented copy constructor and operator= */
@@ -205,9 +224,12 @@
// fGrammarRegistry:
//
// container
+ // fStringPool
+ // grammars need a string pool for URI -> int mappings
//
// -----------------------------------------------------------------------
RefHashTableOf<Grammar>* fGrammarRegistry;
+ XMLStringPool * fStringPool;
};
1.19 +5 -1 xml-xerces/c/src/xercesc/validators/common/GrammarResolver.cpp
Index: GrammarResolver.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/GrammarResolver.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- GrammarResolver.cpp 2 Sep 2003 09:04:44 -0000 1.18
+++ GrammarResolver.cpp 16 Sep 2003 18:30:54 -0000 1.19
@@ -57,6 +57,9 @@
/*
* $Log$
+ * Revision 1.19 2003/09/16 18:30:54 neilg
+ * make Grammar pool be responsible for creating and owning URI string pools. This is one more step towards having grammars be independent of the parsers involved in their creation
+ *
* Revision 1.18 2003/09/02 09:04:44 gareth
* added API to get enumerator to referenced grammars.
*
@@ -147,7 +150,7 @@
:fCacheGrammar(false)
,fUseCachedGrammar(false)
,fGrammarPoolFromExternalApplication(true)
-,fStringPool(109, manager)
+,fStringPool(0)
,fGrammarBucket(0)
,fGrammarFromPool(0)
,fDataTypeReg(0)
@@ -172,6 +175,7 @@
fGrammarPool = new (manager) XMLGrammarPoolImpl(manager);
fGrammarPoolFromExternalApplication=false;
}
+ fStringPool = fGrammarPool->getURIStringPool();
}
1.16 +4 -3 xml-xerces/c/src/xercesc/validators/common/GrammarResolver.hpp
Index: GrammarResolver.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/GrammarResolver.hpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- GrammarResolver.hpp 2 Sep 2003 09:04:44 -0000 1.15
+++ GrammarResolver.hpp 16 Sep 2003 18:30:54 -0000 1.16
@@ -228,6 +228,7 @@
//
// fStringPool The string pool used by TraverseSchema to store
// element/attribute names and prefixes.
+ // Always owned by Grammar pool implementation
//
// fGrammarBucket The parsed Grammar Pool, if no caching option.
//
@@ -243,7 +244,7 @@
bool fCacheGrammar;
bool fUseCachedGrammar;
bool fGrammarPoolFromExternalApplication;
- XMLStringPool fStringPool;
+ XMLStringPool* fStringPool;
RefHashTableOf<Grammar>* fGrammarBucket;
RefHashTableOf<Grammar>* fGrammarFromPool;
DatatypeValidatorFactory* fDataTypeReg;
@@ -253,7 +254,7 @@
inline XMLStringPool* GrammarResolver::getStringPool() {
- return &fStringPool;
+ return fStringPool;
}
1.51 +4 -3 xml-xerces/c/src/xercesc/parsers/AbstractDOMParser.cpp
Index: AbstractDOMParser.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/AbstractDOMParser.cpp,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- AbstractDOMParser.cpp 22 Aug 2003 08:42:34 -0000 1.50
+++ AbstractDOMParser.cpp 16 Sep 2003 18:30:54 -0000 1.51
@@ -154,7 +154,7 @@
{
// Create grammar resolver and string pool to pass to the scanner
fGrammarResolver = new (fMemoryManager) GrammarResolver(fGrammarPool, fMemoryManager);
- fURIStringPool = new (fMemoryManager) XMLStringPool(109, fMemoryManager);
+ fURIStringPool = fGrammarResolver->getStringPool();
// Create a scanner and tell it what validator to use. Then set us
// as the document event handler so we can fill the DOM document.
@@ -178,7 +178,8 @@
delete fNodeStack;
delete fScanner;
delete fGrammarResolver;
- delete fURIStringPool;
+ // grammar pool *always* owns this
+ //delete fURIStringPool;
fMemoryManager->deallocate(fImplementationFeatures);
if (fValidator)
1.25 +6 -2 xml-xerces/c/src/xercesc/parsers/SAXParser.cpp
Index: SAXParser.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/SAXParser.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- SAXParser.cpp 13 Aug 2003 15:43:24 -0000 1.24
+++ SAXParser.cpp 16 Sep 2003 18:30:54 -0000 1.25
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.25 2003/09/16 18:30:54 neilg
+ * make Grammar pool be responsible for creating and owning URI string pools. This is one more step towards having grammars be independent of the parsers involved in their creation
+ *
* Revision 1.24 2003/08/13 15:43:24 knoaman
* Use memory manager when creating SAX exceptions.
*
@@ -314,7 +317,7 @@
{
// Create grammar resolver and string pool to pass to scanner
fGrammarResolver = new (fMemoryManager) GrammarResolver(fGrammarPool, fMemoryManager);
- fURIStringPool = new (fMemoryManager) XMLStringPool(109, fMemoryManager);
+ fURIStringPool = fGrammarResolver->getStringPool();
// Create our scanner and tell it what validator to use
fScanner = XMLScannerResolver::getDefaultScanner(fValidator, fGrammarResolver, fMemoryManager);
@@ -333,7 +336,8 @@
fMemoryManager->deallocate(fAdvDHList);//delete [] fAdvDHList;
delete fScanner;
delete fGrammarResolver;
- delete fURIStringPool;
+ // grammar pool must do this
+ //delete fURIStringPool;
if (fValidator)
delete fValidator;
1.27 +6 -2 xml-xerces/c/src/xercesc/parsers/SAX2XMLReaderImpl.cpp
Index: SAX2XMLReaderImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/SAX2XMLReaderImpl.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- SAX2XMLReaderImpl.cpp 13 Aug 2003 15:43:24 -0000 1.26
+++ SAX2XMLReaderImpl.cpp 16 Sep 2003 18:30:54 -0000 1.27
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.27 2003/09/16 18:30:54 neilg
+ * make Grammar pool be responsible for creating and owning URI string pools. This is one more step towards having grammars be independent of the parsers involved in their creation
+ *
* Revision 1.26 2003/08/13 15:43:24 knoaman
* Use memory manager when creating SAX exceptions.
*
@@ -362,7 +365,7 @@
{
// Create grammar resolver and string pool that we pass to the scanner
fGrammarResolver = new (fMemoryManager) GrammarResolver(fGrammarPool, fMemoryManager);
- fURIStringPool = new (fMemoryManager) XMLStringPool(109, fMemoryManager);
+ fURIStringPool = fGrammarResolver->getStringPool();
// Create a scanner and tell it what validator to use. Then set us
// as the document event handler so we can fill the DOM document.
@@ -396,7 +399,8 @@
delete fTempAttrVec;
delete fPrefixCounts;
delete fGrammarResolver;
- delete fURIStringPool;
+ // grammar pool must do this
+ //delete fURIStringPool;
}
// ---------------------------------------------------------------------------
1.25 +4 -3 xml-xerces/c/src/xercesc/dom/deprecated/DOMParser.cpp
Index: DOMParser.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/deprecated/DOMParser.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- DOMParser.cpp 13 Aug 2003 15:43:24 -0000 1.24
+++ DOMParser.cpp 16 Sep 2003 18:30:54 -0000 1.25
@@ -147,7 +147,7 @@
{
// Create grammar resolver and URI string pool to pass to the scanner
fGrammarResolver = new (fMemoryManager) GrammarResolver(fGrammarPool, fMemoryManager);
- fURIStringPool = new (fMemoryManager) XMLStringPool(109, fMemoryManager);
+ fURIStringPool = fGrammarResolver->getStringPool();
// Create a scanner and tell it what validator to use. Then set us
// as the document event handler so we can fill the DOM document.
@@ -165,7 +165,8 @@
delete fNodeStack;
delete fScanner;
delete fGrammarResolver;
- delete fURIStringPool;
+ // grammar pool must do this
+ //delete fURIStringPool;
if (fValidator)
delete fValidator;
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org