Changeset 3601


Ignore:
Timestamp:
Jan 3, 2014, 1:56:57 PM (5 years ago)
Author:
nmedfort
Message:

couple fixes for namespace scope issues.

Location:
icXML/icXML-devel/src/icxmlc
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • icXML/icXML-devel/src/icxmlc/Array.hpp

    r3563 r3601  
    167167                {
    168168            #ifdef PRINT_DEBUG_MESSAGE
    169             assert(i < capacity());
     169            if (i >= capacity())
     170            {
     171                generateCallstack();
     172                assert(i < capacity());
     173            }
    170174            #endif
    171175            return _array[i];
     
    176180                {
    177181            #ifdef PRINT_DEBUG_MESSAGE
    178             assert(i < capacity());
     182            if (i >= capacity())
     183            {
     184                generateCallstack();
     185                assert(i < capacity());
     186            }
    179187            #endif
    180188            return _array[i];
  • icXML/icXML-devel/src/icxmlc/XMLConfig.hpp

    r3563 r3601  
    2828
    2929#ifndef PRINT_DEBUG_IGNORE_GRAMMAR_MESSAGES
    30 #define PRINT_DEBUG_IGNORE_GRAMMAR_MESSAGES
     30//#define PRINT_DEBUG_IGNORE_GRAMMAR_MESSAGES
    3131#endif
    3232
    3333#ifndef PRINT_DEBUG_IGNORE_NAMESPACE_MESSAGES
    34 #define PRINT_DEBUG_IGNORE_NAMESPACE_MESSAGES
     34//#define PRINT_DEBUG_IGNORE_NAMESPACE_MESSAGES
    3535#endif
    3636
    3737#ifndef PRINT_DEBUG_IGNORE_SYMBOL_STREAM_MESSAGES
    38 #define PRINT_DEBUG_IGNORE_SYMBOL_STREAM_MESSAGES
     38//#define PRINT_DEBUG_IGNORE_SYMBOL_STREAM_MESSAGES
    3939#endif
    4040
    4141#ifndef PRINT_DEBUG_IGNORE_REFERENCE_STREAM_MESSAGES
    42 #define PRINT_DEBUG_IGNORE_REFERENCE_STREAM_MESSAGES
     42//#define PRINT_DEBUG_IGNORE_REFERENCE_STREAM_MESSAGES
    4343#endif
    4444
  • icXML/icXML-devel/src/icxmlc/XMLGrammarResolver.hpp

    r3563 r3601  
    6161        if (unlikely(uriId >= fList.capacity()))
    6262        {       
    63         fList.resizeToFit(max<size_t>(uriId, fList.capacity() * 2));
    64         DEBUG_MESSAGE("cap'=" << fList.capacity())
     63        fList.resizeToFit(max<size_t>(uriId + 1, fList.capacity() * 2));
    6564        }
    6665        fList[uriId] = grammar;
  • icXML/icXML-devel/src/icxmlc/XMLNamespaceBindingSet.hpp

    r3585 r3601  
    718718                void increaseBitCapacity(const size_t minimum = 0)
    719719                {
    720                         DEBUG_MESSAGE("BindingSets::increaseBitCapacity(" << minimum << ')')
     720            DEBUG_MESSAGE("BindingSets::increaseBitCapacity(" << minimum << ") " << this->bitCapacity())
    721721
    722722            if (minimum < bitCapacity()) return;
     
    761761                void increaseSetCapacity(const size_t minumum = 0)
    762762                {
    763                         DEBUG_MESSAGE("BindingSets::increaseSetCapacity(" << minumum << ')')
     763            DEBUG_MESSAGE("BindingSets::increaseSetCapacity(" << minumum << ") " << this->setCapacity())
    764764
    765765            if (minumum < setCapacity()) return;
  • icXML/icXML-devel/src/icxmlc/XMLNamespaceResolver.c

    r3563 r3601  
    235235gid_t XMLNamespaceResolver::addOrFindPrefixId(const XMLCh * qName, const XMLSize_t length)
    236236{
    237     return addOrFindPrefix(qName, length)->getId();
     237    const gid_t prefixId = addOrFindPrefix(qName, length)->getId();
     238    DEBUG_NAMESPACE_MESSAGE(" -- prefixId=" << prefixId)
     239    return prefixId;
    238240}
    239241
     
    260262XMLNamespaceResolver::findPrefix(const XMLCh * prefix, const int length) const
    261263{
     264    DEBUG_NAMESPACE_MESSAGE("XMLNamespaceResolver::findPrefix(" << prefix << ',' << length << ')')
    262265    // resolve the prefix id from the prefix; since this will not be required
    263266    // very often, just iterate through a list.
     
    266269        if (fPrefixList[index].equals(prefix, length))
    267270        {
     271            DEBUG_NAMESPACE_MESSAGE(" -- found @ " << index)
    268272            return &fPrefixList[index];
    269273        }
     
    279283XMLNamespaceResolver::getPrefixForId(const gid_t prefixId) const
    280284{
    281     if (likely((prefixId < fPrefixCount) && (fPrefixList[prefixId].id == prefixId)))
    282     {
    283         return fPrefixList[prefixId].getKey();
     285    DEBUG_NAMESPACE_MESSAGE("XMLNamespaceResolver::getPrefixForId(" << prefixId << ") " << fPrefixList.capacity())
     286
     287    assert (prefixId < fPrefixList.capacity());
     288
     289    if (likely(prefixId < fPrefixCount))
     290    {
     291        const XMLPrefixEntry & prefix = fPrefixList[prefixId];
     292        DEBUG_MESSAGE(" &(prefix)=" << (size_t)(&prefix))
     293        if (prefix.id == prefixId)
     294        {
     295            return prefix.getKey();
     296        }
    284297    }
    285298
     
    288301    for (gid_t index = 0; index < fPrefixCount; index++)
    289302    {
    290         if (fPrefixList[index].id == prefixId)
    291         {
    292             return fPrefixList[index].getKey();
     303        const XMLPrefixEntry & entry = fPrefixList[index];
     304        DEBUG_MESSAGE("entry[" << index << "]=" << (size_t)(&entry))
     305        if (entry.id == prefixId)
     306        {
     307            return entry.getKey();
    293308        }
    294309    }
     
    315330    const gid_t prefixId = max<size_t>(fPrefixCount, fUriPool.count());
    316331
     332    DEBUG_NAMESPACE_MESSAGE(" -- new prefixId=max(" << fPrefixCount << ',' << fUriPool.count() << ")=" << prefixId)
     333
    317334        if (unlikely(fPrefixToNamespaceBindingTable.setCapacity() <= prefixId))
    318335        {
     
    324341
    325342    // if our prefix count equals our capacity, then we need to expand all of the related buffers
    326     if (unlikely(fPrefixCount == fPrefixList.capacity()))
     343    if (unlikely(fPrefixCount >= fPrefixList.capacity()))
    327344    {
    328345        DEBUG_NAMESPACE_MESSAGE(" -- resizing fPrefixList");
    329         fPrefixList.resizeToFit(fPrefixList.capacity(), fPrefixList.capacity() * 2);
    330     }
    331 
    332     XMLPrefixEntry * newPrefix = &fPrefixList[fPrefixCount++];
     346        fPrefixList.resizeToFit(fPrefixList.capacity() * 2);
     347    }
     348
     349    XMLPrefixEntry & newPrefix = fPrefixList[fPrefixCount++];
    333350        // QUESTION: does storing the prefixes in the string pool help or hinder? we can just point to
    334351        // the symbols and store only the prefix's length?
    335352        // NOTE: this may require modifying the TraverseSchema class to do this safely.
    336     newPrefix->key = fPrefixPool.insert(prefix, length);
    337     newPrefix->length = length;
    338     newPrefix->id = prefixId;
     353    newPrefix.key = fPrefixPool.insert(prefix, length);
     354    newPrefix.length = length;
     355    newPrefix.id = prefixId;
     356
     357    DEBUG_NAMESPACE_MESSAGE(" &(newPrefix)=" << (size_t)(&newPrefix))
    339358
    340359        // add this entry to the canonical prefix set since we assume that the prefix and uri ids
     
    342361        fCanonicalBindingSet += prefixId;
    343362
    344     return newPrefix;
     363    return &newPrefix;
    345364}
    346365
     
    354373    if (unlikely(linkId == XMLNamespaceResolver::fUnknownUriId))
    355374        {
    356         DEBUG_MESSAGE(" -- adding new uriId")
     375        DEBUG_MESSAGE(" -- adding new uriId (prefixId=" << prefixId << " of " << fUriPool.capacity() << ')')
    357376        linkId = prefixId;
    358377        if (unlikely(prefixId > fUriPool.capacity()))
     
    381400XMLNamespaceResolver::mapPrefixToUri(const gid_t prefixId, const gid_t uriId)
    382401{
    383 
    384402    // both the prefixId and the uriId exist, but they are not mapped to one another.
    385403    const gid_t namespaceId = bindPrefixToUri(prefixId, uriId);
     404
     405    assert (fScope < fLocallyModifiedNamespaces.setCapacity());
     406    assert (namespaceId < fLocallyModifiedNamespaces.bitCapacity());
     407    assert (namespaceId < fCurrentlyVisibleNamespaces.capacity());
    386408
    387409    // add the new namespace to the namespace 'stack'
     
    498520
    499521
    500         XMLPrefixEntry * entry = &fPrefixList[id];
     522    XMLPrefixEntry & entry = fPrefixList[id];
    501523        // QUESTION: does storing the prefixes in the string pool help or hinder? we can just point to
    502524        // the symbols and store only the prefix's length?
    503525        // NOTE: this may require modifying the TraverseSchema class to do this safely.
    504         entry->key = prefix; // _prefixAndUriStringPool.insert(prefix, length);
    505         entry->length = prefixLength;
    506         entry->id = id;
     526    entry.key = prefix; // _prefixAndUriStringPool.insert(prefix, length);
     527    entry.length = prefixLength;
     528    entry.id = id;
    507529
    508530        // create the namespace entry and add it
     
    567589    }
    568590    else
    569     {
     591    {       
    570592        fCurrentContextId = contextId;
     593        assert (fScope < fContextIdStack.capacity());
    571594        fContextIdStack[fScope] = contextId;
    572595    }
     
    588611IDISA_ALWAYS_INLINE
    589612BindingSetIterator XMLNamespaceResolver::getNamespaceIterator(const gid_t contextId) const
    590 {   
     613{
     614    assert (contextId < fDistinctContextSet.setCapacity());
     615
    591616    return BindingSetIterator(fDistinctContextSet[contextId]);
    592617}
     
    597622MaskedBindingSetIterator XMLNamespaceResolver::getNamespaceIterator(const gid_t contextId0, const gid_t contextId1) const
    598623{
     624    assert (contextId0 < fDistinctContextSet.setCapacity());
     625    assert (contextId1 < fDistinctContextSet.setCapacity());
     626
    599627    return MaskedBindingSetIterator(fDistinctContextSet[contextId0], fDistinctContextSet[contextId1], true);
    600628}
     
    628656XMLNamespaceResolver::getPrefixForNamespaceId(const gid_t namespaceId) const
    629657{
     658    assert (namespaceId < fNamespaceToPrefixBindingTable.capacity());
    630659    return getPrefixForId(fNamespaceToPrefixBindingTable[namespaceId]);
    631660}
     
    637666XMLNamespaceResolver::getUriForNamespaceId(const gid_t namespaceId) const
    638667{
     668    assert (namespaceId < fNamespaceToUriBindingTable.capacity());
    639669    return getUriForId(fNamespaceToUriBindingTable[namespaceId]);
    640670}
  • icXML/icXML-devel/src/icxmlc/XMLNamespaceResolver.hpp

    r3563 r3601  
    166166        void setMaxScope(const size_t maxScope)
    167167        {
    168             DEBUG_NAMESPACE_MESSAGE("XMLNamespaceResolver::setMaxScope(" << maxScope << ')')
     168            if (maxScope < getMaxScope()) return;
    169169            fLocallyModifiedNamespaces.increaseSetCapacity(maxScope);
    170             fContextIdStack.resizeToFit(fScope, maxScope + 1);
     170            fContextIdStack.resizeToFit(fScope, getMaxScope());
    171171        }
    172172
     
    316316
    317317        DynamicArray<gid_t, INITIAL_MAX_SCOPE>                  fContextIdStack;
    318         BindingSets<sizeof(hash_t) * 8>                                                 fPrefixToNamespaceBindingTable;
    319         DynamicArray<gid_t, sizeof(hash_t) * 8>                                 fNamespaceToUriBindingTable;
    320         DynamicArray<gid_t, sizeof(hash_t) * 8>                                 fNamespaceToPrefixBindingTable;
     318        BindingSets<sizeof(hash_t) * 8>                                                 fPrefixToNamespaceBindingTable;       
     319        DynamicArray<gid_t, sizeof(hash_t) * 8>                                 fNamespaceToUriBindingTable;       
     320        DynamicArray<gid_t, sizeof(hash_t) * 8>                                 fNamespaceToPrefixBindingTable;       
    321321        BindingSets<INITIAL_MAX_SCOPE>                                                  fLocallyModifiedNamespaces;
    322322        DynamicArray<XMLPrefixEntry, sizeof(hash_t) * 8>                fPrefixList;
    323         XMLNamespaceTable                                                                               fUriPool;
     323        XMLNamespaceTable                                                                               fUriPool;       
    324324        BindingSets<INITIAL_MAX_SCOPE>                                                  fDistinctContextSet;       
    325325        StringPool<XMLCh, DEFAULT_PREFIX_POOL_SIZE>             fPrefixPool;
  • icXML/icXML-devel/src/icxmlc/XMLNamespaceUriTable.hpp

    r3563 r3601  
    136136        private:
    137137
    138                 HashTable<XMLNamespaceEntry, XMLCh, sizeof(hash_t) * 16, 1>                     fHashTable;
     138        HashTable<XMLNamespaceEntry, XMLCh, sizeof(hash_t) * 8, 1>                      fHashTable;
    139139};
    140140
  • icXML/icXML-devel/src/icxmlc/XMLParserImpl.c

    r3563 r3601  
    267267XMLParserImpl<XMLScannerType>::
    268268scanElementPage()
    269 {     
     269{
     270    assert (fDocumentDesseminator);
     271
    270272    START_PAPI_COUNTER(fPapiCounter, PAPI_MEASURE_DD);
    271273
     
    273275    DEBUG_MESSAGE("PRINT ELEMENT PAGE:");
    274276    DEBUG_MESSAGE("######################################################################");
    275     if (fDocumentDesseminator)
    276     {
    277         fDocumentDesseminator->scanPage();
    278     }
     277
     278    try
     279    {
     280        if (fDocumentDesseminator)
     281        {
     282            fDocumentDesseminator->scanPage();
     283        }
     284    }
     285    catch (const std::exception & ex)
     286    {
     287        std::cerr << "Error scanning element page! " << ex.what() << std::endl;
     288        exit(-1);
     289    }
     290
     291    DEBUG_MESSAGE(" -- done scanning element page.")
    279292
    280293    STOP_PAPI_COUNTER(fPapiCounter, PAPI_MEASURE_DD);
     
    391404        }
    392405
    393         if (unlikely(fNamespaceResolver.getMaxScope() <= fMaxScope))
    394         {
    395             fNamespaceResolver.setMaxScope(fMaxScope);
    396             fChildren.resizeToFit(fScope, fNamespaceResolver.getMaxScope());
    397             fContentFlag.resizeToFit(fScope, fMaxScope);
    398             DEBUG_MESSAGE(" -- resizing scopes to fit " << fMaxScope << " -> " << fNamespaceResolver.getMaxScope() << ',' << fChildren.capacity() << ',' << fGidStack.capacity() << ',' << fContentFlag.capacity())
    399         }
     406        fNamespaceResolver.setMaxScope(fMaxScope + 1);
     407        fChildren.resizeToFit(fScope, fNamespaceResolver.getMaxScope());
     408        fContentFlag.resizeToFit(fScope, fNamespaceResolver.getMaxScope());
    400409
    401410        if (unlikely(fUriStream.capacity() <= fUriCount))
  • icXML/icXML-devel/src/icxmlc/parsers/SAX2DocumentDisseminatorImpl.c

    r3563 r3601  
    3131    , fNoXmlnsAttrList(16, false, manager)
    3232    {
    33 
     33        DEBUG_MESSAGE("SAX2DocumentDisseminatorImpl(docHandler, manager)")
    3434    }
    3535
     
    4242    , fNoXmlnsAttrList(16, false, manager)
    4343    {
    44 
     44        DEBUG_MESSAGE("SAX2DocumentDisseminatorImpl(docHandler, psviHandler, manager)")
    4545    }
    4646
     
    109109            {
    110110                XMLSize_t length = *this->fDocumentContextPtr++;
    111 
    112111                const XMLCh * content = this->fDocumentObjectPtr[0].string;
    113112                this->fDocumentObjectPtr++;
     
    169168        for (size_t index = 0; index < attributeCount; index++)
    170169        {
     170            assert (this->fDocumentContextPtr + 3 <= this->fParser->fDocumentContextStream.limit());
     171            assert (this->fDocumentObjectPtr + 2 <= this->fParser->fDocumentObjectStream.limit());
     172
    171173            DocumentContextType attributeType = this->fDocumentContextPtr[0];
    172174            const AttType attType = static_cast<AttType>((attributeType >> 8) & 0xFF);
     
    195197        for (size_t index = 0; index < attributeCount; index++)
    196198        {
     199            assert (this->fDocumentContextPtr + 3 <= this->fParser->fDocumentContextStream.limit());
     200            assert (this->fDocumentObjectPtr + 2 <= this->fParser->fDocumentObjectStream.limit());
     201
    197202            DocumentContextType attributeType = this->fDocumentContextPtr[0];
    198203            const AttType attType = static_cast<AttType>((attributeType >> 8) & 0xFF);
     
    218223    if (likely(fMapNamespaces))
    219224    {
     225
     226
    220227        // test whether we need to announce any prefix mappings
    221228        const gid_t lastNamespaceContextId = fNamespaceContextId;
     
    329336reset(XMLParser * parser, XSModel * model, const XMLCh * rootElemName)
    330337{
     338    #ifdef DEBUG_MESSAGE
     339    this->fParser = parser;
     340    #endif
    331341    this->fDocumentContextPtr = &(parser->fDocumentContextStream[0]);
    332342    this->fDocumentObjectPtr = &(parser->fDocumentObjectStream[0]);
     
    377387    if (unlikely(fNamespaceContextCount == 0))
    378388    {
     389        assert (fNamespaceContextPtr + 2 <= fNamespaceContextStream->limit());
     390
    379391        fNamespaceContextPtr += 2;
    380392        fNamespaceContextId = fNamespaceContextPtr[0];
     
    389401startNamespaceMappings(const gid_t inScopeId, const gid_t outOfScopeId)
    390402{
    391     MaskedBindingSetIterator inScopeItr = this->fNamespaceResolver->getNamespaceIterator(inScopeId, outOfScopeId);
     403    MaskedBindingSetIterator inScopeItr = this->fNamespaceResolver->getNamespaceIterator(inScopeId, outOfScopeId);   
    392404    while (inScopeItr.next())
    393405    {
  • icXML/icXML-devel/src/icxmlc/parsers/SAXDocumentDisseminatorImpl.hpp

    r3563 r3601  
    358358reset(XMLParser * parser, XSModel * model, const XMLCh * rootElemName)
    359359{
     360    #ifdef DEBUG_MESSAGE
     361    this->fParser = parser;
     362    #endif
    360363    this->fDocumentContextPtr = &(parser->fDocumentContextStream[0]);
    361364    this->fDocumentObjectPtr = &(parser->fDocumentObjectStream[0]);
  • icXML/icXML-devel/src/icxmlc/parsers/XMLDocumentDisseminatorImpl.hpp

    r3563 r3601  
    125125
    126126    MemoryManager *                     fMemoryManager;
     127    #ifdef DEBUG_MESSAGE
     128    XMLParser *                         fParser;
     129    #endif
    127130};
    128131
     
    131134reset(XMLParser * parser, XSModel * model, const XMLCh * rootElemName)
    132135{
     136    #ifdef DEBUG_MESSAGE
     137    fParser = parser;
     138    #endif
     139
    133140    fDocumentContextPtr = &(parser->fDocumentContextStream[0]);
    134141    fDocumentObjectPtr = &(parser->fDocumentObjectStream[0]);
  • icXML/icXML-devel/src/icxmlc/parsers/XMLNamespaceParser.hpp

    r3563 r3601  
    7171
    7272        fContainsXsiTypeOrNil = false;
    73         fNamespaceResolver.setMaxScope(parser.fMaxScope);
     73        fNamespaceResolver.setMaxScope(parser.fMaxScope + 1);
    7474    }
    7575
     
    525525
    526526    // record the localPartId for this attribute and its value
     527    assert (index < fLocalPartIds.capacity());
    527528    fLocalPartIds[index] = attribute.getLocalPartId();
    528529
  • icXML/icXML-devel/src/icxmlc/parsers/XSDDOMDocumentDisseminatorImpl.c

    r3560 r3601  
    139139void XSDDOMDocumentDisseminatorImpl::reset(XMLParser * parser, XSModel *, const XMLCh *)
    140140{
     141    #ifdef DEBUG_MESSAGE
     142    this->fParser = parser;
     143    #endif
    141144    this->fDocumentContextPtr = &(parser->fDocumentContextStream[0]);
    142145    this->fDocumentObjectPtr = &(parser->fDocumentObjectStream[0]);
  • icXML/icXML-devel/src/icxmlc/stringpool.h

    r3563 r3601  
    131131insert(const Char * string, const size_t length)
    132132{
    133     Char * retVal = allocate(length + NullTerminated);
     133    Char * retVal = allocate(NullTerminated ? (length + 1) : length);
    134134    Array<Char>::move(string, retVal, length);
    135135    if (NullTerminated)
     
    168168    const size_t additionalCapacity = max(minimumSize * 2, fMinAdditionalCapacity);
    169169
    170 
    171     DEBUG_MESSAGE("additionalCapacity=" << additionalCapacity)
    172 
    173170    MemoryNode * node = (MemoryNode *)
    174171    #ifdef USE_MEMORY_MANAGER_ALLOCATION
Note: See TracChangeset for help on using the changeset viewer.