diff --git a/src/generator.h b/src/generator.h index 115ec17..ac01ec0 100644 --- a/src/generator.h +++ b/src/generator.h @@ -1445,7 +1445,6 @@ bool Generator::CallSpace { pt::Space * space = space_wrapper.get_space(); size_t model_wrapper_space_table_index = 0; - //space_wrapper.set_last_for_loop_status(false); while( find_helper.is_next_field() ) { @@ -1462,7 +1461,6 @@ bool Generator::CallSpace else { // may this is a global function so return true - //find_helper.found = false; // set find_helper.found here? return true; } } @@ -1480,6 +1478,7 @@ bool Generator::CallSpace if( space->table_size() > 0 ) { find_helper.result->set(*space->value.value_table.front(), false); + find_helper.found = true; return true; } else @@ -1496,6 +1495,7 @@ bool Generator::CallSpace if( space->table_size() > 0 ) { find_helper.result->set(*space->value.value_table.back(), false); + find_helper.found = true; return true; } else @@ -1513,6 +1513,7 @@ bool Generator::CallSpace // a [for ...] was not used beforehand // return true, this can be a global method such as 'size' find_helper.result->set(*space, false); + find_helper.found = true; return true; } @@ -1528,8 +1529,8 @@ bool Generator::CallSpace find_helper.field_index += 1; size_t iterator_value = space_wrapper.get_space_iterator_value(model_wrapper_space_table_index); find_helper.result->set(static_cast(iterator_value)); + find_helper.found = true; return true; - break; } else if( next_field == L"index-one" ) @@ -1537,8 +1538,8 @@ bool Generator::CallSpace find_helper.field_index += 1; size_t iterator_value = space_wrapper.get_space_iterator_value(model_wrapper_space_table_index); find_helper.result->set(static_cast(iterator_value + 1)); + find_helper.found = true; return true; - break; } else if( next_field == L"is_first" ) @@ -1546,8 +1547,8 @@ bool Generator::CallSpace find_helper.field_index += 1; size_t iterator_value = space_wrapper.get_space_iterator_value(model_wrapper_space_table_index); find_helper.result->set(iterator_value == 0); + find_helper.found = true; return true; - break; } else if( next_field == L"is_last" ) @@ -1555,8 +1556,8 @@ bool Generator::CallSpace find_helper.field_index += 1; size_t iterator_value = space_wrapper.get_space_iterator_value(model_wrapper_space_table_index); find_helper.result->set(iterator_value + 1 == space->table_size()); + find_helper.found = true; return true; - break; } else { @@ -1580,6 +1581,8 @@ bool Generator::CallSpace model_wrapper_space_table_index += 1; } + find_helper.found = true; + if( space->is_table() ) { CallSpaceTableForLastField(space_wrapper, *space, find_helper, model_wrapper_space_table_index); @@ -1590,7 +1593,7 @@ bool Generator::CallSpace //PrintLastSpaceField(*space, find_helper); find_helper.result->set(*space, false); // WARNING here a new space wrapper will be created, need to invastigate - if( find_helper.is_last_field() ) + if( find_helper.is_last_field() ) // find_index will be incremented and the result is always false here DumpSpaceIfNeeded(*space, find_helper); } @@ -1608,8 +1611,8 @@ bool Generator::CallSpace { if( space->is_object() ) { - const std::wstring & next_field = find_helper.fields[find_helper.field_index - 1]; - pt::Space * next_space = space->get_space(next_field); + const std::wstring & current_field = find_helper.fields[find_helper.field_index - 1]; + pt::Space * next_space = space->get_space(current_field); if( next_space ) { @@ -1618,8 +1621,6 @@ bool Generator::CallSpace } else { - // may this is a global function so return true - //find_helper.found = false; // set find_helper.found here? return true; } } @@ -1637,6 +1638,8 @@ bool Generator::CallSpace } } + find_helper.found = true; + if( space->is_table() ) { // CreateMsg(L"you cannot iterate through space table when the space is added without a wrapper"); // IMPROVE the message @@ -1650,7 +1653,7 @@ bool Generator::CallSpace //PrintLastSpaceField(*space, find_helper); find_helper.result->set(*space, false); - if( find_helper.is_last_field() ) + if( find_helper.is_last_field() ) // !! find_index was incremented and here find_index is greater than fields.size(), this returns false DumpSpaceIfNeeded(*space, find_helper); } @@ -1984,7 +1987,7 @@ void Generator::FindVaria } else { - if( find_helper.is_last_field() ) + if( find_helper.is_last_field() ) // find_index was incremented and is greater than fields.size(), this returns false { find_helper.result->clear(); }