Function rb_eval_string_protect

Source
pub unsafe extern "C" fn rb_eval_string_protect(
    str_: *const c_char,
    state: *mut c_int,
) -> VALUE
Expand description

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.

@param[in] str Ruby code to evaluate. @param[out] state State of execution. @return The evaluated result if succeeded, an undefined value if otherwise. @post *state is set to zero if succeeded. Nonzero otherwise. @warning You have to clear the error info with [rb_set_errinfo]Qnil) if you decide to ignore the caught exception. @see rb_eval_string @see rb_protect

@internal

The “undefined value” described above is in fact ::RUBY_Qnil for now. But @shyouhei doesn’t think that we would never change that.

§Though not a part of our public API, state is in fact an enum ruby_tag_type. You can see the potential “nonzero” values by looking at vm_core.h.

Generated by rb-sys for Ruby mri-x86_64-linux-gnu-3.2.3