diff options
| author | Ralph Desir(Mav7) <[email protected]> | 2015-10-15 19:41:45 -0400 |
|---|---|---|
| committer | Ralph Desir(Mav7) <[email protected]> | 2015-10-15 19:41:45 -0400 |
| commit | d16912681a13a2dc6d5e1779bf36b67debce2a55 (patch) | |
| tree | 2e0e9e78395bdfd119f4670a4453e994dbbb777d /include | |
| parent | 2df9786f33e8be5ef50e36330e54e6d6d02bf234 (diff) | |
| download | mruby-d16912681a13a2dc6d5e1779bf36b67debce2a55.tar.gz mruby-d16912681a13a2dc6d5e1779bf36b67debce2a55.zip | |
updated YARD docs on mruby.h
Diffstat (limited to 'include')
| -rw-r--r-- | include/mruby.h | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/include/mruby.h b/include/mruby.h index cecf6fa47..efdd45a87 100644 --- a/include/mruby.h +++ b/include/mruby.h @@ -496,6 +496,21 @@ MRB_API void mrb_undef_class_method(mrb_state*, struct RClass*, const char*); /** * Initialize a new object instace of c class. * + * // Example: + * #include <stdio.h> + * #include <mruby.h> + * + * void + * mrb_example_gem_init(mrb_state* mrb) { + * struct RClass *example_class; + * + * mrb_value *argv[1]; + * mrb_value obj; + * + * example_class = mrb_define_class(mrb, "ExampleClass", mrb->object_class);* argv[0] = example_class; + * obj = mrb_obj_new(mrb, mrb->object_class, 1, argv); // => ExampleClass + * mrb_funcall(mrb, obj, "puts", 1, example_class); + * } * @param mrb The current mruby state. * @param c Reference to the class of the new object. * @param argc Number of arguments in argv @@ -504,7 +519,31 @@ MRB_API void mrb_undef_class_method(mrb_state*, struct RClass*, const char*); */ MRB_API mrb_value mrb_obj_new(mrb_state *mrb, struct RClass *c, mrb_int argc, const mrb_value *argv); -/** @see mrb_obj_new */ +/** + * Initialize a new object instace of c class. + * + * // Example: + * #include <stdio.h> + * #include <mruby.h> + * + * void + * mrb_example_gem_init(mrb_state* mrb) { + * struct RClass *example_class; + * + * mrb_value *argv[1]; + * mrb_value obj; + * mrb_value obj_inst; + * + * example_class = mrb_define_class(mrb, "ExampleClass", mrb->object_class);* + * argv[0] = example_class; + * obj = mrb_obj_new(mrb, mrb->object_class, 1, argv); + * obj_inst = mrb_class_new_instance(mrb, 0, argv, example_class); // => #<ExampleClass:0x89734f8> + * mrb_funcall(mrb, obj, "puts", 1, obj_inst); + * } + * @param mrb The current mruby state. + * @param argc Number of arguments in argv + * @param c Reference to the class of the new object. + */ MRB_INLINE mrb_value mrb_class_new_instance(mrb_state *mrb, mrb_int argc, const mrb_value *argv, struct RClass *c) { return mrb_obj_new(mrb,c,argc,argv); |
