forked from OctaForge/libcubescript
hide command members
This commit is contained in:
parent
bb4c34a3fb
commit
52eb44e0bc
18
cs_vm.cc
18
cs_vm.cc
|
@ -75,7 +75,7 @@ static inline bool cs_has_cmd_cb(CsIdent *id) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CsCommand *cb = static_cast<CsCommand *>(id);
|
CsCommand *cb = static_cast<CsCommand *>(id);
|
||||||
return !!cb->cb_cftv;
|
return !!cb->get_raw_cb();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void cs_push_alias(CsIdent *id, CsIdentStack &st) {
|
static inline void cs_push_alias(CsIdent *id, CsIdentStack &st) {
|
||||||
|
@ -483,12 +483,12 @@ static inline void callcommand(
|
||||||
cscript::util::tvals_concat(buf, ostd::iter(args, i), " ");
|
cscript::util::tvals_concat(buf, ostd::iter(args, i), " ");
|
||||||
CsValue tv;
|
CsValue tv;
|
||||||
tv.set_mstr(buf.get().iter());
|
tv.set_mstr(buf.get().iter());
|
||||||
id->cb_cftv(CsValueRange(&tv, 1), res);
|
id->get_raw_cb()(CsValueRange(&tv, 1), res);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
case 'V':
|
case 'V':
|
||||||
i = ostd::max(i + 1, numargs);
|
i = ostd::max(i + 1, numargs);
|
||||||
id->cb_cftv(ostd::iter(args, i), res);
|
id->get_raw_cb()(ostd::iter(args, i), res);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
case '1':
|
case '1':
|
||||||
case '2':
|
case '2':
|
||||||
|
@ -502,7 +502,7 @@ static inline void callcommand(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
id->cb_cftv(CsValueRange(args, i), res);
|
id->get_raw_cb()(CsValueRange(args, i), res);
|
||||||
cleanup:
|
cleanup:
|
||||||
for (ostd::Size k = 0; k < ostd::Size(i); ++k) {
|
for (ostd::Size k = 0; k < ostd::Size(i); ++k) {
|
||||||
args[k].cleanup();
|
args[k].cleanup();
|
||||||
|
@ -1384,7 +1384,7 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) {
|
||||||
CsCommand *id = static_cast<CsCommand *>(cs.identmap[op >> 8]);
|
CsCommand *id = static_cast<CsCommand *>(cs.identmap[op >> 8]);
|
||||||
int offset = numargs - id->get_num_args();
|
int offset = numargs - id->get_num_args();
|
||||||
result.force_null();
|
result.force_null();
|
||||||
id->cb_cftv(
|
id->get_raw_cb()(
|
||||||
CsValueRange(args + offset, id->get_num_args()), result
|
CsValueRange(args + offset, id->get_num_args()), result
|
||||||
);
|
);
|
||||||
force_arg(result, op & CODE_RET_MASK);
|
force_arg(result, op & CODE_RET_MASK);
|
||||||
|
@ -1399,7 +1399,9 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) {
|
||||||
CsCommand *id = static_cast<CsCommand *>(cs.identmap[op >> 13]);
|
CsCommand *id = static_cast<CsCommand *>(cs.identmap[op >> 13]);
|
||||||
int callargs = (op >> 8) & 0x1F, offset = numargs - callargs;
|
int callargs = (op >> 8) & 0x1F, offset = numargs - callargs;
|
||||||
result.force_null();
|
result.force_null();
|
||||||
id->cb_cftv(ostd::iter(&args[offset], callargs), result);
|
id->get_raw_cb()(
|
||||||
|
ostd::iter(&args[offset], callargs), result
|
||||||
|
);
|
||||||
force_arg(result, op & CODE_RET_MASK);
|
force_arg(result, op & CODE_RET_MASK);
|
||||||
free_args(args, numargs, offset);
|
free_args(args, numargs, offset);
|
||||||
continue;
|
continue;
|
||||||
|
@ -1418,7 +1420,9 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) {
|
||||||
);
|
);
|
||||||
CsValue tv;
|
CsValue tv;
|
||||||
tv.set_mstr(buf.get().iter());
|
tv.set_mstr(buf.get().iter());
|
||||||
id->cb_cftv(CsValueRange(&tv, 1), result);
|
id->get_raw_cb()(
|
||||||
|
CsValueRange(&tv, 1), result
|
||||||
|
);
|
||||||
}
|
}
|
||||||
force_arg(result, op & CODE_RET_MASK);
|
force_arg(result, op & CODE_RET_MASK);
|
||||||
free_args(args, numargs, offset);
|
free_args(args, numargs, offset);
|
||||||
|
|
|
@ -101,7 +101,7 @@ CsCommand::CsCommand(
|
||||||
int nargs, CsCommandCb f
|
int nargs, CsCommandCb f
|
||||||
):
|
):
|
||||||
CsIdent(CsIdentType::command, name, 0),
|
CsIdent(CsIdentType::command, name, 0),
|
||||||
p_cargs(cs_dup_ostr(args)), p_numargs(nargs), cb_cftv(ostd::move(f))
|
p_cargs(cs_dup_ostr(args)), p_numargs(nargs), p_cb_cftv(ostd::move(f))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool CsIdent::is_alias() const {
|
bool CsIdent::is_alias() const {
|
||||||
|
|
|
@ -304,15 +304,19 @@ struct CsCommand: CsIdent {
|
||||||
return p_numargs;
|
return p_numargs;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *p_cargs;
|
CsCommandCb &get_raw_cb() {
|
||||||
int p_numargs;
|
return p_cb_cftv;
|
||||||
CsCommandCb cb_cftv;
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CsCommand(
|
CsCommand(
|
||||||
ostd::ConstCharRange name, ostd::ConstCharRange args,
|
ostd::ConstCharRange name, ostd::ConstCharRange args,
|
||||||
int numargs, CsCommandCb func
|
int numargs, CsCommandCb func
|
||||||
);
|
);
|
||||||
|
|
||||||
|
char *p_cargs;
|
||||||
|
int p_numargs;
|
||||||
|
CsCommandCb p_cb_cftv;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CsIdentLink {
|
struct CsIdentLink {
|
||||||
|
|
Loading…
Reference in a new issue