From 52eb44e0bca14e9af89f3568026867d7bda9ce03 Mon Sep 17 00:00:00 2001 From: q66 Date: Fri, 2 Sep 2016 20:27:37 +0100 Subject: [PATCH] hide command members --- cs_vm.cc | 18 +++++++++++------- cubescript.cc | 2 +- cubescript.hh | 10 +++++++--- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/cs_vm.cc b/cs_vm.cc index 8e080609..4a7e94e0 100644 --- a/cs_vm.cc +++ b/cs_vm.cc @@ -75,7 +75,7 @@ static inline bool cs_has_cmd_cb(CsIdent *id) { return false; } CsCommand *cb = static_cast(id); - return !!cb->cb_cftv; + return !!cb->get_raw_cb(); } 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), " "); CsValue tv; tv.set_mstr(buf.get().iter()); - id->cb_cftv(CsValueRange(&tv, 1), res); + id->get_raw_cb()(CsValueRange(&tv, 1), res); goto cleanup; } case 'V': 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; case '1': case '2': @@ -502,7 +502,7 @@ static inline void callcommand( } } ++i; - id->cb_cftv(CsValueRange(args, i), res); + id->get_raw_cb()(CsValueRange(args, i), res); cleanup: for (ostd::Size k = 0; k < ostd::Size(i); ++k) { args[k].cleanup(); @@ -1384,7 +1384,7 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) { CsCommand *id = static_cast(cs.identmap[op >> 8]); int offset = numargs - id->get_num_args(); result.force_null(); - id->cb_cftv( + id->get_raw_cb()( CsValueRange(args + offset, id->get_num_args()), result ); 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(cs.identmap[op >> 13]); int callargs = (op >> 8) & 0x1F, offset = numargs - callargs; 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); free_args(args, numargs, offset); continue; @@ -1418,7 +1420,9 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) { ); CsValue tv; 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); free_args(args, numargs, offset); diff --git a/cubescript.cc b/cubescript.cc index 5f8e2bbd..42d36e0a 100644 --- a/cubescript.cc +++ b/cubescript.cc @@ -101,7 +101,7 @@ CsCommand::CsCommand( int nargs, CsCommandCb f ): 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 { diff --git a/cubescript.hh b/cubescript.hh index 7152844d..6a7af13e 100644 --- a/cubescript.hh +++ b/cubescript.hh @@ -304,15 +304,19 @@ struct CsCommand: CsIdent { return p_numargs; } - char *p_cargs; - int p_numargs; - CsCommandCb cb_cftv; + CsCommandCb &get_raw_cb() { + return p_cb_cftv; + } private: CsCommand( ostd::ConstCharRange name, ostd::ConstCharRange args, int numargs, CsCommandCb func ); + + char *p_cargs; + int p_numargs; + CsCommandCb p_cb_cftv; }; struct CsIdentLink {