diff options
| author | take_cheeze <[email protected]> | 2014-07-13 20:46:50 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2016-11-13 16:17:36 +0900 |
| commit | 451985d44be9078660bcb43e4c7d91b3398230a4 (patch) | |
| tree | 134ac4eb1ca745a24f3b42993c1e415d250a41da /mrbgems/mruby-module-ext/src/module.c | |
| parent | 88604e39ac9c25ffdad2e3f03be26516fe866038 (diff) | |
| download | mruby-451985d44be9078660bcb43e4c7d91b3398230a4.tar.gz mruby-451985d44be9078660bcb43e4c7d91b3398230a4.zip | |
Implement Module#name.
Solves #2132.
Diffstat (limited to 'mrbgems/mruby-module-ext/src/module.c')
| -rw-r--r-- | mrbgems/mruby-module-ext/src/module.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/mrbgems/mruby-module-ext/src/module.c b/mrbgems/mruby-module-ext/src/module.c new file mode 100644 index 000000000..74bece800 --- /dev/null +++ b/mrbgems/mruby-module-ext/src/module.c @@ -0,0 +1,23 @@ +#include "mruby.h" +#include "mruby/class.h" +#include "mruby/string.h" + +static mrb_value +mrb_mod_name(mrb_state *mrb, mrb_value self) +{ + mrb_value name = mrb_class_path(mrb, mrb_class_ptr(self)); + return mrb_nil_p(name)? name : mrb_str_dup(mrb, name); +} + +void +mrb_mruby_module_ext_gem_init(mrb_state *mrb) +{ + struct RClass *mod = mrb->module_class; + + mrb_define_method(mrb, mod, "name", mrb_mod_name, MRB_ARGS_NONE()); +} + +void +mrb_mruby_module_ext_gem_final(mrb_state *mrb) +{ +} |
