Ruby: include/ruby/internal/iterator.h Source File

Ruby 3.3.7p123 (2025-01-15 revision be31f993d7fa0219d85f7b3c694d454da4ecc10b)

iterator.h
Go to the documentation of this file.
1#ifndef RBIMPL_ITERATOR_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_ITERATOR_H
23#include "ruby/internal/attr/deprecated.h"
24#include "ruby/internal/attr/noreturn.h"
25#include "ruby/internal/dllexport.h"
26#include "ruby/internal/value.h"
27
28 RBIMPL_SYMBOL_EXPORT_BEGIN()
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
83 typedef VALUE rb_block_call_func(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg));
84
88 typedef rb_block_call_func *rb_block_call_func_t;
89
108 VALUE rb_each(VALUE obj);
109
136 VALUE rb_yield(VALUE val);
137
147 VALUE rb_yield_values(int n, ...);
148
158 VALUE rb_yield_values2(int n, const VALUE *argv);
159
173 VALUE rb_yield_values_kw(int n, const VALUE *argv, int kw_splat);
174
183 VALUE rb_yield_splat(VALUE ary);
184
197 VALUE rb_yield_splat_kw(VALUE ary, int kw_splat);
198
235 VALUE 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
269 RBIMPL_ATTR_DEPRECATED(("by: rb_block_call since 1.9"))
270#endif
283 VALUE 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
301rb_iterate_deprecated(VALUE (*iter)(VALUE), VALUE data1, rb_block_call_func_t bl, VALUE data2)
302{
303 return ::rb_iterate(iter, data1, bl, data2);
304}}}
305
306 RBIMPL_ATTR_DEPRECATED(("by: rb_block_call since 1.9"))
307 VALUE rb_iterate(VALUE (*func1)(VALUE), VALUE data1, rb_block_call_func_t proc, VALUE data2);
308#endif
309
324 VALUE rb_block_call(VALUE obj, ID mid, int argc, const VALUE *argv, rb_block_call_func_t proc, VALUE data2);
325
343 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);
344
364 VALUE rb_rescue(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*r_proc)(VALUE, VALUE), VALUE data2);
365
388 VALUE rb_rescue2(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*r_proc)(VALUE, VALUE), VALUE data2, ...);
389
408 VALUE rb_vrescue2(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*r_proc)(VALUE, VALUE), VALUE data2, va_list ap);
409
425 VALUE rb_ensure(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2);
426
472 VALUE rb_catch(const char *tag, rb_block_call_func_t func, VALUE data);
473
483 VALUE rb_catch_obj(VALUE tag, rb_block_call_func_t func, VALUE data);
484
485 RBIMPL_ATTR_NORETURN()
497void rb_throw(const char *tag, VALUE val);
498
499 RBIMPL_ATTR_NORETURN()
509void rb_throw_obj(VALUE tag, VALUE val);
510
511 RBIMPL_SYMBOL_EXPORT_END()
512
513#endif /* RBIMPL_ITERATOR_H */
deprecated.h
Defines RBIMPL_ATTR_DEPRECATED.
RBIMPL_ATTR_DEPRECATED
#define RBIMPL_ATTR_DEPRECATED(msg)
Wraps (or simulates) [[deprecated]]
Definition deprecated.h:64
dllexport.h
Tweaking visibility of C variables/functions.
RBIMPL_SYMBOL_EXPORT_END
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:74
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:65
rb_need_block
void rb_need_block(void)
Declares that the current method needs a block.
Definition eval.c:887
rb_keyword_given_p
int rb_keyword_given_p(void)
Determines if the current method is given a keyword argument.
Definition eval.c:879
rb_block_given_p
int rb_block_given_p(void)
Determines if the current method is given a block.
Definition eval.c:866
rb_rescue2
VALUE rb_rescue2(VALUE(*b_proc)(VALUE), VALUE data1, VALUE(*r_proc)(VALUE, VALUE), VALUE data2,...)
An equivalent of rescue clause.
Definition eval.c:895
rb_vrescue2
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:906
rb_rescue
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:966
rb_ensure
VALUE rb_ensure(VALUE(*b_proc)(VALUE), VALUE data1, VALUE(*e_proc)(VALUE), VALUE data2)
An equivalent to ensure clause.
Definition eval.c:995
RB_BLOCK_CALL_FUNC_ARGLIST
#define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg)
Shim for block function parameters.
Definition iterator.h:58
rb_catch_obj
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:2391
rb_each
VALUE rb_each(VALUE obj)
This is a shorthand of calling obj.each.
Definition vm_eval.c:1618
rb_block_call
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:1556
rb_yield_values
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:1388
rb_yield_splat
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:1422
rb_throw
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:2279
rb_yield_values2
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:1410
rb_yield
VALUE rb_yield(VALUE val)
Yields the block.
Definition vm_eval.c:1376
rb_yield_values_kw
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:1416
rb_block_call_func_t
rb_block_call_func * rb_block_call_func_t
Shorthand type that represents an iterator-written-in-C function pointer.
Definition iterator.h:88
rb_yield_block
VALUE rb_yield_block(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
Pass a passed block.
rb_throw_obj
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:2254
rb_block_call_func
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
rb_iterate
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:1530
rb_catch
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:2349
rb_block_call_kw
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:1563
rb_yield_splat_kw
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:1435
ruby::backward::rb_iterate_deprecated
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
ruby
The main namespace.
Definition cxxanyargs.hpp:37
noreturn.h
Defines RBIMPL_ATTR_NORETURN.
RBIMPL_ATTR_NORETURN
#define RBIMPL_ATTR_NORETURN()
Wraps (or simulates) [[noreturn]]
Definition noreturn.h:38
value.h
Defines VALUE and ID.
ID
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
Definition value.h:52
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40