forked from OctaForge/libcubescript
use standard type traits
parent
2241bcf4b8
commit
2536179500
|
@ -6,12 +6,12 @@
|
|||
|
||||
#include <optional>
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
|
||||
#include "cubescript_conf.hh"
|
||||
|
||||
#include <ostd/platform.hh>
|
||||
#include <ostd/types.hh>
|
||||
#include <ostd/type_traits.hh>
|
||||
#include <ostd/string.hh>
|
||||
#include <ostd/vector.hh>
|
||||
#include <ostd/range.hh>
|
||||
|
@ -23,9 +23,9 @@ namespace cscript {
|
|||
|
||||
using CsString = std::string;
|
||||
|
||||
static_assert(ostd::IsIntegral<CsInt>, "CsInt must be integral");
|
||||
static_assert(ostd::IsSigned<CsInt>, "CsInt must be signed");
|
||||
static_assert(ostd::IsFloatingPoint<CsFloat>, "CsFloat must be floating point");
|
||||
static_assert(std::is_integral_v<CsInt>, "CsInt must be integral");
|
||||
static_assert(std::is_signed_v<CsInt>, "CsInt must be signed");
|
||||
static_assert(std::is_floating_point_v<CsFloat>, "CsFloat must be floating point");
|
||||
|
||||
enum {
|
||||
CsIdfPersist = 1 << 0,
|
||||
|
@ -108,7 +108,7 @@ struct OSTD_EXPORT CsValue {
|
|||
bool code_is_empty() const;
|
||||
|
||||
private:
|
||||
ostd::AlignedUnion<1, CsInt, CsFloat, void *> p_stor;
|
||||
std::aligned_union_t<1, CsInt, CsFloat, void *> p_stor;
|
||||
size_t p_len;
|
||||
CsValueType p_type;
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include <ctype.h>
|
||||
|
||||
#include <ostd/limits.hh>
|
||||
#include <limits>
|
||||
|
||||
namespace cscript {
|
||||
|
||||
|
@ -354,7 +354,7 @@ lookupid:
|
|||
numargs++;
|
||||
break;
|
||||
case 'b':
|
||||
gs.gen_int(ostd::NumericLimitMin<CsInt>);
|
||||
gs.gen_int(std::numeric_limits<CsInt>::min());
|
||||
numargs++;
|
||||
break;
|
||||
case 'f':
|
||||
|
@ -942,7 +942,7 @@ static void compile_cmd(
|
|||
if (rep) {
|
||||
break;
|
||||
}
|
||||
gs.gen_int(ostd::NumericLimitMin<CsInt>);
|
||||
gs.gen_int(std::numeric_limits<CsInt>::min());
|
||||
fakeargs++;
|
||||
}
|
||||
numargs++;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#ifndef LIBCUBESCRIPT_CS_UTIL_HH
|
||||
#define LIBCUBESCRIPT_CS_UTIL_HH
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include <ostd/string.hh>
|
||||
#include <ostd/utility.hh>
|
||||
#include <ostd/type_traits.hh>
|
||||
#include <ostd/unordered_map.hh>
|
||||
|
||||
namespace cscript {
|
||||
|
@ -29,7 +30,7 @@ struct CsScopeExit {
|
|||
~CsScopeExit() {
|
||||
func();
|
||||
}
|
||||
ostd::Decay<F> func;
|
||||
std::decay_t<F> func;
|
||||
};
|
||||
|
||||
template<typename F1, typename F2>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "cs_vm.hh"
|
||||
#include "cs_util.hh"
|
||||
|
||||
#include <ostd/limits.hh>
|
||||
#include <limits>
|
||||
|
||||
namespace cscript {
|
||||
|
||||
|
@ -322,7 +322,7 @@ static inline void callcommand(
|
|||
if (rep) {
|
||||
break;
|
||||
}
|
||||
args[i].set_int(ostd::NumericLimitMin<CsInt>);
|
||||
args[i].set_int(std::numeric_limits<CsInt>::min());
|
||||
fakeargs++;
|
||||
} else {
|
||||
args[i].force_int();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
#include <climits>
|
||||
#include <functional>
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -243,7 +244,7 @@ void cs_init_lib_math(CsState &cs) {
|
|||
cs.new_command("<<", "i1V", [](auto &, auto args, auto &res) {
|
||||
cs_mathop<CsInt>(
|
||||
args, res, 0, [](CsInt val1, CsInt val2) {
|
||||
return (val2 < CsInt(ostd::SizeInBits<CsInt>))
|
||||
return (val2 < CsInt(sizeof(CsInt) * CHAR_BIT))
|
||||
? (val1 << std::max(val2, CsInt(0)))
|
||||
: 0;
|
||||
}, CsMathNoop<CsInt>()
|
||||
|
@ -253,7 +254,7 @@ void cs_init_lib_math(CsState &cs) {
|
|||
cs_mathop<CsInt>(
|
||||
args, res, 0, [](CsInt val1, CsInt val2) {
|
||||
return val1 >> std::clamp(
|
||||
val2, CsInt(0), CsInt(ostd::SizeInBits<CsInt>)
|
||||
val2, CsInt(0), CsInt(sizeof(CsInt) * CHAR_BIT)
|
||||
);
|
||||
}, CsMathNoop<CsInt>()
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue