diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-07-19 07:45:16 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-07-19 07:45:16 +0900 |
| commit | d023adcb12191de7d8ae8144f100db46db887e1a (patch) | |
| tree | f54205fde31d9ee2ac0301f1ea4b4638d943df73 /src | |
| parent | 5b2763821e1be3709fd70d732ad1ed6c343f649f (diff) | |
| download | mruby-d023adcb12191de7d8ae8144f100db46db887e1a.tar.gz mruby-d023adcb12191de7d8ae8144f100db46db887e1a.zip | |
Add new specifier `c` to `mrb_get_args`.
`C` retrieves a `mrb_value` that refers a class/module.
`c` retrieves a `struct RClass*` pointer to a class/module.
Diffstat (limited to 'src')
| -rw-r--r-- | src/class.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/class.c b/src/class.c index 1a36c1333..30dc4c17a 100644 --- a/src/class.c +++ b/src/class.c @@ -587,6 +587,7 @@ void mrb_hash_check_kdict(mrb_state *mrb, mrb_value self); s: String [char*,mrb_int] Receive two arguments; s! gives (NULL,0) for nil z: String [char*] NUL terminated string; z! gives NULL for nil a: Array [mrb_value*,mrb_int] Receive two arguments; a! gives (NULL,0) for nil + c: Class/Module [strcut RClass*] f: Fixnum/Float [mrb_float] i: Fixnum/Float [mrb_int] b: boolean [mrb_bool] @@ -713,6 +714,22 @@ mrb_get_args(mrb_state *mrb, const char *format, ...) } } break; + case 'c': + { + struct RClass **p; + + p = va_arg(ap, struct RClass**); + if (i < argc) { + mrb_value ss; + + ss = argv[i++]; + if (!class_ptr_p(ss)) { + mrb_raisef(mrb, E_TYPE_ERROR, "%v is not class/module", ss); + } + *p = mrb_class_ptr(ss); + } + } + break; case 'S': { mrb_value *p; |
