forked from OctaForge/libcubescript
update to latest ostd
parent
57478f6866
commit
d14c8f8593
|
@ -371,7 +371,7 @@ struct OSTD_EXPORT CsState {
|
||||||
template<typename F>
|
template<typename F>
|
||||||
CsHookCb set_call_hook(F &&f) {
|
CsHookCb set_call_hook(F &&f) {
|
||||||
return set_call_hook(CsHookCb(
|
return set_call_hook(CsHookCb(
|
||||||
ostd::allocator_arg, CsAllocator<char>(*this), ostd::forward<F>(f)
|
ostd::allocator_arg, CsAllocator<char>(*this), std::forward<F>(f)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,7 +401,7 @@ struct OSTD_EXPORT CsState {
|
||||||
ostd::ConstCharRange n, CsInt m, CsInt x, CsInt v, F &&f, int flags = 0
|
ostd::ConstCharRange n, CsInt m, CsInt x, CsInt v, F &&f, int flags = 0
|
||||||
) {
|
) {
|
||||||
return new_ivar(n, m, x, v, CsVarCb(
|
return new_ivar(n, m, x, v, CsVarCb(
|
||||||
ostd::allocator_arg, CsAllocator<char>(*this), ostd::forward<F>(f)
|
ostd::allocator_arg, CsAllocator<char>(*this), std::forward<F>(f)
|
||||||
), flags);
|
), flags);
|
||||||
}
|
}
|
||||||
template<typename F>
|
template<typename F>
|
||||||
|
@ -410,15 +410,15 @@ struct OSTD_EXPORT CsState {
|
||||||
int flags = 0
|
int flags = 0
|
||||||
) {
|
) {
|
||||||
return new_fvar(n, m, x, v, CsVarCb(
|
return new_fvar(n, m, x, v, CsVarCb(
|
||||||
ostd::allocator_arg, CsAllocator<char>(*this), ostd::forward<F>(f)
|
ostd::allocator_arg, CsAllocator<char>(*this), std::forward<F>(f)
|
||||||
), flags);
|
), flags);
|
||||||
}
|
}
|
||||||
template<typename F>
|
template<typename F>
|
||||||
CsSvar *new_svar(
|
CsSvar *new_svar(
|
||||||
ostd::ConstCharRange n, CsString v, F &&f, int flags = 0
|
ostd::ConstCharRange n, CsString v, F &&f, int flags = 0
|
||||||
) {
|
) {
|
||||||
return new_svar(n, ostd::move(v), CsVarCb(
|
return new_svar(n, std::move(v), CsVarCb(
|
||||||
ostd::allocator_arg, CsAllocator<char>(*this), ostd::forward<F>(f)
|
ostd::allocator_arg, CsAllocator<char>(*this), std::forward<F>(f)
|
||||||
), flags);
|
), flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,7 +431,7 @@ struct OSTD_EXPORT CsState {
|
||||||
ostd::ConstCharRange name, ostd::ConstCharRange args, F &&f
|
ostd::ConstCharRange name, ostd::ConstCharRange args, F &&f
|
||||||
) {
|
) {
|
||||||
return new_command(name, args, CsCommandCb(
|
return new_command(name, args, CsCommandCb(
|
||||||
ostd::allocator_arg, CsAllocator<char>(*this), ostd::forward<F>(f)
|
ostd::allocator_arg, CsAllocator<char>(*this), std::forward<F>(f)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,7 +596,7 @@ struct CsErrorException {
|
||||||
CsErrorException() = delete;
|
CsErrorException() = delete;
|
||||||
CsErrorException(CsErrorException const &) = delete;
|
CsErrorException(CsErrorException const &) = delete;
|
||||||
CsErrorException(CsErrorException &&v):
|
CsErrorException(CsErrorException &&v):
|
||||||
p_errmsg(v.p_errmsg), p_stack(ostd::move(v.p_stack))
|
p_errmsg(v.p_errmsg), p_stack(std::move(v.p_stack))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
ostd::ConstCharRange what() const {
|
ostd::ConstCharRange what() const {
|
||||||
|
@ -624,7 +624,7 @@ struct CsErrorException {
|
||||||
{
|
{
|
||||||
char fbuf[512];
|
char fbuf[512];
|
||||||
auto ret = ostd::format(
|
auto ret = ostd::format(
|
||||||
ostd::CharRange(fbuf, sizeof(fbuf)), msg, ostd::forward<A>(args)...
|
ostd::CharRange(fbuf, sizeof(fbuf)), msg, std::forward<A>(args)...
|
||||||
);
|
);
|
||||||
if ((ret < 0) || (ostd::Size(ret) > sizeof(fbuf))) {
|
if ((ret < 0) || (ostd::Size(ret) > sizeof(fbuf))) {
|
||||||
p_errmsg = save_msg(cs, msg);
|
p_errmsg = save_msg(cs, msg);
|
||||||
|
@ -776,7 +776,7 @@ namespace util {
|
||||||
template<typename R>
|
template<typename R>
|
||||||
ostd::Size get_item(R &&writer) const {
|
ostd::Size get_item(R &&writer) const {
|
||||||
if (!p_quote.empty() && (*p_quote == '"')) {
|
if (!p_quote.empty() && (*p_quote == '"')) {
|
||||||
return unescape_string(ostd::forward<R>(writer), p_item);
|
return unescape_string(std::forward<R>(writer), p_item);
|
||||||
} else {
|
} else {
|
||||||
return writer.put_n(p_item.data(), p_item.size());
|
return writer.put_n(p_item.data(), p_item.size());
|
||||||
}
|
}
|
||||||
|
@ -785,7 +785,7 @@ namespace util {
|
||||||
CsString get_item() const {
|
CsString get_item() const {
|
||||||
auto app = ostd::appender<CsString>();
|
auto app = ostd::appender<CsString>();
|
||||||
get_item(app);
|
get_item(app);
|
||||||
return ostd::move(app.get());
|
return std::move(app.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
ostd::ConstCharRange &get_raw_item(bool quoted = false) {
|
ostd::ConstCharRange &get_raw_item(bool quoted = false) {
|
||||||
|
@ -809,13 +809,13 @@ private:
|
||||||
|
|
||||||
template<typename R>
|
template<typename R>
|
||||||
inline ostd::Ptrdiff format_int(R &&writer, CsInt val) {
|
inline ostd::Ptrdiff format_int(R &&writer, CsInt val) {
|
||||||
return ostd::format(ostd::forward<R>(writer), IntFormat, val);
|
return ostd::format(std::forward<R>(writer), IntFormat, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename R>
|
template<typename R>
|
||||||
inline ostd::Ptrdiff format_float(R &&writer, CsFloat val) {
|
inline ostd::Ptrdiff format_float(R &&writer, CsFloat val) {
|
||||||
return ostd::format(
|
return ostd::format(
|
||||||
ostd::forward<R>(writer),
|
std::forward<R>(writer),
|
||||||
(val == CsInt(val)) ? RoundFloatFormat : FloatFormat, val
|
(val == CsInt(val)) ? RoundFloatFormat : FloatFormat, val
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -831,7 +831,7 @@ private:
|
||||||
switch (vals[i].get_type()) {
|
switch (vals[i].get_type()) {
|
||||||
case CsValueType::Int: {
|
case CsValueType::Int: {
|
||||||
auto r = format_int(
|
auto r = format_int(
|
||||||
ostd::forward<R>(writer), vals[i].get_int()
|
std::forward<R>(writer), vals[i].get_int()
|
||||||
);
|
);
|
||||||
if (r > 0) {
|
if (r > 0) {
|
||||||
ret += ostd::Size(r);
|
ret += ostd::Size(r);
|
||||||
|
@ -840,7 +840,7 @@ private:
|
||||||
}
|
}
|
||||||
case CsValueType::Float: {
|
case CsValueType::Float: {
|
||||||
auto r = format_float(
|
auto r = format_float(
|
||||||
ostd::forward<R>(writer), vals[i].get_float()
|
std::forward<R>(writer), vals[i].get_float()
|
||||||
);
|
);
|
||||||
if (r > 0) {
|
if (r > 0) {
|
||||||
ret += ostd::Size(r);
|
ret += ostd::Size(r);
|
||||||
|
|
|
@ -26,7 +26,7 @@ CsString GenState::get_str_dup(bool unescape) {
|
||||||
} else {
|
} else {
|
||||||
app.get() = str;
|
app.get() = str;
|
||||||
}
|
}
|
||||||
return ostd::move(app.get());
|
return std::move(app.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
ostd::ConstCharRange GenState::read_macro_name() {
|
ostd::ConstCharRange GenState::read_macro_name() {
|
||||||
|
@ -483,7 +483,7 @@ static bool compileblockstr(GenState &gs, ostd::ConstCharRange str, bool macro)
|
||||||
int startc = gs.code.size();
|
int startc = gs.code.size();
|
||||||
gs.code.push_back(macro ? CsCodeMacro : CsCodeVal | CsRetString);
|
gs.code.push_back(macro ? CsCodeMacro : CsCodeVal | CsRetString);
|
||||||
gs.code.reserve(gs.code.size() + str.size() / sizeof(ostd::Uint32) + 1);
|
gs.code.reserve(gs.code.size() + str.size() / sizeof(ostd::Uint32) + 1);
|
||||||
char *buf = new char[str.size() / sizeof(ostd::Uint32) + 1];
|
char *buf = new char[(str.size() / sizeof(uint32_t) + 1) * sizeof(uint32_t)];
|
||||||
int len = 0;
|
int len = 0;
|
||||||
while (!str.empty()) {
|
while (!str.empty()) {
|
||||||
char const *p = str.data();
|
char const *p = str.data();
|
||||||
|
|
|
@ -24,7 +24,7 @@ CsFloat cs_parse_float(
|
||||||
template<typename F>
|
template<typename F>
|
||||||
struct CsScopeExit {
|
struct CsScopeExit {
|
||||||
template<typename FF>
|
template<typename FF>
|
||||||
CsScopeExit(FF &&f): func(ostd::forward<FF>(f)) {}
|
CsScopeExit(FF &&f): func(std::forward<FF>(f)) {}
|
||||||
~CsScopeExit() {
|
~CsScopeExit() {
|
||||||
func();
|
func();
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ struct CsScopeExit {
|
||||||
|
|
||||||
template<typename F1, typename F2>
|
template<typename F1, typename F2>
|
||||||
inline void cs_do_and_cleanup(F1 &&dof, F2 &&clf) {
|
inline void cs_do_and_cleanup(F1 &&dof, F2 &&clf) {
|
||||||
CsScopeExit<F2> cleanup(ostd::forward<F2>(clf));
|
CsScopeExit<F2> cleanup(std::forward<F2>(clf));
|
||||||
dof();
|
dof();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ CsValue::CsValue(CsValue const &v): CsValue() {
|
||||||
}
|
}
|
||||||
|
|
||||||
CsValue::CsValue(CsValue &&v): CsValue() {
|
CsValue::CsValue(CsValue &&v): CsValue() {
|
||||||
*this = ostd::move(v);
|
*this = std::move(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
CsValue &CsValue::operator=(CsValue const &v) {
|
CsValue &CsValue::operator=(CsValue const &v) {
|
||||||
|
@ -197,10 +197,10 @@ ostd::ConstCharRange CsValue::force_str() {
|
||||||
CsString rs;
|
CsString rs;
|
||||||
switch (get_type()) {
|
switch (get_type()) {
|
||||||
case CsValueType::Float:
|
case CsValueType::Float:
|
||||||
rs = ostd::move(floatstr(csv_get<CsFloat>(p_stor)));
|
rs = std::move(floatstr(csv_get<CsFloat>(p_stor)));
|
||||||
break;
|
break;
|
||||||
case CsValueType::Int:
|
case CsValueType::Int:
|
||||||
rs = ostd::move(intstr(csv_get<CsInt>(p_stor)));
|
rs = std::move(intstr(csv_get<CsInt>(p_stor)));
|
||||||
break;
|
break;
|
||||||
case CsValueType::Macro:
|
case CsValueType::Macro:
|
||||||
case CsValueType::Cstring:
|
case CsValueType::Cstring:
|
||||||
|
@ -211,7 +211,7 @@ ostd::ConstCharRange CsValue::force_str() {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
set_str(ostd::move(rs));
|
set_str(std::move(rs));
|
||||||
return ostd::ConstCharRange(csv_get<char const *>(p_stor), p_len);
|
return ostd::ConstCharRange(csv_get<char const *>(p_stor), p_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,7 +383,7 @@ CsStackedValue &CsStackedValue::operator=(CsValue const &v) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CsStackedValue &CsStackedValue::operator=(CsValue &&v) {
|
CsStackedValue &CsStackedValue::operator=(CsValue &&v) {
|
||||||
*static_cast<CsValue *>(this) = ostd::move(v);
|
*static_cast<CsValue *>(this) = std::move(v);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
44
src/cs_vm.cc
44
src/cs_vm.cc
|
@ -431,7 +431,7 @@ static inline void callcommand(
|
||||||
auto buf = ostd::appender<CsString>();
|
auto buf = ostd::appender<CsString>();
|
||||||
cscript::util::tvals_concat(buf, ostd::iter(args, i), " ");
|
cscript::util::tvals_concat(buf, ostd::iter(args, i), " ");
|
||||||
CsValue tv;
|
CsValue tv;
|
||||||
tv.set_str(ostd::move(buf.get()));
|
tv.set_str(std::move(buf.get()));
|
||||||
CsCommandInternal::call(cs, id, CsValueRange(&tv, 1), res);
|
CsCommandInternal::call(cs, id, CsValueRange(&tv, 1), res);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -666,7 +666,7 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) {
|
||||||
force_arg(result, op & CsCodeRetMask);
|
force_arg(result, op & CsCodeRetMask);
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
case CsCodeResultArg | CsRetNull:
|
case CsCodeResultArg | CsRetNull:
|
||||||
args[numargs++] = ostd::move(result);
|
args[numargs++] = std::move(result);
|
||||||
continue;
|
continue;
|
||||||
case CsCodePrint:
|
case CsCodePrint:
|
||||||
cs.print_var(static_cast<CsVar *>(cs.p_state->identmap[op >> 8]));
|
cs.print_var(static_cast<CsVar *>(cs.p_state->identmap[op >> 8]));
|
||||||
|
@ -731,7 +731,7 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) {
|
||||||
if (args[numargs].get_type() == CsValueType::Code) {
|
if (args[numargs].get_type() == CsValueType::Code) {
|
||||||
cs.run(args[numargs].get_code(), result);
|
cs.run(args[numargs].get_code(), result);
|
||||||
} else {
|
} else {
|
||||||
result = ostd::move(args[numargs]);
|
result = std::move(args[numargs]);
|
||||||
}
|
}
|
||||||
if (result.get_bool()) {
|
if (result.get_bool()) {
|
||||||
code += len;
|
code += len;
|
||||||
|
@ -744,7 +744,7 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) {
|
||||||
if (args[numargs].get_type() == CsValueType::Code) {
|
if (args[numargs].get_type() == CsValueType::Code) {
|
||||||
cs.run(args[numargs].get_code(), result);
|
cs.run(args[numargs].get_code(), result);
|
||||||
} else {
|
} else {
|
||||||
result = ostd::move(args[numargs]);
|
result = std::move(args[numargs]);
|
||||||
}
|
}
|
||||||
if (!result.get_bool()) {
|
if (!result.get_bool()) {
|
||||||
code += len;
|
code += len;
|
||||||
|
@ -829,7 +829,7 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) {
|
||||||
numargs++;
|
numargs++;
|
||||||
continue;
|
continue;
|
||||||
case CsCodeDup | CsRetString:
|
case CsCodeDup | CsRetString:
|
||||||
args[numargs].set_str(ostd::move(args[numargs - 1].get_str()));
|
args[numargs].set_str(std::move(args[numargs - 1].get_str()));
|
||||||
numargs++;
|
numargs++;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -844,12 +844,12 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case CsCodeResult | CsRetNull:
|
case CsCodeResult | CsRetNull:
|
||||||
result = ostd::move(args[--numargs]);
|
result = std::move(args[--numargs]);
|
||||||
continue;
|
continue;
|
||||||
case CsCodeResult | CsRetString:
|
case CsCodeResult | CsRetString:
|
||||||
case CsCodeResult | CsRetInt:
|
case CsCodeResult | CsRetInt:
|
||||||
case CsCodeResult | CsRetFloat:
|
case CsCodeResult | CsRetFloat:
|
||||||
result = ostd::move(args[--numargs]);
|
result = std::move(args[--numargs]);
|
||||||
force_arg(result, op & CsCodeRetMask);
|
force_arg(result, op & CsCodeRetMask);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -994,7 +994,7 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) {
|
||||||
CsValue &arg = args[numargs - 1];
|
CsValue &arg = args[numargs - 1];
|
||||||
switch (cs_get_lookupu_type(cs, arg, id, op)) {
|
switch (cs_get_lookupu_type(cs, arg, id, op)) {
|
||||||
case CsIdAlias:
|
case CsIdAlias:
|
||||||
arg.set_str(ostd::move(
|
arg.set_str(std::move(
|
||||||
static_cast<CsAlias *>(id)->get_value().get_str()
|
static_cast<CsAlias *>(id)->get_value().get_str()
|
||||||
));
|
));
|
||||||
continue;
|
continue;
|
||||||
|
@ -1002,12 +1002,12 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) {
|
||||||
arg.set_str(static_cast<CsSvar *>(id)->get_value());
|
arg.set_str(static_cast<CsSvar *>(id)->get_value());
|
||||||
continue;
|
continue;
|
||||||
case CsIdIvar:
|
case CsIdIvar:
|
||||||
arg.set_str(ostd::move(
|
arg.set_str(std::move(
|
||||||
intstr(static_cast<CsIvar *>(id)->get_value())
|
intstr(static_cast<CsIvar *>(id)->get_value())
|
||||||
));
|
));
|
||||||
continue;
|
continue;
|
||||||
case CsIdFvar:
|
case CsIdFvar:
|
||||||
arg.set_str(ostd::move(
|
arg.set_str(std::move(
|
||||||
floatstr(static_cast<CsFvar *>(id)->get_value())
|
floatstr(static_cast<CsFvar *>(id)->get_value())
|
||||||
));
|
));
|
||||||
continue;
|
continue;
|
||||||
|
@ -1020,7 +1020,7 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) {
|
||||||
}
|
}
|
||||||
case CsCodeLookup | CsRetString:
|
case CsCodeLookup | CsRetString:
|
||||||
args[numargs++].set_str(
|
args[numargs++].set_str(
|
||||||
ostd::move(cs_get_lookup_id(cs, op)->get_value().get_str())
|
std::move(cs_get_lookup_id(cs, op)->get_value().get_str())
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
case CsCodeLookupArg | CsRetString: {
|
case CsCodeLookupArg | CsRetString: {
|
||||||
|
@ -1029,7 +1029,7 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) {
|
||||||
args[numargs++].set_str("");
|
args[numargs++].set_str("");
|
||||||
} else {
|
} else {
|
||||||
args[numargs++].set_str(
|
args[numargs++].set_str(
|
||||||
ostd::move(a->get_value().get_str())
|
std::move(a->get_value().get_str())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -1171,12 +1171,12 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) {
|
||||||
arg.set_cstr(static_cast<CsSvar *>(id)->get_value());
|
arg.set_cstr(static_cast<CsSvar *>(id)->get_value());
|
||||||
continue;
|
continue;
|
||||||
case CsIdIvar:
|
case CsIdIvar:
|
||||||
arg.set_str(ostd::move(
|
arg.set_str(std::move(
|
||||||
intstr(static_cast<CsIvar *>(id)->get_value())
|
intstr(static_cast<CsIvar *>(id)->get_value())
|
||||||
));
|
));
|
||||||
continue;
|
continue;
|
||||||
case CsIdFvar:
|
case CsIdFvar:
|
||||||
arg.set_str(ostd::move(
|
arg.set_str(std::move(
|
||||||
floatstr(static_cast<CsFvar *>(id)->get_value())
|
floatstr(static_cast<CsFvar *>(id)->get_value())
|
||||||
));
|
));
|
||||||
continue;
|
continue;
|
||||||
|
@ -1270,7 +1270,7 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) {
|
||||||
)->get_value());
|
)->get_value());
|
||||||
continue;
|
continue;
|
||||||
case CsCodeIvar | CsRetString:
|
case CsCodeIvar | CsRetString:
|
||||||
args[numargs++].set_str(ostd::move(intstr(static_cast<CsIvar *>(
|
args[numargs++].set_str(std::move(intstr(static_cast<CsIvar *>(
|
||||||
cs.p_state->identmap[op >> 8]
|
cs.p_state->identmap[op >> 8]
|
||||||
)->get_value())));
|
)->get_value())));
|
||||||
continue;
|
continue;
|
||||||
|
@ -1309,7 +1309,7 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) {
|
||||||
)->get_value());
|
)->get_value());
|
||||||
continue;
|
continue;
|
||||||
case CsCodeFvar | CsRetString:
|
case CsCodeFvar | CsRetString:
|
||||||
args[numargs++].set_str(ostd::move(floatstr(
|
args[numargs++].set_str(std::move(floatstr(
|
||||||
static_cast<CsFvar *>(
|
static_cast<CsFvar *>(
|
||||||
cs.p_state->identmap[op >> 8]
|
cs.p_state->identmap[op >> 8]
|
||||||
)->get_value()
|
)->get_value()
|
||||||
|
@ -1376,7 +1376,7 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) {
|
||||||
buf, ostd::iter(&args[offset], callargs), " "
|
buf, ostd::iter(&args[offset], callargs), " "
|
||||||
);
|
);
|
||||||
CsValue tv;
|
CsValue tv;
|
||||||
tv.set_str(ostd::move(buf.get()));
|
tv.set_str(std::move(buf.get()));
|
||||||
CsCommandInternal::call(cs, id, CsValueRange(&tv, 1), result);
|
CsCommandInternal::call(cs, id, CsValueRange(&tv, 1), result);
|
||||||
}
|
}
|
||||||
force_arg(result, op & CsCodeRetMask);
|
force_arg(result, op & CsCodeRetMask);
|
||||||
|
@ -1399,7 +1399,7 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) {
|
||||||
((op & CsCodeOpMask) == CsCodeConc) ? " " : ""
|
((op & CsCodeOpMask) == CsCodeConc) ? " " : ""
|
||||||
);
|
);
|
||||||
numargs = numargs - numconc;
|
numargs = numargs - numconc;
|
||||||
args[numargs].set_str(ostd::move(buf.get()));
|
args[numargs].set_str(std::move(buf.get()));
|
||||||
force_arg(args[numargs], op & CsCodeRetMask);
|
force_arg(args[numargs], op & CsCodeRetMask);
|
||||||
numargs++;
|
numargs++;
|
||||||
continue;
|
continue;
|
||||||
|
@ -1415,7 +1415,7 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) {
|
||||||
buf, ostd::iter(&args[numargs - numconc], numconc)
|
buf, ostd::iter(&args[numargs - numconc], numconc)
|
||||||
);
|
);
|
||||||
numargs = numargs - numconc;
|
numargs = numargs - numconc;
|
||||||
result.set_str(ostd::move(buf.get()));
|
result.set_str(std::move(buf.get()));
|
||||||
force_arg(result, op & CsCodeRetMask);
|
force_arg(result, op & CsCodeRetMask);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1435,7 +1435,7 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) {
|
||||||
case CsCodeAliasU:
|
case CsCodeAliasU:
|
||||||
numargs -= 2;
|
numargs -= 2;
|
||||||
cs.set_alias(
|
cs.set_alias(
|
||||||
args[numargs].get_str(), ostd::move(args[numargs + 1])
|
args[numargs].get_str(), std::move(args[numargs + 1])
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1489,7 +1489,7 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) {
|
||||||
idarg.get_type() != CsValueType::Cstring
|
idarg.get_type() != CsValueType::Cstring
|
||||||
) {
|
) {
|
||||||
litval:
|
litval:
|
||||||
result = ostd::move(idarg);
|
result = std::move(idarg);
|
||||||
force_arg(result, op & CsCodeRetMask);
|
force_arg(result, op & CsCodeRetMask);
|
||||||
numargs = offset - 1;
|
numargs = offset - 1;
|
||||||
continue;
|
continue;
|
||||||
|
@ -1833,7 +1833,7 @@ ostd::Maybe<CsString> CsState::run_file_str(ostd::ConstCharRange fname) {
|
||||||
if (!cs_run_file(*this, fname, ret)) {
|
if (!cs_run_file(*this, fname, ret)) {
|
||||||
return ostd::nothing;
|
return ostd::nothing;
|
||||||
}
|
}
|
||||||
return ostd::move(ret.get_str());
|
return std::move(ret.get_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
ostd::Maybe<CsInt> CsState::run_file_int(ostd::ConstCharRange fname) {
|
ostd::Maybe<CsInt> CsState::run_file_int(ostd::ConstCharRange fname) {
|
||||||
|
|
24
src/cs_vm.hh
24
src/cs_vm.hh
|
@ -107,7 +107,7 @@ struct CsSharedState {
|
||||||
template<typename T, typename ...A>
|
template<typename T, typename ...A>
|
||||||
T *create(A &&...args) {
|
T *create(A &&...args) {
|
||||||
T *ret = static_cast<T *>(alloc(nullptr, 0, sizeof(T)));
|
T *ret = static_cast<T *>(alloc(nullptr, 0, sizeof(T)));
|
||||||
new (ret) T(ostd::forward<A>(args)...);
|
new (ret) T(std::forward<A>(args)...);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,14 +321,14 @@ struct CsAliasInternal {
|
||||||
) {
|
) {
|
||||||
if (a->p_astack == &st) {
|
if (a->p_astack == &st) {
|
||||||
/* prevent cycles and unnecessary code elsewhere */
|
/* prevent cycles and unnecessary code elsewhere */
|
||||||
a->p_val = ostd::move(v);
|
a->p_val = std::move(v);
|
||||||
clean_code(a);
|
clean_code(a);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
st.val_s = ostd::move(a->p_val);
|
st.val_s = std::move(a->p_val);
|
||||||
st.next = a->p_astack;
|
st.next = a->p_astack;
|
||||||
a->p_astack = &st;
|
a->p_astack = &st;
|
||||||
a->p_val = ostd::move(v);
|
a->p_val = std::move(v);
|
||||||
clean_code(a);
|
clean_code(a);
|
||||||
if (um) {
|
if (um) {
|
||||||
a->p_flags &= ~CsIdfUnknown;
|
a->p_flags &= ~CsIdfUnknown;
|
||||||
|
@ -340,31 +340,31 @@ struct CsAliasInternal {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CsIdentStack *st = a->p_astack;
|
CsIdentStack *st = a->p_astack;
|
||||||
a->p_val = ostd::move(a->p_astack->val_s);
|
a->p_val = std::move(a->p_astack->val_s);
|
||||||
clean_code(a);
|
clean_code(a);
|
||||||
a->p_astack = st->next;
|
a->p_astack = st->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void undo_arg(CsAlias *a, CsIdentStack &st) {
|
static void undo_arg(CsAlias *a, CsIdentStack &st) {
|
||||||
CsIdentStack *prev = a->p_astack;
|
CsIdentStack *prev = a->p_astack;
|
||||||
st.val_s = ostd::move(a->p_val);
|
st.val_s = std::move(a->p_val);
|
||||||
st.next = prev;
|
st.next = prev;
|
||||||
a->p_astack = prev->next;
|
a->p_astack = prev->next;
|
||||||
a->p_val = ostd::move(prev->val_s);
|
a->p_val = std::move(prev->val_s);
|
||||||
clean_code(a);
|
clean_code(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void redo_arg(CsAlias *a, CsIdentStack &st) {
|
static void redo_arg(CsAlias *a, CsIdentStack &st) {
|
||||||
CsIdentStack *prev = st.next;
|
CsIdentStack *prev = st.next;
|
||||||
prev->val_s = ostd::move(a->p_val);
|
prev->val_s = std::move(a->p_val);
|
||||||
a->p_astack = prev;
|
a->p_astack = prev;
|
||||||
a->p_val = ostd::move(st.val_s);
|
a->p_val = std::move(st.val_s);
|
||||||
clean_code(a);
|
clean_code(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_arg(CsAlias *a, CsState &cs, CsValue &v) {
|
static void set_arg(CsAlias *a, CsState &cs, CsValue &v) {
|
||||||
if (cs_is_arg_used(cs, a)) {
|
if (cs_is_arg_used(cs, a)) {
|
||||||
a->p_val = ostd::move(v);
|
a->p_val = std::move(v);
|
||||||
clean_code(a);
|
clean_code(a);
|
||||||
} else {
|
} else {
|
||||||
push_arg(a, v, cs.p_callstack->argstack[a->get_index()], false);
|
push_arg(a, v, cs.p_callstack->argstack[a->get_index()], false);
|
||||||
|
@ -373,7 +373,7 @@ struct CsAliasInternal {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_alias(CsAlias *a, CsState &cs, CsValue &v) {
|
static void set_alias(CsAlias *a, CsState &cs, CsValue &v) {
|
||||||
a->p_val = ostd::move(v);
|
a->p_val = std::move(v);
|
||||||
clean_code(a);
|
clean_code(a);
|
||||||
a->p_flags = (a->p_flags & cs.identflags) | cs.identflags;
|
a->p_flags = (a->p_flags & cs.identflags) | cs.identflags;
|
||||||
}
|
}
|
||||||
|
@ -423,7 +423,7 @@ static void cs_do_args(CsState &cs, F body) {
|
||||||
prevstack ? prevstack->argstack : nullptr
|
prevstack ? prevstack->argstack : nullptr
|
||||||
};
|
};
|
||||||
cs.p_callstack = &aliaslink;
|
cs.p_callstack = &aliaslink;
|
||||||
cs_do_and_cleanup(ostd::move(body), [&]() {
|
cs_do_and_cleanup(std::move(body), [&]() {
|
||||||
if (prevstack) {
|
if (prevstack) {
|
||||||
prevstack->usedargs = aliaslink.usedargs;
|
prevstack->usedargs = aliaslink.usedargs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,13 @@ namespace cscript {
|
||||||
CsString intstr(CsInt v) {
|
CsString intstr(CsInt v) {
|
||||||
auto app = ostd::appender<CsString>();
|
auto app = ostd::appender<CsString>();
|
||||||
cscript::util::format_int(app, v);
|
cscript::util::format_int(app, v);
|
||||||
return ostd::move(app.get());
|
return std::move(app.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
CsString floatstr(CsFloat v) {
|
CsString floatstr(CsFloat v) {
|
||||||
auto app = ostd::appender<CsString>();
|
auto app = ostd::appender<CsString>();
|
||||||
cscript::util::format_float(app, v);
|
cscript::util::format_float(app, v);
|
||||||
return ostd::move(app.get());
|
return std::move(app.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cs_check_num(ostd::ConstCharRange s) {
|
bool cs_check_num(ostd::ConstCharRange s) {
|
||||||
|
@ -35,33 +35,33 @@ CsIdent::CsIdent(CsIdentType tp, ostd::ConstCharRange nm, int fl):
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CsVar::CsVar(CsIdentType tp, ostd::ConstCharRange name, CsVarCb f, int fl):
|
CsVar::CsVar(CsIdentType tp, ostd::ConstCharRange name, CsVarCb f, int fl):
|
||||||
CsIdent(tp, name, fl), cb_var(ostd::move(f))
|
CsIdent(tp, name, fl), cb_var(std::move(f))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CsIvar::CsIvar(
|
CsIvar::CsIvar(
|
||||||
ostd::ConstCharRange name, CsInt m, CsInt x, CsInt v, CsVarCb f, int fl
|
ostd::ConstCharRange name, CsInt m, CsInt x, CsInt v, CsVarCb f, int fl
|
||||||
):
|
):
|
||||||
CsVar(CsIdentType::Ivar, name, ostd::move(f), fl | ((m > x) ? CsIdfReadOnly : 0)),
|
CsVar(CsIdentType::Ivar, name, std::move(f), fl | ((m > x) ? CsIdfReadOnly : 0)),
|
||||||
p_storage(v), p_minval(m), p_maxval(x), p_overrideval(0)
|
p_storage(v), p_minval(m), p_maxval(x), p_overrideval(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CsFvar::CsFvar(
|
CsFvar::CsFvar(
|
||||||
ostd::ConstCharRange name, CsFloat m, CsFloat x, CsFloat v, CsVarCb f, int fl
|
ostd::ConstCharRange name, CsFloat m, CsFloat x, CsFloat v, CsVarCb f, int fl
|
||||||
):
|
):
|
||||||
CsVar(CsIdentType::Fvar, name, ostd::move(f), fl | ((m > x) ? CsIdfReadOnly : 0)),
|
CsVar(CsIdentType::Fvar, name, std::move(f), fl | ((m > x) ? CsIdfReadOnly : 0)),
|
||||||
p_storage(v), p_minval(m), p_maxval(x), p_overrideval(0)
|
p_storage(v), p_minval(m), p_maxval(x), p_overrideval(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CsSvar::CsSvar(ostd::ConstCharRange name, CsString v, CsVarCb f, int fl):
|
CsSvar::CsSvar(ostd::ConstCharRange name, CsString v, CsVarCb f, int fl):
|
||||||
CsVar(CsIdentType::Svar, name, ostd::move(f), fl),
|
CsVar(CsIdentType::Svar, name, std::move(f), fl),
|
||||||
p_storage(ostd::move(v)), p_overrideval()
|
p_storage(std::move(v)), p_overrideval()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CsAlias::CsAlias(ostd::ConstCharRange name, CsString a, int fl):
|
CsAlias::CsAlias(ostd::ConstCharRange name, CsString a, int fl):
|
||||||
CsIdent(CsIdentType::Alias, name, fl),
|
CsIdent(CsIdentType::Alias, name, fl),
|
||||||
p_acode(nullptr), p_astack(nullptr)
|
p_acode(nullptr), p_astack(nullptr)
|
||||||
{
|
{
|
||||||
p_val.set_str(ostd::move(a));
|
p_val.set_str(std::move(a));
|
||||||
}
|
}
|
||||||
CsAlias::CsAlias(ostd::ConstCharRange name, CsInt a, int fl):
|
CsAlias::CsAlias(ostd::ConstCharRange name, CsInt a, int fl):
|
||||||
CsIdent(CsIdentType::Alias, name, fl),
|
CsIdent(CsIdentType::Alias, name, fl),
|
||||||
|
@ -83,7 +83,7 @@ CsAlias::CsAlias(ostd::ConstCharRange name, int fl):
|
||||||
}
|
}
|
||||||
CsAlias::CsAlias(ostd::ConstCharRange name, CsValue v, int fl):
|
CsAlias::CsAlias(ostd::ConstCharRange name, CsValue v, int fl):
|
||||||
CsIdent(CsIdentType::Alias, name, fl),
|
CsIdent(CsIdentType::Alias, name, fl),
|
||||||
p_acode(nullptr), p_astack(nullptr), p_val(ostd::move(v))
|
p_acode(nullptr), p_astack(nullptr), p_val(std::move(v))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CsCommand::CsCommand(
|
CsCommand::CsCommand(
|
||||||
|
@ -91,7 +91,7 @@ CsCommand::CsCommand(
|
||||||
int nargs, CsCommandCb f
|
int nargs, CsCommandCb f
|
||||||
):
|
):
|
||||||
CsIdent(CsIdentType::Command, name, 0),
|
CsIdent(CsIdentType::Command, name, 0),
|
||||||
p_cargs(args), p_cb_cftv(ostd::move(f)), p_numargs(nargs)
|
p_cargs(args), p_cb_cftv(std::move(f)), p_numargs(nargs)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool CsIdent::is_alias() const {
|
bool CsIdent::is_alias() const {
|
||||||
|
@ -234,7 +234,7 @@ CsString CsIvar::to_printable() const {
|
||||||
} else {
|
} else {
|
||||||
format(app, IvarHexFormat, get_name(), i);
|
format(app, IvarHexFormat, get_name(), i);
|
||||||
}
|
}
|
||||||
return ostd::move(app.get());
|
return std::move(app.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
CsFloat CsFvar::get_val_min() const {
|
CsFloat CsFvar::get_val_min() const {
|
||||||
|
@ -255,14 +255,14 @@ CsString CsFvar::to_printable() const {
|
||||||
CsFloat f = p_storage;
|
CsFloat f = p_storage;
|
||||||
auto app = ostd::appender<CsString>();
|
auto app = ostd::appender<CsString>();
|
||||||
format(app, (f == CsInt(f)) ? FvarRoundFormat : FvarFormat, get_name(), f);
|
format(app, (f == CsInt(f)) ? FvarRoundFormat : FvarFormat, get_name(), f);
|
||||||
return ostd::move(app.get());
|
return std::move(app.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
ostd::ConstCharRange CsSvar::get_value() const {
|
ostd::ConstCharRange CsSvar::get_value() const {
|
||||||
return p_storage.iter();
|
return p_storage.iter();
|
||||||
}
|
}
|
||||||
void CsSvar::set_value(CsString val) {
|
void CsSvar::set_value(CsString val) {
|
||||||
p_storage = ostd::move(val);
|
p_storage = std::move(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
CsString CsSvar::to_printable() const {
|
CsString CsSvar::to_printable() const {
|
||||||
|
@ -273,7 +273,7 @@ CsString CsSvar::to_printable() const {
|
||||||
} else {
|
} else {
|
||||||
format(app, SvarQuotedFormat, get_name(), s);
|
format(app, SvarQuotedFormat, get_name(), s);
|
||||||
}
|
}
|
||||||
return ostd::move(app.get());
|
return std::move(app.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
ostd::ConstCharRange CsCommand::get_args() const {
|
ostd::ConstCharRange CsCommand::get_args() const {
|
||||||
|
@ -330,7 +330,7 @@ CsState::CsState(CsAllocCb func, void *data):
|
||||||
})->p_type = CsIdIf;
|
})->p_type = CsIdIf;
|
||||||
|
|
||||||
new_command("result", "T", [](auto &, auto args, auto &res) {
|
new_command("result", "T", [](auto &, auto args, auto &res) {
|
||||||
res = ostd::move(args[0]);
|
res = std::move(args[0]);
|
||||||
})->p_type = CsIdResult;
|
})->p_type = CsIdResult;
|
||||||
|
|
||||||
new_command("!", "t", [](auto &, auto args, auto &res) {
|
new_command("!", "t", [](auto &, auto args, auto &res) {
|
||||||
|
@ -346,7 +346,7 @@ CsState::CsState(CsAllocCb func, void *data):
|
||||||
if (code) {
|
if (code) {
|
||||||
cs.run(code, res);
|
cs.run(code, res);
|
||||||
} else {
|
} else {
|
||||||
res = ostd::move(args[i]);
|
res = std::move(args[i]);
|
||||||
}
|
}
|
||||||
if (!res.get_bool()) {
|
if (!res.get_bool()) {
|
||||||
break;
|
break;
|
||||||
|
@ -364,7 +364,7 @@ CsState::CsState(CsAllocCb func, void *data):
|
||||||
if (code) {
|
if (code) {
|
||||||
cs.run(code, res);
|
cs.run(code, res);
|
||||||
} else {
|
} else {
|
||||||
res = ostd::move(args[i]);
|
res = std::move(args[i]);
|
||||||
}
|
}
|
||||||
if (res.get_bool()) {
|
if (res.get_bool()) {
|
||||||
break;
|
break;
|
||||||
|
@ -411,8 +411,8 @@ CsState::~CsState() {
|
||||||
}
|
}
|
||||||
|
|
||||||
CsHookCb CsState::set_call_hook(CsHookCb func) {
|
CsHookCb CsState::set_call_hook(CsHookCb func) {
|
||||||
auto hk = ostd::move(p_callhook);
|
auto hk = std::move(p_callhook);
|
||||||
p_callhook = ostd::move(func);
|
p_callhook = std::move(func);
|
||||||
return hk;
|
return hk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -545,7 +545,7 @@ CsIvar *CsState::new_ivar(
|
||||||
ostd::ConstCharRange n, CsInt m, CsInt x, CsInt v, CsVarCb f, int flags
|
ostd::ConstCharRange n, CsInt m, CsInt x, CsInt v, CsVarCb f, int flags
|
||||||
) {
|
) {
|
||||||
return add_ident(
|
return add_ident(
|
||||||
p_state->create<CsIvar>(n, m, x, v, ostd::move(f), flags)
|
p_state->create<CsIvar>(n, m, x, v, std::move(f), flags)
|
||||||
)->get_ivar();
|
)->get_ivar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,7 +553,7 @@ CsFvar *CsState::new_fvar(
|
||||||
ostd::ConstCharRange n, CsFloat m, CsFloat x, CsFloat v, CsVarCb f, int flags
|
ostd::ConstCharRange n, CsFloat m, CsFloat x, CsFloat v, CsVarCb f, int flags
|
||||||
) {
|
) {
|
||||||
return add_ident(
|
return add_ident(
|
||||||
p_state->create<CsFvar>(n, m, x, v, ostd::move(f), flags)
|
p_state->create<CsFvar>(n, m, x, v, std::move(f), flags)
|
||||||
)->get_fvar();
|
)->get_fvar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -561,7 +561,7 @@ CsSvar *CsState::new_svar(
|
||||||
ostd::ConstCharRange n, CsString v, CsVarCb f, int flags
|
ostd::ConstCharRange n, CsString v, CsVarCb f, int flags
|
||||||
) {
|
) {
|
||||||
return add_ident(
|
return add_ident(
|
||||||
p_state->create<CsSvar>(n, ostd::move(v), ostd::move(f), flags)
|
p_state->create<CsSvar>(n, std::move(v), std::move(f), flags)
|
||||||
)->get_svar();
|
)->get_svar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -614,7 +614,7 @@ void CsState::set_alias(ostd::ConstCharRange name, CsValue v) {
|
||||||
} else if (cs_check_num(name)) {
|
} else if (cs_check_num(name)) {
|
||||||
throw CsErrorException(*this, "cannot alias number %s", name);
|
throw CsErrorException(*this, "cannot alias number %s", name);
|
||||||
} else {
|
} else {
|
||||||
add_ident(p_state->create<CsAlias>(name, ostd::move(v), identflags));
|
add_ident(p_state->create<CsAlias>(name, std::move(v), identflags));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -632,10 +632,10 @@ void CsAlias::get_cstr(CsValue &v) const {
|
||||||
v.set_cstr(p_val.get_strr());
|
v.set_cstr(p_val.get_strr());
|
||||||
break;
|
break;
|
||||||
case CsValueType::Int:
|
case CsValueType::Int:
|
||||||
v.set_str(ostd::move(intstr(p_val.get_int())));
|
v.set_str(std::move(intstr(p_val.get_int())));
|
||||||
break;
|
break;
|
||||||
case CsValueType::Float:
|
case CsValueType::Float:
|
||||||
v.set_str(ostd::move(floatstr(p_val.get_float())));
|
v.set_str(std::move(floatstr(p_val.get_float())));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
v.set_cstr("");
|
v.set_cstr("");
|
||||||
|
@ -829,7 +829,7 @@ CsState::get_alias_val(ostd::ConstCharRange name) {
|
||||||
if ((a->get_index() < MaxArguments) && !cs_is_arg_used(*this, a)) {
|
if ((a->get_index() < MaxArguments) && !cs_is_arg_used(*this, a)) {
|
||||||
return ostd::nothing;
|
return ostd::nothing;
|
||||||
}
|
}
|
||||||
return ostd::move(a->get_value().get_str());
|
return std::move(a->get_value().get_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
CsInt cs_clamp_var(CsState &cs, CsIvar *iv, CsInt v) {
|
CsInt cs_clamp_var(CsState &cs, CsIvar *iv, CsInt v) {
|
||||||
|
@ -975,7 +975,7 @@ CsCommand *CsState::new_command(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return static_cast<CsCommand *>(
|
return static_cast<CsCommand *>(
|
||||||
add_ident(p_state->create<CsCommand>(name, args, nargs, ostd::move(func)))
|
add_ident(p_state->create<CsCommand>(name, args, nargs, std::move(func)))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1031,7 +1031,7 @@ static inline void cs_loop_conc(
|
||||||
s += v.get_str();
|
s += v.get_str();
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
res.set_str(ostd::move(s));
|
res.set_str(std::move(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
void cs_init_lib_base(CsState &gcs) {
|
void cs_init_lib_base(CsState &gcs) {
|
||||||
|
@ -1055,7 +1055,7 @@ void cs_init_lib_base(CsState &gcs) {
|
||||||
if (e.get_stack().get()) {
|
if (e.get_stack().get()) {
|
||||||
auto app = ostd::appender<CsString>();
|
auto app = ostd::appender<CsString>();
|
||||||
cscript::util::print_stack(app, e.get_stack());
|
cscript::util::print_stack(app, e.get_stack());
|
||||||
tback.set_str(ostd::move(app.get()));
|
tback.set_str(std::move(app.get()));
|
||||||
}
|
}
|
||||||
rc = false;
|
rc = false;
|
||||||
}
|
}
|
||||||
|
@ -1066,9 +1066,9 @@ void cs_init_lib_base(CsState &gcs) {
|
||||||
|
|
||||||
gcs.new_command("?", "tTT", [](auto &, auto args, auto &res) {
|
gcs.new_command("?", "tTT", [](auto &, auto args, auto &res) {
|
||||||
if (args[0].get_bool()) {
|
if (args[0].get_bool()) {
|
||||||
res = ostd::move(args[1]);
|
res = std::move(args[1]);
|
||||||
} else {
|
} else {
|
||||||
res = ostd::move(args[2]);
|
res = std::move(args[2]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1131,7 +1131,7 @@ void cs_init_lib_base(CsState &gcs) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (args[1].get_bool()) {
|
if (args[1].get_bool()) {
|
||||||
idv = ostd::move(args[1]);
|
idv = std::move(args[1]);
|
||||||
idv.push();
|
idv.push();
|
||||||
cs.run(args[2].get_code(), res);
|
cs.run(args[2].get_code(), res);
|
||||||
}
|
}
|
||||||
|
@ -1274,7 +1274,7 @@ end:
|
||||||
if (!idv.has_alias() || (idv.get_alias()->get_index() < MaxArguments)) {
|
if (!idv.has_alias() || (idv.get_alias()->get_index() < MaxArguments)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
idv = ostd::move(args[1]);
|
idv = std::move(args[1]);
|
||||||
idv.push();
|
idv.push();
|
||||||
cs.run(args[2].get_code(), res);
|
cs.run(args[2].get_code(), res);
|
||||||
});
|
});
|
||||||
|
@ -1284,7 +1284,7 @@ end:
|
||||||
});
|
});
|
||||||
|
|
||||||
gcs.new_command("alias", "sT", [](auto &cs, auto args, auto &) {
|
gcs.new_command("alias", "sT", [](auto &cs, auto args, auto &) {
|
||||||
cs.set_alias(args[0].get_strr(), ostd::move(args[1]));
|
cs.set_alias(args[0].get_strr(), std::move(args[1]));
|
||||||
});
|
});
|
||||||
|
|
||||||
gcs.new_command("getvarmin", "s", [](auto &cs, auto args, auto &res) {
|
gcs.new_command("getvarmin", "s", [](auto &cs, auto args, auto &res) {
|
||||||
|
@ -1306,7 +1306,7 @@ end:
|
||||||
|
|
||||||
gcs.new_command("getalias", "s", [](auto &cs, auto args, auto &res) {
|
gcs.new_command("getalias", "s", [](auto &cs, auto args, auto &res) {
|
||||||
res.set_str(
|
res.set_str(
|
||||||
ostd::move(cs.get_alias_val(args[0].get_strr()).value_or(""))
|
std::move(cs.get_alias_val(args[0].get_strr()).value_or(""))
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ static void cs_loop_list_conc(
|
||||||
r += v.get_str();
|
r += v.get_str();
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
res.set_str(ostd::move(r));
|
res.set_str(std::move(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
int cs_list_includes(
|
int cs_list_includes(
|
||||||
|
@ -132,7 +132,7 @@ static inline void cs_list_merge(
|
||||||
buf += p.get_raw_item(true);
|
buf += p.get_raw_item(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res.set_str(ostd::move(buf));
|
res.set_str(std::move(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cs_init_lib_list_sort(CsState &cs);
|
static void cs_init_lib_list_sort(CsState &cs);
|
||||||
|
@ -146,7 +146,7 @@ void cs_init_lib_list(CsState &gcs) {
|
||||||
if (args.empty()) {
|
if (args.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CsString str = ostd::move(args[0].get_str());
|
CsString str = std::move(args[0].get_str());
|
||||||
util::ListParser p(cs, str);
|
util::ListParser p(cs, str);
|
||||||
p.get_raw_item() = str;
|
p.get_raw_item() = str;
|
||||||
for (ostd::Size i = 1; i < args.size(); ++i) {
|
for (ostd::Size i = 1; i < args.size(); ++i) {
|
||||||
|
@ -398,7 +398,7 @@ end:
|
||||||
r += p.get_raw_item(true);
|
r += p.get_raw_item(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res.set_str(ostd::move(r));
|
res.set_str(std::move(r));
|
||||||
});
|
});
|
||||||
|
|
||||||
gcs.new_command("listcount", "rse", [](auto &cs, auto args, auto &res) {
|
gcs.new_command("listcount", "rse", [](auto &cs, auto args, auto &res) {
|
||||||
|
@ -442,7 +442,7 @@ end:
|
||||||
buf.put(' ');
|
buf.put(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res.set_str(ostd::move(buf.get()));
|
res.set_str(std::move(buf.get()));
|
||||||
});
|
});
|
||||||
|
|
||||||
gcs.new_command("indexof", "ss", [](auto &cs, auto args, auto &res) {
|
gcs.new_command("indexof", "ss", [](auto &cs, auto args, auto &res) {
|
||||||
|
@ -504,7 +504,7 @@ end:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res.set_str(ostd::move(buf));
|
res.set_str(std::move(buf));
|
||||||
});
|
});
|
||||||
|
|
||||||
cs_init_lib_list_sort(gcs);
|
cs_init_lib_list_sort(gcs);
|
||||||
|
@ -613,7 +613,7 @@ static void cs_list_sort(
|
||||||
}
|
}
|
||||||
sorted += item.quote;
|
sorted += item.quote;
|
||||||
}
|
}
|
||||||
res.set_str(ostd::move(sorted));
|
res.set_str(std::move(sorted));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cs_init_lib_list_sort(CsState &gcs) {
|
static void cs_init_lib_list_sort(CsState &gcs) {
|
||||||
|
|
|
@ -58,7 +58,7 @@ void cs_init_lib_string(CsState &cs) {
|
||||||
for (auto i: ostd::range(s.size())) {
|
for (auto i: ostd::range(s.size())) {
|
||||||
s[i] = tolower(s[i]);
|
s[i] = tolower(s[i]);
|
||||||
}
|
}
|
||||||
res.set_str(ostd::move(s));
|
res.set_str(std::move(s));
|
||||||
});
|
});
|
||||||
|
|
||||||
cs.new_command("strupper", "s", [](auto &, auto args, auto &res) {
|
cs.new_command("strupper", "s", [](auto &, auto args, auto &res) {
|
||||||
|
@ -66,31 +66,31 @@ void cs_init_lib_string(CsState &cs) {
|
||||||
for (auto i: ostd::range(s.size())) {
|
for (auto i: ostd::range(s.size())) {
|
||||||
s[i] = toupper(s[i]);
|
s[i] = toupper(s[i]);
|
||||||
}
|
}
|
||||||
res.set_str(ostd::move(s));
|
res.set_str(std::move(s));
|
||||||
});
|
});
|
||||||
|
|
||||||
cs.new_command("escape", "s", [](auto &, auto args, auto &res) {
|
cs.new_command("escape", "s", [](auto &, auto args, auto &res) {
|
||||||
auto s = ostd::appender<CsString>();
|
auto s = ostd::appender<CsString>();
|
||||||
util::escape_string(s, args[0].get_strr());
|
util::escape_string(s, args[0].get_strr());
|
||||||
res.set_str(ostd::move(s.get()));
|
res.set_str(std::move(s.get()));
|
||||||
});
|
});
|
||||||
|
|
||||||
cs.new_command("unescape", "s", [](auto &, auto args, auto &res) {
|
cs.new_command("unescape", "s", [](auto &, auto args, auto &res) {
|
||||||
auto s = ostd::appender<CsString>();
|
auto s = ostd::appender<CsString>();
|
||||||
util::unescape_string(s, args[0].get_strr());
|
util::unescape_string(s, args[0].get_strr());
|
||||||
res.set_str(ostd::move(s.get()));
|
res.set_str(std::move(s.get()));
|
||||||
});
|
});
|
||||||
|
|
||||||
cs.new_command("concat", "V", [](auto &, auto args, auto &res) {
|
cs.new_command("concat", "V", [](auto &, auto args, auto &res) {
|
||||||
auto s = ostd::appender<CsString>();
|
auto s = ostd::appender<CsString>();
|
||||||
cscript::util::tvals_concat(s, args, " ");
|
cscript::util::tvals_concat(s, args, " ");
|
||||||
res.set_str(ostd::move(s.get()));
|
res.set_str(std::move(s.get()));
|
||||||
});
|
});
|
||||||
|
|
||||||
cs.new_command("concatword", "V", [](auto &, auto args, auto &res) {
|
cs.new_command("concatword", "V", [](auto &, auto args, auto &res) {
|
||||||
auto s = ostd::appender<CsString>();
|
auto s = ostd::appender<CsString>();
|
||||||
cscript::util::tvals_concat(s, args);
|
cscript::util::tvals_concat(s, args);
|
||||||
res.set_str(ostd::move(s.get()));
|
res.set_str(std::move(s.get()));
|
||||||
});
|
});
|
||||||
|
|
||||||
cs.new_command("format", "V", [](auto &, auto args, auto &res) {
|
cs.new_command("format", "V", [](auto &, auto args, auto &res) {
|
||||||
|
@ -118,7 +118,7 @@ void cs_init_lib_string(CsState &cs) {
|
||||||
s += c;
|
s += c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res.set_str(ostd::move(s));
|
res.set_str(std::move(s));
|
||||||
});
|
});
|
||||||
|
|
||||||
cs.new_command("tohex", "ii", [](auto &, auto args, auto &res) {
|
cs.new_command("tohex", "ii", [](auto &, auto args, auto &res) {
|
||||||
|
@ -127,7 +127,7 @@ void cs_init_lib_string(CsState &cs) {
|
||||||
r, "0x%.*X", ostd::max(args[1].get_int(), CsInt(1)),
|
r, "0x%.*X", ostd::max(args[1].get_int(), CsInt(1)),
|
||||||
args[0].get_int()
|
args[0].get_int()
|
||||||
);
|
);
|
||||||
res.set_str(ostd::move(r.get()));
|
res.set_str(std::move(r.get()));
|
||||||
});
|
});
|
||||||
|
|
||||||
cs.new_command("substr", "siiN", [](auto &, auto args, auto &res) {
|
cs.new_command("substr", "siiN", [](auto &, auto args, auto &res) {
|
||||||
|
@ -193,7 +193,7 @@ void cs_init_lib_string(CsState &cs) {
|
||||||
s = found + oldval.size();
|
s = found + oldval.size();
|
||||||
} else {
|
} else {
|
||||||
buf += s;
|
buf += s;
|
||||||
res.set_str(ostd::move(buf));
|
res.set_str(std::move(buf));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ void cs_init_lib_string(CsState &cs) {
|
||||||
if ((offset + len) < CsInt(s.size())) {
|
if ((offset + len) < CsInt(s.size())) {
|
||||||
p += s.slice(offset + len, s.size());
|
p += s.slice(offset + len, s.size());
|
||||||
}
|
}
|
||||||
res.set_str(ostd::move(p));
|
res.set_str(std::move(p));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ static ostd::Maybe<ostd::String> read_line(CsState &, CsSvar *pr) {
|
||||||
for (char c = ostd::in.getchar(); c && (c != '\n'); c = ostd::in.getchar()) {
|
for (char c = ostd::in.getchar(); c && (c != '\n'); c = ostd::in.getchar()) {
|
||||||
ret += c;
|
ret += c;
|
||||||
}
|
}
|
||||||
return ostd::move(ret);
|
return std::move(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_history(CsState &, ostd::ConstCharRange) {
|
static void add_history(CsState &, ostd::ConstCharRange) {
|
||||||
|
|
|
@ -71,7 +71,7 @@ static ostd::Maybe<ostd::String> read_line(CsState &, CsSvar *pr) {
|
||||||
}
|
}
|
||||||
ostd::String ret = line;
|
ostd::String ret = line;
|
||||||
linenoiseFree(line);
|
linenoiseFree(line);
|
||||||
return ostd::move(ret);
|
return std::move(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_history(CsState &, ostd::ConstCharRange line) {
|
static void add_history(CsState &, ostd::ConstCharRange line) {
|
||||||
|
|
|
@ -75,7 +75,7 @@ static ostd::Maybe<ostd::String> read_line(CsState &, CsSvar *pr) {
|
||||||
}
|
}
|
||||||
ostd::String ret = line;
|
ostd::String ret = line;
|
||||||
free(line);
|
free(line);
|
||||||
return ostd::move(ret);
|
return std::move(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_history(CsState &, ostd::ConstCharRange line) {
|
static void add_history(CsState &, ostd::ConstCharRange line) {
|
||||||
|
|
|
@ -243,7 +243,7 @@ static void do_tty(CsState &cs) {
|
||||||
if (!line) {
|
if (!line) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto lv = ostd::move(line.value());
|
auto lv = std::move(line.value());
|
||||||
if (lv.empty()) {
|
if (lv.empty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue