textrendering/texthandling/stext/ParseLst.cpp
changeset 40 91ef7621b7fc
parent 0 1fb32624e06b
child 55 336bee5c2d35
equal deleted inserted replaced
21:f2f7b3284356 40:91ef7621b7fc
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include "TXTSTD.H"
    19 #include "TXTSTD.H"
    20 #include "ParseLst.h"
    20 #include "ParseLst.h"
       
    21 #include "OstTraceDefinitions.h"
       
    22 #ifdef OST_TRACE_COMPILER_IN_USE
       
    23 #include "ParseLstTraces.h"
       
    24 #endif
       
    25 
       
    26 
       
    27 
    21 //++ sort out definitive hash includes
    28 //++ sort out definitive hash includes
    22 
    29 
    23 
    30 
    24 CParserList::CParserItem::CParserItem(MParser* aParser, const TUint aTagIndex)
    31 CParserList::CParserItem::CParserItem(MParser* aParser, const TUint aTagIndex)
    25 : iParser(aParser),
    32 : iParser(aParser),
    29 
    36 
    30 
    37 
    31 // Panic the process with UikParse as the category.
    38 // Panic the process with UikParse as the category.
    32 void CParserList::Panic(TParserListPanic aPanic) const
    39 void CParserList::Panic(TParserListPanic aPanic) const
    33 	{
    40 	{
       
    41 	OstTraceExt2( TRACE_FATAL, DUP1_CPARSERLIST_PANIC, "CParserList::Panic;this=%x;aPanic=%x", (unsigned int)this, ( TUint )&( aPanic ) );
    34 	_LIT(panicStr, "ParseLst");
    42 	_LIT(panicStr, "ParseLst");
    35 	User::Panic(panicStr, aPanic);
    43 	User::Panic(panicStr, aPanic);
    36 	}
    44 	}
    37 
    45 
    38 
    46 
    57 	// Check the index isn't rolling over
    65 	// Check the index isn't rolling over
    58 	// N.B. This is somewhat unlikely. Since index is effectively a 29-bit
    66 	// N.B. This is somewhat unlikely. Since index is effectively a 29-bit
    59 	// uint (I'm using the top 3 bits as flags) this allows 268435456 parsers
    67 	// uint (I'm using the top 3 bits as flags) this allows 268435456 parsers
    60 	// to be installed. (Assuming we deinstall almost as many, as we went
    68 	// to be installed. (Assuming we deinstall almost as many, as we went
    61 	// along, to avoid OOM.) At 50 per sec that's 20 years continuous action!
    69 	// along, to avoid OOM.) At 50 per sec that's 20 years continuous action!
       
    70 	if (iHighestIndex >= EMaxParserIndex)
       
    71 	    {
       
    72 	    OstTrace0( TRACE_DUMP, CPARSERLIST_ACTIVATEAPARSERL, "EParserIndexRollover" );
       
    73 	    }
    62 	__ASSERT_DEBUG((iHighestIndex < EMaxParserIndex), Panic(EParserIndexRollover));
    74 	__ASSERT_DEBUG((iHighestIndex < EMaxParserIndex), Panic(EParserIndexRollover));
       
    75 	if (!aParser)
       
    76 	    {
       
    77 	    OstTrace0( TRACE_DUMP, DUP1_CPARSERLIST_ACTIVATEAPARSERL, "EParserNullPtr" );
       
    78 	    }
    63 	__ASSERT_DEBUG(aParser, Panic(EParserNullPtr));
    79 	__ASSERT_DEBUG(aParser, Panic(EParserNullPtr));
    64 	TUint parserIndex = iHighestIndex + 1;
    80 	TUint parserIndex = iHighestIndex + 1;
    65 	// Adjust flags to describe parser
    81 	// Adjust flags to describe parser
    66 	if (aParser->ReformatOnRecognise())
    82 	if (aParser->ReformatOnRecognise())
    67 		parserIndex |= static_cast<TUint>( EReformatOnRecogniseFlag );
    83 		parserIndex |= static_cast<TUint>( EReformatOnRecogniseFlag );
   110 // N.B. We can't just delete CParserList and zero TLS when we get back
   126 // N.B. We can't just delete CParserList and zero TLS when we get back
   111 // to a list with no specific or default parsers because there could be
   127 // to a list with no specific or default parsers because there could be
   112 // an EText left with a local ptr to it.
   128 // an EText left with a local ptr to it.
   113 void CParserList::DeactivateParser(MParser* aParser)
   129 void CParserList::DeactivateParser(MParser* aParser)
   114 	{
   130 	{
       
   131 	if (!iNumberInList)
       
   132 	    {
       
   133 	    OstTrace0( TRACE_DUMP, CPARSERLIST_DEACTIVATEPARSER, "EParserNoneActive" );
       
   134 	    }
   115 	__ASSERT_DEBUG(iNumberInList, Panic(EParserNoneActive));
   135 	__ASSERT_DEBUG(iNumberInList, Panic(EParserNoneActive));
       
   136 	if (!aParser)
       
   137 	    {
       
   138 	    OstTrace0( TRACE_DUMP, DUP1_CPARSERLIST_DEACTIVATEPARSER, "EParserNullPtr" );
       
   139 	    }
   116 	__ASSERT_DEBUG(aParser, Panic(EParserNullPtr));
   140 	__ASSERT_DEBUG(aParser, Panic(EParserNullPtr));
   117 	// Run thru list till find entry we need
   141 	// Run thru list till find entry we need
   118 	TInt count;
   142 	TInt count;
   119 	for (count = 0; count < iNumberInList; count++)
   143 	for (count = 0; count < iNumberInList; count++)
   120 		{
   144 		{
   123 			delete iParserList[count];
   147 			delete iParserList[count];
   124 			iParserList.Remove(count);
   148 			iParserList.Remove(count);
   125 			break;
   149 			break;
   126 			}
   150 			}
   127 		}
   151 		}
       
   152 	if (count >= iNumberInList)
       
   153 	    {
       
   154 	    OstTrace0( TRACE_DUMP, DUP2_CPARSERLIST_DEACTIVATEPARSER, "EParserInstanceNotActive" );
       
   155 	     }
   128 	__ASSERT_DEBUG((count < iNumberInList), Panic(EParserInstanceNotActive));
   156 	__ASSERT_DEBUG((count < iNumberInList), Panic(EParserInstanceNotActive));
   129 	iNumberInList--;
   157 	iNumberInList--;
   130 	}
   158 	}
   131 
   159 
   132 
   160 
   272 				TInt localStartTag = aTextObj.DocumentLength();
   300 				TInt localStartTag = aTextObj.DocumentLength();
   273 				TInt localTagLength = 0;
   301 				TInt localTagLength = 0;
   274 				TInt result = parser->ParseThisText(aTextObj, allowBack, localStartScan, localScanLength, localStartTag, localTagLength);
   302 				TInt result = parser->ParseThisText(aTextObj, allowBack, localStartScan, localScanLength, localStartTag, localTagLength);
   275 				if (!result)
   303 				if (!result)
   276 					break;
   304 					break;
       
   305 				if (!allowBack && (localStartTag < localStartScan))
       
   306 				    {
       
   307 				    OstTrace0( TRACE_DUMP, CPARSERLIST_PARSETHISTEXT, "EParserIgnoringAllowFlag" );
       
   308 				    }
   277 				__ASSERT_DEBUG(allowBack || (localStartTag >= localStartScan), Panic(EParserIgnoringAllowFlag));
   309 				__ASSERT_DEBUG(allowBack || (localStartTag >= localStartScan), Panic(EParserIgnoringAllowFlag));
   278 				TInt startNewTag = localStartTag;
   310 				TInt startNewTag = localStartTag;
   279 				TInt lengthNewTag = localTagLength;
   311 				TInt lengthNewTag = localTagLength;
   280 				aTextObj.GetExtendedCharFormat(format, varies, localStartTag, localTagLength);
   312 				aTextObj.GetExtendedCharFormat(format, varies, localStartTag, localTagLength);
   281 				if (format.iParserTag || varies.AttribIsSet(EAttParserTag))
   313 				if (format.iParserTag || varies.AttribIsSet(EAttParserTag))
   422 			{
   454 			{
   423 			tagIndex = iParserList[count]->TagIndex();
   455 			tagIndex = iParserList[count]->TagIndex();
   424 			break;
   456 			break;
   425 			}
   457 			}
   426 		}
   458 		}
       
   459 	if (!tagIndex)
       
   460 	    {
       
   461 	    OstTrace0( TRACE_DUMP, CPARSERLIST_TAGFORTHISPARSER, "EParserNoSuchTag" );
       
   462 	    }
   427 	__ASSERT_DEBUG(tagIndex, Panic(EParserNoSuchTag));
   463 	__ASSERT_DEBUG(tagIndex, Panic(EParserNoSuchTag));
   428 	return tagIndex;
   464 	return tagIndex;
   429 	}
   465 	}
   430 
   466 
   431 
   467