From: Leon W. <moo...@us...> - 2005-04-11 06:53:24
|
Update of /cvsroot/anyedit/AnyEditv2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32072 Modified Files: SyntaxFile.cpp SyntaxFile.h Log Message: - Added CriticalSection and a SingleLock on the Parse function, to be able to Parse the SyntaxFiles in a seperate thread - Added extra code to make sure the file is parsed in every function. Index: SyntaxFile.cpp =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/SyntaxFile.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** SyntaxFile.cpp 11 Apr 2005 06:40:10 -0000 1.25 --- SyntaxFile.cpp 11 Apr 2005 06:52:58 -0000 1.26 *************** *** 74,77 **** --- 74,81 ---- pug::xml_node xnode; + // Ok, lock the parse function. So it can be done in another thread. + // The waiting thread will return immediatly by the next statement after parsing is done. + CSingleLock sLock( &m_csCriticalSection, TRUE ); + // We also check it here, so we don't read the rest // everytime we call this function. *************** *** 132,135 **** --- 136,143 ---- { if( iSet < 0 || iSet >= KEYWORDSET_MAX ) return _T(""); + + // Make sure the file is parsed. + if( !m_bParsed && !Parse() ) return _T(""); + return KeywordDescription[iSet]; } *************** *** 143,146 **** --- 151,157 ---- if( iSet < 0 || iSet >= KEYWORDSET_MAX ) return false; + // Make sure the file is parsed. + if( !m_bParsed && !Parse() ) return false; + KeywordsSpaceDelimited[iSet].Empty(); *************** *** 197,201 **** { if( iSet < 0 || iSet >= KEYWORDSET_MAX ) return _T(""); ! else return KeywordsSpaceDelimited[iSet]; } --- 208,216 ---- { if( iSet < 0 || iSet >= KEYWORDSET_MAX ) return _T(""); ! ! // Make sure the file is parsed. ! if( !m_bParsed && !Parse() ) return _T(""); ! ! return KeywordsSpaceDelimited[iSet]; } *************** *** 206,212 **** CString szDelimited; ! if( iSet < 0 || iSet >= KEYWORDSET_MAX ) return ""; ! if( 0 == Keywords[iSet].GetSize() ) return ""; for( iCount = 0; iCount < Keywords[iSet].GetSize(); ++ iCount ) --- 221,230 ---- CString szDelimited; ! if( iSet < 0 || iSet >= KEYWORDSET_MAX ) return _T(""); ! // Make sure the file is parsed. ! if( !m_bParsed && !Parse() ) return _T(""); ! ! if( 0 == Keywords[iSet].GetSize() ) return _T(""); for( iCount = 0; iCount < Keywords[iSet].GetSize(); ++ iCount ) *************** *** 232,235 **** --- 250,256 ---- CSortedArray<CString, CString> AllKeywords; + // Make sure the file is parsed. + if( !m_bParsed && !Parse() ) return _T(""); + AllKeywords.SetCompareFunction( CompareCString ); *************** *** 263,270 **** pug::xml_node xnode; xnode = m_xml_parser.document().first_element_by_name( TAG_LEXER ); ! if( xnode.empty() ) return -1; xnode = xnode.first_element_by_name( TAG_LEXER_NAME ); ! if( xnode.empty() && !xnode.children() ) return -1; name = xnode.child(0).value(); --- 284,294 ---- pug::xml_node xnode; + // Make sure the file is parsed. + if( !m_bParsed && !Parse() ) return SCLEX_NULL; + xnode = m_xml_parser.document().first_element_by_name( TAG_LEXER ); ! if( xnode.empty() ) return SCLEX_NULL; xnode = xnode.first_element_by_name( TAG_LEXER_NAME ); ! if( xnode.empty() && !xnode.children() ) return SCLEX_NULL; name = xnode.child(0).value(); *************** *** 337,341 **** for( i = 0; i < name.GetLength(); ++ i ) { ! if( !isdigit( name[i] ) ) return -1; } --- 361,365 ---- for( i = 0; i < name.GetLength(); ++ i ) { ! if( !isdigit( name[i] ) ) return SCLEX_NULL; } *************** *** 352,355 **** --- 376,382 ---- pug::xml_node xnode; + // Make sure the file is parsed. + if( !m_bParsed && !Parse() ) return 0; + xnode = m_xml_parser.document().first_element_by_name( TAG_LEXER ); if( xnode.empty() ) return 0; Index: SyntaxFile.h =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/SyntaxFile.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** SyntaxFile.h 11 Apr 2005 06:40:10 -0000 1.17 --- SyntaxFile.h 11 Apr 2005 06:52:58 -0000 1.18 *************** *** 145,148 **** --- 145,151 ---- { protected: + /// Critical Section object to be able to Parse the file Thread-Safe. + CCriticalSection m_csCriticalSection; + /// Keep track of the max defined style. int iMaxStyle; |