libcubescript/include/cubescript/cubescript_conf.hh

45 lines
1.6 KiB
C++
Raw Normal View History

2016-08-21 00:34:03 +00:00
#ifndef LIBCUBESCRIPT_CUBESCRIPT_CONF_HH
#define LIBCUBESCRIPT_CUBESCRIPT_CONF_HH
#include <limits.h>
2017-01-31 18:28:34 +00:00
#include <functional>
#include <ostd/range.hh>
2016-08-21 00:34:03 +00:00
2017-01-29 17:32:12 +00:00
/* do not modify */
namespace cscript {
2017-02-13 17:10:40 +00:00
struct cs_state;
struct cs_ident;
struct cs_value;
2021-03-17 23:03:30 +00:00
struct cs_var;
2017-01-29 17:32:12 +00:00
2017-02-16 19:03:08 +00:00
using cs_value_r = ostd::iterator_range<cs_value *>;
using cs_ident_r = ostd::iterator_range<cs_ident **>;
using cs_const_ident_r = ostd::iterator_range<cs_ident const **>;
2017-01-29 17:32:12 +00:00
}
/* configurable section */
2016-08-21 00:34:03 +00:00
namespace cscript {
2017-02-13 17:10:40 +00:00
using cs_int = int;
using cs_float = float;
2016-08-21 00:34:03 +00:00
2017-01-29 18:30:54 +00:00
/* probably don't want to change these, but if you use a custom allocation
* function for your state, keep in mind potential heap allocations in
* these are not handled by it (as std::function has no allocator support)
*
* normally std::function is optimized not to do allocations for small
* objects, so as long as you don't pass a lambda that captures by copy
* or move or something similar, you should be fine - but if you really
* need to make sure, override this with your own type
*/
2017-02-13 17:10:40 +00:00
using cs_var_cb = std::function<void(cs_state &, cs_ident &)>;
2021-03-17 23:03:30 +00:00
using cs_vprint_cb = std::function<void(cs_state const &, cs_var const &)>;
2017-02-13 17:10:40 +00:00
using cs_command_cb = std::function<void(cs_state &, cs_value_r, cs_value &)>;
using cs_hook_cb = std::function<void(cs_state &)>;
using cs_alloc_cb = void *(*)(void *, void *, size_t, size_t);
2017-01-29 17:32:12 +00:00
2016-08-21 00:34:03 +00:00
constexpr auto const IntFormat = "%d";
constexpr auto const FloatFormat = "%.7g";
constexpr auto const RoundFloatFormat = "%.1f";
} /* namespace cscript */
#endif /* LIBCUBESCRIPT_CUBESCRIPT_CONF_HH */