template FunInfo<> renamed to Env<>

This commit is contained in:
Tomasz Sowa 2021-08-29 20:55:15 +02:00
parent e826ba34ae
commit 09beafeab7
6 changed files with 34 additions and 99 deletions

View File

@ -3,7 +3,7 @@
blocks.o: blocks.h item.h cache.h functions.h ../../pikotools/src/utf8/utf8.h
blocks.o: ../../pikotools/src/textstream/stream.h
blocks.o: ../../pikotools/src/utf8/utf8_templates.h
blocks.o: ../../pikotools/src/utf8/utf8_private.h funinfo.h var.h
blocks.o: ../../pikotools/src/utf8/utf8_private.h env.h var.h
blocks.o: ../../pikotools/src/date/date.h
blocks.o: ../../pikotools/src/convert/inttostr.h
blocks.o: ../../pikotools/src/textstream/textstream.h
@ -15,7 +15,7 @@ blocks.o: ../../pikotools/src/textstream/types.h objects.h
cache.o: cache.h item.h functions.h ../../pikotools/src/utf8/utf8.h
cache.o: ../../pikotools/src/textstream/stream.h
cache.o: ../../pikotools/src/utf8/utf8_templates.h
cache.o: ../../pikotools/src/utf8/utf8_private.h funinfo.h var.h
cache.o: ../../pikotools/src/utf8/utf8_private.h env.h var.h
cache.o: ../../pikotools/src/date/date.h
cache.o: ../../pikotools/src/convert/inttostr.h
cache.o: ../../pikotools/src/textstream/textstream.h
@ -30,7 +30,7 @@ pattern.o: pattern.h item.h cache.h functions.h
pattern.o: ../../pikotools/src/utf8/utf8.h
pattern.o: ../../pikotools/src/textstream/stream.h
pattern.o: ../../pikotools/src/utf8/utf8_templates.h
pattern.o: ../../pikotools/src/utf8/utf8_private.h funinfo.h var.h
pattern.o: ../../pikotools/src/utf8/utf8_private.h env.h var.h
pattern.o: ../../pikotools/src/date/date.h
pattern.o: ../../pikotools/src/convert/inttostr.h
pattern.o: ../../pikotools/src/textstream/textstream.h
@ -43,7 +43,7 @@ patternparser.o: patternparser.h blocks.h item.h cache.h functions.h
patternparser.o: ../../pikotools/src/utf8/utf8.h
patternparser.o: ../../pikotools/src/textstream/stream.h
patternparser.o: ../../pikotools/src/utf8/utf8_templates.h
patternparser.o: ../../pikotools/src/utf8/utf8_private.h funinfo.h var.h
patternparser.o: ../../pikotools/src/utf8/utf8_private.h env.h var.h
patternparser.o: ../../pikotools/src/date/date.h
patternparser.o: ../../pikotools/src/convert/inttostr.h
patternparser.o: ../../pikotools/src/textstream/textstream.h

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2007-2016, Tomasz Sowa
* Copyright (c) 2007-2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -36,8 +36,8 @@
*/
#ifndef headerfile_ezc_funinfo
#define headerfile_ezc_funinfo
#ifndef headerfile_ezc_env
#define headerfile_ezc_env
#include <vector>
#include <map>
@ -128,7 +128,7 @@ struct Stack
// the name is bad
// may it should be called Env (environment) or FunEnv
template<class StreamType>
struct FunInfo
struct Env
{
// a result consists of a string and a boolean value
// output stream
@ -191,17 +191,17 @@ struct FunInfo
FunInfo(Var & result,
std::vector<Var> & pars,
const StreamType & input_stream,
Stack & s,
const Item & item_) : out(result.stream), res(result), params(pars), in(input_stream), stack(s), item(item_)
Env(Var & result,
std::vector<Var> & pars,
const StreamType & input_stream,
Stack & s,
const Item & item_) : out(result.stream), res(result), params(pars), in(input_stream), stack(s), item(item_)
{
Clear();
clear();
}
void Clear()
void clear()
{
is_for = false;
is_if = false;
@ -214,70 +214,6 @@ struct FunInfo
stack_index = 0;
}
/*
* CHECK ME can it be done only for [for] statements?
*
* can return a null pointer if there is no such an item on the stack
*
* add a function with const wchar_t *
*/
/*
Stack * FindLastFor(const std::wstring & name)
{
for(size_t i = stack_index ; i > 0 ; --i)
{
if( stack_tab[i-1].is_for && stack_tab[i-1].item->has_function )
{
if( stack_tab[i-1].item->function.name == name )
{
return &stack_tab[i-1];
}
}
}
return 0;
}
*/
/*
Stack * FindLastFor(const std::wstring & name, const std::wstring & postfix)
{
for(size_t i = stack_index ; i > 0 ; --i)
{
if( stack_tab[i-1].is_for && stack_tab[i-1].item->has_function )
{
if( stack_tab[i-1].item->function.name == name && stack_tab[i-1].item->function.postfix == postfix )
{
return &stack_tab[i-1];
}
}
}
return 0;
}
*/
/*
template<class FunUserObject>
FunUserObject * FindUserObject(const std::wstring & function_name, Stack ** ezc_stack = 0)
{
Stack * stack;
if( item.has_function && item.function.is_function )
stack = FindLastFor(function_name, item.function.postfix);
else
stack = FindLastFor(function_name);
if( ezc_stack )
*ezc_stack = stack;
if( stack && stack->fun_data )
return dynamic_cast<FunUserObject*>(stack->fun_data);
return 0;
}
*/
};

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2007-2015, Tomasz Sowa
* Copyright (c) 2007-2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -40,7 +40,7 @@
#include <map>
#include "utf8/utf8.h"
#include "funinfo.h"
#include "env.h"
@ -56,7 +56,7 @@ class Functions
{
public:
typedef void (*UserFunction)(FunInfo<StreamType> &);
typedef void (*UserFunction)(Env<StreamType> &);
typedef std::map<std::wstring, UserFunction> FunctionsTable;
typedef typename FunctionsTable::iterator Iterator;

View File

@ -301,9 +301,9 @@ private:
bool FindInVariables(const std::wstring & name, FindHelper & find_helper);
bool Find(Item::Function & item_fun, FindHelper & find_helper);
void PrepareEnvStruct(FunInfo<StreamType> & info);
void PrepareEnvStruct(Env<StreamType> & info);
void CallFunction(typename Functions<StreamType>::UserFunction & function, FunInfo<StreamType> & info);
void CallFunction(typename Functions<StreamType>::UserFunction & function, Env<StreamType> & info);
void CallFunction(typename Functions<StreamType>::UserFunction & function,
Var & result,
@ -314,7 +314,7 @@ private:
Var & result,
std::vector<Var> & parameters);
void CallObject(BaseObj<StreamType> & base_obj, int method_index, FunInfo<StreamType> & info);
void CallObject(BaseObj<StreamType> & base_obj, int method_index, Env<StreamType> & info);
void PrintDate(pt::Date * date, Var & result, std::vector<Var> & parameters);
bool PrintDatePart(pt::Date * date, const std::wstring & field, Var & result, std::vector<Var> & parameters);
@ -1142,9 +1142,9 @@ bool Generator<StreamType, is_pikotools_stream, is_autoescape_stream>::Find(Item
template<class StreamType, bool is_pikotools_stream, bool is_autoescape_stream>
void Generator<StreamType, is_pikotools_stream, is_autoescape_stream>::PrepareEnvStruct(FunInfo<StreamType> & info)
void Generator<StreamType, is_pikotools_stream, is_autoescape_stream>::PrepareEnvStruct(Env<StreamType> & info)
{
info.Clear();
info.clear();
info.is_for = is_generating_for;
info.is_if = is_generating_if;
@ -1160,7 +1160,7 @@ void Generator<StreamType, is_pikotools_stream, is_autoescape_stream>::PrepareEn
template<class StreamType, bool is_pikotools_stream, bool is_autoescape_stream>
void Generator<StreamType, is_pikotools_stream, is_autoescape_stream>::CallFunction(typename Functions<StreamType>::UserFunction & function, FunInfo<StreamType> & info)
void Generator<StreamType, is_pikotools_stream, is_autoescape_stream>::CallFunction(typename Functions<StreamType>::UserFunction & function, Env<StreamType> & info)
{
PrepareEnvStruct(info);
(function)(info);
@ -1179,12 +1179,12 @@ void Generator<StreamType, is_pikotools_stream, is_autoescape_stream>::CallFunct
{
if( parameters.empty() )
{
FunInfo<StreamType> info(result, parameters, in_stream, stack_tab[stack_index-1], *stack_tab[stack_index-1].item);
Env<StreamType> info(result, parameters, in_stream, stack_tab[stack_index-1], *stack_tab[stack_index-1].item);
CallFunction(function, info);
}
else
{
FunInfo<StreamType> info(result, parameters, in_stream, stack_tab[stack_index-1], *stack_tab[stack_index-1].item);
Env<StreamType> info(result, parameters, in_stream, stack_tab[stack_index-1], *stack_tab[stack_index-1].item);
CallFunction(function, info);
}
}
@ -1194,7 +1194,7 @@ void Generator<StreamType, is_pikotools_stream, is_autoescape_stream>::CallFunct
template<class StreamType, bool is_pikotools_stream, bool is_autoescape_stream>
void Generator<StreamType, is_pikotools_stream, is_autoescape_stream>::CallObject(BaseObj<StreamType> & base_obj, int method_index, FunInfo<StreamType> & info)
void Generator<StreamType, is_pikotools_stream, is_autoescape_stream>::CallObject(BaseObj<StreamType> & base_obj, int method_index, Env<StreamType> & info)
{
PrepareEnvStruct(info);
base_obj.CallFun(method_index, info);
@ -1666,7 +1666,7 @@ bool Generator<StreamType, is_pikotools_stream, is_autoescape_stream>::CallModel
/*
* if 'field' is a POD type then 'str' will be used in get_raw_value()
* if 'field' is a getter method with pt::Stream then 'str' will be used too
* if 'field' is a getter method which takes FunInfo<> then out_stream will be used and 'str' will be empty
* if 'field' is a getter method which takes Env<> then out_stream will be used and 'str' will be empty
*
*/
pt::WTextStream str;
@ -1674,13 +1674,13 @@ bool Generator<StreamType, is_pikotools_stream, is_autoescape_stream>::CallModel
if( parameters.empty() )
{
FunInfo<StreamType> info(result, parameters, in_stream, stack_tab[stack_index-1], *stack_tab[stack_index-1].item);
Env<StreamType> info(result, parameters, in_stream, stack_tab[stack_index-1], *stack_tab[stack_index-1].item);
found = model.get_raw_value(nullptr, field.c_str(), nullptr, info, str, false);
//last_res = info.res;
}
else
{
FunInfo<StreamType> info(result, parameters, in_stream, stack_tab[stack_index-1], *stack_tab[stack_index-1].item);
Env<StreamType> info(result, parameters, in_stream, stack_tab[stack_index-1], *stack_tab[stack_index-1].item);
found = model.get_raw_value(nullptr, field.c_str(), nullptr, info, str, false);
//last_res = info.res;
}
@ -1865,12 +1865,12 @@ void Generator<StreamType, is_pikotools_stream, is_autoescape_stream>::CallObjec
{
if( parameters.empty() )
{
FunInfo<StreamType> info(result, parameters, in_stream, stack_tab[stack_index-1], *stack_tab[stack_index-1].item);
Env<StreamType> info(result, parameters, in_stream, stack_tab[stack_index-1], *stack_tab[stack_index-1].item);
CallObject(base_obj, method_index, info);
}
else
{
FunInfo<StreamType> info(result, parameters, in_stream, stack_tab[stack_index-1], *stack_tab[stack_index-1].item);
Env<StreamType> info(result, parameters, in_stream, stack_tab[stack_index-1], *stack_tab[stack_index-1].item);
CallObject(base_obj, method_index, info);
}
}

View File

@ -41,7 +41,6 @@
#ifdef EZC_HAS_MORM_LIBRARY
#include "wrapper.h"
#include "funinfo.h"
#include "space/space.h"

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2015, Tomasz Sowa
* Copyright (c) 2015-2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -72,7 +72,7 @@ public:
/*
*
*/
virtual void CallFun(int fun_index, FunInfo<StreamType> &) = 0;
virtual void CallFun(int fun_index, Env<StreamType> &) = 0;
/*