make init_libs a method on state

master
Daniel Kolesa 2016-08-18 19:47:29 +01:00
parent 303e219ad0
commit 8be7f74f5f
2 changed files with 15 additions and 15 deletions

View File

@ -1532,18 +1532,18 @@ void cs_init_lib_math(CsState &cs);
void cs_init_lib_string(CsState &cs);
void cs_init_lib_list(CsState &cs);
OSTD_EXPORT void init_libs(CsState &cs, int libs) {
OSTD_EXPORT void CsState::init_libs(int libs) {
if (libs & CS_LIB_IO) {
cs_init_lib_io(cs);
cs_init_lib_io(*this);
}
if (libs & CS_LIB_MATH) {
cs_init_lib_math(cs);
cs_init_lib_math(*this);
}
if (libs & CS_LIB_STRING) {
cs_init_lib_string(cs);
cs_init_lib_string(*this);
}
if (libs & CS_LIB_LIST) {
cs_init_lib_list(cs);
cs_init_lib_list(*this);
}
}

View File

@ -339,6 +339,14 @@ struct IdentLink {
IdentStack *argstack;
};
enum {
CS_LIB_IO = 1 << 0,
CS_LIB_MATH = 1 << 1,
CS_LIB_STRING = 1 << 2,
CS_LIB_LIST = 1 << 3,
CS_LIB_ALL = 0b1111
};
using CmdFunc = ostd::Function<void(CsValueRange, CsValue &)>;
struct OSTD_EXPORT CsState {
@ -361,6 +369,8 @@ struct OSTD_EXPORT CsState {
CsState();
~CsState();
void init_libs(int libs = CS_LIB_ALL);
void clear_override(Ident &id);
void clear_overrides();
@ -463,16 +473,6 @@ struct OSTD_EXPORT CsState {
void print_var_str(Svar *sv, ostd::ConstCharRange s);
};
enum {
CS_LIB_IO = 1 << 0,
CS_LIB_MATH = 1 << 1,
CS_LIB_STRING = 1 << 2,
CS_LIB_LIST = 1 << 3,
CS_LIB_ALL = 0b1111
};
OSTD_EXPORT void init_libs(CsState &cs, int libs = CS_LIB_ALL);
struct OSTD_EXPORT StackedValue: CsValue {
StackedValue(Ident *id = nullptr):
CsValue(), p_a(nullptr), p_stack(), p_pushed(false)