From abd1500f0743604adc6358f5b09a45665b818664 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Wed, 23 Mar 2016 15:20:42 +0000 Subject: [PATCH] changed: some refactoring in miscspace git-svn-id: svn://ttmath.org/publicrep/winix/trunk@1036 e52654a7-88a9-db11-a3e9-0013d4bc506e --- winixd/templates/miscspace.cpp | 59 ++++++++++++++++++++++++++++++++-- winixd/templates/miscspace.h | 4 +++ 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/winixd/templates/miscspace.cpp b/winixd/templates/miscspace.cpp index f169e24..48ee3d6 100644 --- a/winixd/templates/miscspace.cpp +++ b/winixd/templates/miscspace.cpp @@ -318,6 +318,7 @@ void spaces_tab_init(std::vector & 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 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(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(stack->fun_data); + + if( stack_item && stack->iter < stack_item->values.size() ) + i.out << stack_item->values[stack->iter]; + } +} + + + + + } // namespace TemplatesFunctions } // namespace Winix diff --git a/winixd/templates/miscspace.h b/winixd/templates/miscspace.h index 0c57094..53e7d80 100644 --- a/winixd/templates/miscspace.h +++ b/winixd/templates/miscspace.h @@ -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)