diff options
| author | dearblue <[email protected]> | 2018-03-04 22:23:47 +0900 |
|---|---|---|
| committer | dearblue <[email protected]> | 2018-03-04 22:23:47 +0900 |
| commit | 2ce6d23db628df3eef3a5bda0091768bccdbe9cd (patch) | |
| tree | 92158d41280e8c3eb6b49fece909564c25a53cf0 /src/class.c | |
| parent | 10f28fc82d497233a4d60b0b3e2800cb3a6e2e9c (diff) | |
| download | mruby-2ce6d23db628df3eef3a5bda0091768bccdbe9cd.tar.gz mruby-2ce6d23db628df3eef3a5bda0091768bccdbe9cd.zip | |
add forced block arguments feature to mrb_get_args
Diffstat (limited to 'src/class.c')
| -rw-r--r-- | src/class.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/class.c b/src/class.c index 3f24528ca..e0f8d4673 100644 --- a/src/class.c +++ b/src/class.c @@ -593,7 +593,7 @@ mrb_get_argv(mrb_state *mrb) n: Symbol [mrb_sym] d: Data [void*,mrb_data_type const] 2nd argument will be used to check data type so it won't be modified I: Inline struct [void*] - &: Block [mrb_value] + &: Block [mrb_value] when && gives raised exception if no block given *: rest argument [mrb_value*,mrb_int] The rest of the arguments as an array; *! avoid copy of the stack |: optional Following arguments are optional ?: optional given [mrb_bool] true if preceding argument (optional) is given @@ -937,6 +937,12 @@ mrb_get_args(mrb_state *mrb, const char *format, ...) else { bp = mrb->c->stack + mrb->c->ci->argc + 1; } + if (*format == '&') { + format ++; + if (mrb_nil_p(*bp)) { + mrb_raise(mrb, E_ARGUMENT_ERROR, "no block given"); + } + } *p = *bp; } break; |
