diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/-test-/method/arity.c | 22 | ||||
-rw-r--r-- | ext/-test-/method/extconf.rb | 6 | ||||
-rw-r--r-- | ext/-test-/method/init.c | 11 |
3 files changed, 39 insertions, 0 deletions
diff --git a/ext/-test-/method/arity.c b/ext/-test-/method/arity.c new file mode 100644 index 0000000000..239b9f7f10 --- /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); +} diff --git a/ext/-test-/method/extconf.rb b/ext/-test-/method/extconf.rb new file mode 100644 index 0000000000..658b7af1f1 --- /dev/null +++ b/ext/-test-/method/extconf.rb @@ -0,0 +1,6 @@ +$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")] +inits = $srcs.map {|s| File.basename(s, ".*")} +inits.delete("init") +inits.map! {|s|"X(#{s})"} +$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\"" +create_makefile("-test-/method") diff --git a/ext/-test-/method/init.c b/ext/-test-/method/init.c new file mode 100644 index 0000000000..cea2346240 --- /dev/null +++ b/ext/-test-/method/init.c @@ -0,0 +1,11 @@ +#include "ruby.h" + +#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);} + +void +Init_method(void) +{ + VALUE mBug = rb_define_module("Bug"); + VALUE klass = rb_define_module_under(mBug, "Method"); + TEST_INIT_FUNCS(init); +} |