diff --git a/include/cubescript/cubescript.hh b/include/cubescript/cubescript.hh index 72353560..0a76bde6 100644 --- a/include/cubescript/cubescript.hh +++ b/include/cubescript/cubescript.hh @@ -65,8 +65,6 @@ private: OSTD_EXPORT bool cs_code_is_empty(CsBytecode *code); -struct CsIdent; - enum class CsValueType { Null = 0, Int, Float, String, Cstring, Code, Macro, Ident }; @@ -115,14 +113,11 @@ private: CsValueType p_type; }; -using CsValueRange = ostd::PointerRange; - struct CsIdentStack { CsValue val_s; CsIdentStack *next; }; -struct CsState; struct CsSharedState; struct CsErrorException; struct GenState; @@ -200,11 +195,6 @@ private: int p_index = -1; }; -using CsIdentRange = ostd::PointerRange; -using CsConstIdentRange = ostd::PointerRange; - -using CsVarCb = ostd::Function; - struct OSTD_EXPORT CsVar: CsIdent { friend struct CsState; friend struct CsSharedState; @@ -307,8 +297,6 @@ private: CsValue p_val; }; -using CsCommandCb = ostd::Function; - struct CsCommand: CsIdent { friend struct CsState; friend struct CsSharedState; @@ -337,9 +325,6 @@ enum { CsLibAll = 0b111 }; -using CsHookCb = ostd::Function; -using CsAllocCb = void *(*)(void *, void *, size_t, size_t); - enum class CsLoopState { Normal = 0, Break, Continue }; @@ -368,13 +353,6 @@ struct OSTD_EXPORT CsState { CsHookCb const &get_call_hook() const; CsHookCb &get_call_hook(); - template - CsHookCb set_call_hook(F &&f) { - return set_call_hook(CsHookCb( - ostd::allocator_arg, CsAllocator(*this), std::forward(f) - )); - } - void init_libs(int libs = CsLibAll); void clear_override(CsIdent &id); @@ -396,45 +374,10 @@ struct OSTD_EXPORT CsState { CsVarCb f = CsVarCb(), int flags = 0 ); - template - CsIvar *new_ivar( - ostd::ConstCharRange n, CsInt m, CsInt x, CsInt v, F &&f, int flags = 0 - ) { - return new_ivar(n, m, x, v, CsVarCb( - ostd::allocator_arg, CsAllocator(*this), std::forward(f) - ), flags); - } - template - CsFvar *new_fvar( - ostd::ConstCharRange n, CsFloat m, CsFloat x, CsFloat v, F &&f, - int flags = 0 - ) { - return new_fvar(n, m, x, v, CsVarCb( - ostd::allocator_arg, CsAllocator(*this), std::forward(f) - ), flags); - } - template - CsSvar *new_svar( - ostd::ConstCharRange n, CsString v, F &&f, int flags = 0 - ) { - return new_svar(n, std::move(v), CsVarCb( - ostd::allocator_arg, CsAllocator(*this), std::forward(f) - ), flags); - } - CsCommand *new_command( ostd::ConstCharRange name, ostd::ConstCharRange args, CsCommandCb func ); - template - CsCommand *new_command( - ostd::ConstCharRange name, ostd::ConstCharRange args, F &&f - ) { - return new_command(name, args, CsCommandCb( - ostd::allocator_arg, CsAllocator(*this), std::forward(f) - )); - } - CsIdent *get_ident(ostd::ConstCharRange name); CsAlias *get_alias(ostd::ConstCharRange name); bool have_ident(ostd::ConstCharRange name); diff --git a/include/cubescript/cubescript_conf.hh b/include/cubescript/cubescript_conf.hh index 9a8bc1c6..ac6532bd 100644 --- a/include/cubescript/cubescript_conf.hh +++ b/include/cubescript/cubescript_conf.hh @@ -9,10 +9,28 @@ #include #include +/* do not modify */ +namespace cscript { + struct CsState; + struct CsIdent; + struct CsValue; + + using CsValueRange = ostd::PointerRange; + using CsIdentRange = ostd::PointerRange; + using CsConstIdentRange = ostd::PointerRange; +} + +/* configurable section */ namespace cscript { using CsInt = int; using CsFloat = float; + using CsVarCb = std::function; + using CsCommandCb = std::function; + using CsHookCb = std::function; + using CsAllocCb = void *(*)(void *, void *, size_t, size_t); + + constexpr auto const IntFormat = "%d"; constexpr auto const FloatFormat = "%.7g"; constexpr auto const RoundFloatFormat = "%.1f";