forked from OctaForge/libcubescript
make init_libs a method on state
parent
303e219ad0
commit
8be7f74f5f
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue