diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-06-20 12:49:46 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-06-20 12:49:46 +0900 |
| commit | 49ae2a69f2c3acbb952406768320401cf1769425 (patch) | |
| tree | fd0b49d898327a1de29e143fb2c68e6991cf710d /mrbgems/mruby-struct | |
| parent | 2ffb77586a8ce6f325d2981e2ad88cc9e62ae39b (diff) | |
| download | mruby-49ae2a69f2c3acbb952406768320401cf1769425.tar.gz mruby-49ae2a69f2c3acbb952406768320401cf1769425.zip | |
Add `mrb_get_arg1()` that retrieves single (and only) argument.
`mrb_get_arg1()` raises `ArgumentError` if the method does not receive one
argument.
And replaces all `mrb_get_args(mrb, "o", &arg)` by the new function.
Diffstat (limited to 'mrbgems/mruby-struct')
| -rw-r--r-- | mrbgems/mruby-struct/src/struct.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/mrbgems/mruby-struct/src/struct.c b/mrbgems/mruby-struct/src/struct.c index f42a5f1ea..7fbf9225f 100644 --- a/mrbgems/mruby-struct/src/struct.c +++ b/mrbgems/mruby-struct/src/struct.c @@ -154,9 +154,8 @@ mrb_struct_set_m(mrb_state *mrb, mrb_value obj) { mrb_int i = mrb_fixnum(mrb_proc_cfunc_env_get(mrb, 0)); mrb_value *ptr; - mrb_value val; + mrb_value val = mrb_get_arg1(mrb); - mrb_get_args(mrb, "o", &val); mrb_struct_modify(mrb, obj); ptr = RSTRUCT_PTR(obj); if (ptr == NULL || i >= RSTRUCT_LEN(obj)) { @@ -356,9 +355,7 @@ mrb_struct_initialize(mrb_state *mrb, mrb_value self) static mrb_value mrb_struct_init_copy(mrb_state *mrb, mrb_value copy) { - mrb_value s; - - mrb_get_args(mrb, "o", &s); + mrb_value s = mrb_get_arg1(mrb); if (mrb_obj_equal(mrb, copy, s)) return copy; if (!mrb_obj_is_instance_of(mrb, s, mrb_obj_class(mrb, copy))) { @@ -428,9 +425,8 @@ struct_aref_int(mrb_state *mrb, mrb_value s, mrb_int i) static mrb_value mrb_struct_aref(mrb_state *mrb, mrb_value s) { - mrb_value idx; + mrb_value idx = mrb_get_arg1(mrb); - mrb_get_args(mrb, "o", &idx); if (mrb_string_p(idx)) { mrb_value sym = mrb_check_intern_str(mrb, idx); @@ -545,11 +541,10 @@ mrb_struct_aset(mrb_state *mrb, mrb_value s) static mrb_value mrb_struct_equal(mrb_state *mrb, mrb_value s) { - mrb_value s2; + mrb_value s2 = mrb_get_arg1(mrb); mrb_value *ptr, *ptr2; mrb_int i, len; - mrb_get_args(mrb, "o", &s2); if (mrb_obj_equal(mrb, s, s2)) { return mrb_true_value(); } @@ -582,11 +577,10 @@ mrb_struct_equal(mrb_state *mrb, mrb_value s) static mrb_value mrb_struct_eql(mrb_state *mrb, mrb_value s) { - mrb_value s2; + mrb_value s2 = mrb_get_arg1(mrb); mrb_value *ptr, *ptr2; mrb_int i, len; - mrb_get_args(mrb, "o", &s2); if (mrb_obj_equal(mrb, s, s2)) { return mrb_true_value(); } |
