diff options
| author | Yukihiro Matsumoto <[email protected]> | 2012-06-03 08:20:48 +0900 |
|---|---|---|
| committer | Yukihiro Matsumoto <[email protected]> | 2012-06-03 08:20:48 +0900 |
| commit | df80b7835a5d99e2f5a25446abb53ea3e68e7709 (patch) | |
| tree | 93de7d66f45975293e160dd99ca5b0a550a426e1 /src | |
| parent | 12d75223d62ed90f334980c3a15e96618250fe90 (diff) | |
| download | mruby-df80b7835a5d99e2f5a25446abb53ea3e68e7709.tar.gz mruby-df80b7835a5d99e2f5a25446abb53ea3e68e7709.zip | |
Add Class#superclass; a patch made by @bovi; close #234
Diffstat (limited to 'src')
| -rw-r--r-- | src/class.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/class.c b/src/class.c index 544f36527..748996e62 100644 --- a/src/class.c +++ b/src/class.c @@ -819,6 +819,15 @@ mrb_class_new_class(mrb_state *mrb, mrb_value cv) return mrb_obj_value(new_class); } +mrb_value +mrb_class_superclass(mrb_state *mrb, mrb_value klass) +{ + struct RClass *c, *s; + c = mrb_class_ptr(klass); + s = c->super; + return mrb_obj_value(s); +} + static mrb_value mrb_bob_init(mrb_state *mrb, mrb_value cv) { @@ -1240,6 +1249,7 @@ mrb_init_class(mrb_state *mrb) mrb_define_method(mrb, bob, "!", mrb_bob_not, ARGS_NONE()); mrb_define_method(mrb, bob, "method_missing", mrb_bob_missing, ARGS_ANY()); /* 15.3.1.3.30 */ mrb_define_class_method(mrb, cls, "new", mrb_class_new_class, ARGS_ANY()); + mrb_define_method(mrb, cls, "superclass", mrb_class_superclass, ARGS_NONE()); mrb_define_method(mrb, cls, "new", mrb_instance_new, ARGS_ANY()); mrb_define_method(mrb, cls, "inherited", mrb_bob_init, ARGS_REQ(1)); mrb_define_method(mrb, mod, "include", mrb_mod_include, ARGS_REQ(1)); |
