mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Added MRB_API function to get block arguments info.
- ` mrb_block_given_p()` -- The name comes from CRuby's `rb_block_given_p ()` At the same time, it applies to `f_instance_eval()` and `f_class_eval()` of `mruby-eval`.
This commit is contained in:
committed by
Yukihiro "Matz" Matsumoto
parent
43eddfd4d5
commit
c40802865a
+11
@@ -859,6 +859,17 @@ mrb_get_arg1(mrb_state *mrb)
|
||||
return array_argv[0];
|
||||
}
|
||||
|
||||
MRB_API mrb_bool
|
||||
mrb_block_given_p(mrb_state *mrb)
|
||||
{
|
||||
const mrb_callinfo *ci = mrb->c->ci;
|
||||
int argc = ci->argc;
|
||||
int idx = (argc < 0) ? 2 : argc + 1;
|
||||
mrb_value b = ci->stack[idx];
|
||||
|
||||
return !mrb_nil_p(b);
|
||||
}
|
||||
|
||||
void mrb_hash_check_kdict(mrb_state *mrb, mrb_value self);
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user