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

@@ -44,6 +44,7 @@ Patterns::Patterns()
{
del_white_items = false;
ezc_fun = 0;
ezc_blocks = 0;
locale = 0;
locale_filter = 0;
}
@@ -84,6 +85,18 @@ void Patterns::SetEzcFunctions(TemplatesFunctions::EzcFun * fun)
}
void Patterns::SetEzcBlocks(Ezc::Blocks * blocks)
{
ezc_blocks = blocks;
}
void Patterns::SetEzcCommentary(const std::wstring & start, const std::wstring & end)
{
pattern_parser.SetCommentary(start, end);
}
size_t Patterns::Add(const wchar_t * file_name, bool read_pattern)
{
for(size_t i=0 ; i<pat_tab.size() ; ++i)
@@ -121,30 +134,44 @@ void Patterns::ReadPatterns(Template & templ)
templ.patterns.resize(len);
/*
* CHECK ME
* make sure everything else is set correctly from pattern_parser
* (default values)
* pattern_parser.SetCommentary() is set beforehand
*/
pattern_parser.DeleteWhiteTextItems(del_white_items);
pattern_parser.Directory(templates_dir, templates_dir_def);
if( ezc_blocks )
pattern_parser.SetBlocks(*ezc_blocks);
for(size_t i=0 ; i<len ; ++i)
{
pattern_parser.ParseFile(templ.file_name, templ.patterns[i]);
if( ezc_fun )
templ.patterns[i].CacheFunctions(*ezc_fun);
/*
* IMPROVE ME
* add caching blocks
*/
locale_filter->Filter(templ.patterns[i], *locale, i);
}
}
// caching should be done after all patterns are read
// because patterns can define blocks
void Patterns::RebuildCache()
{
for(size_t a = 0 ; a < pat_tab.size() ; ++a)
{
for(size_t b = 0 ; b < pat_tab[a].patterns.size() ; ++b)
{
Ezc::Pattern & pat = pat_tab[a].patterns[b];
pat.ClearCache();
if( ezc_fun )
pat.CacheFunctions(*ezc_fun);
if( ezc_blocks )
pat.CacheBlocks(*ezc_blocks);
}
}
}
Ezc::Pattern * Patterns::Get(size_t index, size_t lang_id)
{
@@ -174,6 +201,8 @@ void Patterns::Reload()
for(size_t i=0 ; i<pat_tab.size() ; ++i)
if( pat_tab[i].references > 0 )
ReadPatterns(pat_tab[i]);
RebuildCache();
}