mrubyを超漢字で動作させる
Revision | fd8634d26b9dc98b60e29c031dca7d7aa0755d4c (tree) |
---|---|
Time | 2015-10-15 23:12:47 |
Author | Yukihiro "Matz" Matsumoto <matz@ruby...> |
Commiter | Yukihiro "Matz" Matsumoto |
Merge pull request #2993 from Mav7/master
Updated mruby.h YARD doc.
@@ -243,8 +243,8 @@ MRB_API mrb_value mrb_singleton_class(mrb_state*, mrb_value); | ||
243 | 243 | * Include a module in another class or module. |
244 | 244 | * Equivalent to: |
245 | 245 | * |
246 | - * module B * | |
247 | - * include A * | |
246 | + * module B | |
247 | + * include A | |
248 | 248 | * end |
249 | 249 | * @param mrb_state* The current mruby state. |
250 | 250 | * @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 | ||
292 | 292 | * Defines a class method. |
293 | 293 | * # Ruby style |
294 | 294 | * class Foo |
295 | + * | |
295 | 296 | * def Foo.bar |
296 | 297 | * end |
298 | + * | |
297 | 299 | * end |
298 | 300 | * // C style |
299 | 301 | * mrb_value bar_method(mrb_state* mrb, mrb_value self){ |
302 | + * | |
300 | 303 | * return mrb_nil_value(); |
304 | + * | |
301 | 305 | * } |
302 | 306 | * void mrb_example_gem_init(mrb_state* mrb){ |
307 | + * | |
303 | 308 | * struct RClass *foo; |
309 | + * | |
304 | 310 | * 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 | + * | |
306 | 314 | * } |
307 | 315 | * @param mrb_state* The MRuby state reference. |
308 | 316 | * @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 | ||
316 | 324 | /** |
317 | 325 | * Defines a module fuction. |
318 | 326 | * # Ruby style |
319 | - * module Foo | |
327 | + * module Foo | |
328 | + * | |
320 | 329 | * def Foo.bar * end |
330 | + * | |
321 | 331 | * end |
322 | 332 | * // 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(); * | |
325 | 336 | * } |
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 | + * | |
329 | 343 | * mrb_define_module_function(mrb, foo, "bar", bar_method, MRB_ARGS_NONE()); |
344 | + * | |
330 | 345 | * } |
331 | 346 | * @param mrb_state* The MRuby state reference. |
332 | 347 | * @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*, | ||
339 | 354 | /** |
340 | 355 | * Defines a constant. |
341 | 356 | * # Ruby style |
357 | + * | |
358 | + * class ExampleClass | |
359 | + * | |
342 | 360 | * AGE = 22 |
361 | + * | |
362 | + * end | |
363 | + * | |
343 | 364 | * // 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 | + * } | |
345 | 379 | * @param mrb_state* The MRuby state reference. |
346 | 380 | * @param RClass* A class or module the constant is defined in. |
347 | 381 | * @param name The name of the constant. |
348 | 382 | * @param mrb_value The value for the constant. |
349 | 383 | */ |
350 | 384 | 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 | + */ | |
351 | 446 | 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 | + */ | |
352 | 494 | MRB_API void mrb_undef_class_method(mrb_state*, struct RClass*, const char*); |
353 | 495 | |
354 | 496 | /** |