diff --git a/src/generator.h b/src/generator.h index 554cd47..c9755e0 100644 --- a/src/generator.h +++ b/src/generator.h @@ -1419,10 +1419,14 @@ bool Generator::CallDate( template void Generator::CallSpaceObjectForLastField(std::vector & parameters, StreamType & out_stream, pt::Space * space) { - if( !IsTestingFunctionExistence() ) + if( IsTestingFunctionExistence() ) + { + last_res = true; + } + else { - // CHECKME should we convert the last value to last_res? DumpSpaceIfNeeded(parameters, out_stream, space); + last_res = space->object_size() > 0; } } @@ -1460,8 +1464,14 @@ void Generator::CallSpace else { // we are not in [for..], it can be for example [if...], return true if the table is not empty - // if we are in [if-def...] - then last_res is set later in MakeTextIfDef(Item & item) when Call() method returns - last_res = !table->empty(); + if( IsTestingFunctionExistence() ) + { + last_res = true; + } + else + { + last_res = !table->empty(); + } } if( !IsTestingFunctionExistence() ) @@ -1593,9 +1603,14 @@ bool Generator::CallSpace { if( is_last_field ) { - if( !IsTestingFunctionExistence() ) + if( IsTestingFunctionExistence() ) + { + last_res = true; + } + else { PrintLastSpaceField(space, parameters, out_stream); + last_res = space->to_bool(); } field_index += 1; @@ -1666,6 +1681,8 @@ bool Generator::CallModel if( find_helper.field_index == fields.size() ) { // all fields items are models or models containers + // at the moment we do not set last_res + // we don't know whether the last object has properties (fields) or not if( !IsTestingFunctionExistence() ) { DumpModelIfNeeded(model, parameters, out_stream);