update according to ostd

master
Daniel Kolesa 2017-02-08 01:07:35 +01:00
parent 0dd69fedea
commit 896ab4aba2
4 changed files with 38 additions and 34 deletions

View File

@ -5,6 +5,7 @@
#include <stdlib.h>
#include <optional>
#include <functional>
#include "cubescript_conf.hh"
@ -16,7 +17,6 @@
#include <ostd/range.hh>
#include <ostd/utility.hh>
#include <ostd/io.hh>
#include <ostd/functional.hh>
#include <ostd/format.hh>
namespace cscript {

View File

@ -1,3 +1,5 @@
#include <functional>
#include "cubescript/cubescript.hh"
#include "cs_util.hh"
@ -452,13 +454,13 @@ end:
});
gcs.new_command("listdel", "ss", [](auto &cs, auto args, auto &res) {
cs_list_merge<false, false>(cs, args, res, ostd::Less<int>());
cs_list_merge<false, false>(cs, args, res, std::less<int>());
});
gcs.new_command("listintersect", "ss", [](auto &cs, auto args, auto &res) {
cs_list_merge<false, false>(cs, args, res, ostd::GreaterEqual<int>());
cs_list_merge<false, false>(cs, args, res, std::greater_equal<int>());
});
gcs.new_command("listunion", "ss", [](auto &cs, auto args, auto &res) {
cs_list_merge<true, true>(cs, args, res, ostd::Less<int>());
cs_list_merge<true, true>(cs, args, res, std::less<int>());
});
gcs.new_command("listsplice", "ssii", [](auto &cs, auto args, auto &res) {

View File

@ -2,6 +2,8 @@
#include <stdlib.h>
#include <math.h>
#include <functional>
#include "cubescript/cubescript.hh"
namespace cscript {
@ -232,37 +234,37 @@ void cs_init_lib_math(CsState &cs) {
});
cs.new_command("+", "i1V", [](auto &, auto args, auto &res) {
cs_mathop<CsInt>(args, res, 0, ostd::Add<CsInt>(), CsMathNoop<CsInt>());
cs_mathop<CsInt>(args, res, 0, std::plus<CsInt>(), CsMathNoop<CsInt>());
});
cs.new_command("*", "i1V", [](auto &, auto args, auto &res) {
cs_mathop<CsInt>(
args, res, 1, ostd::Multiply<CsInt>(), CsMathNoop<CsInt>()
args, res, 1, std::multiplies<CsInt>(), CsMathNoop<CsInt>()
);
});
cs.new_command("-", "i1V", [](auto &, auto args, auto &res) {
cs_mathop<CsInt>(
args, res, 0, ostd::Subtract<CsInt>(), ostd::Negate<CsInt>()
args, res, 0, std::minus<CsInt>(), std::negate<CsInt>()
);
});
cs.new_command("^", "i1V", [](auto &, auto args, auto &res) {
cs_mathop<CsInt>(
args, res, 0, ostd::BitXor<CsInt>(), [](CsInt val) { return ~val; }
args, res, 0, std::bit_xor<CsInt>(), [](CsInt val) { return ~val; }
);
});
cs.new_command("~", "i1V", [](auto &, auto args, auto &res) {
cs_mathop<CsInt>(
args, res, 0, ostd::BitXor<CsInt>(), [](CsInt val) { return ~val; }
args, res, 0, std::bit_xor<CsInt>(), [](CsInt val) { return ~val; }
);
});
cs.new_command("&", "i1V", [](auto &, auto args, auto &res) {
cs_mathop<CsInt>(
args, res, 0, ostd::BitAnd<CsInt>(), CsMathNoop<CsInt>()
args, res, 0, std::bit_and<CsInt>(), CsMathNoop<CsInt>()
);
});
cs.new_command("|", "i1V", [](auto &, auto args, auto &res) {
cs_mathop<CsInt>(
args, res, 0, ostd::BitOr<CsInt>(), CsMathNoop<CsInt>()
args, res, 0, std::bit_or<CsInt>(), CsMathNoop<CsInt>()
);
});
@ -325,17 +327,17 @@ void cs_init_lib_math(CsState &cs) {
cs.new_command("+f", "f1V", [](auto &, auto args, auto &res) {
cs_mathop<CsFloat>(
args, res, 0, ostd::Add<CsFloat>(), CsMathNoop<CsFloat>()
args, res, 0, std::plus<CsFloat>(), CsMathNoop<CsFloat>()
);
});
cs.new_command("*f", "f1V", [](auto &, auto args, auto &res) {
cs_mathop<CsFloat>(
args, res, 1, ostd::Multiply<CsFloat>(), CsMathNoop<CsFloat>()
args, res, 1, std::multiplies<CsFloat>(), CsMathNoop<CsFloat>()
);
});
cs.new_command("-f", "f1V", [](auto &, auto args, auto &res) {
cs_mathop<CsFloat>(
args, res, 0, ostd::Subtract<CsFloat>(), ostd::Negate<CsFloat>()
args, res, 0, std::minus<CsFloat>(), std::negate<CsFloat>()
);
});
@ -389,41 +391,41 @@ void cs_init_lib_math(CsState &cs) {
});
cs.new_command("=", "i1V", [](auto &, auto args, auto &res) {
cs_cmpop<CsInt>(args, res, ostd::Equal<CsInt>());
cs_cmpop<CsInt>(args, res, std::equal_to<CsInt>());
});
cs.new_command("!=", "i1V", [](auto &, auto args, auto &res) {
cs_cmpop<CsInt>(args, res, ostd::NotEqual<CsInt>());
cs_cmpop<CsInt>(args, res, std::not_equal_to<CsInt>());
});
cs.new_command("<", "i1V", [](auto &, auto args, auto &res) {
cs_cmpop<CsInt>(args, res, ostd::Less<CsInt>());
cs_cmpop<CsInt>(args, res, std::less<CsInt>());
});
cs.new_command(">", "i1V", [](auto &, auto args, auto &res) {
cs_cmpop<CsInt>(args, res, ostd::Greater<CsInt>());
cs_cmpop<CsInt>(args, res, std::greater<CsInt>());
});
cs.new_command("<=", "i1V", [](auto &, auto args, auto &res) {
cs_cmpop<CsInt>(args, res, ostd::LessEqual<CsInt>());
cs_cmpop<CsInt>(args, res, std::less_equal<CsInt>());
});
cs.new_command(">=", "i1V", [](auto &, auto args, auto &res) {
cs_cmpop<CsInt>(args, res, ostd::GreaterEqual<CsInt>());
cs_cmpop<CsInt>(args, res, std::greater_equal<CsInt>());
});
cs.new_command("=f", "f1V", [](auto &, auto args, auto &res) {
cs_cmpop<CsFloat>(args, res, ostd::Equal<CsFloat>());
cs_cmpop<CsFloat>(args, res, std::equal_to<CsFloat>());
});
cs.new_command("!=f", "f1V", [](auto &, auto args, auto &res) {
cs_cmpop<CsFloat>(args, res, ostd::NotEqual<CsFloat>());
cs_cmpop<CsFloat>(args, res, std::not_equal_to<CsFloat>());
});
cs.new_command("<f", "f1V", [](auto &, auto args, auto &res) {
cs_cmpop<CsFloat>(args, res, ostd::Less<CsFloat>());
cs_cmpop<CsFloat>(args, res, std::less<CsFloat>());
});
cs.new_command(">f", "f1V", [](auto &, auto args, auto &res) {
cs_cmpop<CsFloat>(args, res, ostd::Greater<CsFloat>());
cs_cmpop<CsFloat>(args, res, std::greater<CsFloat>());
});
cs.new_command("<=f", "f1V", [](auto &, auto args, auto &res) {
cs_cmpop<CsFloat>(args, res, ostd::LessEqual<CsFloat>());
cs_cmpop<CsFloat>(args, res, std::less_equal<CsFloat>());
});
cs.new_command(">=f", "f1V", [](auto &, auto args, auto &res) {
cs_cmpop<CsFloat>(args, res, ostd::GreaterEqual<CsFloat>());
cs_cmpop<CsFloat>(args, res, std::greater_equal<CsFloat>());
});
}

View File

@ -1,4 +1,4 @@
#include <ostd/functional.hh>
#include <functional>
#include "cubescript/cubescript.hh"
@ -144,25 +144,25 @@ void cs_init_lib_string(CsState &cs) {
});
cs.new_command("strcmp", "s1V", [](auto &, auto args, auto &res) {
cs_strgcmp(args, res, ostd::Equal<ostd::ConstCharRange>());
cs_strgcmp(args, res, std::equal_to<ostd::ConstCharRange>());
});
cs.new_command("=s", "s1V", [](auto &, auto args, auto &res) {
cs_strgcmp(args, res, ostd::Equal<ostd::ConstCharRange>());
cs_strgcmp(args, res, std::equal_to<ostd::ConstCharRange>());
});
cs.new_command("!=s", "s1V", [](auto &, auto args, auto &res) {
cs_strgcmp(args, res, ostd::NotEqual<ostd::ConstCharRange>());
cs_strgcmp(args, res, std::not_equal_to<ostd::ConstCharRange>());
});
cs.new_command("<s", "s1V", [](auto &, auto args, auto &res) {
cs_strgcmp(args, res, ostd::Less<ostd::ConstCharRange>());
cs_strgcmp(args, res, std::less<ostd::ConstCharRange>());
});
cs.new_command(">s", "s1V", [](auto &, auto args, auto &res) {
cs_strgcmp(args, res, ostd::Greater<ostd::ConstCharRange>());
cs_strgcmp(args, res, std::greater<ostd::ConstCharRange>());
});
cs.new_command("<=s", "s1V", [](auto &, auto args, auto &res) {
cs_strgcmp(args, res, ostd::LessEqual<ostd::ConstCharRange>());
cs_strgcmp(args, res, std::less_equal<ostd::ConstCharRange>());
});
cs.new_command(">=s", "s1V", [](auto &, auto args, auto &res) {
cs_strgcmp(args, res, ostd::GreaterEqual<ostd::ConstCharRange>());
cs_strgcmp(args, res, std::greater_equal<ostd::ConstCharRange>());
});
cs.new_command("strreplace", "ssss", [](auto &, auto args, auto &res) {