mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
ddbee25a3b
commit
347e748bdd
6 changed files with 56 additions and 1 deletions
14
ext/-test-/class/class2name.c
Normal file
14
ext/-test-/class/class2name.c
Normal file
|
|
@ -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);
|
||||
}
|
||||
7
ext/-test-/class/extconf.rb
Normal file
7
ext/-test-/class/extconf.rb
Normal file
|
|
@ -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")
|
||||
11
ext/-test-/class/init.c
Normal file
11
ext/-test-/class/init.c
Normal file
|
|
@ -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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue