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