Browse Source

use overloads for new var methods

master
Daniel Kolesa 3 weeks ago
parent
commit
8207ef0ce3
3 changed files with 10 additions and 10 deletions
  1. +3
    -3
      include/cubescript/cubescript/state.hh
  2. +5
    -5
      src/cs_state.cc
  3. +2
    -2
      tools/repl.cc

+ 3
- 3
include/cubescript/cubescript/state.hh View File

@ -52,15 +52,15 @@ struct LIBCUBESCRIPT_EXPORT state {
void clear_override(ident &id);
void clear_overrides();
integer_var &new_ivar(
integer_var &new_var(
std::string_view n, integer_type v, bool read_only = false,
var_type vtp = var_type::DEFAULT
);
float_var &new_fvar(
float_var &new_var(
std::string_view n, float_type v, bool read_only = false,
var_type vtp = var_type::DEFAULT
);
string_var &new_svar(
string_var &new_var(
std::string_view n, std::string_view v, bool read_only = false,
var_type vtp = var_type::DEFAULT
);


+ 5
- 5
src/cs_state.cc View File

@ -116,8 +116,8 @@ state::state(alloc_func func, void *data) {
statep->id_dummy = &statep->new_ident(*this, "//dummy", IDENT_FLAG_UNKNOWN);
statep->ivar_numargs = &new_ivar("numargs", 0, true);
statep->ivar_dbgalias = &new_ivar("dbgalias", 4);
statep->ivar_numargs = &new_var("numargs", 0, true);
statep->ivar_dbgalias = &new_var("dbgalias", 4);
/* default handlers for variables */
@ -426,7 +426,7 @@ static void var_name_check(
}
}
LIBCUBESCRIPT_EXPORT integer_var &state::new_ivar(
LIBCUBESCRIPT_EXPORT integer_var &state::new_var(
std::string_view n, integer_type v, bool read_only, var_type vtp
) {
auto *iv = p_tstate->istate->create<ivar_impl>(
@ -442,7 +442,7 @@ LIBCUBESCRIPT_EXPORT integer_var &state::new_ivar(
return *iv;
}
LIBCUBESCRIPT_EXPORT float_var &state::new_fvar(
LIBCUBESCRIPT_EXPORT float_var &state::new_var(
std::string_view n, float_type v, bool read_only, var_type vtp
) {
auto *fv = p_tstate->istate->create<fvar_impl>(
@ -458,7 +458,7 @@ LIBCUBESCRIPT_EXPORT float_var &state::new_fvar(
return *fv;
}
LIBCUBESCRIPT_EXPORT string_var &state::new_svar(
LIBCUBESCRIPT_EXPORT string_var &state::new_var(
std::string_view n, std::string_view v, bool read_only, var_type vtp
) {
auto *sv = p_tstate->istate->create<svar_impl>(


+ 2
- 2
tools/repl.cc View File

@ -277,8 +277,8 @@ static bool do_call(cs::state &cs, std::string_view line, bool file = false) {
}
static void do_tty(cs::state &cs) {
auto &prompt = cs.new_svar("PROMPT", "> ");
auto &prompt2 = cs.new_svar("PROMPT2", ">> ");
auto &prompt = cs.new_var("PROMPT", "> ");
auto &prompt2 = cs.new_var("PROMPT2", ">> ");
bool do_exit = false;
cs.new_command("quit", "", [&do_exit](auto &, auto, auto &) {


Loading…
Cancel
Save