summaryrefslogtreecommitdiff
path: root/ext/-test-/method/arity.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-29 07:49:22 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-29 07:49:22 +0000
commitb0c4ac77799fdf60a489f9e735158647c630865a (patch)
tree9ce10d018542a7dc056975f659fa064ce0c1c9e8 /ext/-test-/method/arity.c
parent2d55537dce5fde5e3581351bd274ecabf1e284d7 (diff)
proc.c: original arity
* proc.c (rb_mod_method_arity): return original arity of the method if aliased because of visibility change, like as Method#arity. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/-test-/method/arity.c')
-rw-r--r--ext/-test-/method/arity.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/ext/-test-/method/arity.c b/ext/-test-/method/arity.c
new file mode 100644
index 0000000..239b9f7
--- /dev/null
+++ b/ext/-test-/method/arity.c
@@ -0,0 +1,22 @@
+#include "ruby.h"
+
+static VALUE
+obj_method_arity(VALUE self, VALUE obj, VALUE mid)
+{
+ int arity = rb_obj_method_arity(obj, rb_check_id(&mid));
+ return INT2FIX(arity);
+}
+
+static VALUE
+mod_method_arity(VALUE self, VALUE mod, VALUE mid)
+{
+ int arity = rb_mod_method_arity(mod, rb_check_id(&mid));
+ return INT2FIX(arity);
+}
+
+void
+Init_arity(VALUE mod)
+{
+ rb_define_module_function(mod, "obj_method_arity", obj_method_arity, 2);
+ rb_define_module_function(mod, "mod_method_arity", mod_method_arity, 2);
+}