mrubyを超漢字で動作させる
修訂 | 4e63ea96493d7a074277d59a395401182f02d4a3 (tree) |
---|---|
時間 | 2015-11-15 05:10:52 |
作者 | Yukihiro "Matz" Matsumoto <matz@ruby...> |
Commiter | Yukihiro "Matz" Matsumoto |
Merge pull request #3011 from Mav7/master
Added more YARD docs to mruby.h
@@ -21,7 +21,6 @@ MRuby::Build.new do |conf| | ||
21 | 21 | |
22 | 22 | # include the default GEMs |
23 | 23 | conf.gembox 'default' |
24 | - | |
25 | 24 | # C compiler settings |
26 | 25 | # conf.cc do |cc| |
27 | 26 | # cc.command = ENV['CC'] || 'gcc' |
@@ -548,7 +548,7 @@ MRB_API struct RClass * mrb_class_new(mrb_state *mrb, struct RClass *super); | ||
548 | 548 | MRB_API struct RClass * mrb_module_new(mrb_state *mrb); |
549 | 549 | |
550 | 550 | /** |
551 | - * Creates a new module, Module. | |
551 | + * Returns an mrb_bool. True if class was defined, and false if the class was not defined. | |
552 | 552 | * |
553 | 553 | * Example: |
554 | 554 | * void |
@@ -610,8 +610,58 @@ MRB_API struct RClass * mrb_module_get(mrb_state *mrb, const char *name); | ||
610 | 610 | MRB_API struct RClass * mrb_module_get_under(mrb_state *mrb, struct RClass *outer, const char *name); |
611 | 611 | MRB_API mrb_value mrb_notimplement_m(mrb_state*, mrb_value); |
612 | 612 | |
613 | +/** | |
614 | + * Duplicate an object. | |
615 | + * | |
616 | + * Equivalent to: | |
617 | + * Object#dup | |
618 | + * @param mrb The current mruby state. | |
619 | + * @param obj Object to be duplicate. | |
620 | + * @return The newly duplicated object. | |
621 | + */ | |
613 | 622 | MRB_API mrb_value mrb_obj_dup(mrb_state *mrb, mrb_value obj); |
614 | 623 | MRB_API mrb_value mrb_check_to_integer(mrb_state *mrb, mrb_value val, const char *method); |
624 | + | |
625 | +/** | |
626 | + * Returns true if obj responds to the given method. If the method was defined for that | |
627 | + * class it returns true, it returns false otherwise. | |
628 | + * | |
629 | + * Example: | |
630 | + * # Ruby style | |
631 | + * class ExampleClass | |
632 | + * def example_method | |
633 | + * end | |
634 | + * end | |
635 | + * | |
636 | + * ExampleClass.new.respond_to?(:example_method) # => true | |
637 | + * | |
638 | + * // C style | |
639 | + * void | |
640 | + * mrb_example_gem_init(mrb_state* mrb) { | |
641 | + * struct RClass *example_class; | |
642 | + * mrb_sym mid; | |
643 | + * mrb_bool obj_resp; | |
644 | + * | |
645 | + * example_class = mrb_define_class(mrb, "ExampleClass", mrb->object_class); | |
646 | + * mrb_define_method(mrb, example_class, "example_method", exampleMethod, MRB_ARGS_NONE()); | |
647 | + * mid = mrb_intern_str(mrb, mrb_str_new_cstr(mrb, "example_method" )); | |
648 | + * obj_resp = mrb_obj_respond_to(mrb, example_class, mid); // => 1(true in Ruby world) | |
649 | + * | |
650 | + * // If mrb_obj_respond_to returns 1 then puts "True" | |
651 | + * // If mrb_obj_respond_to returns 0 then puts "False" | |
652 | + * if (obj_resp == 1) { | |
653 | + * puts("True"); | |
654 | + * } | |
655 | + * else if (obj_resp == 0) { | |
656 | + * puts("False"); | |
657 | + * } | |
658 | + * } | |
659 | + * | |
660 | + * @param mrb The current mruby state. | |
661 | + * @param c A reference to a class. | |
662 | + * @param mid A symbol referencing a method id. | |
663 | + * @return mrb_bool A boolean value. | |
664 | + */ | |
615 | 665 | MRB_API mrb_bool mrb_obj_respond_to(mrb_state *mrb, struct RClass* c, mrb_sym mid); |
616 | 666 | |
617 | 667 | /** |