Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)
Macros | Typedefs | Functions
iterator.h File Reference

Block related APIs. More...

#include "ruby/internal/attr/noreturn.h"
#include "ruby/internal/dllexport.h"
#include "ruby/internal/value.h"

Go to the source code of this file.

Macros

#define RB_BLOCK_CALL_FUNC_STRICT   1
 
#define RUBY_BLOCK_CALL_FUNC_TAKES_BLOCKARG   1
 
#define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg)    VALUE yielded_arg, VALUE callback_arg, int argc, const VALUE *argv, VALUE blockarg
 

Typedefs

typedef VALUE rb_block_call_func(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
 
typedef rb_block_call_funcrb_block_call_func_t
 

Functions

VALUE rb_each (VALUE)
 
VALUE rb_yield (VALUE)
 
VALUE rb_yield_values (int n,...)
 
VALUE rb_yield_values2 (int n, const VALUE *argv)
 
VALUE rb_yield_values_kw (int n, const VALUE *argv, int kw_splat)
 
VALUE rb_yield_splat (VALUE)
 
VALUE rb_yield_splat_kw (VALUE, int)
 
VALUE rb_yield_block (RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
 
int rb_keyword_given_p (void)
 
int rb_block_given_p (void)
 Determines if the current method is given a block. More...
 
void rb_need_block (void)
 Declares that the current method needs a block. More...
 
VALUE rb_iterate (VALUE(*)(VALUE), VALUE, rb_block_call_func_t, VALUE)
 
VALUE rb_block_call (VALUE, ID, int, const VALUE *, rb_block_call_func_t, VALUE)
 
VALUE rb_block_call_kw (VALUE, ID, int, const VALUE *, rb_block_call_func_t, VALUE, int)
 
VALUE rb_rescue (VALUE(*)(VALUE), VALUE, VALUE(*)(VALUE, VALUE), VALUE)
 An equivalent of rescue clause. More...
 
VALUE rb_rescue2 (VALUE(*)(VALUE), VALUE, VALUE(*)(VALUE, VALUE), VALUE,...)
 An equivalent of rescue clause. More...
 
VALUE rb_vrescue2 (VALUE(*)(VALUE), VALUE, VALUE(*)(VALUE, VALUE), VALUE, va_list)
 An equivalent of rescue clause. More...
 
VALUE rb_ensure (VALUE(*)(VALUE), VALUE, VALUE(*)(VALUE), VALUE)
 An equivalent to ensure clause. More...
 
VALUE rb_catch (const char *, rb_block_call_func_t, VALUE)
 
VALUE rb_catch_obj (VALUE, rb_block_call_func_t, VALUE)
 
void rb_throw (const char *, VALUE)
 
void rb_throw_obj (VALUE, VALUE)
 

Detailed Description

Block related APIs.

Author
Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org
Warning
Symbols prefixed with either RBIMPL or rbimpl are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will.
Note
To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance __VA_ARGS__ is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98.

Definition in file iterator.h.

Macro Definition Documentation

◆ RB_BLOCK_CALL_FUNC_ARGLIST

#define RB_BLOCK_CALL_FUNC_ARGLIST (   yielded_arg,
  callback_arg 
)     VALUE yielded_arg, VALUE callback_arg, int argc, const VALUE *argv, VALUE blockarg

Definition at line 31 of file iterator.h.

◆ RB_BLOCK_CALL_FUNC_STRICT

#define RB_BLOCK_CALL_FUNC_STRICT   1

Definition at line 29 of file iterator.h.

◆ RUBY_BLOCK_CALL_FUNC_TAKES_BLOCKARG

#define RUBY_BLOCK_CALL_FUNC_TAKES_BLOCKARG   1

Definition at line 30 of file iterator.h.

Typedef Documentation

◆ rb_block_call_func

typedef VALUE rb_block_call_func(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))

Definition at line 33 of file iterator.h.

◆ rb_block_call_func_t

Definition at line 34 of file iterator.h.

Function Documentation

◆ rb_block_call()

VALUE rb_block_call ( VALUE  obj,
ID  mid,
int  argc,
const VALUE argv,
rb_block_call_func_t  bl_proc,
VALUE  data2 
)

◆ rb_block_call_kw()

VALUE rb_block_call_kw ( VALUE  obj,
ID  mid,
int  argc,
const VALUE argv,
rb_block_call_func_t  bl_proc,
VALUE  data2,
int  kw_splat 
)

◆ rb_catch()

VALUE rb_catch ( const char *  tag,
rb_block_call_func_t  func,
VALUE  data 
)

◆ rb_catch_obj()

VALUE rb_catch_obj ( VALUE  t,
rb_block_call_func_t  func,
VALUE  data 
)

Definition at line 2427 of file vm_eval.c.

References EC_JUMP_TAG, rb_vm_tag::state, and t.

Referenced by rb_catch().

◆ rb_each()

VALUE rb_each ( VALUE  obj)

Definition at line 1639 of file vm_eval.c.

References CALL_FCALL, and iter_method_arg::obj.

◆ rb_iterate()

VALUE rb_iterate ( VALUE(*)(VALUE it_proc,
VALUE  data1,
rb_block_call_func_t  bl_proc,
VALUE  data2 
)

Definition at line 1544 of file vm_eval.c.

Referenced by rb_block_call(), rb_block_call_kw(), and rb_check_block_call().

◆ rb_keyword_given_p()

int rb_keyword_given_p ( void  )

Definition at line 948 of file eval.c.

References rb_vm_cframe_keyword_p().

Referenced by rb_arith_seq_new(), rb_enumeratorize_with_size(), and rb_yield_block().

◆ rb_throw()

void rb_throw ( const char *  tag,
VALUE  val 
)

Definition at line 2315 of file vm_eval.c.

References rb_sym_intern_ascii_cstr, rb_throw_obj(), and rb_vm_tag::tag.

◆ rb_throw_obj()

void rb_throw_obj ( VALUE  tag,
VALUE  value 
)

◆ rb_vrescue2()

VALUE rb_vrescue2 ( VALUE(*)(VALUE b_proc,
VALUE  data1,
VALUE(*)(VALUE, VALUE r_proc,
VALUE  data2,
va_list  args 
)

An equivalent of rescue clause.

Equivalent to begin .. rescue err_type .. end

Parameters
[in]b_proca function which potentially raises an exception.
[in]data1the argument of b_proc
[in]r_proca function which rescues an exception in b_proc.
[in]data2the first argument of r_proc
[in]...1 or more exception classes. Must be terminated by (VALUE)0.

First it calls the function b_proc, with data1 as the argument. When b_proc raises an exception, it calls r_proc with data2 and the exception object if the exception is a kind of one of the given exception classes.

Returns
the return value of b_proc if no exception occurs, or the return value of r_proc if otherwise.
See also
rb_rescue
rb_ensure
rb_protect
Parameters
[in]argsexception classes, terminated by (VALUE)0.

Definition at line 1006 of file eval.c.

References rb_execution_context_struct::cfp, EC_EXEC_TAG, EC_JUMP_TAG, EC_POP_TAG, EC_PUSH_TAG, rb_execution_context_struct::errinfo, FALSE, Qfalse, Qnil, rb_obj_is_kind_of(), rb_vm_rewind_cfp(), TAG_NONE, TAG_RAISE, TAG_RETRY, and TRUE.

Referenced by ruby::backward::cxxanyargs::rb_rescue2(), and rb_rescue2().

◆ rb_yield()

VALUE rb_yield ( VALUE  val)

Definition at line 1341 of file vm_eval.c.

References NULL, and Qundef.

Referenced by ossl_generate_cb_2(), rb_ary_delete(), rb_ary_each(), and ruby_float_step().

◆ rb_yield_block()

VALUE rb_yield_block ( RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg)  )

◆ rb_yield_splat()

VALUE rb_yield_splat ( VALUE  values)

◆ rb_yield_splat_kw()

VALUE rb_yield_splat_kw ( VALUE  values,
int  kw_splat 
)

◆ rb_yield_values()

VALUE rb_yield_values ( int  n,
  ... 
)

Definition at line 1353 of file vm_eval.c.

References ALLOCA_N, and argv.

◆ rb_yield_values2()

VALUE rb_yield_values2 ( int  n,
const VALUE argv 
)

Definition at line 1375 of file vm_eval.c.

References argc, and argv.

◆ rb_yield_values_kw()

VALUE rb_yield_values_kw ( int  n,
const VALUE argv,
int  kw_splat 
)

Definition at line 1381 of file vm_eval.c.

References argc, and argv.