| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-additional-options "-Wno-return-type" } */ |
| 3 |
/* { dg-skip-if "no pthread_barrier" { *-*-darwin* } } */ |
| 4 |
|
| 5 |
extern "C" { |
| 6 |
typedef __SIZE_TYPE__ size_t; |
| 7 |
typedef struct { |
| 8 |
} __sigset_t; |
| 9 |
typedef union { |
| 10 |
} pthread_barrierattr_t; |
| 11 |
} |
| 12 |
typedef unsigned short XMLCh; |
| 13 |
typedef unsigned long XMLSize_t; |
| 14 |
namespace xercesc_2_5 { |
| 15 |
class DOMNodeList; |
| 16 |
class DOMNode { |
| 17 |
}; |
| 18 |
class DOMDocumentRange { |
| 19 |
}; |
| 20 |
class DOMDocument: public DOMDocumentRange, public DOMNode { |
| 21 |
}; |
| 22 |
union wait { |
| 23 |
struct { |
| 24 |
} |
| 25 |
__wait_stopped; |
| 26 |
} |
| 27 |
div_t; |
| 28 |
class MemoryManager; |
| 29 |
class XMemory { |
| 30 |
public : void* operator new(size_t size, MemoryManager* memMgr); |
| 31 |
void operator delete(void* p); |
| 32 |
void operator delete(void* p, MemoryManager* memMgr); |
| 33 |
}; |
| 34 |
class XMLExcepts { |
| 35 |
public : enum Codes { |
| 36 |
NoError = 0 , HshTbl_ZeroModulus = 48 , HshTbl_BadHashFromKey = 49 }; |
| 37 |
}; |
| 38 |
class XMLUni { |
| 39 |
}; |
| 40 |
} |
| 41 |
namespace xercesc_2_5 { |
| 42 |
class XMLException : public XMemory { |
| 43 |
public: |
| 44 |
virtual ~XMLException(); |
| 45 |
XMLException(const char* const srcFile, const unsigned int srcLine, MemoryManager* const memoryManager = 0); |
| 46 |
void loadExceptText ( const XMLExcepts::Codes toLoad ); |
| 47 |
}; |
| 48 |
class XMLDeleter { |
| 49 |
}; |
| 50 |
class XMLPlatformUtils { |
| 51 |
public : static MemoryManager* fgMemoryManager; |
| 52 |
static inline size_t alignPointerForNewBlockAllocation(size_t ptrSize); |
| 53 |
}; |
| 54 |
inline size_t XMLPlatformUtils::alignPointerForNewBlockAllocation(size_t ptrSize) { |
| 55 |
} |
| 56 |
class HashBase : public XMemory { |
| 57 |
public: |
| 58 |
virtual bool equals(const void *const key1, const void *const key2) = 0; |
| 59 |
virtual ~HashBase() { |
| 60 |
}; |
| 61 |
}; |
| 62 |
class IllegalArgumentException : public XMLException { |
| 63 |
public: |
| 64 |
IllegalArgumentException(const char* const srcFile , const unsigned int srcLine , const XMLExcepts::Codes toThrow , MemoryManager* memoryManager = 0) : XMLException(srcFile, srcLine, memoryManager) { |
| 65 |
loadExceptText(toThrow); |
| 66 |
} |
| 67 |
}; |
| 68 |
class RuntimeException : public XMLException { |
| 69 |
public: |
| 70 |
RuntimeException(const char* const srcFile , const unsigned int srcLine , const XMLExcepts::Codes toThrow , MemoryManager* memoryManager = 0) : XMLException(srcFile, srcLine, memoryManager) { |
| 71 |
loadExceptText(toThrow); |
| 72 |
} |
| 73 |
}; |
| 74 |
class MemoryManager { |
| 75 |
public: |
| 76 |
virtual ~MemoryManager() { |
| 77 |
} |
| 78 |
virtual void* allocate(size_t size) = 0; |
| 79 |
}; |
| 80 |
template <class TElem> class BaseRefVectorOf : public XMemory { |
| 81 |
BaseRefVectorOf ( const unsigned int maxElems , const bool adoptElems = true , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); |
| 82 |
virtual ~BaseRefVectorOf(); |
| 83 |
bool fAdoptedElems; |
| 84 |
TElem** fElemList; |
| 85 |
}; |
| 86 |
template <class TElem> BaseRefVectorOf<TElem>::BaseRefVectorOf( const unsigned int maxElems , const bool adoptElems , MemoryManager* const manager) : fAdoptedElems(adoptElems) { |
| 87 |
for (unsigned int index = 0; |
| 88 |
index < maxElems; |
| 89 |
index++) fElemList[index] = 0; |
| 90 |
} |
| 91 |
template <class TElem> BaseRefVectorOf<TElem>::~BaseRefVectorOf() { |
| 92 |
} |
| 93 |
class XMLString { |
| 94 |
public: |
| 95 |
static bool equals ( const XMLCh* const str1 , const XMLCh* const str2 ); |
| 96 |
static void moveChars ( XMLCh* const targetStr , const XMLCh* const srcStr , const unsigned int count ); |
| 97 |
}; |
| 98 |
inline void XMLString::moveChars( XMLCh* const targetStr , const XMLCh* const srcStr , const unsigned int count) { |
| 99 |
} |
| 100 |
inline bool XMLString::equals( const XMLCh* const str1 , const XMLCh* const str2) { |
| 101 |
const XMLCh* psz1 = str1; |
| 102 |
const XMLCh* psz2 = str2; |
| 103 |
if (psz1 == 0 || psz2 == 0) { |
| 104 |
return true; |
| 105 |
} |
| 106 |
} |
| 107 |
} |
| 108 |
namespace xercesc_2_5 { |
| 109 |
class HashPtr : public HashBase { |
| 110 |
virtual bool equals(const void *const key1, const void *const key2); |
| 111 |
}; |
| 112 |
template <class TVal> struct DOMDeepNodeListPoolTableBucketElem : public XMemory { |
| 113 |
void* fKey1; |
| 114 |
XMLCh* fKey2; |
| 115 |
XMLCh* fKey3; |
| 116 |
}; |
| 117 |
template <class TVal> class DOMDeepNodeListPool { |
| 118 |
public: |
| 119 |
DOMDeepNodeListPool ( const XMLSize_t modulus , const bool adoptElems , const XMLSize_t initSize = 128 ); |
| 120 |
TVal* getByKey(const void* const key1, const XMLCh* const key2, const XMLCh* const key3); |
| 121 |
DOMDeepNodeListPoolTableBucketElem<TVal>* findBucketElem(const void* const key1, const XMLCh* const key2, const XMLCh* const key3, XMLSize_t& hashVal); |
| 122 |
bool fAdoptedElems; |
| 123 |
DOMDeepNodeListPoolTableBucketElem<TVal>** fBucketList; |
| 124 |
XMLSize_t fHashModulus; |
| 125 |
HashBase* fHash; |
| 126 |
TVal** fIdPtrs; |
| 127 |
XMLSize_t fIdPtrsCount; |
| 128 |
MemoryManager* fMemoryManager; |
| 129 |
}; |
| 130 |
template <class TVal> DOMDeepNodeListPool<TVal>::DOMDeepNodeListPool( const XMLSize_t modulus , const bool adoptElems , const XMLSize_t initSize) : fAdoptedElems(adoptElems) , fBucketList(0) , fHash(0) , fIdPtrs(0) { |
| 131 |
fHash = new (fMemoryManager) HashPtr(); |
| 132 |
fIdPtrs = (TVal**) fMemoryManager->allocate(fIdPtrsCount * sizeof(TVal*)); |
| 133 |
if (modulus == 0) throw IllegalArgumentException("./xercesc/dom/impl/bad.c", 38, XMLExcepts::HshTbl_ZeroModulus, fMemoryManager); |
| 134 |
} |
| 135 |
template <class TVal> TVal* DOMDeepNodeListPool<TVal>::getByKey(const void* const key1, const XMLCh* const key2, const XMLCh* const key3) { |
| 136 |
XMLSize_t hashVal; |
| 137 |
DOMDeepNodeListPoolTableBucketElem<TVal>* findIt = findBucketElem(key1, key2, key3, hashVal); |
| 138 |
} |
| 139 |
template <class TVal> DOMDeepNodeListPoolTableBucketElem<TVal>* DOMDeepNodeListPool<TVal>:: findBucketElem(const void* const key1, const XMLCh* const key2, const XMLCh* const key3, XMLSize_t& hashVal) { |
| 140 |
if (hashVal > fHashModulus) throw RuntimeException("./xercesc/dom/impl/bad.c", 64, XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager); |
| 141 |
DOMDeepNodeListPoolTableBucketElem<TVal>* curElem = fBucketList[hashVal]; |
| 142 |
if (fHash->equals(key1, curElem->fKey1) && (XMLString::equals(key2, curElem->fKey2)) && (XMLString::equals(key3, curElem->fKey3))) { |
| 143 |
return curElem; |
| 144 |
} |
| 145 |
} |
| 146 |
class DOMDeepNodeListImpl; |
| 147 |
class DOMDocumentImpl: public DOMDocument { |
| 148 |
DOMNodeList* getElementsByTagName(const XMLCh * tagname) const; |
| 149 |
DOMNodeList* getDeepNodeList(const DOMNode *rootNode, const XMLCh *tagName); |
| 150 |
DOMNodeList* getDeepNodeList(const DOMNode *rootNode, const XMLCh *namespaceURI, const XMLCh *localName); |
| 151 |
DOMDeepNodeListPool<DOMDeepNodeListImpl>* fNodeListPool; |
| 152 |
}; |
| 153 |
} |
| 154 |
void * operator new(size_t amt, xercesc_2_5:: DOMDocument *doc); |
| 155 |
namespace xercesc_2_5 { |
| 156 |
class DOMNodeList { |
| 157 |
}; |
| 158 |
class DOMDeepNodeListImpl: public DOMNodeList { |
| 159 |
}; |
| 160 |
DOMNodeList *DOMDocumentImpl::getElementsByTagName(const XMLCh *tagname) const { |
| 161 |
return ((DOMDocumentImpl*)this)->getDeepNodeList(this,tagname); |
| 162 |
} |
| 163 |
DOMNodeList *DOMDocumentImpl::getDeepNodeList(const DOMNode *rootNode, const XMLCh *tagName) { |
| 164 |
if(!fNodeListPool) { |
| 165 |
fNodeListPool = new (this) DOMDeepNodeListPool<DOMDeepNodeListImpl>(109, false); |
| 166 |
} |
| 167 |
DOMNodeList* retList = fNodeListPool->getByKey(rootNode, tagName, 0); |
| 168 |
} |
| 169 |
DOMNodeList *DOMDocumentImpl::getDeepNodeList(const DOMNode *rootNode, const XMLCh *namespaceURI, const XMLCh *localName) { |
| 170 |
DOMNodeList* retList = fNodeListPool->getByKey(rootNode, localName, namespaceURI); |
| 171 |
} |
| 172 |
} |
| 173 |
|