// --------------------------------------------------------------------------- // XMLTransService: Constructors and destructor // --------------------------------------------------------------------------- XMLTransService::XMLTransService() { if (!gMappings) { RefHashTableOf<ENameMap>* t = new RefHashTableOf<ENameMap>(103); if (XMLPlatformUtils::compareAndSwap((void **)&gMappings, t, 0) != 0) { delete t; } else { mappingsCleanup.registerCleanup(reinitMappings); } } if (!gMappingsRecognizer) { RefVectorOf<ENameMap>* t = new RefVectorOf<ENameMap>(XMLRecognizer::Encodings_Count); if (XMLPlatformUtils::compareAndSwap((void **)&gMappingsRecognizer, t, 0) != 0) { delete t; } else { mappingsRecognizerCleanup.registerCleanup(reinitMappingsRecognizer); } } }
// This function can be called either from XMLPlatformUtils::Terminate // to state that the cleanup has been performed and should not be // performed again, or from code that you have written that determines // that cleanup is no longer necessary. void XMLRegisterCleanup::unregisterCleanup() { gXMLCleanupListMutex->lock(); // // To protect against some compiler's (eg hp11) optimization // to change "this" as they update gXMLCleanupList // // refer to // void XMLPlatformUtils::Terminate() // ... // while (gXMLCleanupList) // gXMLCleanupList->doCleanup(); // XMLRegisterCleanup *tmpThis = (XMLRegisterCleanup*) this; // Unlink this object from the cleanup list if (m_nextCleanup) m_nextCleanup->m_prevCleanup = m_prevCleanup; if (!m_prevCleanup) gXMLCleanupList = m_nextCleanup; else m_prevCleanup->m_nextCleanup = m_nextCleanup; gXMLCleanupListMutex->unlock(); // Reset the object to the default state tmpThis->resetCleanup(); }
void XMLInitializer::initializeXSDErrReporterMsgLoader() { gErrMsgLoader = XMLPlatformUtils::loadMsgSet(XMLUni::fgXMLErrDomain); if (gErrMsgLoader) { cleanupErrMsgLoader.registerCleanup(reinitErrMsgLoader); } gValidMsgLoader = XMLPlatformUtils::loadMsgSet(XMLUni::fgValidityDomain); if (gValidMsgLoader) { cleanupValidMsgLoader.registerCleanup(reinitValidMsgLoader); } }
void XMLInitializer::initializeDOMImplementationRegistry() { // mutex gDOMImplSrcVectorMutex = new XMLMutex(XMLPlatformUtils::fgMemoryManager); if (gDOMImplSrcVectorMutex) { cleanupDOMImplSrcVectorMutex.registerCleanup(reinitDOMImplSrcVectorMutex); } // vector gDOMImplSrcVector = new RefVectorOf<DOMImplementationSource>(3, false); if (gDOMImplSrcVector) { cleanupDOMImplSrcVector.registerCleanup(reinitDOMImplSrcVector); } }
void GeneralAttributeCheck::mapElements() { if (!sGeneralAttCheckMutexRegistered) { if (!sGeneralAttCheckMutex) { XMLMutexLock lock(XMLPlatformUtils::fgAtomicMutex); if (!sGeneralAttCheckMutex) sGeneralAttCheckMutex = new XMLMutex(XMLPlatformUtils::fgMemoryManager); } // Use a faux scope to synchronize while we do this { XMLMutexLock lock(sGeneralAttCheckMutex); // If we got here first, then register it and set the registered flag if (!sGeneralAttCheckMutexRegistered) { // initialize setUpValidators(); mapAttributes(); // register for cleanup at Termination. sGeneralAttCheckCleanup.registerCleanup(GeneralAttributeCheck::reinitGeneralAttCheck); sGeneralAttCheckMutexRegistered = true; } } } }
void XMLInitializer::initializeMsgLoader4DOM() { sMsgLoader4DOM = XMLPlatformUtils::loadMsgSet(XMLUni::fgXMLDOMMsgDomain); if (sMsgLoader4DOM) { msgLoader4DOMCleanup.registerCleanup(reinitMsgLoader4DOM); } }
void XMLInitializer::initializeEmptyNodeList() { gEmptyNodeList = new DOMNodeListImpl(0); if (gEmptyNodeList) { emptyNodeListCleanup.registerCleanup(reinitEmptyNodeList); } }
DOMNodeList *DOMNodeImpl::getChildNodes() const { if (!gEmptyNodeList) { if (!gEmptyNodeListMutex) { XMLMutexLock lock(XMLPlatformUtils::fgAtomicMutex); if (!gEmptyNodeListMutex) gEmptyNodeListMutex = new XMLMutex(XMLPlatformUtils::fgMemoryManager); } // Use a faux scope to synchronize while we do this { XMLMutexLock lock(gEmptyNodeListMutex); if (!gEmptyNodeList) { gEmptyNodeList = new DOMNodeListImpl(0); emptyNodeListCleanup.registerCleanup(reinitEmptyNodeList); } } } return (DOMNodeList *)gEmptyNodeList; }
void XMLInitializer::initializeDOMImplementationImpl() { gDomimp = new DOMImplementationImpl; if (gDomimp) { implementationCleanup.registerCleanup(reinitImplementation); } }
void XMLInitializer::initializeEncodingValidator() { EncodingValidator::fInstance = new EncodingValidator(); if (EncodingValidator::fInstance) { instanceCleanup.registerCleanup(EncodingValidator::reinitInstance); } }
void XMLInitializer::initializeExceptionMsgLoader() { sMsgLoader = XMLPlatformUtils::loadMsgSet(XMLUni::fgExceptDomain); if (sMsgLoader) { msgLoaderCleanup.registerCleanup(XMLException::reinitMsgLoader); } }
// getImplementation() - Always returns the same singleton instance, which // is lazily created on the first call. Note that // DOM_Implementation must be thread-safe because // it is common to all DOM documents, and while a single // document is not thread-safe within itself, we do // promise that different documents can safely be // used concurrently by different threads. // DOM_DOMImplementation &DOM_DOMImplementation::getImplementation() { static XMLRegisterCleanup implementationCleanup; if (gDomimp == 0) { DOM_DOMImplementation *t = new DOM_DOMImplementation; if (XMLPlatformUtils::compareAndSwap((void **)&gDomimp, t, 0) != 0) { delete t; } else { implementationCleanup.registerCleanup(reinitImplementation); } } return *gDomimp; }
void XMLInitializer::initializeRangeTokenMap() { RangeTokenMap::fInstance = new RangeTokenMap(XMLPlatformUtils::fgMemoryManager); if (RangeTokenMap::fInstance) { rangeTokMapInstanceCleanup.registerCleanup(RangeTokenMap::reinitInstance); RangeTokenMap::fInstance->buildTokenRanges(); } }
void RegularExpression::staticInitialize(MemoryManager* memoryManager) { fWordRange = TokenFactory::staticGetRange(fgUniIsWord, false); if (fWordRange == 0) ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Regex_RangeTokenGetError, fgUniIsWord, memoryManager); WordRangeCleanup.registerCleanup(localCleanup); }
// ----------------------------------------------------------------------- // Get the static data // ----------------------------------------------------------------------- RefVectorOf<DOMImplementationSource>* getDOMImplSrcVector() { // Note: we are not synchronizing on creation since that caller is doing // it (i.e. caller is locking a mutex before calling us) if (!gDOMImplSrcVector) { gDOMImplSrcVector = new RefVectorOf<DOMImplementationSource>(3, false); cleanupDOMImplSrcVector.registerCleanup(reinitDOMImplSrcVector); } return gDOMImplSrcVector; }
static XMLMutex& getErrRprtrMutex() { if (!sErrRprtrMutex) { XMLMutexLock lockInit(XMLPlatformUtils::fgAtomicMutex); if (!sErrRprtrMutex) { sErrRprtrMutex = new XMLMutex(XMLPlatformUtils::fgMemoryManager); errRprtrMutexCleanup.registerCleanup(reinitErrRprtrMutex); } } return *sErrRprtrMutex; }
static XMLMutex& getEncValMutex() { if (!sEncValMutex) { XMLMutexLock lock(XMLPlatformUtils::fgAtomicMutex); // If we got here first, then register it and set the registered flag if (!sEncValMutex) { sEncValMutex = new XMLMutex; encValRegistryCleanup.registerCleanup(reinitEncValMutex); } } return *sEncValMutex; }
// --------------------------------------------------------------------------- // RangeTokenMap: Instance methods // --------------------------------------------------------------------------- RangeTokenMap* RangeTokenMap::instance() { if (!fInstance) { XMLMutexLock lock(&getRangeTokMapMutex()); if (!fInstance) { fInstance = new RangeTokenMap(XMLPlatformUtils::fgMemoryManager); rangeTokMapInstanceCleanup.registerCleanup(RangeTokenMap::reinitInstance); } } return (fInstance); }
static XMLMutex& getMutex4DOM() { if (!sMutex4DOM) { XMLMutexLock lock(XMLPlatformUtils::fgAtomicMutex); // If we got here first, then register it and set the registered flag if (!sMutex4DOM) { sMutex4DOM = new XMLMutex; mutex4DOMCleanup.registerCleanup(reinitMutex4DOM); } } return *sMutex4DOM; }
// getImplementation() - Always returns the same singleton instance, which // is lazily created on the first call. Note that // DOM_Implementation must be thread-safe because // it is common to all DOM documents, and while a single // document is not thread-safe within itself, we do // promise that different documents can safely be // used concurrently by different threads. // DOMImplementationImpl *DOMImplementationImpl::getDOMImplementationImpl() { if (!gDomimp) { XMLMutexLock lock(&getMutex4DOM()); if (!gDomimp) { gDomimp = new DOMImplementationImpl; implementationCleanup.registerCleanup(reinitImplementation); } } return gDomimp; }
// --------------------------------------------------------------------------- // RangeTokenMap: Instance methods // --------------------------------------------------------------------------- RangeTokenMap* RangeTokenMap::instance() { if (!fInstance) { XMLMutexLock lock(&getRangeTokMapMutex()); if (!fInstance) { fInstance = new RangeTokenMap(); rangeTokMapInstanceCleanup.registerCleanup(RangeTokenMap::reinitInstance); } } return (fInstance); }
// --------------------------------------------------------------------------- // EncodingValidator: Instance methods // --------------------------------------------------------------------------- EncodingValidator* EncodingValidator::instance() { if (!fInstance) { XMLMutexLock lock(&getEncValMutex()); if (!fInstance) { fInstance = new EncodingValidator(); instanceCleanup.registerCleanup(EncodingValidator::reinitInstance); } } return (fInstance); }
static XMLMutex& getRangeTokMapMutex() { if (!sRangeTokMapMutex) { XMLMutexLock lock(XMLPlatformUtils::fgAtomicMutex); // If we got here first, then register it and set the registered flag if (!sRangeTokMapMutex) { sRangeTokMapMutex = new XMLMutex(XMLPlatformUtils::fgMemoryManager); rangeTokMapRegistryCleanup.registerCleanup(reinitRangeTokMapMutex); } } return *sRangeTokMapMutex; }
XMLMutex& getDOMImplSrcVectorMutex() { if (!gDOMImplSrcVectorMutex) { XMLMutexLock lock(XMLPlatformUtils::fgAtomicMutex); if (!gDOMImplSrcVectorMutex) { gDOMImplSrcVectorMutex = new XMLMutex(XMLPlatformUtils::fgMemoryManager); cleanupDOMImplSrcVectorMutex.registerCleanup(reinitDOMImplSrcVectorMutex); } } return *gDOMImplSrcVectorMutex; }
// We need to fault in this mutex. But, since its used for synchronization // itself, we have to do this the low level way using a compare and swap. static XMLMutex& gTokenFactoryMutex() { if (!sTokFactoryMutexRegistered) { XMLMutexLock lock(XMLPlatformUtils::fgAtomicMutex); if (!sTokFactoryMutexRegistered) { sTokFactoryMutex = new XMLMutex; tokenFactoryMutexCleanup.registerCleanup(TokenFactory::reinitTokenFactoryMutex); sTokFactoryMutexRegistered = true; } } return *sTokFactoryMutex; }
XMLLCPTranscoder* getDomConverter() { if (!gDomConverter) { XMLLCPTranscoder* transcoder = XMLPlatformUtils::fgTransService->makeNewLCPTranscoder(); if (!transcoder) XMLPlatformUtils::panic(PanicHandler::Panic_NoDefTranscoder ); if (XMLPlatformUtils::compareAndSwap((void **)&gDomConverter, transcoder, 0) != 0) delete transcoder; else cleanupDomConverter.registerCleanup(reinitDomConverter); } return gDomConverter; }
// // We need to fault in this mutex. But, since its used for synchronization // itself, we have to do this the low level way using a compare and swap. // static XMLMutex& gMsgMutex() { if (!sScannerMutexRegistered) { XMLMutexLock lockInit(XMLPlatformUtils::fgAtomicMutex); if (!sScannerMutexRegistered) { sMsgMutex = new XMLMutex; msgMutexCleanup.registerCleanup(XMLException::reinitMsgMutex); sScannerMutexRegistered = true; } } return *sMsgMutex; }
XMLMutex& DOMStringHandle::getMutex() { if (!DOMStringHandleMutex) { XMLMutex* tmpMutex = new XMLMutex(XMLPlatformUtils::fgMemoryManager); if (XMLPlatformUtils::compareAndSwap((void**)&DOMStringHandleMutex, tmpMutex, 0)) { // Someone beat us to it, so let's clean up ours delete tmpMutex; } else cleanupDomMutex.registerCleanup(reinitDomMutex); } return *DOMStringHandleMutex; }
static XMLMsgLoader* getValidMsgLoader() { if (!gValidMsgLoader) { XMLMutexLock lock(&getErrRprtrMutex()); if (!gValidMsgLoader) { gValidMsgLoader = XMLPlatformUtils::loadMsgSet(XMLUni::fgValidityDomain); if (!gValidMsgLoader) XMLPlatformUtils::panic(PanicHandler::Panic_CantLoadMsgDomain); else cleanupValidMsgLoader.registerCleanup(reinitValidMsgLoader); } } return gValidMsgLoader; }
void DTDGrammar::resetEntityDeclPool() { // Initialize default entities if not initialized if (!sEntityPoolMutexRegistered) { if (!sEntityPoolMutex) { XMLMutexLock lock(XMLPlatformUtils::fgAtomicMutex); if (!sEntityPoolMutex) sEntityPoolMutex = new XMLMutex; } // Use a faux scope to synchronize while we do this { XMLMutexLock lock(sEntityPoolMutex); // If we got here first, then register it and set the registered flag if (!sEntityPoolMutexRegistered) { fDefaultEntities = new NameIdPool<DTDEntityDecl>(11, 12); // // Add the default entity entries for the character refs that must // always be present. We indicate that they are from the internal // subset. They aren't really, but they have to look that way so // that they are still valid for use within a standalone document. // // We also mark them as special char entities, which allows them // to be used in places whether other non-numeric general entities // cannot. // fDefaultEntities->put(new DTDEntityDecl(XMLUni::fgAmp, chAmpersand, true, true)); fDefaultEntities->put(new DTDEntityDecl(XMLUni::fgLT, chOpenAngle, true, true)); fDefaultEntities->put(new DTDEntityDecl(XMLUni::fgGT, chCloseAngle, true, true)); fDefaultEntities->put(new DTDEntityDecl(XMLUni::fgQuot, chDoubleQuote, true, true)); fDefaultEntities->put(new DTDEntityDecl(XMLUni::fgApos, chSingleQuote, true, true)); // register cleanup method entityPoolRegistryCleanup.registerCleanup(DTDGrammar::reinitDfltEntities); sEntityPoolMutexRegistered = true; } } } }