История изменений
Исправление aido, (текущая версия) :
Хочу нечто похожее (таблицу встроенных функций в единообразном формате):
enum type
{
VOID,
INT_T,
DOUBLE_T,
WORD_T,
OBJECT,
FUNCTION
};
struct arg_proto//for func_proto
{
int number;
type type_val;
std::string var_name;
std::shared_ptr<arg_proto> prev_arg;
std::shared_ptr<arg_proto> next_arg;
};
struct func_proto//for comparing with proto
{
std::string name;
arg_proto prototype;
type ret;
void* (*pbody)(void* arg);//pointer to the function
};
static const func_proto func_table[]=
{
{"exit",{VOID},VOID,[](){exit(EXIT_SUCCESS);}},
{"help",{VOID},VOID,show_help},
/*General User Info*/
{"s",{VOID},WORD_T,get_status},
{"hist",{VOID},WORD_T,get_history},
{"histat",{VOID},WORD_T,get_history_statistics},
/*OS operations*/
{"pwd", {VOID}, WORD_T, pwd},
{"cd", {FILENAME_T}, VOID, emulate_cd(const char*)},
{"ls", {VOID}, WORD_T, emulate_ls},
{"ls", {FILENAME_T}, WORD_T, emulate_ls(const char*)},
{"ls", {WORD_T, FILENAME_T}, WORD_T, emulate_ls(const char*, const char*)},
{"cat", {FILENAME_T}, WORD_T, emulate_cat(const char*)}
};
Здесь есть пара важных ошибок, которые С++ никогда не пропустит, ибо прямое нарушение стандартов.
Исходная версия aido, :
Хочу нечто похожее (таблицу встроенных функций в единообразном формате):
enum type
{
VOID,
INT_T,
DOUBLE_T,
WORD_T,
OBJECT,
FUNCTION
};
struct arg_proto//for func_proto
{
int number;
type type_val;
std::string var_name;
std::shared_ptr<arg_proto> prev_arg;
std::shared_ptr<arg_proto> next_arg;
};
struct func_proto//for comparing with proto
{
std::string name;
arg_proto prototype;
type ret;
void* (*pbody)(void* arg);//pointer to the function
};
static const func_proto func_table[]=
{
{"exit",{VOID},VOID,[](){exit(EXIT_SUCCESS);}},
{"help",{VOID},VOID,show_help},
/*General User Info*/
{"s",{VOID},WORD_T,get_status},
{"hist",{VOID},WORD_T,get_history},
{"histat",{VOID},WORD_T,get_history_statistics},
/*OS operations*/
{"pwd", {VOID}, WORD_T, pwd},
{"cd", {FILENAME_T}, VOID, emulate_cd(const char*)},
{"ls", {VOID}, WORD_T, emulate_ls},
{"ls", {FILENAME_T}, WORD_T, emulate_ls(const char*)},
{"ls", {WORD_T, FILENAME_T}, WORD_T, emulate_ls(const char*, const char*)},
{"cat", {FILENAME_T}, WORD_T, emulate_cat(const char*)}
};