From 8be7f74f5f7de014eebc9072445be27988ef020b Mon Sep 17 00:00:00 2001 From: q66 Date: Thu, 18 Aug 2016 19:47:29 +0100 Subject: [PATCH] make init_libs a method on state --- cubescript.cc | 10 +++++----- cubescript.hh | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/cubescript.cc b/cubescript.cc index f6dcd360..16cb1170 100644 --- a/cubescript.cc +++ b/cubescript.cc @@ -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); } } diff --git a/cubescript.hh b/cubescript.hh index c40df00c..1cb6473d 100644 --- a/cubescript.hh +++ b/cubescript.hh @@ -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; 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)