• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

mrubyを超漢字で動作させる


Commit MetaInfo

Revisionfd8634d26b9dc98b60e29c031dca7d7aa0755d4c (tree)
Time2015-10-15 23:12:47
AuthorYukihiro "Matz" Matsumoto <matz@ruby...>
CommiterYukihiro "Matz" Matsumoto

Log Message

Merge pull request #2993 from Mav7/master

Updated mruby.h YARD doc.

Change Summary

Incremental Difference

--- a/include/mruby.h
+++ b/include/mruby.h
@@ -243,8 +243,8 @@ MRB_API mrb_value mrb_singleton_class(mrb_state*, mrb_value);
243243 * Include a module in another class or module.
244244 * Equivalent to:
245245 *
246- * module B *
247- * include A *
246+ * module B
247+ * include A
248248 * end
249249 * @param mrb_state* The current mruby state.
250250 * @param RClass* A reference to module or a class.
@@ -292,17 +292,25 @@ MRB_API void mrb_define_method(mrb_state *mrb, struct RClass *cla, const char *n
292292 * Defines a class method.
293293 * # Ruby style
294294 * class Foo
295+ *
295296 * def Foo.bar
296297 * end
298+ *
297299 * end
298300 * // C style
299301 * mrb_value bar_method(mrb_state* mrb, mrb_value self){
302+ *
300303 * return mrb_nil_value();
304+ *
301305 * }
302306 * void mrb_example_gem_init(mrb_state* mrb){
307+ *
303308 * struct RClass *foo;
309+ *
304310 * foo = mrb_define_class(mrb, "Foo", mrb->object_class);
305- * mrb_define_class_method(mrb, foo, "bar", bar_method, MRB_ARGS_NONE());
311+ *
312+ * mrb_define_class_method(mrb, foo, "bar", bar_method, MRB_ARGS_NONE());
313+ *
306314 * }
307315 * @param mrb_state* The MRuby state reference.
308316 * @param RClass* The class where the class method will be defined.
@@ -316,17 +324,24 @@ MRB_API void mrb_define_singleton_method(mrb_state*, struct RObject*, const char
316324 /**
317325 * Defines a module fuction.
318326 * # Ruby style
319- * module Foo
327+ * module Foo
328+ *
320329 * def Foo.bar * end
330+ *
321331 * end
322332 * // C style
323- * mrb_value bar_method(mrb_state* mrb, mrb_value self){
324- * return mrb_nil_value();
333+ * mrb_value bar_method(mrb_state* mrb, mrb_value self){
334+ *
335+ * return mrb_nil_value(); *
325336 * }
326- * void mrb_example_gem_init(mrb_state* mrb){
327- * struct RClass *foo;
328- * foo = mrb_define_module(mrb, "Foo");
337+ * void mrb_example_gem_init(mrb_state* mrb){
338+ *
339+ * struct RClass *foo;
340+ *
341+ * foo = mrb_define_module(mrb, "Foo");
342+ *
329343 * mrb_define_module_function(mrb, foo, "bar", bar_method, MRB_ARGS_NONE());
344+ *
330345 * }
331346 * @param mrb_state* The MRuby state reference.
332347 * @param RClass* The module where the module function will be defined.
@@ -339,16 +354,143 @@ MRB_API void mrb_define_module_function(mrb_state*, struct RClass*, const char*,
339354 /**
340355 * Defines a constant.
341356 * # Ruby style
357+ *
358+ * class ExampleClass
359+ *
342360 * AGE = 22
361+ *
362+ * end
363+ *
343364 * // C style
344- * mrb_define_const(mrb, mrb->kernel_module, "AGE", mrb_fixnum_value(22));
365+ * #include <stdio.h>
366+ * #include <mruby.h>
367+ *
368+ * void
369+ * mrb_example_gem_init(mrb_state* mrb){
370+ *
371+ * mrb_define_const(mrb, mrb->kernel_module, "AGE", mrb_fixnum_value(22));
372+ *
373+ * }
374+ *
375+ * mrb_value
376+ * mrb_example_gem_final(mrb_state* mrb){
377+ *
378+ * }
345379 * @param mrb_state* The MRuby state reference.
346380 * @param RClass* A class or module the constant is defined in.
347381 * @param name The name of the constant.
348382 * @param mrb_value The value for the constant.
349383 */
350384 MRB_API void mrb_define_const(mrb_state*, struct RClass*, const char *name, mrb_value);
385+
386+/**
387+ * Undefines a method.
388+ *
389+ * # Ruby style
390+ *
391+ * class ExampleClassA
392+ *
393+ * def example_method
394+ * "example"
395+ * end
396+ *
397+ * end
398+ *
399+ * ExampleClassA.new.example_method # => example
400+ *
401+ * class ExampleClassB < ExampleClassA
402+ *
403+ * undef_method :example_method
404+ *
405+ * end
406+ *
407+ * ExampleClassB.new.example_method # => undefined method 'example_method' for ExampleClassB (NoMethodError)
408+ *
409+ * // C style
410+ * #include <stdio.h>
411+ * #include <mruby.h>
412+ *
413+ * mrb_value
414+ * mrb_example_method(mrb_state *mrb){
415+ *
416+ * return mrb_str_new_cstr(mrb, "example");
417+ *
418+ * }
419+ *
420+ * void
421+ * mrb_example_gem_init(mrb_state* mrb){
422+ * struct RClass *example_class_a;
423+ * struct RClass *example_class_b;
424+ * struct RClass *example_class_c;
425+ *
426+ * example_class_a = mrb_define_class(mrb, "ExampleClassA", mrb->object_class);
427+ *
428+ * mrb_define_method(mrb, example_class_a, "example_method", mrb_example_method, MRB_ARGS_NONE());
429+ *
430+ * example_class_b = mrb_define_class(mrb, "ExampleClassB", example_class_a);
431+ *
432+ * example_class_c = mrb_define_class(mrb, "ExampleClassC", example_class_b);
433+ *
434+ * mrb_undef_method(mrb, example_class_c, "example_method");
435+ *
436+ * }
437+ *
438+ * mrb_example_gem_final(mrb_state* mrb){
439+ *
440+ * }
441+ *
442+ * @param mrb_state* The mruby state reference.
443+ * @param RClass* A class the method will be undefined from.
444+ * @param constchar* The name of the method to be undefined.
445+ */
351446 MRB_API void mrb_undef_method(mrb_state*, struct RClass*, const char*);
447+
448+/**
449+ * Undefine a class method.
450+ * # Ruby style
451+ *
452+ * class ExampleClass
453+ *
454+ * def self.example_method
455+ * "example"
456+ * end
457+ *
458+ * end
459+ *
460+ * ExampleClass.example_method
461+ *
462+ * // C style
463+ * #include <stdio.h>
464+ * #include <mruby.h>
465+ *
466+ * mrb_value
467+ * mrb_example_method(mrb_state *mrb){
468+ *
469+ * return mrb_str_new_cstr(mrb, "example");
470+ *
471+ * }
472+ *
473+ * void
474+ * mrb_example_gem_init(mrb_state* mrb){
475+ *
476+ * struct RClass *example_class;
477+ *
478+ * example_class = mrb_define_class(mrb, "ExampleClass", mrb->object_class);
479+ *
480+ * mrb_define_class_method(mrb, example_class, "example_method", mrb_example_method, MRB_ARGS_NONE());
481+ *
482+ * mrb_undef_class_method(mrb, example_class, "example_method");
483+ *
484+ * }
485+ *
486+ * void
487+ * mrb_example_gem_final(mrb_state* mrb){
488+ *
489+ * }
490+ * @param mrb_state* The mruby state reference.
491+ * @param RClass* A class the class method will be undefined from.
492+ * @param constchar* The name of the class method to be undefined.
493+ */
352494 MRB_API void mrb_undef_class_method(mrb_state*, struct RClass*, const char*);
353495
354496 /**