2016-08-17 18:17:12 +00:00
|
|
|
#include <limits.h>
|
2016-08-14 15:14:10 +00:00
|
|
|
#include <math.h>
|
|
|
|
|
2016-08-17 18:17:12 +00:00
|
|
|
#include <ostd/functional.hh>
|
|
|
|
|
|
|
|
#include "cubescript.hh"
|
|
|
|
|
2016-08-02 00:21:36 +00:00
|
|
|
namespace cscript {
|
|
|
|
|
2016-08-14 16:35:38 +00:00
|
|
|
static constexpr CsFloat PI = 3.14159265358979f;
|
|
|
|
static constexpr CsFloat RAD = PI / 180.0f;
|
2016-08-02 00:21:36 +00:00
|
|
|
|
2016-08-17 18:17:12 +00:00
|
|
|
template<typename T>
|
|
|
|
struct CsMathVal;
|
|
|
|
|
|
|
|
template<>
|
|
|
|
struct CsMathVal<CsInt> {
|
2016-08-18 18:38:30 +00:00
|
|
|
static CsInt get(CsValue &tv) {
|
2016-08-17 18:17:12 +00:00
|
|
|
return tv.get_int();
|
|
|
|
}
|
2016-08-18 18:38:30 +00:00
|
|
|
static void set(CsValue &res, CsInt val) {
|
2016-08-17 18:17:12 +00:00
|
|
|
res.set_int(val);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<>
|
|
|
|
struct CsMathVal<CsFloat> {
|
2016-08-18 18:38:30 +00:00
|
|
|
static CsFloat get(CsValue &tv) {
|
2016-08-17 18:17:12 +00:00
|
|
|
return tv.get_float();
|
|
|
|
}
|
2016-08-18 18:38:30 +00:00
|
|
|
static void set(CsValue &res, CsFloat val) {
|
2016-08-17 18:17:12 +00:00
|
|
|
res.set_float(val);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
struct CsMathNoop {
|
|
|
|
T operator()(T arg) {
|
|
|
|
return arg;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T, typename F1, typename F2>
|
|
|
|
static inline void cs_mathop(
|
2016-08-18 18:38:30 +00:00
|
|
|
CsValueRange args, CsValue &res, T initval,
|
2016-08-17 18:17:12 +00:00
|
|
|
F1 binop, F2 unop
|
|
|
|
) {
|
|
|
|
T val;
|
|
|
|
if (args.size() >= 2) {
|
|
|
|
val = binop(CsMathVal<T>::get(args[0]), CsMathVal<T>::get(args[1]));
|
|
|
|
for (ostd::Size i = 2; i < args.size(); ++i) {
|
|
|
|
val = binop(val, CsMathVal<T>::get(args[i]));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
val = unop(!args.empty() ? CsMathVal<T>::get(args[0]) : initval);
|
|
|
|
}
|
|
|
|
CsMathVal<T>::set(res, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T, typename F>
|
2016-08-18 18:38:30 +00:00
|
|
|
static inline void cs_cmpop(CsValueRange args, CsValue &res, F cmp) {
|
2016-08-17 18:17:12 +00:00
|
|
|
bool val;
|
|
|
|
if (args.size() >= 2) {
|
|
|
|
val = cmp(CsMathVal<T>::get(args[0]), CsMathVal<T>::get(args[1]));
|
|
|
|
for (ostd::Size i = 2; (i < args.size()) && val; ++i) {
|
|
|
|
val = cmp(val, CsMathVal<T>::get(args[i]));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
val = cmp(!args.empty() ? CsMathVal<T>::get(args[0]) : T(0), T(0));
|
|
|
|
}
|
|
|
|
res.set_int(CsInt(val));
|
|
|
|
}
|
|
|
|
|
2016-08-02 00:21:36 +00:00
|
|
|
void cs_init_lib_math(CsState &cs) {
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("sin", "f", [](CsValueRange args, CsValue &res) {
|
2016-08-11 17:14:18 +00:00
|
|
|
res.set_float(sin(args[0].get_float() * RAD));
|
2016-08-02 00:21:36 +00:00
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("cos", "f", [](CsValueRange args, CsValue &res) {
|
2016-08-11 17:14:18 +00:00
|
|
|
res.set_float(cos(args[0].get_float() * RAD));
|
2016-08-02 00:21:36 +00:00
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("tan", "f", [](CsValueRange args, CsValue &res) {
|
2016-08-11 17:14:18 +00:00
|
|
|
res.set_float(tan(args[0].get_float() * RAD));
|
2016-08-02 00:21:36 +00:00
|
|
|
});
|
|
|
|
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("asin", "f", [](CsValueRange args, CsValue &res) {
|
2016-08-11 17:14:18 +00:00
|
|
|
res.set_float(asin(args[0].get_float()) / RAD);
|
2016-08-02 00:21:36 +00:00
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("acos", "f", [](CsValueRange args, CsValue &res) {
|
2016-08-11 17:14:18 +00:00
|
|
|
res.set_float(acos(args[0].get_float()) / RAD);
|
2016-08-02 00:21:36 +00:00
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("atan", "f", [](CsValueRange args, CsValue &res) {
|
2016-08-11 17:14:18 +00:00
|
|
|
res.set_float(atan(args[0].get_float()) / RAD);
|
2016-08-02 00:21:36 +00:00
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("atan2", "ff", [](CsValueRange args, CsValue &res) {
|
2016-08-11 17:14:18 +00:00
|
|
|
res.set_float(atan2(args[0].get_float(), args[1].get_float()) / RAD);
|
2016-08-02 00:21:36 +00:00
|
|
|
});
|
|
|
|
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("sqrt", "f", [](CsValueRange args, CsValue &res) {
|
2016-08-11 17:14:18 +00:00
|
|
|
res.set_float(sqrt(args[0].get_float()));
|
2016-08-02 00:21:36 +00:00
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("loge", "f", [](CsValueRange args, CsValue &res) {
|
2016-08-11 17:14:18 +00:00
|
|
|
res.set_float(log(args[0].get_float()));
|
2016-08-02 00:21:36 +00:00
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("log2", "f", [](CsValueRange args, CsValue &res) {
|
2016-08-11 17:14:18 +00:00
|
|
|
res.set_float(log(args[0].get_float()) / M_LN2);
|
2016-08-02 00:21:36 +00:00
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("log10", "f", [](CsValueRange args, CsValue &res) {
|
2016-08-11 17:14:18 +00:00
|
|
|
res.set_float(log10(args[0].get_float()));
|
2016-08-02 00:21:36 +00:00
|
|
|
});
|
|
|
|
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("exp", "f", [](CsValueRange args, CsValue &res) {
|
2016-08-11 17:14:18 +00:00
|
|
|
res.set_float(exp(args[0].get_float()));
|
2016-08-02 00:21:36 +00:00
|
|
|
});
|
|
|
|
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("min", "i1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
CsInt v = (!args.empty() ? args[0].get_int() : 0);
|
|
|
|
for (ostd::Size i = 1; i < args.size(); ++i) {
|
|
|
|
v = ostd::min(v, args[i].get_int());
|
|
|
|
}
|
|
|
|
res.set_int(v);
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("max", "i1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
CsInt v = (!args.empty() ? args[0].get_int() : 0);
|
|
|
|
for (ostd::Size i = 1; i < args.size(); ++i) {
|
|
|
|
v = ostd::max(v, args[i].get_int());
|
|
|
|
}
|
|
|
|
res.set_int(v);
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("minf", "f1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
CsFloat v = (!args.empty() ? args[0].get_float() : 0);
|
|
|
|
for (ostd::Size i = 1; i < args.size(); ++i) {
|
|
|
|
v = ostd::min(v, args[i].get_float());
|
|
|
|
}
|
|
|
|
res.set_float(v);
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("maxf", "f1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
CsFloat v = (!args.empty() ? args[0].get_float() : 0);
|
|
|
|
for (ostd::Size i = 1; i < args.size(); ++i) {
|
|
|
|
v = ostd::max(v, args[i].get_float());
|
|
|
|
}
|
|
|
|
res.set_float(v);
|
|
|
|
});
|
2016-08-02 00:21:36 +00:00
|
|
|
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("abs", "i", [](CsValueRange args, CsValue &res) {
|
2016-08-11 17:14:18 +00:00
|
|
|
res.set_int(abs(args[0].get_int()));
|
2016-08-02 00:21:36 +00:00
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("absf", "f", [](CsValueRange args, CsValue &res) {
|
2016-08-11 17:14:18 +00:00
|
|
|
res.set_float(fabs(args[0].get_float()));
|
2016-08-02 00:21:36 +00:00
|
|
|
});
|
|
|
|
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("floor", "f", [](CsValueRange args, CsValue &res) {
|
2016-08-11 17:14:18 +00:00
|
|
|
res.set_float(floor(args[0].get_float()));
|
2016-08-02 00:21:36 +00:00
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("ceil", "f", [](CsValueRange args, CsValue &res) {
|
2016-08-11 17:14:18 +00:00
|
|
|
res.set_float(ceil(args[0].get_float()));
|
2016-08-02 00:21:36 +00:00
|
|
|
});
|
|
|
|
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("round", "ff", [](CsValueRange args, CsValue &res) {
|
2016-08-02 00:21:36 +00:00
|
|
|
double step = args[1].get_float();
|
|
|
|
double r = args[0].get_float();
|
|
|
|
if (step > 0) {
|
|
|
|
r += step * ((r < 0) ? -0.5 : 0.5);
|
|
|
|
r -= fmod(r, step);
|
|
|
|
} else {
|
|
|
|
r = (r < 0) ? ceil(r - 0.5) : floor(r + 0.5);
|
|
|
|
}
|
2016-08-14 16:35:38 +00:00
|
|
|
res.set_float(CsFloat(r));
|
2016-08-02 00:21:36 +00:00
|
|
|
});
|
|
|
|
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("+", "i1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_mathop<CsInt>(args, res, 0, ostd::Add<CsInt>(), CsMathNoop<CsInt>());
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("*", "i1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_mathop<CsInt>(
|
|
|
|
args, res, 1, ostd::Multiply<CsInt>(), CsMathNoop<CsInt>()
|
|
|
|
);
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("-", "i1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_mathop<CsInt>(
|
|
|
|
args, res, 0, ostd::Subtract<CsInt>(), ostd::Negate<CsInt>()
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("^", "i1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_mathop<CsInt>(
|
|
|
|
args, res, 0, ostd::BitXor<CsInt>(), [](CsInt val) { return ~val; }
|
|
|
|
);
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("~", "i1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_mathop<CsInt>(
|
|
|
|
args, res, 0, ostd::BitXor<CsInt>(), [](CsInt val) { return ~val; }
|
|
|
|
);
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("&", "i1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_mathop<CsInt>(
|
|
|
|
args, res, 0, ostd::BitAnd<CsInt>(), CsMathNoop<CsInt>()
|
|
|
|
);
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("|", "i1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_mathop<CsInt>(
|
|
|
|
args, res, 0, ostd::BitOr<CsInt>(), CsMathNoop<CsInt>()
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
/* special combined cases */
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("^~", "i1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
CsInt val;
|
|
|
|
if (args.size() >= 2) {
|
|
|
|
val = args[0].get_int() ^ ~args[1].get_int();
|
|
|
|
for (ostd::Size i = 2; i < args.size(); ++i) {
|
|
|
|
val ^= ~args[i].get_int();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
val = !args.empty() ? args[0].get_int() : 0;
|
|
|
|
}
|
|
|
|
res.set_int(val);
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("&~", "i1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
CsInt val;
|
|
|
|
if (args.size() >= 2) {
|
|
|
|
val = args[0].get_int() & ~args[1].get_int();
|
|
|
|
for (ostd::Size i = 2; i < args.size(); ++i) {
|
|
|
|
val &= ~args[i].get_int();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
val = !args.empty() ? args[0].get_int() : 0;
|
|
|
|
}
|
|
|
|
res.set_int(val);
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("|~", "i1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
CsInt val;
|
|
|
|
if (args.size() >= 2) {
|
|
|
|
val = args[0].get_int() | ~args[1].get_int();
|
|
|
|
for (ostd::Size i = 2; i < args.size(); ++i) {
|
|
|
|
val |= ~args[i].get_int();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
val = !args.empty() ? args[0].get_int() : 0;
|
|
|
|
}
|
|
|
|
res.set_int(val);
|
|
|
|
});
|
|
|
|
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("<<", "i1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_mathop<CsInt>(
|
|
|
|
args, res, 0, [](CsInt val1, CsInt val2) {
|
|
|
|
return (val2 < CsInt(sizeof(CsInt) * CHAR_BIT))
|
|
|
|
? (val1 << ostd::max(val2, 0))
|
|
|
|
: 0;
|
|
|
|
}, CsMathNoop<CsInt>()
|
|
|
|
);
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command(">>", "i1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_mathop<CsInt>(
|
|
|
|
args, res, 0, [](CsInt val1, CsInt val2) {
|
|
|
|
return val1 >> ostd::clamp(
|
|
|
|
val2, 0, CsInt(sizeof(CsInt) * CHAR_BIT)
|
|
|
|
);
|
|
|
|
}, CsMathNoop<CsInt>()
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("+f", "f1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_mathop<CsFloat>(
|
|
|
|
args, res, 0, ostd::Add<CsFloat>(), CsMathNoop<CsFloat>()
|
|
|
|
);
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("*f", "f1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_mathop<CsFloat>(
|
|
|
|
args, res, 1, ostd::Multiply<CsFloat>(), CsMathNoop<CsFloat>()
|
|
|
|
);
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("-f", "f1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_mathop<CsFloat>(
|
|
|
|
args, res, 0, ostd::Subtract<CsFloat>(), ostd::Negate<CsFloat>()
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("div", "i1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_mathop<CsInt>(
|
|
|
|
args, res, 0, [](CsInt val1, CsInt val2) {
|
|
|
|
if (val2) {
|
|
|
|
return val1 / val2;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}, CsMathNoop<CsInt>()
|
|
|
|
);
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("mod", "i1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_mathop<CsInt>(
|
|
|
|
args, res, 0, [](CsInt val1, CsInt val2) {
|
|
|
|
if (val2) {
|
|
|
|
return val1 % val2;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}, CsMathNoop<CsInt>()
|
|
|
|
);
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("divf", "f1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_mathop<CsFloat>(
|
|
|
|
args, res, 0, [](CsFloat val1, CsFloat val2) {
|
|
|
|
if (val2) {
|
|
|
|
return val1 / val2;
|
|
|
|
}
|
|
|
|
return CsFloat(0);
|
|
|
|
}, CsMathNoop<CsFloat>()
|
|
|
|
);
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("modf", "f1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_mathop<CsFloat>(
|
|
|
|
args, res, 0, [](CsFloat val1, CsFloat val2) {
|
|
|
|
if (val2) {
|
|
|
|
return CsFloat(fmod(val1, val2));
|
|
|
|
}
|
|
|
|
return CsFloat(0);
|
|
|
|
}, CsMathNoop<CsFloat>()
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("pow", "f1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_mathop<CsFloat>(
|
|
|
|
args, res, 0, [](CsFloat val1, CsFloat val2) {
|
|
|
|
return CsFloat(pow(val1, val2));
|
|
|
|
}, CsMathNoop<CsFloat>()
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("=", "i1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_cmpop<CsInt>(args, res, ostd::Equal<CsInt>());
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("!=", "i1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_cmpop<CsInt>(args, res, ostd::NotEqual<CsInt>());
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("<", "i1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_cmpop<CsInt>(args, res, ostd::Less<CsInt>());
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command(">", "i1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_cmpop<CsInt>(args, res, ostd::Greater<CsInt>());
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("<=", "i1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_cmpop<CsInt>(args, res, ostd::LessEqual<CsInt>());
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command(">=", "i1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_cmpop<CsInt>(args, res, ostd::GreaterEqual<CsInt>());
|
|
|
|
});
|
|
|
|
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("=f", "f1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_cmpop<CsFloat>(args, res, ostd::Equal<CsFloat>());
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("!=f", "f1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_cmpop<CsFloat>(args, res, ostd::NotEqual<CsFloat>());
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("<f", "f1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_cmpop<CsFloat>(args, res, ostd::Less<CsFloat>());
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command(">f", "f1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_cmpop<CsFloat>(args, res, ostd::Greater<CsFloat>());
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command("<=f", "f1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_cmpop<CsFloat>(args, res, ostd::LessEqual<CsFloat>());
|
|
|
|
});
|
2016-08-18 18:38:30 +00:00
|
|
|
cs.add_command(">=f", "f1V", [](CsValueRange args, CsValue &res) {
|
2016-08-17 18:17:12 +00:00
|
|
|
cs_cmpop<CsFloat>(args, res, ostd::GreaterEqual<CsFloat>());
|
|
|
|
});
|
2016-08-02 00:21:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} /* namespace cscript */
|