ditch cs_string from public headers + style fix
parent
9d0494a9da
commit
d3ec4a47dd
|
@ -19,8 +19,6 @@
|
|||
|
||||
namespace cscript {
|
||||
|
||||
using cs_string = std::string;
|
||||
|
||||
static_assert(std::is_integral_v<cs_int>, "cs_int must be integral");
|
||||
static_assert(std::is_signed_v<cs_int>, "cs_int must be signed");
|
||||
static_assert(std::is_floating_point_v<cs_float>, "cs_float must be floating point");
|
||||
|
@ -761,7 +759,7 @@ namespace util {
|
|||
template<typename R>
|
||||
inline void format_int(R &&writer, cs_int val) {
|
||||
try {
|
||||
ostd::format(std::forward<R>(writer), IntFormat, val);
|
||||
ostd::format(std::forward<R>(writer), CS_INT_FORMAT, val);
|
||||
} catch (ostd::format_error const &e) {
|
||||
throw cs_internal_error{e.what()};
|
||||
}
|
||||
|
@ -772,7 +770,7 @@ namespace util {
|
|||
try {
|
||||
ostd::format(
|
||||
std::forward<R>(writer),
|
||||
(val == cs_int(val)) ? RoundFloatFormat : FloatFormat, val
|
||||
(val == floor(val)) ? CS_ROUND_FLOAT_FORMAT : CS_FLOAT_FORMAT, val
|
||||
);
|
||||
} catch (ostd::format_error const &e) {
|
||||
throw cs_internal_error{e.what()};
|
||||
|
|
|
@ -37,9 +37,9 @@ namespace cscript {
|
|||
using cs_hook_cb = std::function<void(cs_state &)>;
|
||||
using cs_alloc_cb = void *(*)(void *, void *, size_t, size_t);
|
||||
|
||||
constexpr auto const IntFormat = "%d";
|
||||
constexpr auto const FloatFormat = "%.7g";
|
||||
constexpr auto const RoundFloatFormat = "%.1f";
|
||||
constexpr auto const CS_INT_FORMAT = "%d";
|
||||
constexpr auto const CS_FLOAT_FORMAT = "%.7g";
|
||||
constexpr auto const CS_ROUND_FLOAT_FORMAT = "%.1f";
|
||||
} /* namespace cscript */
|
||||
|
||||
#endif /* LIBCUBESCRIPT_CUBESCRIPT_CONF_HH */
|
|
@ -14,6 +14,8 @@ using cs_map = std::unordered_map<K, V>;
|
|||
template<typename T>
|
||||
using cs_vector = std::vector<T>;
|
||||
|
||||
using cs_string = std::string;
|
||||
|
||||
cs_int cs_parse_int(
|
||||
ostd::string_range input, ostd::string_range *end = nullptr
|
||||
);
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include <cubescript/cubescript.hh>
|
||||
|
||||
#include "cs_util.hh"
|
||||
|
||||
namespace cscript {
|
||||
|
||||
template<typename F>
|
||||
|
|
Loading…
Reference in New Issue