From e52720ebb2423c3a3f3b0b20307e83f6b0687452 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Thu, 29 Apr 2021 04:15:16 +0200 Subject: [PATCH] rename N in arglist to # --- include/cubescript/cubescript/state.hh | 6 +++--- src/cs_parser.cc | 6 +++--- src/cs_state.cc | 8 ++++---- src/cs_vm.cc | 2 +- src/lib_list.cc | 2 +- src/lib_str.cc | 2 +- tests/runner.cc | 2 +- tools/repl.cc | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/cubescript/cubescript/state.hh b/include/cubescript/cubescript/state.hh index cd3c310..5646e5d 100644 --- a/include/cubescript/cubescript/state.hh +++ b/include/cubescript/cubescript/state.hh @@ -301,7 +301,7 @@ struct LIBCUBESCRIPT_EXPORT state { * * `b` - bytecode/block * * `c` - condition (see below) * * `r` - ident - * * `N` - number of real arguments passed up until now + * * `#` - number of real arguments passed up until now * * `$` - self ident (the command, except for special hooks) * * For condition types, the type of the value is generally kept as is, @@ -342,13 +342,13 @@ struct LIBCUBESCRIPT_EXPORT state { * printing or setting them using syntax `varname optional_vals` or using * `varname = value`. Their type signature must always start with `$` * and can be followed by any user types, generally you will also want - * to terminate the list with `N` to find out whether any values were + * to terminate the list with `#` to find out whether any values were * passed. * * This way you can have custom handlers for printing as well as custom * syntaxes for setting (e.g. your custom integer var handler may want to * take up to 4 values to allow setting of RGBA color channels). When no - * arguments are passed (checked using `N`) you will want to print the + * arguments are passed (checked using `#`) you will want to print the * value using a format you want. When using the `=` assignment syntax, * one value is passed. * diff --git a/src/cs_parser.cc b/src/cs_parser.cc index 7871fb2..6119952 100644 --- a/src/cs_parser.cc +++ b/src/cs_parser.cc @@ -539,7 +539,7 @@ lookup_id: gs.gen_val_ident(id); ++numargs; break; - case 'N': + case '#': gs.gen_val_integer(-1); ++numargs; break; @@ -990,7 +990,7 @@ bool parser_state::parse_call_command( gs.gen_val_ident(self); ++numargs; break; - case 'N': /* number of arguments */ + case '#': /* number of arguments */ gs.gen_val_integer(numargs - fakeargs); ++numargs; break; @@ -1271,7 +1271,7 @@ static bool parse_assign_var( ps.gs.gen_val_ident(var); ++nargs; break; - case 'N': + case '#': ps.gs.gen_val_integer(nargs); ++nargs; break; diff --git a/src/cs_state.cc b/src/cs_state.cc index 2d8b4dc..86eab69 100644 --- a/src/cs_state.cc +++ b/src/cs_state.cc @@ -121,7 +121,7 @@ state::state(alloc_func func, void *data) { /* default handlers for variables */ - statep->cmd_ivar = &new_command("//ivar_builtin", "$iN", []( + statep->cmd_ivar = &new_command("//ivar_builtin", "$i#", []( auto &cs, auto args, auto & ) { auto &iv = static_cast(args[0].get_ident(cs)); @@ -134,7 +134,7 @@ state::state(alloc_func func, void *data) { } }); - statep->cmd_fvar = &new_command("//fvar_builtin", "$fN", []( + statep->cmd_fvar = &new_command("//fvar_builtin", "$f#", []( auto &cs, auto args, auto & ) { auto &fv = static_cast(args[0].get_ident(cs)); @@ -152,7 +152,7 @@ state::state(alloc_func func, void *data) { } }); - statep->cmd_svar = &new_command("//svar_builtin", "$sN", []( + statep->cmd_svar = &new_command("//svar_builtin", "$s#", []( auto &cs, auto args, auto & ) { auto &sv = static_cast(args[0].get_ident(cs)); @@ -599,7 +599,7 @@ LIBCUBESCRIPT_EXPORT command &state::new_command( case 'f': case 'a': case 'c': - case 'N': + case '#': case 's': case 'b': case 'r': diff --git a/src/cs_vm.cc b/src/cs_vm.cc index 2e38034..bb892b9 100644 --- a/src/cs_vm.cc +++ b/src/cs_vm.cc @@ -108,7 +108,7 @@ void exec_command( i += 1; args[i].set_ident(*self); break; - case 'N': + case '#': i += 1; args[i].set_integer(integer_type(lookup ? -1 : i - fakeargs)); break; diff --git a/src/lib_list.cc b/src/lib_list.cc index 64ea906..9e8ac2a 100644 --- a/src/lib_list.cc +++ b/src/lib_list.cc @@ -172,7 +172,7 @@ LIBCUBESCRIPT_EXPORT void std_init_list(state &gcs) { res.set_string(p.get_item()); }); - new_cmd_quiet(gcs, "sublist", "siiN", [](auto &cs, auto args, auto &res) { + new_cmd_quiet(gcs, "sublist", "sii#", [](auto &cs, auto args, auto &res) { integer_type skip = args[1].get_integer(), count = args[2].get_integer(), numargs = args[3].get_integer(); diff --git a/src/lib_str.cc b/src/lib_str.cc index 1fc349e..4e1beaf 100644 --- a/src/lib_str.cc +++ b/src/lib_str.cc @@ -152,7 +152,7 @@ LIBCUBESCRIPT_EXPORT void std_init_string(state &cs) { throw internal_error{"format error"}; }); - new_cmd_quiet(cs, "substr", "siiN", [](auto &ccs, auto args, auto &res) { + new_cmd_quiet(cs, "substr", "sii#", [](auto &ccs, auto args, auto &res) { std::string_view s = args[0].get_string(ccs); auto start = args[1].get_integer(), count = args[2].get_integer(); auto numargs = args[3].get_integer(); diff --git a/tests/runner.cc b/tests/runner.cc index 62e1741..0bced93 100644 --- a/tests/runner.cc +++ b/tests/runner.cc @@ -59,7 +59,7 @@ int main(int argc, char **argv) { }); /* takes a string so we can print it */ - gcs.new_command("assert", "ssN", [](auto &s, auto args, auto &ret) { + gcs.new_command("assert", "ss#", [](auto &s, auto args, auto &ret) { auto val = args[0]; val.force_code(s); if (!s.run(val.get_code()).get_bool()) { diff --git a/tools/repl.cc b/tools/repl.cc index e53bd1a..10e14ce 100644 --- a/tools/repl.cc +++ b/tools/repl.cc @@ -322,7 +322,7 @@ int main(int argc, char **argv) { * work equivalently - in this case we want to allow multiple values * to be set, but you may also not be using standard i/o and so on */ - gcs.new_command("//ivar", "$iiiN", [](auto &css, auto args, auto &) { + gcs.new_command("//ivar", "$iii#", [](auto &css, auto args, auto &) { auto &iv = static_cast(args[0].get_ident(css)); auto nargs = args[4].get_integer(); if (nargs <= 1) {