Ruby 3.5.0dev (2025-02-20 revision 34098b669c0cbc024cd08e686891f1dfe0a10aaf)
iterator.h
Go to the documentation of this file.
1#ifndef RBIMPL_ITERATOR_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_ITERATOR_H
26#include "ruby/internal/value.h"
27
29
30
37#define RB_BLOCK_CALL_FUNC_STRICT 1
38
46#define RUBY_BLOCK_CALL_FUNC_TAKES_BLOCKARG 1
47
58#define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg) \
59 VALUE yielded_arg, VALUE callback_arg, int argc, const VALUE *argv, VALUE blockarg
60
83typedef VALUE rb_block_call_func(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg));
84
89
108VALUE rb_each(VALUE obj);
109
136VALUE rb_yield(VALUE val);
137
147VALUE rb_yield_values(int n, ...);
148
158VALUE rb_yield_values2(int n, const VALUE *argv);
159
173VALUE rb_yield_values_kw(int n, const VALUE *argv, int kw_splat);
174
184
197VALUE rb_yield_splat_kw(VALUE ary, int kw_splat);
198
235VALUE rb_yield_block(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg)); /* rb_block_call_func */
236
244int rb_keyword_given_p(void);
245
258int rb_block_given_p(void);
259
266void rb_need_block(void);
267
268#ifndef __cplusplus
269RBIMPL_ATTR_DEPRECATED(("by: rb_block_call since 1.9"))
270#endif
283VALUE rb_iterate(VALUE (*func1)(VALUE), VALUE data1, rb_block_call_func_t proc, VALUE data2);
284
285#ifdef __cplusplus
286namespace ruby {
287namespace backward {
300static inline VALUE
302{
303 return ::rb_iterate(iter, data1, bl, data2);
304}}}
305
306RBIMPL_ATTR_DEPRECATED(("by: rb_block_call since 1.9"))
307VALUE rb_iterate(VALUE (*func1)(VALUE), VALUE data1, rb_block_call_func_t proc, VALUE data2);
308#endif
309
324VALUE rb_block_call(VALUE obj, ID mid, int argc, const VALUE *argv, rb_block_call_func_t proc, VALUE data2);
325
343VALUE rb_block_call_kw(VALUE obj, ID mid, int argc, const VALUE *argv, rb_block_call_func_t proc, VALUE data2, int kw_splat);
344
364VALUE rb_rescue(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*r_proc)(VALUE, VALUE), VALUE data2);
365
388VALUE rb_rescue2(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*r_proc)(VALUE, VALUE), VALUE data2, ...);
389
408VALUE rb_vrescue2(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*r_proc)(VALUE, VALUE), VALUE data2, va_list ap);
409
425VALUE rb_ensure(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2);
426
472VALUE rb_catch(const char *tag, rb_block_call_func_t func, VALUE data);
473
484
497void rb_throw(const char *tag, VALUE val);
498
509void rb_throw_obj(VALUE tag, VALUE val);
510
512
513#endif /* RBIMPL_ITERATOR_H */
Defines RBIMPL_ATTR_DEPRECATED.
#define RBIMPL_ATTR_DEPRECATED(msg)
Wraps (or simulates) [[deprecated]]
Definition deprecated.h:64
Tweaking visibility of C variables/functions.
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:74
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:65
void rb_need_block(void)
Declares that the current method needs a block.
Definition eval.c:957
int rb_keyword_given_p(void)
Determines if the current method is given a keyword argument.
Definition eval.c:949
int rb_block_given_p(void)
Determines if the current method is given a block.
Definition eval.c:936
VALUE rb_rescue2(VALUE(*b_proc)(VALUE), VALUE data1, VALUE(*r_proc)(VALUE, VALUE), VALUE data2,...)
An equivalent of rescue clause.
Definition eval.c:965
VALUE rb_vrescue2(VALUE(*b_proc)(VALUE), VALUE data1, VALUE(*r_proc)(VALUE, VALUE), VALUE data2, va_list ap)
Identical to rb_rescue2(), except it takes va_list instead of variadic number of arguments.
Definition eval.c:976
VALUE rb_rescue(VALUE(*b_proc)(VALUE), VALUE data1, VALUE(*r_proc)(VALUE, VALUE), VALUE data2)
Identical to rb_rescue2(), except it does not take a list of exception classes.
Definition eval.c:1036
VALUE rb_ensure(VALUE(*b_proc)(VALUE), VALUE data1, VALUE(*e_proc)(VALUE), VALUE data2)
An equivalent to ensure clause.
Definition eval.c:1065
#define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg)
Shim for block function parameters.
Definition iterator.h:58
VALUE rb_catch_obj(VALUE tag, rb_block_call_func_t func, VALUE data)
Identical to rb_catch(), except it catches arbitrary Ruby objects.
Definition vm_eval.c:2630
VALUE rb_each(VALUE obj)
This is a shorthand of calling obj.each.
Definition vm_eval.c:1627
VALUE rb_block_call(VALUE obj, ID mid, int argc, const VALUE *argv, rb_block_call_func_t proc, VALUE data2)
Identical to rb_funcallv(), except it additionally passes a function as a block.
Definition vm_eval.c:1534
VALUE rb_yield_values(int n,...)
Identical to rb_yield(), except it takes variadic number of parameters and pass them to the block.
Definition vm_eval.c:1366
VALUE rb_yield_splat(VALUE ary)
Identical to rb_yield_values(), except it splats an array to generate the list of parameters.
Definition vm_eval.c:1400
void rb_throw(const char *tag, VALUE val)
Transfers control to the end of the active catch block waiting for tag.
Definition vm_eval.c:2518
VALUE rb_yield_values2(int n, const VALUE *argv)
Identical to rb_yield_values(), except it takes the parameters as a C array instead of variadic argum...
Definition vm_eval.c:1388
VALUE rb_yield(VALUE val)
Yields the block.
Definition vm_eval.c:1354
VALUE rb_yield_values_kw(int n, const VALUE *argv, int kw_splat)
Identical to rb_yield_values2(), except you can specify how to handle the last element of the given a...
Definition vm_eval.c:1394
rb_block_call_func * rb_block_call_func_t
Shorthand type that represents an iterator-written-in-C function pointer.
Definition iterator.h:88
VALUE rb_yield_block(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
Pass a passed block.
void rb_throw_obj(VALUE tag, VALUE val)
Identical to rb_throw(), except it allows arbitrary Ruby object to become a tag.
Definition vm_eval.c:2493
VALUE rb_block_call_func(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
This is the type of a function that the interpreter expect for C-backended blocks.
Definition iterator.h:83
VALUE rb_iterate(VALUE(*func1)(VALUE), VALUE data1, rb_block_call_func_t proc, VALUE data2)
Old way to iterate a block.
Definition vm_eval.c:1508
VALUE rb_catch(const char *tag, rb_block_call_func_t func, VALUE data)
Executes the passed block and catches values thrown from inside of it.
Definition vm_eval.c:2588
VALUE rb_block_call_kw(VALUE obj, ID mid, int argc, const VALUE *argv, rb_block_call_func_t proc, VALUE data2, int kw_splat)
Identical to rb_funcallv_kw(), except it additionally passes a function as a block.
Definition vm_eval.c:1541
VALUE rb_yield_splat_kw(VALUE ary, int kw_splat)
Identical to rb_yield_splat(), except you can specify how to handle the last element of the given arr...
Definition vm_eval.c:1413
static VALUE rb_iterate_deprecated(VALUE(*iter)(VALUE), VALUE data1, rb_block_call_func_t bl, VALUE data2)
Old way to iterate a block.
Definition iterator.h:301
The main namespace.
Defines RBIMPL_ATTR_NORETURN.
#define RBIMPL_ATTR_NORETURN()
Wraps (or simulates) [[noreturn]]
Definition noreturn.h:38
Defines VALUE and ID.
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
Definition value.h:52
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40