diff options
| author | Ralph Desir(Mav7) <[email protected]> | 2015-10-14 02:50:12 -0400 |
|---|---|---|
| committer | Ralph Desir(Mav7) <[email protected]> | 2015-10-14 02:50:12 -0400 |
| commit | a5b416e2ce31f28ec4c588b3bc1d0b0567faf7ba (patch) | |
| tree | 657a21c74735eb62237c0a02891b291bf3343b52 | |
| parent | 6276227e70753a1f7462fd8b6dfb1d29f36f0e88 (diff) | |
| download | mruby-a5b416e2ce31f28ec4c588b3bc1d0b0567faf7ba.tar.gz mruby-a5b416e2ce31f28ec4c588b3bc1d0b0567faf7ba.zip | |
Added documentation for mrb_undef_method
| -rw-r--r-- | build_config.rb | 6 | ||||
| -rw-r--r-- | include/mruby.h | 63 |
2 files changed, 64 insertions, 5 deletions
diff --git a/build_config.rb b/build_config.rb index 96b1d4684..427600a23 100644 --- a/build_config.rb +++ b/build_config.rb @@ -21,7 +21,7 @@ MRuby::Build.new do |conf| # include the default GEMs conf.gembox 'default' - + conf.gem '/home/thamav/tests/mrbgems_test' # C compiler settings # conf.cc do |cc| # cc.command = ENV['CC'] || 'gcc' @@ -82,7 +82,7 @@ MRuby::Build.new do |conf| # bintest # conf.enable_bintest end - +=begin MRuby::Build.new('host-debug') do |conf| # load specific toolchain settings @@ -117,7 +117,7 @@ MRuby::Build.new('test') do |conf| conf.gembox 'default' end - +=end # Define cross build settings # MRuby::CrossBuild.new('32bit') do |conf| # toolchain :gcc diff --git a/include/mruby.h b/include/mruby.h index fd64a07ec..2288f9546 100644 --- a/include/mruby.h +++ b/include/mruby.h @@ -243,8 +243,8 @@ MRB_API mrb_value mrb_singleton_class(mrb_state*, mrb_value); * Include a module in another class or module. * Equivalent to: * - * module B * - * include A * + * module B + * include A * end * @param mrb_state* The current mruby state. * @param RClass* A reference to module or a class. @@ -348,6 +348,65 @@ MRB_API void mrb_define_module_function(mrb_state*, struct RClass*, const char*, * @param mrb_value The value for the constant. */ MRB_API void mrb_define_const(mrb_state*, struct RClass*, const char *name, mrb_value); + +/** + * Undefines a method. + * + * # Ruby style + * + * class A + * + * def a + * "a" + * end + * + * end + * + * A.new.a # => a + * + * class B < A + * + * undef_method :a + * + * end + * + * B.new.a # => undefined method 'a' for B (NoMethodError) + * + * // C style + * + * mrb_value + * mrb_a(mrb_state *mrb){ + * + * return mrb_str_new_cstr(mrb, "a"); + * + * } + * + * void + * mrb_example_gem_init(mrb_state* mrb){ + * struct RClass *a; + * struct RClass *b; + * struct RClass *c; + * + * a = mrb_define_class(mrb, "A", mrb->object_class); + * + * mrb_define_method(mrb, a, "a", mrb_a, MRB_ARGS_NONE()); + * + * b = mrb_define_class(mrb, "B", a); + * + * c = mrb_define_class(mrb, "C", b); + * + * mrb_undef_method(mrb, c, "a"); + * + * } + * + * mrb_example_gem_final(mrb_state* mrb){ + * + * } + * + * @param mrb_state* The MRuby state reference. + * @param RClass* A class the method will be undefined from. + * @param constchar* The name of the method to be undefined. + */ MRB_API void mrb_undef_method(mrb_state*, struct RClass*, const char*); MRB_API void mrb_undef_class_method(mrb_state*, struct RClass*, const char*); |
