diff options
Diffstat (limited to 'ext/-test-')
-rw-r--r-- | ext/-test-/class/class2name.c | 14 | ||||
-rw-r--r-- | ext/-test-/class/extconf.rb | 7 | ||||
-rw-r--r-- | ext/-test-/class/init.c | 11 |
3 files changed, 32 insertions, 0 deletions
diff --git a/ext/-test-/class/class2name.c b/ext/-test-/class/class2name.c new file mode 100644 index 0000000000..c48df6fb2a --- /dev/null +++ b/ext/-test-/class/class2name.c @@ -0,0 +1,14 @@ +#include <ruby/ruby.h> + +static VALUE +class2name(VALUE self, VALUE klass) +{ + const char *name = rb_class2name(klass); + return name ? rb_str_new_cstr(name) : Qnil; +} + +void +Init_class2name(VALUE klass) +{ + rb_define_singleton_method(klass, "class2name", class2name, 1); +} diff --git a/ext/-test-/class/extconf.rb b/ext/-test-/class/extconf.rb new file mode 100644 index 0000000000..a07d660b87 --- /dev/null +++ b/ext/-test-/class/extconf.rb @@ -0,0 +1,7 @@ +$INCFLAGS << " -I$(topdir) -I$(top_srcdir)" +$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-/class") diff --git a/ext/-test-/class/init.c b/ext/-test-/class/init.c new file mode 100644 index 0000000000..ed715c1942 --- /dev/null +++ b/ext/-test-/class/init.c @@ -0,0 +1,11 @@ +#include "ruby.h" + +#define init(n) {void Init_##n(VALUE mod); Init_##n(mod);} + +void +Init_class(void) +{ + VALUE mBug = rb_define_module("Bug"); + VALUE mod = rb_define_module_under(mBug, "Class"); + TEST_INIT_FUNCS(init); +} |