added: two options to the config:

ezc_error_prefix (string)
        ezc_error_postfix (string)
        // prefix and postfix used when there is an error in Ezc patterns
        // default:
        // prefix:  "<!-- "
        // postfix: " -->"
added:  Ezc::Blocks to templates
added:  although patterns have pointers to functions and blocks cached
        the Ezc::Generator should use SetFunctions() and SetBlocks() method
        in order to correctly recognize variables (aliases)




git-svn-id: svn://ttmath.org/publicrep/winix/trunk@978 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2014-10-19 21:20:09 +00:00
parent 5266a7e4e5
commit fb18b2238e
27 changed files with 1105 additions and 949 deletions

View File

@@ -42,7 +42,8 @@ PatternCacher::PatternCacher()
{
when_delete_patterns = 13;
how_many_delete = 3;
ezc_fun = 0;
ezc_fun = 0;
ezc_blocks = 0;
}
@@ -52,6 +53,16 @@ void PatternCacher::SetEzcFunctions(TemplatesFunctions::EzcFun * fun)
}
void PatternCacher::SetEzcBlocks(Ezc::Blocks * blocks)
{
ezc_blocks = blocks;
}
void PatternCacher::SetEzcCommentary(const std::wstring & start, const std::wstring & end)
{
pattern_parser.SetCommentary(start, end);
}
void PatternCacher::SetWhenDelete(size_t when_delete, size_t how_many_del)
{
when_delete_patterns = when_delete;
@@ -97,30 +108,30 @@ void PatternCacher::DeleteOldPatterns()
void PatternCacher::CreatePattern(const Item & item, Ezc::Pattern & pattern)
{
/*
* CHECK ME
* check the rest flags from pattern_parser
* if the default values are correct
* we do not set pattern_parser.SetBlocks()
* blocks cannot be created in patterns generated from virtual FS
* but we can call other blocks (from normal templates)
*
* IMPROVE ME
* we can add blocks and variables
*
* add caching of blocks
* pattern_parser.SetCommentary() is set beforehand
*/
pattern_parser.AllowInclude(false);
pattern_parser.DeleteWhiteTextItems(false);
pattern_parser.ParseString(item.content, pattern);
if( ezc_fun )
pattern.CacheFunctions(*ezc_fun);
RebuildCache(pattern);
}
Ezc::Pattern * PatternCacher::AddPattern(const Item & item)
{
// don't call DeleteOldPatterns() here
// because you can delete a pattern which is in use
// (think about ezc functions: item run, insert_page etc)
// ezc functions such as: item_run, insert_page etc
// are using GetPattern() method which can call this method
PatternUsed pu;
@@ -196,6 +207,23 @@ size_t PatternCacher::Size()
}
void PatternCacher::RebuildCache(Ezc::Pattern & pattern)
{
pattern.ClearCache();
if( ezc_fun )
pattern.CacheFunctions(*ezc_fun);
if( ezc_blocks )
pattern.CacheBlocks(*ezc_blocks);
}
void PatternCacher::RebuildCache()
{
for(size_t i=0 ; i<pattern_tab.size() ; ++i)
RebuildCache(pattern_tab[i].pattern);
}
} // namespace Winix