Ruby 2.7.7p221 (2022-11-24 revision 168ec2b1e5ad0e4688e963d9de019557c78feed9)
|
There are some APIs to define a method from C. More...
Data Structures | |
struct | rb_scan_args_t |
There are some APIs to define a method from C.
These API takes a C function as a method body.
This form is a normal C function, excepting it takes a receiver object as the first argument.
This form takes three parameters: argc, argv and self. self is the receiver. argc is the number of arguments. argv is a pointer to an array of the arguments.
This form takes two parameters: self and args. self is the receiver. args is an Array object which contains the arguments.
NORETURN | ( | static void | rb_keyword_errorconst char *error, VALUE keys | ) |
NORETURN | ( | static void | unknown_keyword_errorVALUE hash, const ID *table, int keywords | ) |
Determines if the current method is given a block.
zero | if not given |
non-zero | if given |
Definition at line 898 of file eval.c.
Referenced by ossl_pem_passwd_cb(), rb_ary_delete(), rb_method_call(), rb_method_call_kw(), and rb_need_block().
Definition at line 2219 of file class.c.
References FALSE, rb_id_table_size(), RCLASS_M_TBL, and TRUE.
Defines an alias of a method.
klass | the class which the original method belongs to |
name1 | a new name for the method |
name2 | the original name of the method |
Definition at line 1818 of file class.c.
References klass, rb_alias(), and rb_intern.
Defines (a) public accessor method(s) for an attribute.
klass | the class which the attribute will belongs to |
name | name of the attribute |
read | a getter method for the attribute will be defined if read is non-zero. |
write | a setter method for the attribute will be defined if write is non-zero. |
Definition at line 1831 of file class.c.
References FALSE, klass, name, rb_attr(), rb_intern, read(), and write().
Defines a global function.
name | name of the function |
func | the method body |
argc | the number of parameters, or -1 or -2. see Defining methods. |
Definition at line 1805 of file class.c.
References argc, name, rb_define_module_function(), and rb_mKernel.
Definition at line 1569 of file class.c.
References argc, klass, METHOD_VISI_PUBLIC, name, rb_add_method_cfunc(), and rb_intern.
Referenced by rb_define_singleton_method().
Definition at line 1560 of file class.c.
References argc, klass, METHOD_VISI_PUBLIC, and rb_add_method_cfunc().
void rb_define_module_function | ( | VALUE | module, |
const char * | name, | ||
VALUE(*)(ANYARGS) | func, | ||
int | argc | ||
) |
Defines a module function for module.
module | an module or a class. |
name | name of the function |
func | the method body |
argc | the number of parameters, or -1 or -2. see Defining methods. |
Definition at line 1789 of file class.c.
References argc, name, rb_define_private_method(), and rb_define_singleton_method().
Referenced by rb_define_global_function().
Definition at line 1587 of file class.c.
References argc, klass, METHOD_VISI_PRIVATE, name, rb_add_method_cfunc(), and rb_intern.
Referenced by rb_define_module_function().
void rb_define_protected_method | ( | VALUE | klass, |
const char * | name, | ||
VALUE(*)(ANYARGS) | func, | ||
int | argc | ||
) |
Definition at line 1578 of file class.c.
References argc, klass, METHOD_VISI_PROTECTED, name, rb_add_method_cfunc(), and rb_intern.
Defines a singleton method for obj.
obj | an arbitrary object |
name | name of the singleton method |
func | the method body |
argc | the number of parameters, or -1 or -2. see Defining methods. |
Definition at line 1773 of file class.c.
References rb_define_method().
Referenced by rb_define_module_function().
The name of the current method.
The function returns the alias if an alias of the method is called. The function can also return 0 if it is not in a method. This case can happen in a toplevel of a source file, for example.
Definition at line 1200 of file eval.c.
Referenced by rb_insecure_operation(), and rb_secure().
The original name of the current method.
The function returns the original name of the method even if an alias of the method is called. The function can also return 0 if it is not in a method. This case can happen in a toplevel of a source file, for example.
Definition at line 1183 of file eval.c.
Referenced by rb_notimplement().
int rb_get_kwargs | ( | VALUE | keyword_hash, |
const ID * | table, | ||
int | required, | ||
int | optional, | ||
VALUE * | values | ||
) |
Definition at line 1904 of file class.c.
References extract_kwarg, i, ID2SYM, key, NIL_P, Qnil, rb_ary_push(), and rb_ary_tmp_new().
Referenced by rb_num_get_rounding_option(), and rb_opts_exception_p().
MJIT_FUNC_EXPORTED VALUE rb_keyword_error_new | ( | const char * | error, |
VALUE | keys | ||
) |
Definition at line 1837 of file class.c.
References error, i, keys, len, RARRAY_AREF, RARRAY_LEN, rb_eArgError, rb_exc_new_str(), rb_inspect(), rb_sprintf(), rb_str_append(), and rb_str_cat_cstr.
Declares that the current method needs a block.
Raises a LocalJumpError
if not given a block.
Definition at line 932 of file eval.c.
References Qnil, rb_block_given_p(), and rb_vm_localjump_error().
Definition at line 2177 of file class.c.
References arg, error, and rb_scan_args_t::tmp_buffer.
Definition at line 2198 of file class.c.
References arg, error, rb_scan_args_t::tmp_buffer, and rb_scan_args_t::vargs.
Definition at line 1593 of file class.c.
References klass, METHOD_VISI_UNDEF, name, rb_add_method(), rb_intern, and VM_METHOD_TYPE_UNDEF.
Referenced by Init_Binding(), Init_VM(), and rsock_init_basicsocket().
Definition at line 1607 of file class.c.
References rb_id_table_foreach(), and RCLASS_M_TBL.