forked from OctaForge/libcubescript
remove allocator support for callbacks
parent
f1d2bbc8b7
commit
e624f98be7
|
@ -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<CsValue>;
|
||||
|
||||
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<CsIdent *>;
|
||||
using CsConstIdentRange = ostd::PointerRange<CsIdent const *>;
|
||||
|
||||
using CsVarCb = ostd::Function<void(CsState &, CsIdent &)>;
|
||||
|
||||
struct OSTD_EXPORT CsVar: CsIdent {
|
||||
friend struct CsState;
|
||||
friend struct CsSharedState;
|
||||
|
@ -307,8 +297,6 @@ private:
|
|||
CsValue p_val;
|
||||
};
|
||||
|
||||
using CsCommandCb = ostd::Function<void(CsState &, CsValueRange, CsValue &)>;
|
||||
|
||||
struct CsCommand: CsIdent {
|
||||
friend struct CsState;
|
||||
friend struct CsSharedState;
|
||||
|
@ -337,9 +325,6 @@ enum {
|
|||
CsLibAll = 0b111
|
||||
};
|
||||
|
||||
using CsHookCb = ostd::Function<void(CsState &)>;
|
||||
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<typename F>
|
||||
CsHookCb set_call_hook(F &&f) {
|
||||
return set_call_hook(CsHookCb(
|
||||
ostd::allocator_arg, CsAllocator<char>(*this), std::forward<F>(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<typename F>
|
||||
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<char>(*this), std::forward<F>(f)
|
||||
), flags);
|
||||
}
|
||||
template<typename F>
|
||||
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<char>(*this), std::forward<F>(f)
|
||||
), flags);
|
||||
}
|
||||
template<typename F>
|
||||
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<char>(*this), std::forward<F>(f)
|
||||
), flags);
|
||||
}
|
||||
|
||||
CsCommand *new_command(
|
||||
ostd::ConstCharRange name, ostd::ConstCharRange args, CsCommandCb func
|
||||
);
|
||||
|
||||
template<typename F>
|
||||
CsCommand *new_command(
|
||||
ostd::ConstCharRange name, ostd::ConstCharRange args, F &&f
|
||||
) {
|
||||
return new_command(name, args, CsCommandCb(
|
||||
ostd::allocator_arg, CsAllocator<char>(*this), std::forward<F>(f)
|
||||
));
|
||||
}
|
||||
|
||||
CsIdent *get_ident(ostd::ConstCharRange name);
|
||||
CsAlias *get_alias(ostd::ConstCharRange name);
|
||||
bool have_ident(ostd::ConstCharRange name);
|
||||
|
|
|
@ -9,10 +9,28 @@
|
|||
#include <ostd/map.hh>
|
||||
#include <ostd/stream.hh>
|
||||
|
||||
/* do not modify */
|
||||
namespace cscript {
|
||||
struct CsState;
|
||||
struct CsIdent;
|
||||
struct CsValue;
|
||||
|
||||
using CsValueRange = ostd::PointerRange<CsValue>;
|
||||
using CsIdentRange = ostd::PointerRange<CsIdent *>;
|
||||
using CsConstIdentRange = ostd::PointerRange<CsIdent const *>;
|
||||
}
|
||||
|
||||
/* configurable section */
|
||||
namespace cscript {
|
||||
using CsInt = int;
|
||||
using CsFloat = float;
|
||||
|
||||
using CsVarCb = std::function<void(CsState &, CsIdent &)>;
|
||||
using CsCommandCb = std::function<void(CsState &, CsValueRange, CsValue &)>;
|
||||
using CsHookCb = std::function<void(CsState &)>;
|
||||
using CsAllocCb = void *(*)(void *, void *, size_t, size_t);
|
||||
|
||||
|
||||
constexpr auto const IntFormat = "%d";
|
||||
constexpr auto const FloatFormat = "%.7g";
|
||||
constexpr auto const RoundFloatFormat = "%.1f";
|
||||
|
|
Loading…
Reference in New Issue