WIP: add a Val struct as an input/output when calling a function

This commit is contained in:
2025-01-23 07:12:57 +01:00
parent 8819adbb3f
commit 37f78ad8e0
13 changed files with 161 additions and 156 deletions

View File

@@ -94,13 +94,13 @@ void Blocks::CacheObjects(Objects & obj)
} }
void Blocks::CacheFunctions(Functions & fun) // void Blocks::CacheFunctions(Functions & fun)
{ // {
BlocksTable::iterator i = blocks_tab.begin(); // BlocksTable::iterator i = blocks_tab.begin();
for( ; i != blocks_tab.end() ; ++i) // for( ; i != blocks_tab.end() ; ++i)
Cache(fun, i->second); // Cache(fun, i->second);
} // }
void Blocks::CacheBlocks(Blocks & blocks) void Blocks::CacheBlocks(Blocks & blocks)

View File

@@ -63,7 +63,7 @@ public:
void Clear(); void Clear();
void CacheObjects(Objects & obj); void CacheObjects(Objects & obj);
void CacheFunctions(Functions & fun); //void CacheFunctions(Functions & fun);
void CacheBlocks(Blocks & blocks); void CacheBlocks(Blocks & blocks);
void ClearCache(); void ClearCache();

View File

@@ -58,30 +58,30 @@ void Cache(Blocks & blocks, Item::Function & function)
} }
void Cache(Functions & fun, Item::Function & function) // void Cache(Functions & fun, Item::Function & function)
{ // {
function.fun_cache = 0; // function.fun_cache = 0;
if( !function.name.empty() && function.arg < 0 ) // if( !function.name.empty() && function.arg < 0 )
{ // {
typename Functions::Iterator i = fun.Find(function.name); // typename Functions::Iterator i = fun.Find(function.name);
if( i != fun.End() ) // if( i != fun.End() )
function.fun_cache = &i->second; // function.fun_cache = &i->second;
} // }
for(size_t i=0 ; i < function.parameters.size() ; ++i) // for(size_t i=0 ; i < function.parameters.size() ; ++i)
Cache(fun, *function.parameters[i]); // Cache(fun, *function.parameters[i]);
} // }
void Cache(Functions & fun, Item & item) // void Cache(Functions & fun, Item & item)
{ // {
Cache(fun, item.function); // Cache(fun, item.function);
for(size_t i=0; i < item.item_tab.size() ; ++i) // for(size_t i=0; i < item.item_tab.size() ; ++i)
Cache(fun, *item.item_tab[i]); // Cache(fun, *item.item_tab[i]);
} // }

View File

@@ -48,8 +48,8 @@ namespace Ezc
class Blocks; class Blocks;
void Cache(Functions & fun, Item::Function & function); // void Cache(Functions & fun, Item::Function & function);
void Cache(Functions & fun, Item & item); // void Cache(Functions & fun, Item & item);
void Cache(Blocks & blocks, Item & item); void Cache(Blocks & blocks, Item & item);
void Cache(Objects & objects, Item::Function & function); void Cache(Objects & objects, Item::Function & function);
void Cache(Objects & objects, Item & item); void Cache(Objects & objects, Item & item);

View File

@@ -38,7 +38,7 @@
namespace Ezc namespace Ezc
{ {
/*
void Functions::Insert(const char * key, UserFunction ufunction) void Functions::Insert(const char * key, UserFunction ufunction)
{ {
pt::utf8_to_wide(key, temp_key); pt::utf8_to_wide(key, temp_key);
@@ -102,7 +102,7 @@ size_t Functions::Size() const
{ {
return functions_tab.size(); return functions_tab.size();
} }
*/
} // namespace Ezc } // namespace Ezc

View File

@@ -48,6 +48,7 @@ namespace Ezc
// functions or variables // functions or variables
/*
class Functions class Functions
{ {
public: public:
@@ -75,7 +76,7 @@ private:
std::wstring temp_key; std::wstring temp_key;
}; };
*/
} // namespace Ezc } // namespace Ezc

View File

@@ -65,7 +65,7 @@ public:
void SetPattern(Pattern & pattern); void SetPattern(Pattern & pattern);
void SetBlocks(Blocks & blocks); void SetBlocks(Blocks & blocks);
void SetFunctions(Functions & functions); //void SetFunctions(Functions & functions);
void SetObjects(Objects & objects); void SetObjects(Objects & objects);
void SetVariables(Vals & variables); // [def] and [let] void SetVariables(Vals & variables); // [def] and [let]
@@ -142,14 +142,15 @@ private:
Item::Function & item_fun, Item::Function & item_fun,
const std::wstring & fun_name, const std::wstring & fun_name,
std::vector<std::wstring> & fields, std::vector<std::wstring> & fields,
Val & baseval,
std::vector<Val> & parameters, std::vector<Val> & parameters,
Val & result, Val & result,
pt::Stream & out_stream, pt::Stream & out_stream,
const pt::Stream & in_stream) : const pt::Stream & in_stream) :
item_fun(item_fun), fun_name(fun_name), fields(fields), baseval(&baseval), currentval(&baseval), item_fun(item_fun), fun_name(fun_name), fields(fields),
parameters(parameters), result(result), out_stream(out_stream), in_stream(in_stream) parameters(parameters), result(result), out_stream(out_stream), in_stream(in_stream)
{ {
currentval = nullptr;
#ifdef EZC_HAS_MORM_LIBRARY #ifdef EZC_HAS_MORM_LIBRARY
field_index = 0; field_index = 0;
#endif #endif
@@ -158,21 +159,21 @@ private:
FindHelper(const FindHelper &) = delete; FindHelper(const FindHelper &) = delete;
// RENAMEME // RENAMEME
void set_base_val(Val * val) void set_current_val(Val * val)
{ {
baseval = val; //baseval = val;
currentval = val; currentval = val;
} }
void set_base_val(Val & val) void set_current_val(Val & val)
{ {
set_base_val(&val); set_current_val(&val);
} }
Item::Function & item_fun; Item::Function & item_fun;
const std::wstring & fun_name; const std::wstring & fun_name;
std::vector<std::wstring> & fields; std::vector<std::wstring> & fields;
Val * baseval; //Val * baseval;
Val * currentval; Val * currentval;
std::vector<Val> & parameters; std::vector<Val> & parameters;
Val & result; Val & result;
@@ -248,7 +249,7 @@ private:
Pattern * ppattern; Pattern * ppattern;
Blocks * pblocks; Blocks * pblocks;
Functions * pfunctions; //Functions * pfunctions;
Objects * pobjects; Objects * pobjects;
#ifdef EZC_HAS_MORM_LIBRARY #ifdef EZC_HAS_MORM_LIBRARY
Models * pmodels; Models * pmodels;
@@ -366,8 +367,8 @@ private:
void PrepareEnvStruct(Env & env); void PrepareEnvStruct(Env & env);
void CallFunction(Functions::UserFunction & function, Env & env); void CallFunction(Val::UserFunction & function, Env & env);
void CallFunction(FindHelper & find_helper); //void CallFunction(FindHelper & find_helper);
void CallMethod(morm::Model * model, Val::ModelMethod1 method, Env & env); void CallMethod(morm::Model * model, Val::ModelMethod1 method, Env & env);
void CallMethod(morm::Model * model, Val::ModelMethod2 method, Val & res); void CallMethod(morm::Model * model, Val::ModelMethod2 method, Val & res);
@@ -399,11 +400,14 @@ private:
#ifdef EZC_HAS_MORM_LIBRARY #ifdef EZC_HAS_MORM_LIBRARY
//bool CallModelField(FindHelper & find_helper, morm::Model & model); //bool CallModelField(FindHelper & find_helper, morm::Model & model);
bool CallModel(FindHelper & find_helper, morm::Model & model); bool CallModel(FindHelper & find_helper, morm::Model & model);
bool FindLastModelWrapper(FindHelper & find_helper, bool is_for_alias);
bool CallModel(FindHelper & find_helper); bool CallModel(FindHelper & find_helper);
bool CallModelContainerWrapper(FindHelper & find_helper); bool CallModelContainerWrapper(FindHelper & find_helper);
#endif #endif
bool XXXRenameMe(FindHelper & find_helper, bool is_for_alias);
bool FindLastModelWrapper(FindHelper & find_helper, bool is_for_alias);
bool FindLastSpace(FindHelper & find_helper);
bool EvaluateFunctionOrMethod(pt::Stream & out_stream, Val & val, Val & result); bool EvaluateFunctionOrMethod(pt::Stream & out_stream, Val & val, Val & result);
void CallObject(BaseObj & base_obj, void CallObject(BaseObj & base_obj,
@@ -469,11 +473,12 @@ private:
pt::Stream * GetNewStreamForFrame(); pt::Stream * GetNewStreamForFrame();
void DecrementFramesStackIndex(); void DecrementFramesStackIndex();
bool EvaluateResultToBool(Val & result, bool is_empty_stream);
void MakeTextIf_go(Item & item, bool result); void MakeTextIf_go(Item & item, bool result);
void MakeTextIf(Item & item); void MakeTextIf(Item & item);
void MakeTextIfDef(Item & item); void MakeTextIfDef(Item & item);
void MakeTextIfNotDef(Item & item); void MakeTextIfNotDef(Item & item);
bool MakeTextForEvaluate(Item & item, Val & result); bool MakeTextForEvaluate(Item & item, Val & result, bool is_empty_stream);
void MakeTextFor(Item & item); void MakeTextFor(Item & item);
void MakeItemText(Item & item); void MakeItemText(Item & item);
void MakeTextContainer(Item & item); void MakeTextContainer(Item & item);
@@ -507,7 +512,7 @@ Generator::Generator() : empty_stream()
{ {
ppattern = nullptr; ppattern = nullptr;
pblocks = nullptr; pblocks = nullptr;
pfunctions = nullptr; //pfunctions = nullptr;
pobjects = nullptr; pobjects = nullptr;
pvals = nullptr; pvals = nullptr;
plog = nullptr; plog = nullptr;
@@ -550,7 +555,7 @@ Generator::operator=(const Generator & n)
{ {
ppattern = n.ppattern; ppattern = n.ppattern;
pblocks = n.pblocks; pblocks = n.pblocks;
pfunctions = n.pfunctions; //pfunctions = n.pfunctions;
pobjects = n.pobjects; pobjects = n.pobjects;
pvals = n.pvals; pvals = n.pvals;
plog = n.plog; plog = n.plog;
@@ -624,10 +629,10 @@ void Generator::SetBlocks(Blocks & blocks)
void Generator::SetFunctions(Functions & functions) // void Generator::SetFunctions(Functions & functions)
{ // {
pfunctions = &functions; // pfunctions = &functions;
} // }
@@ -1102,7 +1107,7 @@ bool Generator::CheckBlockArgument(FindHelper & find_helper)
if( size_t(find_helper.item_fun.arg) < block_stack.args.size() ) if( size_t(find_helper.item_fun.arg) < block_stack.args.size() )
{ {
find_helper.set_base_val(block_stack.args[find_helper.item_fun.arg]); find_helper.set_current_val(block_stack.args[find_helper.item_fun.arg]);
return true; return true;
} }
} }
@@ -1157,7 +1162,7 @@ bool Generator::FindInModels(FindHelper & find_helper)
if( val ) if( val )
{ {
find_helper.set_base_val(val); find_helper.set_current_val(val);
found = true; found = true;
} }
} }
@@ -1168,19 +1173,20 @@ bool Generator::FindInModels(FindHelper & find_helper)
#endif #endif
// IMPROVEME split me into two functions
bool Generator::FindInFunctions(FindHelper & find_helper) bool Generator::FindInFunctions(FindHelper & find_helper)
{ {
/*
if( pfunctions ) if( pfunctions )
{ {
typename Functions::Iterator i = pfunctions->Find(find_helper.fun_name); typename Functions::Iterator i = pfunctions->Find(find_helper.fun_name);
if( i != pfunctions->End() ) if( i != pfunctions->End() )
{ {
find_helper.baseval->set(i->second); find_helper.currentval->set_pointer_to(i->second);
return true; return true;
} }
} }
*/
return false; return false;
} }
@@ -1194,7 +1200,7 @@ bool Generator::FindInBlocks(FindHelper & find_helper)
if( i != pblocks->End() ) if( i != pblocks->End() )
{ {
find_helper.baseval->set_pointer_to(&i->second); find_helper.currentval->set_pointer_to(&i->second);
return true; return true;
} }
} }
@@ -1211,7 +1217,7 @@ bool Generator::FindInVariables(FindHelper & find_helper)
if( i != pvals->end() ) if( i != pvals->end() )
{ {
find_helper.set_base_val(i->second); find_helper.set_current_val(i->second);
return true; return true;
} }
} }
@@ -1284,27 +1290,27 @@ void Generator::PrepareEnvStruct(Env & env)
void Generator::CallFunction(Functions::UserFunction & function, Env & env) void Generator::CallFunction(Val::UserFunction & function, Env & env)
{ {
PrepareEnvStruct(env); PrepareEnvStruct(env);
(function)(env); (function)(env);
} }
void Generator::CallFunction(FindHelper & find_helper) // void Generator::CallFunction(FindHelper & find_helper)
{ // {
if( !IsTestingFunctionExistence() ) // if( !IsTestingFunctionExistence() )
{ // {
if( find_helper.baseval->type == Val::TYPE_FUNCTION && find_helper.baseval->pointer ) // if( find_helper.baseval->type == Val::TYPE_FUNCTION && find_helper.baseval->pointer )
{ // {
using UserFunction = void (*)(Env &); // using UserFunction = void (*)(Env &);
UserFunction user_function = reinterpret_cast<UserFunction>(find_helper.baseval->pointer); // UserFunction user_function = reinterpret_cast<UserFunction>(find_helper.baseval->pointer);
Env env(find_helper.out_stream, find_helper.parameters, find_helper.result, find_helper.in_stream, stack_tab[stack_index-1], *stack_tab[stack_index-1].item); // Env env(find_helper.out_stream, find_helper.parameters, find_helper.result, find_helper.in_stream, stack_tab[stack_index-1], *stack_tab[stack_index-1].item);
CallFunction(user_function, env); // CallFunction(user_function, env);
} // }
} // }
} // }
void Generator::CallMethod(morm::Model * model, Val::ModelMethod1 method, Env & env) void Generator::CallMethod(morm::Model * model, Val::ModelMethod1 method, Env & env)
@@ -1570,6 +1576,9 @@ pt::Space * Generator::CallSpaceObject(FindHelper & find_helper, pt::Space * spa
if( find_helper.is_last_field() ) if( find_helper.is_last_field() )
{ {
// IsTestingFunctionExistence() can be moved up (to Call() method or level up)
if( IsTestingFunctionExistence() ) if( IsTestingFunctionExistence() )
{ {
find_helper.result.set(true); find_helper.result.set(true);
@@ -2009,11 +2018,31 @@ bool Generator::EvaluateFunctionOrMethod(pt::Stream & out_stream, Val & val, Val
} }
bool Generator::XXXRenameMe(FindHelper & find_helper, bool is_for_alias)
{
if( find_helper.currentval->has_function() || find_helper.currentval->has_method() )
{
//Val res(&find_helper.out_stream);
if( EvaluateFunctionOrMethod(find_helper.out_stream, *find_helper.currentval, find_helper.result) )
{
find_helper.currentval = &find_helper.result;
//child_val = find_helper.currentval->add_child(field, find_helper.result);
}
else
{
// put some error?
return false;
}
}
}
// RENAMEME // RENAMEME
bool Generator::FindLastModelWrapper(FindHelper & find_helper, bool is_for_alias) bool Generator::FindLastModelWrapper(FindHelper & find_helper, bool is_for_alias)
{ {
find_helper.field_index = 0; find_helper.field_index = 0;
Val res(&find_helper.out_stream); //Val res(&find_helper.out_stream);
while( find_helper.field_index < find_helper.fields.size() && find_helper.currentval->has_model_object() ) while( find_helper.field_index < find_helper.fields.size() && find_helper.currentval->has_model_object() )
{ {
@@ -2042,9 +2071,9 @@ bool Generator::FindLastModelWrapper(FindHelper & find_helper, bool is_for_alias
{ {
if( (find_helper.field_index + 1 < find_helper.fields.size()) || !is_for_alias ) if( (find_helper.field_index + 1 < find_helper.fields.size()) || !is_for_alias )
{ {
if( EvaluateFunctionOrMethod(find_helper.out_stream, *find_helper.currentval, res) ) if( EvaluateFunctionOrMethod(find_helper.out_stream, *find_helper.currentval, find_helper.result) )
{ {
child_val = find_helper.currentval->add_child(field, res); child_val = find_helper.currentval->add_child(field, find_helper.result);
} }
else else
{ {
@@ -2069,9 +2098,9 @@ bool Generator::FindLastModelWrapper(FindHelper & find_helper, bool is_for_alias
{ {
if( (find_helper.field_index + 1 < find_helper.fields.size()) || !is_for_alias ) if( (find_helper.field_index + 1 < find_helper.fields.size()) || !is_for_alias )
{ {
if( EvaluateFunctionOrMethod(find_helper.out_stream, val, res) ) if( EvaluateFunctionOrMethod(find_helper.out_stream, val, find_helper.result) )
{ {
child_val = find_helper.currentval->add_child(field, res); child_val = find_helper.currentval->add_child(field, find_helper.result);
} }
else else
{ {
@@ -2106,6 +2135,18 @@ bool Generator::FindLastModelWrapper(FindHelper & find_helper, bool is_for_alias
} }
bool Generator::FindLastSpace(FindHelper & find_helper)
{
if( find_helper.currentval->type == Val::TYPE_SPACE )
{
return CallSpace(find_helper);
}
return true;
}
bool Generator::CallModel(FindHelper & find_helper) bool Generator::CallModel(FindHelper & find_helper)
{ {
morm::Model * model = reinterpret_cast<morm::Model*>(find_helper.currentval->pointer); morm::Model * model = reinterpret_cast<morm::Model*>(find_helper.currentval->pointer);
@@ -2369,14 +2410,13 @@ bool Generator::Call(Item::Function & item_fun,
pt::Stream & out_stream, pt::Stream & out_stream,
const pt::Stream & in_stream) const pt::Stream & in_stream)
{ {
Val current(&out_stream); //Val current(&out_stream);
std::vector<Val> parameters; std::vector<Val> parameters;
if( !fun_name ) if( !fun_name )
fun_name = &item_fun.name; fun_name = &item_fun.name;
FindHelper find_helper(item_fun, *fun_name, item_fun.fields, current, parameters, result, out_stream, in_stream); FindHelper find_helper(item_fun, *fun_name, item_fun.fields, parameters, result, out_stream, in_stream);
// if( clear_out_stream ) // if( clear_out_stream )
// ClearStream(out_stream); // ClearStream(out_stream);
@@ -2389,6 +2429,9 @@ bool Generator::Call(Item::Function & item_fun,
if( !FindLastModelWrapper(find_helper, false) ) if( !FindLastModelWrapper(find_helper, false) )
return false; return false;
if( !FindLastSpace(find_helper) )
return false;
EvaluateParameters(find_helper); EvaluateParameters(find_helper);
bool status = false; bool status = false;
@@ -2872,6 +2915,13 @@ void Generator::MakeTextFunction(Item & item)
} }
bool Generator::EvaluateResultToBool(Val & result, bool is_empty_stream)
{
if( result.type != Val::TYPE_VOID )
return result.to_bool();
return !is_empty_stream;
}
void Generator::MakeTextIf_go(Item & item, bool result) void Generator::MakeTextIf_go(Item & item, bool result)
@@ -2896,6 +2946,8 @@ void Generator::MakeTextIf(Item & item)
{ {
Val result(stream_temp1); Val result(stream_temp1);
is_generating_if = true; is_generating_if = true;
bool is_empty_stream = true;
stream_temp1->clear();
if( program_mode ) if( program_mode )
{ {
@@ -2905,13 +2957,15 @@ void Generator::MakeTextIf(Item & item)
else else
{ {
bool status = Call(item.function, nullptr, result, *stream_temp1, *empty_stream); bool status = Call(item.function, nullptr, result, *stream_temp1, *empty_stream);
ClearStream(*stream_temp1); is_empty_stream = stream_temp1->empty();
stream_temp1->clear();
if( !status ) if( !status )
return; return;
} }
MakeTextIf_go(item, result.to_bool()); MakeTextIf_go(item, EvaluateResultToBool(result, is_empty_stream));
stream_temp1->clear();
} }
@@ -2955,7 +3009,7 @@ void Generator::MakeTextIfNotDef(Item & item)
} }
bool Generator::MakeTextForEvaluate(Item & item, Val & result) bool Generator::MakeTextForEvaluate(Item & item, Val & result, bool is_empty_stream)
{ {
bool status = false; bool status = false;
@@ -2998,7 +3052,7 @@ bool Generator::MakeTextForEvaluate(Item & item, Val & result)
} }
else else
{ {
status = result.to_bool(); status = EvaluateResultToBool(result, is_empty_stream);
} }
return status; return status;
@@ -3023,6 +3077,12 @@ void Generator::MakeTextFor(Item & item)
// so we should set it in each iterations // so we should set it in each iterations
is_generating_for = true; is_generating_for = true;
result.clear(); result.clear();
stream_temp1->clear();
bool is_empty_stream = true;
// CHECKME
// stream_temp1 is cleared correctly in each loop?
if( program_mode ) if( program_mode )
{ {
@@ -3034,12 +3094,14 @@ void Generator::MakeTextFor(Item & item)
return; return;
} }
if( !MakeTextForEvaluate(item, result) ) if( !MakeTextForEvaluate(item, result, is_empty_stream) )
break; break;
if( !item.item_tab.empty() ) if( !item.item_tab.empty() )
MakeText( *item.item_tab[0] ); // should be only one item MakeText( *item.item_tab[0] ); // should be only one item
} }
stream_temp1->clear();
} }

View File

@@ -117,6 +117,14 @@ void Models::Add(const std::wstring & name, const std::wstring & value)
} }
void Models::Add(const std::wstring & name, Val::UserFunction ufunction)
{
Val val;
val.set_pointer_to(ufunction);
models_map[name] = val;
}
Val * Models::Find(const std::wstring & name) Val * Models::Find(const std::wstring & name)
{ {
auto iterator = models_map.find(name); auto iterator = models_map.find(name);
@@ -135,8 +143,6 @@ Models::ModelsMap & Models::GetMap()
return models_map; return models_map;
} }
} }

View File

@@ -65,6 +65,8 @@ public:
void Add(const std::wstring & name, const std::wstring & value); void Add(const std::wstring & name, const std::wstring & value);
void Add(const std::wstring & name, Val::UserFunction ufunction);
template<typename VectorType> template<typename VectorType>
void Add(const std::wstring & name, std::vector<VectorType> & container) void Add(const std::wstring & name, std::vector<VectorType> & container)
{ {

View File

@@ -63,10 +63,10 @@ void Pattern::ClearCache()
} }
void Pattern::CacheFunctions(Functions & fun) // void Pattern::CacheFunctions(Functions & fun)
{ // {
Cache(fun, item_root); // Cache(fun, item_root);
} // }
void Pattern::CacheObjects(Objects & obj) void Pattern::CacheObjects(Objects & obj)

View File

@@ -55,7 +55,7 @@ public:
void Clear(); void Clear();
void CacheFunctions(Functions & fun); //void CacheFunctions(Functions & fun);
void CacheBlocks(Blocks & blocks); void CacheBlocks(Blocks & blocks);
void CacheObjects(Objects & obj); void CacheObjects(Objects & obj);
void ClearCache(); void ClearCache();

View File

@@ -46,7 +46,6 @@ namespace Ezc
Val::Val() Val::Val()
{ {
output_stream = nullptr; output_stream = nullptr;
output_stream_original_size = 0;
initialize_empty(); initialize_empty();
} }
@@ -54,7 +53,6 @@ Val::Val()
Val::Val(pt::Stream * output_stream) Val::Val(pt::Stream * output_stream)
{ {
this->output_stream = output_stream; this->output_stream = output_stream;
this->output_stream_original_size = output_stream->size();
initialize_empty(); initialize_empty();
} }
@@ -108,7 +106,6 @@ void Val::copy(const Val & val)
// space = val.space; // space = val.space;
output_stream = val.output_stream; output_stream = val.output_stream;
output_stream_original_size = val.output_stream_original_size;
increment_model_container_wrapper_ref(); increment_model_container_wrapper_ref();
increment_space_wrapper_ref(); increment_space_wrapper_ref();
@@ -146,7 +143,6 @@ Val::~Val()
void Val::set_output_stream(pt::Stream * output_stream) void Val::set_output_stream(pt::Stream * output_stream)
{ {
this->output_stream = output_stream; this->output_stream = output_stream;
this->output_stream_original_size = (output_stream) ? output_stream->size() : 0;
} }
@@ -310,9 +306,6 @@ bool Val::to_bool() const
case TYPE_MODEL_CONTAINER_WRAPPER: case TYPE_MODEL_CONTAINER_WRAPPER:
return to_bool_model_container_wrapper(); return to_bool_model_container_wrapper();
case TYPE_OUTPUT_STREAM:
return output_stream->size() != output_stream_original_size;
} }
return false; return false;
@@ -910,11 +903,6 @@ bool Val::is_equal_string(const wchar_t * str) const
pt::Stream * stream = reinterpret_cast<pt::Stream*>(pointer); pt::Stream * stream = reinterpret_cast<pt::Stream*>(pointer);
found = is_stream_equal_string(*stream, str); found = is_stream_equal_string(*stream, str);
} }
else
if( type == Type::TYPE_OUTPUT_STREAM && output_stream )
{
found = is_stream_equal_string(*output_stream, str);
}
return found; return found;
} }
@@ -1012,7 +1000,6 @@ void Val::serialize_to(pt::Stream & str)
#ifdef EZC_HAS_MORM_LIBRARY #ifdef EZC_HAS_MORM_LIBRARY
case TYPE_MODEL_METHOD: case TYPE_MODEL_METHOD:
#endif #endif
case TYPE_OUTPUT_STREAM:
case TYPE_ITEM_BLOCK: case TYPE_ITEM_BLOCK:
break; break;
@@ -1093,20 +1080,8 @@ void Val::serialize_space_to(pt::Stream & str)
} }
void Val::assert_type_output_stream()
{
if( type != Val::TYPE_OUTPUT_STREAM )
{
clear();
type = TYPE_OUTPUT_STREAM;
}
}
Val & Val::operator<<(const char * str) Val & Val::operator<<(const char * str)
{ {
assert_type_output_stream();
if( output_stream ) if( output_stream )
{ {
*output_stream << str; *output_stream << str;
@@ -1118,8 +1093,6 @@ Val & Val::operator<<(const char * str)
Val & Val::operator<<(const wchar_t * str) Val & Val::operator<<(const wchar_t * str)
{ {
assert_type_output_stream();
if( output_stream ) if( output_stream )
{ {
*output_stream << str; *output_stream << str;
@@ -1131,8 +1104,6 @@ Val & Val::operator<<(const wchar_t * str)
Val & Val::operator<<(const std::string & str) Val & Val::operator<<(const std::string & str)
{ {
assert_type_output_stream();
if( output_stream ) if( output_stream )
{ {
*output_stream << str; *output_stream << str;
@@ -1144,8 +1115,6 @@ Val & Val::operator<<(const std::string & str)
Val & Val::operator<<(const std::wstring & str) Val & Val::operator<<(const std::wstring & str)
{ {
assert_type_output_stream();
if( output_stream ) if( output_stream )
{ {
*output_stream << str; *output_stream << str;
@@ -1157,8 +1126,6 @@ Val & Val::operator<<(const std::wstring & str)
Val & Val::operator<<(char val) Val & Val::operator<<(char val)
{ {
assert_type_output_stream();
if( output_stream ) if( output_stream )
{ {
*output_stream << val; *output_stream << val;
@@ -1170,8 +1137,6 @@ Val & Val::operator<<(char val)
Val & Val::operator<<(unsigned char val) Val & Val::operator<<(unsigned char val)
{ {
assert_type_output_stream();
if( output_stream ) if( output_stream )
{ {
*output_stream << val; *output_stream << val;
@@ -1183,8 +1148,6 @@ Val & Val::operator<<(unsigned char val)
Val & Val::operator<<(wchar_t val) Val & Val::operator<<(wchar_t val)
{ {
assert_type_output_stream();
if( output_stream ) if( output_stream )
{ {
*output_stream << val; *output_stream << val;
@@ -1196,8 +1159,6 @@ Val & Val::operator<<(wchar_t val)
Val & Val::operator<<(bool val) Val & Val::operator<<(bool val)
{ {
assert_type_output_stream();
if( output_stream ) if( output_stream )
{ {
*output_stream << val; *output_stream << val;
@@ -1209,8 +1170,6 @@ Val & Val::operator<<(bool val)
Val & Val::operator<<(short val) Val & Val::operator<<(short val)
{ {
assert_type_output_stream();
if( output_stream ) if( output_stream )
{ {
*output_stream << val; *output_stream << val;
@@ -1222,8 +1181,6 @@ Val & Val::operator<<(short val)
Val & Val::operator<<(int val) Val & Val::operator<<(int val)
{ {
assert_type_output_stream();
if( output_stream ) if( output_stream )
{ {
*output_stream << val; *output_stream << val;
@@ -1235,8 +1192,6 @@ Val & Val::operator<<(int val)
Val & Val::operator<<(long val) Val & Val::operator<<(long val)
{ {
assert_type_output_stream();
if( output_stream ) if( output_stream )
{ {
*output_stream << val; *output_stream << val;
@@ -1248,8 +1203,6 @@ Val & Val::operator<<(long val)
Val & Val::operator<<(long long val) Val & Val::operator<<(long long val)
{ {
assert_type_output_stream();
if( output_stream ) if( output_stream )
{ {
*output_stream << val; *output_stream << val;
@@ -1261,8 +1214,6 @@ Val & Val::operator<<(long long val)
Val & Val::operator<<(unsigned short val) Val & Val::operator<<(unsigned short val)
{ {
assert_type_output_stream();
if( output_stream ) if( output_stream )
{ {
*output_stream << val; *output_stream << val;
@@ -1274,8 +1225,6 @@ Val & Val::operator<<(unsigned short val)
Val & Val::operator<<(unsigned int val) Val & Val::operator<<(unsigned int val)
{ {
assert_type_output_stream();
if( output_stream ) if( output_stream )
{ {
*output_stream << val; *output_stream << val;
@@ -1287,8 +1236,6 @@ Val & Val::operator<<(unsigned int val)
Val & Val::operator<<(unsigned long val) Val & Val::operator<<(unsigned long val)
{ {
assert_type_output_stream();
if( output_stream ) if( output_stream )
{ {
*output_stream << val; *output_stream << val;
@@ -1300,8 +1247,6 @@ Val & Val::operator<<(unsigned long val)
Val & Val::operator<<(unsigned long long val) Val & Val::operator<<(unsigned long long val)
{ {
assert_type_output_stream();
if( output_stream ) if( output_stream )
{ {
*output_stream << val; *output_stream << val;
@@ -1313,8 +1258,6 @@ Val & Val::operator<<(unsigned long long val)
Val & Val::operator<<(float val) Val & Val::operator<<(float val)
{ {
assert_type_output_stream();
if( output_stream ) if( output_stream )
{ {
*output_stream << val; *output_stream << val;
@@ -1326,8 +1269,6 @@ Val & Val::operator<<(float val)
Val & Val::operator<<(double val) Val & Val::operator<<(double val)
{ {
assert_type_output_stream();
if( output_stream ) if( output_stream )
{ {
*output_stream << val; *output_stream << val;
@@ -1339,8 +1280,6 @@ Val & Val::operator<<(double val)
Val & Val::operator<<(long double val) Val & Val::operator<<(long double val)
{ {
assert_type_output_stream();
if( output_stream ) if( output_stream )
{ {
*output_stream << val; *output_stream << val;
@@ -1352,8 +1291,6 @@ Val & Val::operator<<(long double val)
Val & Val::operator<<(const pt::Stream & str) Val & Val::operator<<(const pt::Stream & str)
{ {
assert_type_output_stream();
if( output_stream ) if( output_stream )
{ {
*output_stream << str; *output_stream << str;

View File

@@ -87,7 +87,6 @@ public:
TYPE_MODEL_METHOD, TYPE_MODEL_METHOD,
#endif #endif
TYPE_SPACE, TYPE_SPACE,
TYPE_OUTPUT_STREAM,
TYPE_ITEM_BLOCK, TYPE_ITEM_BLOCK,
TYPE_CHAR, TYPE_CHAR,
TYPE_WCHAR, // TYPE_WCHAR, //
@@ -276,7 +275,6 @@ public:
// output stream // output stream
pt::Stream * output_stream; pt::Stream * output_stream;
size_t output_stream_original_size;
bool is_equal_string(const wchar_t * str) const; bool is_equal_string(const wchar_t * str) const;
@@ -304,8 +302,6 @@ private:
bool is_space_equal_string(const pt::Space & space, const wchar_t * str) const; bool is_space_equal_string(const pt::Space & space, const wchar_t * str) const;
bool is_stream_equal_string(const pt::Stream & stream, const wchar_t * str) const; bool is_stream_equal_string(const pt::Stream & stream, const wchar_t * str) const;
void assert_type_output_stream();
bool to_bool_stream() const; bool to_bool_stream() const;
bool to_bool_space() const; bool to_bool_space() const;
bool to_bool_model_container_wrapper() const; bool to_bool_model_container_wrapper() const;
@@ -383,6 +379,7 @@ typedef std::map<std::wstring, Val> Vals;
} // namespace Ezc } // namespace Ezc
#endif #endif