WIP: add a Val struct as an input/output when calling a function
This commit is contained in:
@@ -2059,12 +2059,15 @@ bool Generator::EvaluateFunctions(pt::Stream & out_stream, ValWrapper & valwrapp
|
||||
{
|
||||
valwrapper.has_evaluated_val = true;
|
||||
|
||||
if( valwrapper.evaluated_val.is_allowed_to_cache() )
|
||||
{
|
||||
if( out_stream.size() != current_size )
|
||||
{
|
||||
valwrapper.evaluated_str = out_stream.new_empty();
|
||||
copy_stream(out_stream, current_size, out_stream.size(), *valwrapper.evaluated_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
valwrapper.evaluated_val.clear();
|
||||
@@ -2124,13 +2127,16 @@ bool Generator::FindLastModelWrapper(FindHelper & find_helper, bool is_for_alias
|
||||
ValWrapper valwrapper;
|
||||
valwrapper.val = model->get_ezc_val(nullptr, field.c_str()); // may it would be better to provide a pointer to get_ezc_val() method?
|
||||
|
||||
if( valwrapper.val.has_function() || valwrapper.val.has_method() )
|
||||
{
|
||||
if( (find_helper.field_index + 1 < find_helper.fields.size()) || !is_for_alias )
|
||||
{
|
||||
bool use_parameters = (find_helper.field_index + 1 == find_helper.fields.size());
|
||||
|
||||
if( EvaluateFunctions(find_helper, use_parameters, valwrapper) )
|
||||
if( !EvaluateFunctions(find_helper, use_parameters, valwrapper) )
|
||||
{
|
||||
child_valwrapper = find_helper.valwrapper->add_child(field, valwrapper);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
18
src/val.cpp
18
src/val.cpp
@@ -105,6 +105,7 @@ void Val::copy(const Val & val)
|
||||
// space = val.space;
|
||||
|
||||
output_stream = val.output_stream;
|
||||
allow_to_cache_value = val.allow_to_cache_value;
|
||||
|
||||
increment_model_container_wrapper_ref();
|
||||
increment_space_wrapper_ref();
|
||||
@@ -160,6 +161,7 @@ void Val::initialize_empty()
|
||||
model_method4 = nullptr;
|
||||
space_wrapper = nullptr;
|
||||
space_table_index = 0;
|
||||
allow_to_cache_value = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -496,6 +498,7 @@ void Val::set_pointer_to(morm::ModelContainerWrapper * model_container_wrapper)
|
||||
clear();
|
||||
type = TYPE_MODEL_CONTAINER_WRAPPER;
|
||||
this->pointer = model_container_wrapper;
|
||||
this->allow_to_cache_value = true;
|
||||
model_container_wrapper->increment_reference_counter();
|
||||
}
|
||||
|
||||
@@ -507,6 +510,7 @@ void Val::set_pointer_to(morm::SpaceWrapper * space_wrapper)
|
||||
this->pointer = space_wrapper->get_space();
|
||||
this->space_wrapper = space_wrapper;
|
||||
this->space_wrapper->increment_reference_counter();
|
||||
this->allow_to_cache_value = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -518,7 +522,8 @@ void Val::set_pointer_to(pt::Space * space, bool create_wrapper)
|
||||
|
||||
if( create_wrapper )
|
||||
{
|
||||
space_wrapper = new morm::SpaceWrapper(space);
|
||||
this->space_wrapper = new morm::SpaceWrapper(space);
|
||||
this->allow_to_cache_value = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1344,6 +1349,17 @@ void Val::put_pod_type_to_stream()
|
||||
}
|
||||
|
||||
|
||||
void Val::allow_to_cache(bool allow_to_cache)
|
||||
{
|
||||
this->allow_to_cache_value = allow_to_cache;
|
||||
}
|
||||
|
||||
|
||||
bool Val::is_allowed_to_cache()
|
||||
{
|
||||
return this->allow_to_cache_value;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Ezc
|
||||
|
||||
|
12
src/val.h
12
src/val.h
@@ -237,8 +237,14 @@ public:
|
||||
|
||||
Val & operator=(bool res);
|
||||
|
||||
|
||||
void put_pod_type_to_stream();
|
||||
|
||||
|
||||
void allow_to_cache(bool allow_to_cache);
|
||||
bool is_allowed_to_cache();
|
||||
|
||||
|
||||
Type type;
|
||||
pt::Space space_local;
|
||||
void * pointer;
|
||||
@@ -255,6 +261,8 @@ public:
|
||||
morm::SpaceWrapper * space_wrapper;
|
||||
size_t space_table_index;
|
||||
|
||||
bool allow_to_cache_value;
|
||||
|
||||
// UserFunction user_function;
|
||||
|
||||
// // Wrapper
|
||||
@@ -340,6 +348,7 @@ void Val::set_pointer_to(std::vector<ModelType> * model_container)
|
||||
clear();
|
||||
type = TYPE_MODEL_CONTAINER_WRAPPER;
|
||||
this->pointer = new morm::ModelWrapperVector<ModelType>(model_container);
|
||||
this->allow_to_cache_value = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -349,6 +358,7 @@ void Val::set_pointer_to(std::list<ModelType> * model_container)
|
||||
clear();
|
||||
type = TYPE_MODEL_CONTAINER_WRAPPER;
|
||||
this->pointer = new morm::ModelWrapperList<ModelType>(model_container);
|
||||
this->allow_to_cache_value = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -358,6 +368,7 @@ void Val::set_pointer_to(std::vector<ModelType*> * model_container)
|
||||
clear();
|
||||
type = TYPE_MODEL_CONTAINER_WRAPPER;
|
||||
this->pointer = new morm::ModelWrapperVectorPointer<ModelType>(model_container);
|
||||
this->allow_to_cache_value = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -367,6 +378,7 @@ void Val::set_pointer_to(std::list<ModelType*> * model_container)
|
||||
clear();
|
||||
type = TYPE_MODEL_CONTAINER_WRAPPER;
|
||||
this->pointer = new morm::ModelWrapperListPointer<ModelType>(model_container);
|
||||
this->allow_to_cache_value = true;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user