examples/mrbgems: clarify the caller

Before this commit:

  mruby -e 'CRubyExtension.ruby_method' # => A Ruby Extension
  mruby -e 'CRubyExtension.c_method'    # => A C Extension
  mruby -e 'CExtension.c_method'        # => A C Extension
  mruby -e 'RubyExtension.ruby_method'  # => A Ruby Extension

After this commit:

  mruby -e 'CRubyExtension.ruby_method' # => CRubyExtension: A Ruby Extension
  mruby -e 'CRubyExtension.c_method'    # => CRubyExtension: A C Extension
  mruby -e 'CExtension.c_method'        # => CExtension: A C Extension
  mruby -e 'RubyExtension.ruby_method'  # => RubyExtension: A Ruby Extension
parent dffe4bc8
module CRubyExtension module CRubyExtension
def CRubyExtension.ruby_method def CRubyExtension.ruby_method
puts "A Ruby Extension" puts "#{self}: A Ruby Extension"
end end
end end
#include <mruby.h> #include <mruby.h>
#include <mruby/string.h>
#include <stdio.h> #include <stdio.h>
static mrb_value static mrb_value
mrb_c_method(mrb_state *mrb, mrb_value self) mrb_c_method(mrb_state *mrb, mrb_value self)
{ {
puts("A C Extension"); mrb_value self_str = mrb_str_to_str(mrb, self);
printf("%s: A C Extension\n", mrb_str_to_cstr(mrb, self_str));
return self; return self;
} }
......
#include <mruby.h> #include <mruby.h>
#include <mruby/string.h>
#include <stdio.h> #include <stdio.h>
static mrb_value static mrb_value
mrb_c_method(mrb_state *mrb, mrb_value self) mrb_c_method(mrb_state *mrb, mrb_value self)
{ {
puts("A C Extension"); mrb_value self_str = mrb_str_to_str(mrb, self);
printf("%s: A C Extension\n", mrb_str_to_cstr(mrb, self_str));
return self; return self;
} }
......
class RubyExtension class RubyExtension
def RubyExtension.ruby_method def RubyExtension.ruby_method
puts "A Ruby Extension" puts "#{self}: A Ruby Extension"
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment