summaryrefslogtreecommitdiff
path: root/ext/-test-
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-19 20:24:30 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-19 20:24:30 +0000
commit347e748bddd42e5a39dcb5c55ac37704a14b9374 (patch)
tree33aa9f1624bf85f20fb49336e24bd5ee279f7545 /ext/-test-
parentddbee25a3b6c9385880c29efe936906646b58ca4 (diff)
variable.c: real class name
* variable.c (rb_class2name): should return real class name, not singleton class or iclass. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43367 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/-test-')
-rw-r--r--ext/-test-/class/class2name.c14
-rw-r--r--ext/-test-/class/extconf.rb7
-rw-r--r--ext/-test-/class/init.c11
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 0000000..c48df6f
--- /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 0000000..a07d660
--- /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 0000000..ed715c1
--- /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);
+}