summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-method
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-06-20 12:49:46 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2020-06-20 12:49:46 +0900
commit49ae2a69f2c3acbb952406768320401cf1769425 (patch)
treefd0b49d898327a1de29e143fb2c68e6991cf710d /mrbgems/mruby-method
parent2ffb77586a8ce6f325d2981e2ad88cc9e62ae39b (diff)
downloadmruby-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-method')
-rw-r--r--mrbgems/mruby-method/src/method.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/mrbgems/mruby-method/src/method.c b/mrbgems/mruby-method/src/method.c
index d249b463b..111b031b9 100644
--- a/mrbgems/mruby-method/src/method.c
+++ b/mrbgems/mruby-method/src/method.c
@@ -33,9 +33,8 @@ unbound_method_bind(mrb_state *mrb, mrb_value self)
mrb_value name = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "_name"));
mrb_value proc = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "_proc"));
mrb_value klass = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "_klass"));
- mrb_value recv;
+ mrb_value recv = mrb_get_arg1(mrb);
- mrb_get_args(mrb, "o", &recv);
bind_check(mrb, recv, owner);
me = method_object_alloc(mrb, mrb_class_get(mrb, "Method"));
mrb_obj_iv_set(mrb, me, mrb_intern_lit(mrb, "_owner"), owner);
@@ -51,11 +50,11 @@ unbound_method_bind(mrb_state *mrb, mrb_value self)
static mrb_value
method_eql(mrb_state *mrb, mrb_value self)
{
- mrb_value other, receiver, orig_proc, other_proc;
+ mrb_value other = mrb_get_arg1(mrb);
+ mrb_value receiver, orig_proc, other_proc;
struct RClass *owner, *klass;
struct RProc *orig_rproc, *other_rproc;
- mrb_get_args(mrb, "o", &other);
if (!mrb_obj_is_instance_of(mrb, other, mrb_class(mrb, self)))
return mrb_false_value();