diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2016-11-11 08:24:52 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2016-11-11 08:24:52 +0900 |
| commit | 570cbbdf3d5197f77a19d2093964ce27c939e85e (patch) | |
| tree | cef4a43ef288dc930d30bcd85c4bd85ad49a9106 /include/mruby.h | |
| parent | 3f002b6993df9ea4843e2479d706e7426d57bb5a (diff) | |
| parent | 178816626d7f8cf4f60ae76764fbb977c1102a14 (diff) | |
| download | mruby-570cbbdf3d5197f77a19d2093964ce27c939e85e.tar.gz mruby-570cbbdf3d5197f77a19d2093964ce27c939e85e.zip | |
Merge pull request #3234 from AltimitSystems/mrb.class_under_defined
Add mrb_class_defined_under
Diffstat (limited to 'include/mruby.h')
| -rw-r--r-- | include/mruby.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/include/mruby.h b/include/mruby.h index 25514ee2c..1b227d41a 100644 --- a/include/mruby.h +++ b/include/mruby.h @@ -567,6 +567,37 @@ MRB_API mrb_bool mrb_class_defined(mrb_state *mrb, const char *name); MRB_API struct RClass * mrb_class_get(mrb_state *mrb, const char *name); /** + * Returns an mrb_bool. True if inner class was defined, and false if the inner class was not defined. + * + * Example: + * void + * mrb_example_gem_init(mrb_state* mrb) { + * struct RClass *example_outer, *example_inner; + * mrb_bool cd; + * + * example_outer = mrb_define_module(mrb, "ExampleOuter"); + * + * example_inner = mrb_define_class_under(mrb, example_outer, "ExampleInner", mrb->object_class); + * cd = mrb_class_defined_under(mrb, example_outer, "ExampleInner"); + * + * // If mrb_class_defined_under returns 1 then puts "True" + * // If mrb_class_defined_under returns 0 then puts "False" + * if (cd == 1){ + * puts("True"); + * } + * else { + * puts("False"); + * } + * } + * + * @param [mrb_state*] mrb The current mruby state. + * @param [struct RClass *] outer The name of the outer class. + * @param [const char *] name A string representing the name of the inner class. + * @return [mrb_bool] A boolean value. + */ +MRB_API mrb_bool mrb_class_defined_under(mrb_state *mrb, struct RClass *outer, const char *name); + +/** * Gets a child class. * @param [mrb_state*] mrb The current mruby state. * @param [struct RClass *] outer The name of the parent class. |
