rename N in arglist to #
parent
da7548664c
commit
e52720ebb2
|
@ -301,7 +301,7 @@ struct LIBCUBESCRIPT_EXPORT state {
|
||||||
* * `b` - bytecode/block
|
* * `b` - bytecode/block
|
||||||
* * `c` - condition (see below)
|
* * `c` - condition (see below)
|
||||||
* * `r` - ident
|
* * `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)
|
* * `$` - self ident (the command, except for special hooks)
|
||||||
*
|
*
|
||||||
* For condition types, the type of the value is generally kept as is,
|
* 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
|
* printing or setting them using syntax `varname optional_vals` or using
|
||||||
* `varname = value`. Their type signature must always start with `$`
|
* `varname = value`. Their type signature must always start with `$`
|
||||||
* and can be followed by any user types, generally you will also want
|
* 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.
|
* passed.
|
||||||
*
|
*
|
||||||
* This way you can have custom handlers for printing as well as custom
|
* 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
|
* 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
|
* 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,
|
* value using a format you want. When using the `=` assignment syntax,
|
||||||
* one value is passed.
|
* one value is passed.
|
||||||
*
|
*
|
||||||
|
|
|
@ -539,7 +539,7 @@ lookup_id:
|
||||||
gs.gen_val_ident(id);
|
gs.gen_val_ident(id);
|
||||||
++numargs;
|
++numargs;
|
||||||
break;
|
break;
|
||||||
case 'N':
|
case '#':
|
||||||
gs.gen_val_integer(-1);
|
gs.gen_val_integer(-1);
|
||||||
++numargs;
|
++numargs;
|
||||||
break;
|
break;
|
||||||
|
@ -990,7 +990,7 @@ bool parser_state::parse_call_command(
|
||||||
gs.gen_val_ident(self);
|
gs.gen_val_ident(self);
|
||||||
++numargs;
|
++numargs;
|
||||||
break;
|
break;
|
||||||
case 'N': /* number of arguments */
|
case '#': /* number of arguments */
|
||||||
gs.gen_val_integer(numargs - fakeargs);
|
gs.gen_val_integer(numargs - fakeargs);
|
||||||
++numargs;
|
++numargs;
|
||||||
break;
|
break;
|
||||||
|
@ -1271,7 +1271,7 @@ static bool parse_assign_var(
|
||||||
ps.gs.gen_val_ident(var);
|
ps.gs.gen_val_ident(var);
|
||||||
++nargs;
|
++nargs;
|
||||||
break;
|
break;
|
||||||
case 'N':
|
case '#':
|
||||||
ps.gs.gen_val_integer(nargs);
|
ps.gs.gen_val_integer(nargs);
|
||||||
++nargs;
|
++nargs;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -121,7 +121,7 @@ state::state(alloc_func func, void *data) {
|
||||||
|
|
||||||
/* default handlers for variables */
|
/* 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 &cs, auto args, auto &
|
||||||
) {
|
) {
|
||||||
auto &iv = static_cast<integer_var &>(args[0].get_ident(cs));
|
auto &iv = static_cast<integer_var &>(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 &cs, auto args, auto &
|
||||||
) {
|
) {
|
||||||
auto &fv = static_cast<float_var &>(args[0].get_ident(cs));
|
auto &fv = static_cast<float_var &>(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 &cs, auto args, auto &
|
||||||
) {
|
) {
|
||||||
auto &sv = static_cast<string_var &>(args[0].get_ident(cs));
|
auto &sv = static_cast<string_var &>(args[0].get_ident(cs));
|
||||||
|
@ -599,7 +599,7 @@ LIBCUBESCRIPT_EXPORT command &state::new_command(
|
||||||
case 'f':
|
case 'f':
|
||||||
case 'a':
|
case 'a':
|
||||||
case 'c':
|
case 'c':
|
||||||
case 'N':
|
case '#':
|
||||||
case 's':
|
case 's':
|
||||||
case 'b':
|
case 'b':
|
||||||
case 'r':
|
case 'r':
|
||||||
|
|
|
@ -108,7 +108,7 @@ void exec_command(
|
||||||
i += 1;
|
i += 1;
|
||||||
args[i].set_ident(*self);
|
args[i].set_ident(*self);
|
||||||
break;
|
break;
|
||||||
case 'N':
|
case '#':
|
||||||
i += 1;
|
i += 1;
|
||||||
args[i].set_integer(integer_type(lookup ? -1 : i - fakeargs));
|
args[i].set_integer(integer_type(lookup ? -1 : i - fakeargs));
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -172,7 +172,7 @@ LIBCUBESCRIPT_EXPORT void std_init_list(state &gcs) {
|
||||||
res.set_string(p.get_item());
|
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(),
|
integer_type skip = args[1].get_integer(),
|
||||||
count = args[2].get_integer(),
|
count = args[2].get_integer(),
|
||||||
numargs = args[3].get_integer();
|
numargs = args[3].get_integer();
|
||||||
|
|
|
@ -152,7 +152,7 @@ LIBCUBESCRIPT_EXPORT void std_init_string(state &cs) {
|
||||||
throw internal_error{"format error"};
|
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);
|
std::string_view s = args[0].get_string(ccs);
|
||||||
auto start = args[1].get_integer(), count = args[2].get_integer();
|
auto start = args[1].get_integer(), count = args[2].get_integer();
|
||||||
auto numargs = args[3].get_integer();
|
auto numargs = args[3].get_integer();
|
||||||
|
|
|
@ -59,7 +59,7 @@ int main(int argc, char **argv) {
|
||||||
});
|
});
|
||||||
|
|
||||||
/* takes a string so we can print it */
|
/* 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];
|
auto val = args[0];
|
||||||
val.force_code(s);
|
val.force_code(s);
|
||||||
if (!s.run(val.get_code()).get_bool()) {
|
if (!s.run(val.get_code()).get_bool()) {
|
||||||
|
|
|
@ -322,7 +322,7 @@ int main(int argc, char **argv) {
|
||||||
* work equivalently - in this case we want to allow multiple values
|
* 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
|
* 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<cs::integer_var &>(args[0].get_ident(css));
|
auto &iv = static_cast<cs::integer_var &>(args[0].get_ident(css));
|
||||||
auto nargs = args[4].get_integer();
|
auto nargs = args[4].get_integer();
|
||||||
if (nargs <= 1) {
|
if (nargs <= 1) {
|
||||||
|
|
Loading…
Reference in New Issue