changed: some refactoring in miscspace

git-svn-id: svn://ttmath.org/publicrep/winix/trunk@1036 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2016-03-23 15:20:42 +00:00
parent 42144bb31c
commit abd1500f07
2 changed files with 60 additions and 3 deletions

View File

@ -318,6 +318,7 @@ void spaces_tab_init(std::vector<Ezc::Var> & params, PT::Space & space, SpacesTa
else
{
// there is not such a space
// space_list_tab() will return false immediately
spaces_tab_info.cur_stack = spaces_tab_info.stack_tab.size();
}
}
@ -337,8 +338,6 @@ void space_list_tab(Info & i, PT::Space & space)
{
SpaceStackItem & stack_item = spaces_tab_info.stack_tab[spaces_tab_info.cur_stack];
// !! CHECK ME there was a change in EZC lately
// make sure this still is ok
// i.iter is different for each [for] statement (implemented in EZC)
// so we don't have to remember it in our stack
// for each the same space we have only one item in the stack, e.g.
@ -360,7 +359,9 @@ void spaces_tab_value_print(HtmlTextStream & out, SpacesTabInfo & spaces_tab_inf
if( spaces_tab_info.cur_stack < spaces_tab_info.stack_tab.size() )
{
SpaceStackItem & stack_item = spaces_tab_info.stack_tab[spaces_tab_info.cur_stack];
out << stack_item.values[stack_item.value_index];
if( stack_item.value_index < stack_item.values.size() )
out << stack_item.values[stack_item.value_index];
}
}
@ -422,6 +423,58 @@ void space_list_tab_has_next(Info & i, PT::Space & space)
struct Space2StackItem : public Ezc::FunData
{
std::vector<std::wstring> values;
};
void space2_list_tab(Info & i, PT::Space & space)
{
if( !i.stack.fun_data )
{
if( !i.params.empty() )
{
i.stack.for_name = new std::wstring(L"space_list_tab");
Space2StackItem * stack_item = new Space2StackItem();
i.stack.fun_data = stack_item;
PT::Space * dst_space = find_space(i.params, space);
if( dst_space )
dst_space->ListText(i.params.back().str, stack_item->values);
i.res = i.iter < stack_item->values.size();
}
}
else
{
auto stack_item = reinterpret_cast<Space2StackItem*>(i.stack.fun_data);
i.res = i.iter < stack_item->values.size();
}
}
void space2_list_tab_value(Info & i, PT::Space & space)
{
Ezc::Stack * stack = i.FindLastFor(i.par, L"space_list_tab");
if( stack && stack->fun_data )
{
auto stack_item = dynamic_cast<Space2StackItem*>(stack->fun_data);
if( stack_item && stack->iter < stack_item->values.size() )
i.out << stack_item->values[stack->iter];
}
}
} // namespace TemplatesFunctions
} // namespace Winix

View File

@ -77,6 +77,10 @@ void space_list_tab_value(Info & i, PT::Space & space);
void space_list_tab_has_next(Info & i, PT::Space & space);
void space2_list_tab(Info & i, PT::Space & space);
void space2_list_tab_value(Info & i, PT::Space & space);
// !! IMPROVE ME
// !! add space_tab (iteration through spaces)