Ruby 3.4.5p51 (2025-07-16 revision 20cda200d3ce092571d0b5d342dadca69636cb0f)
|
Declares rb_eval_string(). More...
#include "ruby/internal/dllexport.h"
#include "ruby/internal/attr/nonnull.h"
#include "ruby/internal/value.h"
Go to the source code of this file.
Macros | |
#define | rb_funcall2 rb_funcallv |
#define | rb_funcall3 rb_funcallv_public |
Functions | |
VALUE | rb_eval_string (const char *str) |
Evaluates the given string. | |
VALUE | rb_eval_string_protect (const char *str, int *state) |
Identical to rb_eval_string(), except it avoids potential global escapes. | |
VALUE | rb_eval_string_wrap (const char *str, int *state) |
Identical to rb_eval_string_protect(), except it evaluates the given string under a module binding in an isolated binding. | |
VALUE | rb_funcall (VALUE recv, ID mid, int n,...) |
Calls a method. | |
VALUE | rb_funcallv (VALUE recv, ID mid, int argc, const VALUE *argv) |
Identical to rb_funcall(), except it takes the method arguments as a C array. | |
VALUE | rb_funcallv_kw (VALUE recv, ID mid, int argc, const VALUE *argv, int kw_splat) |
Identical to rb_funcallv(), except you can specify how to handle the last element of the given array. | |
VALUE | rb_funcallv_public (VALUE recv, ID mid, int argc, const VALUE *argv) |
Identical to rb_funcallv(), except it only takes public methods into account. | |
VALUE | rb_funcallv_public_kw (VALUE recv, ID mid, int argc, const VALUE *argv, int kw_splat) |
Identical to rb_funcallv_public(), except you can specify how to handle the last element of the given array. | |
VALUE | rb_funcall_passing_block (VALUE recv, ID mid, int argc, const VALUE *argv) |
Identical to rb_funcallv_public(), except you can pass the passed block. | |
VALUE | rb_funcall_passing_block_kw (VALUE recv, ID mid, int argc, const VALUE *argv, int kw_splat) |
Identical to rb_funcallv_passing_block(), except you can specify how to handle the last element of the given array. | |
VALUE | rb_funcall_with_block (VALUE recv, ID mid, int argc, const VALUE *argv, VALUE procval) |
Identical to rb_funcallv_public(), except you can pass a block. | |
VALUE | rb_funcall_with_block_kw (VALUE recv, ID mid, int argc, const VALUE *argv, VALUE procval, int kw_splat) |
Identical to rb_funcallv_with_block(), except you can specify how to handle the last element of the given array. | |
VALUE | rb_call_super (int argc, const VALUE *argv) |
This resembles ruby's super. | |
VALUE | rb_call_super_kw (int argc, const VALUE *argv, int kw_splat) |
Identical to rb_call_super(), except you can specify how to handle the last element of the given array. | |
VALUE | rb_current_receiver (void) |
This resembles ruby's self. | |
int | rb_get_kwargs (VALUE keyword_hash, const ID *table, int required, int optional, VALUE *values) |
Keyword argument deconstructor. | |
VALUE | rb_extract_keywords (VALUE *orighash) |
Splits a hash into two. |
Declares rb_eval_string().
Definition in file eval.h.
#define rb_funcall2 rb_funcallv |
#define rb_funcall3 rb_funcallv_public |
Identical to rb_call_super(), except you can specify how to handle the last element of the given array.
[in] | argc | Number of arguments. |
[in] | argv | Arbitrary number of method arguments. |
[in] | kw_splat | Handling of keyword parameters:
|
rb_eNoMethodError | No super method are there. |
rb_eException | Any exceptions happen inside. |
Definition at line 354 of file vm_eval.c.
Referenced by rb_call_super().
VALUE rb_current_receiver | ( | void | ) |
VALUE rb_eval_string | ( | const char * | str | ) |
Evaluates the given string.
In case it is called from within a C-backended method, the evaluation is done under the current binding. However there can be no method. On such situation this function evaluates in an isolated binding, like require runs in a separate one.
__FILE__ will be "(eval)", and __LINE__ starts from 1 in the evaluation.
[in] | str | Ruby code to evaluate. |
rb_eException | Raises an exception on error. |
VALUE rb_eval_string_protect | ( | const char * | str, |
int * | state ) |
Identical to rb_eval_string(), except it avoids potential global escapes.
Such global escapes include exceptions, throw, break, for example.
It first evaluates the given string as rb_eval_string() does. If no global escape occurred during the evaluation, it returns the result and *state is zero. Otherwise, it returns some undefined value and sets *state to nonzero. If state is NULL, it is not set in both cases.
[in] | str | Ruby code to evaluate. |
[out] | state | State of execution. |
VALUE rb_eval_string_wrap | ( | const char * | str, |
int * | state ) |
Identical to rb_eval_string_protect(), except it evaluates the given string under a module binding in an isolated binding.
This is the same as a binding for loaded libraries on rb_load(something, true).
[in] | str | Ruby code to evaluate. |
[out] | state | State of execution. |
Definition at line 2091 of file vm_eval.c.
Referenced by rb_eval_string_wrap().
Calls a method.
Can call both public and private methods.
[in,out] | recv | Receiver of the method. |
[in] | mid | Name of the method to call. |
[in] | n | Number of arguments that follow. |
[in] | ... | Arbitrary number of method arguments. |
rb_eNoMethodError | No such method. |
rb_eException | Any exceptions happen inside. |
Definition at line 1099 of file vm_eval.c.
Referenced by rb_class_inherited(), rb_cmpint(), rb_eql(), rb_equal(), rb_fiber_scheduler_block(), rb_fiber_scheduler_io_wait(), rb_fiber_scheduler_kernel_sleep(), rb_fiber_scheduler_unblock(), rb_file_size(), rb_num_coerce_bin(), rb_num_coerce_cmp(), rb_num_coerce_relop(), rb_obj_as_string(), rb_obj_init_clone(), and rb_obj_init_dup_clone().
Identical to rb_funcallv_public(), except you can pass the passed block.
Sometimes you want to "pass" a block parameter form one method to another. Suppose you have this Ruby method foo:
And suppose you want to translate this into C. Then rb_funcall_passing_block() function is usable in this situation.
[in,out] | recv | Receiver of the method. |
[in] | mid | Name of the method to call. |
[in] | argc | Number of arguments. |
[in] | argv | Arbitrary number of method arguments. |
rb_eNoMethodError | No such method. |
rb_eNoMethodError | The method is private or protected. |
rb_eException | Any exceptions happen inside. |
VALUE rb_funcall_passing_block_kw | ( | VALUE | recv, |
ID | mid, | ||
int | argc, | ||
const VALUE * | argv, | ||
int | kw_splat ) |
Identical to rb_funcallv_passing_block(), except you can specify how to handle the last element of the given array.
It can also be seen as a routine identical to rb_funcallv_public_kw(), except you can pass the passed block.
[in,out] | recv | Receiver of the method. |
[in] | mid | Name of the method to call. |
[in] | argc | Number of arguments. |
[in] | argv | Arbitrary number of method arguments. |
[in] | kw_splat | Handling of keyword parameters:
|
rb_eNoMethodError | No such method. |
rb_eNoMethodError | The method is private or protected. |
rb_eException | Any exceptions happen inside. |
Definition at line 1169 of file vm_eval.c.
Referenced by rb_fiber_scheduler_fiber().
Identical to rb_funcallv_public(), except you can pass a block.
A block here basically is an instance of rb_cProc. If you want to exercise to_proc conversion, do so before passing it here. However nil and symbols are special-case allowed.
[in,out] | recv | Receiver of the method. |
[in] | mid | Name of the method to call. |
[in] | argc | Number of arguments. |
[in] | argv | Arbitrary number of method arguments. |
[in] | procval | An instance of Proc, Symbol, or NilClass. |
rb_eNoMethodError | No such method. |
rb_eNoMethodError | The method is private or protected. |
rb_eException | Any exceptions happen inside. |
VALUE rb_funcall_with_block_kw | ( | VALUE | recv, |
ID | mid, | ||
int | argc, | ||
const VALUE * | argv, | ||
VALUE | procval, | ||
int | kw_splat ) |
Identical to rb_funcallv_with_block(), except you can specify how to handle the last element of the given array.
It can also be seen as a routine identical to rb_funcallv_public_kw(), except you can pass a block.
[in,out] | recv | Receiver of the method. |
[in] | mid | Name of the method to call. |
[in] | argc | Number of arguments. |
[in] | argv | Arbitrary number of method arguments. |
[in] | procval | An instance of Proc, Symbol, or NilClass. |
[in] | kw_splat | Handling of keyword parameters:
|
rb_eNoMethodError | No such method. |
rb_eNoMethodError | The method is private or protected. |
rb_eException | Any exceptions happen inside. |
Identical to rb_funcall(), except it takes the method arguments as a C array.
[in,out] | recv | Receiver of the method. |
[in] | mid | Name of the method to call. |
[in] | argc | Number of arguments. |
[in] | argv | Arbitrary number of method arguments. |
rb_eNoMethodError | No such method. |
rb_eException | Any exceptions happen inside. |
Identical to rb_funcallv(), except you can specify how to handle the last element of the given array.
[in,out] | recv | Receiver of the method. |
[in] | mid | Name of the method to call. |
[in] | argc | Number of arguments. |
[in] | argv | Arbitrary number of method arguments. |
[in] | kw_splat | Handling of keyword parameters:
|
rb_eNoMethodError | No such method. |
rb_eException | Any exceptions happen inside. |
Definition at line 1066 of file vm_eval.c.
Referenced by rb_eval_cmd_kw(), and rb_obj_call_init_kw().
Identical to rb_funcallv(), except it only takes public methods into account.
This is roughly Ruby's Object#public_send.
[in,out] | recv | Receiver of the method. |
[in] | mid | Name of the method to call. |
[in] | argc | Number of arguments. |
[in] | argv | Arbitrary number of method arguments. |
rb_eNoMethodError | No such method. |
rb_eNoMethodError | The method is private or protected. |
rb_eException | Any exceptions happen inside. |
Definition at line 1150 of file vm_eval.c.
Referenced by rb_funcall_passing_block(), rb_funcall_with_block(), and rb_random_ulong_limited().
Identical to rb_funcallv_public(), except you can specify how to handle the last element of the given array.
It can also be seen as a routine identical to rb_funcallv_kw(), except it only takes public methods into account.
[in,out] | recv | Receiver of the method. |
[in] | mid | Name of the method to call. |
[in] | argc | Number of arguments. |
[in] | argv | Arbitrary number of method arguments. |
[in] | kw_splat | Handling of keyword parameters:
|
rb_eNoMethodError | No such method. |
rb_eNoMethodError | The method is private or protected. |
rb_eException | Any exceptions happen inside. |