Ruby: enumerator.c File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Data Structures | Macros | Typedefs | Functions | Variables
enumerator.c File Reference
`#include "ruby/internal/config.h"`
`#include "id.h"`
`#include "internal.h"`
`#include "internal/enumerator.h"`
`#include "internal/error.h"`
`#include "internal/hash.h"`
`#include "internal/imemo.h"`
`#include "internal/numeric.h"`
`#include "internal/range.h"`
`#include "internal/rational.h"`
`#include "ruby/ruby.h"`

Go to the source code of this file.

## Data Structures
struct | enumerator
struct | generator
struct | yielder
struct | producer
struct | lazyenum_funcs
struct | proc_entry
struct | enum_chain
struct | flat_map_i_arg
struct | arith_seq_gen

## Macros
#define | id_call idCall
#define | id_each idEach
#define | id_eqq idEqq
#define | id_initialize idInitialize
#define | id_size idSize
#define | enumerator_free RUBY_TYPED_DEFAULT_FREE
#define | proc_entry_free RUBY_TYPED_DEFAULT_FREE
#define | yielder_free RUBY_TYPED_DEFAULT_FREE
#define | generator_free RUBY_TYPED_DEFAULT_FREE
#define | lazy_receiver_size lazy_map_size
#define | memo_value v2
#define | memo_flags u3.state
#define | LAZY_MEMO_BREAK 1
#define | LAZY_MEMO_PACKED 2
#define | LAZY_MEMO_BREAK_P(memo) ((memo)->memo_flags & LAZY_MEMO_BREAK)
#define | LAZY_MEMO_PACKED_P(memo) ((memo)->memo_flags & LAZY_MEMO_PACKED)
#define | LAZY_MEMO_SET_BREAK(memo) ((memo)->memo_flags |= LAZY_MEMO_BREAK)
#define | LAZY_MEMO_RESET_BREAK(memo) ((memo)->memo_flags &= ~LAZY_MEMO_BREAK)
#define | LAZY_MEMO_SET_VALUE(memo, value) MEMO_V2_SET(memo, value)
#define | LAZY_MEMO_SET_PACKED(memo) ((memo)->memo_flags |= LAZY_MEMO_PACKED)
#define | LAZY_MEMO_RESET_PACKED(memo) ((memo)->memo_flags &= ~LAZY_MEMO_PACKED)
#define | producer_free RUBY_TYPED_DEFAULT_FREE
#define | enum_chain_free RUBY_TYPED_DEFAULT_FREE
#define | NUM_GE(x, y) RTEST(rb_num_coerce_relop((x), (y), idGE))
#define | sym(name) ID2SYM(rb_intern_const(name))

## Typedefs
typedef struct MEMO * | lazyenum_proc_func(VALUE, struct MEMO *, VALUE, long)
typedef VALUE | lazyenum_size_func(VALUE, VALUE)

## Functions
VALUE | rb_enumeratorize (VALUE obj, VALUE meth, int argc, const VALUE *argv)
VALUE | rb_enumeratorize_with_size (VALUE obj, VALUE meth, int argc, const VALUE *argv, rb_enumerator_size_func *size_fn)
VALUE | rb_enumeratorize_with_size_kw (VALUE obj, VALUE meth, int argc, const VALUE *argv, rb_enumerator_size_func *size_fn, int kw_splat)
VALUE | rb_arith_seq_new (VALUE obj, VALUE meth, int argc, VALUE const *argv, rb_enumerator_size_func *size_fn, VALUE beg, VALUE end, VALUE step, int excl)
int | rb_arithmetic_sequence_extract (VALUE obj, rb_arithmetic_sequence_components_t *component)
VALUE | rb_arithmetic_sequence_beg_len_step (VALUE obj, long *begp, long *lenp, long *stepp, long len, int err)
void | InitVM_Enumerator (void)
void | Init_Enumerator (void)

## Variables
VALUE | rb_cEnumerator
VALUE | rb_eStopIteration
VALUE | rb_cArithSeq

## Macro Definition Documentation

## ◆ enum_chain_free

#define enum_chain_free RUBY_TYPED_DEFAULT_FREE

Definition at line 3051 of file enumerator.c.

## ◆ enumerator_free

#define enumerator_free RUBY_TYPED_DEFAULT_FREE

Definition at line 232 of file enumerator.c.

## ◆ generator_free

#define generator_free RUBY_TYPED_DEFAULT_FREE

Definition at line 1399 of file enumerator.c.

## ◆ id_call

#define id_call idCall

Definition at line 135 of file enumerator.c.

## ◆ id_each

#define id_each idEach

Definition at line 136 of file enumerator.c.

## ◆ id_eqq

#define id_eqq idEqq

Definition at line 137 of file enumerator.c.

## ◆ id_initialize

#define id_initialize idInitialize

Definition at line 138 of file enumerator.c.

## ◆ id_size

#define id_size idSize

Definition at line 139 of file enumerator.c.

## ◆ LAZY_MEMO_BREAK

#define LAZY_MEMO_BREAK 1

Definition at line 1574 of file enumerator.c.

## ◆ LAZY_MEMO_BREAK_P

#define LAZY_MEMO_BREAK_P | ( |  | memo | ) | ((memo)->memo_flags & LAZY_MEMO_BREAK)

Definition at line 1576 of file enumerator.c.

## ◆ LAZY_MEMO_PACKED

#define LAZY_MEMO_PACKED 2

Definition at line 1575 of file enumerator.c.

## ◆ LAZY_MEMO_PACKED_P

#define LAZY_MEMO_PACKED_P | ( |  | memo | ) | ((memo)->memo_flags & LAZY_MEMO_PACKED)

Definition at line 1577 of file enumerator.c.

## ◆ LAZY_MEMO_RESET_BREAK

#define LAZY_MEMO_RESET_BREAK | ( |  | memo | ) | ((memo)->memo_flags &= ~LAZY_MEMO_BREAK)

Definition at line 1579 of file enumerator.c.

## ◆ LAZY_MEMO_RESET_PACKED

#define LAZY_MEMO_RESET_PACKED | ( |  | memo | ) | ((memo)->memo_flags &= ~LAZY_MEMO_PACKED)

Definition at line 1582 of file enumerator.c.

## ◆ LAZY_MEMO_SET_BREAK

#define LAZY_MEMO_SET_BREAK | ( |  | memo | ) | ((memo)->memo_flags |= LAZY_MEMO_BREAK)

Definition at line 1578 of file enumerator.c.

## ◆ LAZY_MEMO_SET_PACKED

#define LAZY_MEMO_SET_PACKED | ( |  | memo | ) | ((memo)->memo_flags |= LAZY_MEMO_PACKED)

Definition at line 1581 of file enumerator.c.

## ◆ LAZY_MEMO_SET_VALUE

#define LAZY_MEMO_SET_VALUE | ( |  | memo,
|  |  | value
| ) |  | MEMO_V2_SET(memo, value)

Definition at line 1580 of file enumerator.c.

## ◆ lazy_receiver_size

#define lazy_receiver_size lazy_map_size

Definition at line 1537 of file enumerator.c.

## ◆ memo_flags

#define memo_flags u3.state

Definition at line 1573 of file enumerator.c.

## ◆ memo_value

#define memo_value v2

Definition at line 1572 of file enumerator.c.

## ◆ NUM_GE

#define NUM_GE | ( |  | x,
|  |  | y
| ) |  | RTEST(rb_num_coerce_relop((x), (y), idGE))

Definition at line 3870 of file enumerator.c.

## ◆ proc_entry_free

#define proc_entry_free RUBY_TYPED_DEFAULT_FREE

Definition at line 279 of file enumerator.c.

## ◆ producer_free

#define producer_free RUBY_TYPED_DEFAULT_FREE

Definition at line 2865 of file enumerator.c.

## ◆ sym

#define sym | ( |  | name | ) | ID2SYM(rb_intern_const(name))

Definition at line 4007 of file enumerator.c.

## ◆ yielder_free

#define yielder_free RUBY_TYPED_DEFAULT_FREE

Definition at line 1259 of file enumerator.c.

## Typedef Documentation

## ◆ lazyenum_proc_func

typedef struct MEMO * lazyenum_proc_func(VALUE, struct MEMO *, VALUE, long)

Definition at line 174 of file enumerator.c.

## ◆ lazyenum_size_func

typedef VALUE lazyenum_size_func(VALUE, VALUE)

Definition at line 175 of file enumerator.c.

## Function Documentation

## ◆ Init_Enumerator()

void Init_Enumerator | ( | void |  | ) |

Definition at line 4198 of file enumerator.c.

References ID2SYM, id_each, and InitVM.

## ◆ InitVM_Enumerator()

void InitVM_Enumerator | ( | void |  | ) |

Definition at line 4009 of file enumerator.c.

References CLASS_OF, rb_cArithSeq, rb_cEnumerator, rb_cObject, rb_define_alias(), rb_define_alloc_func(), rb_define_class(), rb_define_class_under(), rb_define_method, rb_define_private_method, rb_define_singleton_method, rb_eIndexError, rb_eStopIteration, rb_funcall(), rb_gc_register_mark_object(), rb_hash_aset(), rb_hash_new_with_size(), rb_include_module(), rb_mEnumerable, rb_mKernel, rb_obj_freeze(), rb_provide(), rb_undef_alloc_func(), rb_undef_method(), and sym.

## ◆ rb_arith_seq_new()

VALUE rb_arith_seq_new | ( | VALUE | obj,
|  | VALUE | meth,
|  | int | argc,
|  | VALUE const * | argv,
|  | rb_enumerator_size_func * | size_fn,
|  | VALUE | beg,
|  | VALUE | end,
|  | VALUE | step,
|  | int | excl
| ) |  |

Definition at line 3327 of file enumerator.c.

References argc, argv, Qfalse, Qnil, Qtrue, rb_cArithSeq, rb_ivar_set(), and rb_keyword_given_p().

## ◆ rb_arithmetic_sequence_beg_len_step()

VALUE rb_arithmetic_sequence_beg_len_step | ( | VALUE | obj,
|  | long * | begp,
|  | long * | lenp,
|  | long * | stepp,
|  | long | len,
|  | int | err
| ) |  |

Definition at line 3411 of file enumerator.c.

References rb_arithmetic_sequence_components_t::begin, rb_arithmetic_sequence_components_t::end, err, rb_arithmetic_sequence_components_t::exclude_end, len, NIL_P, NULL, NUM2LONG, PRIsVALUE, Qfalse, Qnil, Qtrue, rb_arithmetic_sequence_extract(), rb_eRangeError, rb_raise(), rb_range_component_beg_len(), RUBY_ASSERT, and rb_arithmetic_sequence_components_t::step.

Referenced by rb_ary_aref1().

## ◆ rb_arithmetic_sequence_extract()

int rb_arithmetic_sequence_extract | ( | VALUE | obj,
|  | rb_arithmetic_sequence_components_t * | component
| ) |  |

Definition at line 3393 of file enumerator.c.

References rb_arithmetic_sequence_components_t::begin, rb_arithmetic_sequence_components_t::end, rb_arithmetic_sequence_components_t::exclude_end, INT2FIX, rb_cArithSeq, rb_obj_is_kind_of(), rb_range_values(), and rb_arithmetic_sequence_components_t::step.

Referenced by rb_arithmetic_sequence_beg_len_step().

## ◆ rb_enumeratorize()

VALUE rb_enumeratorize | ( | VALUE | obj,
|  | VALUE | meth,
|  | int | argc,
|  | const VALUE * | argv
| ) |  |

Definition at line 511 of file enumerator.c.

References argc, argv, enumerator::meth, enumerator::obj, and rb_enumeratorize_with_size.

## ◆ rb_enumeratorize_with_size()

VALUE rb_enumeratorize_with_size | ( | VALUE | obj,
|  | VALUE | meth,
|  | int | argc,
|  | const VALUE * | argv,
|  | rb_enumerator_size_func * | size_fn
| ) |  |

Definition at line 520 of file enumerator.c.

References argc, argv, enumerator::meth, enumerator::obj, Qnil, rb_cEnumerator, rb_keyword_given_p(), rb_obj_is_kind_of(), RTEST, and enumerator::size_fn.

## ◆ rb_enumeratorize_with_size_kw()

VALUE rb_enumeratorize_with_size_kw | ( | VALUE | obj,
|  | VALUE | meth,
|  | int | argc,
|  | const VALUE * | argv,
|  | rb_enumerator_size_func * | size_fn,
|  | int | kw_splat
| ) |  |

Definition at line 532 of file enumerator.c.

References argc, argv, enumerator::kw_splat, enumerator::meth, enumerator::obj, Qnil, rb_cEnumerator, rb_obj_is_kind_of(), RTEST, and enumerator::size_fn.

## Variable Documentation

## ◆ rb_cArithSeq

VALUE rb_cArithSeq

Definition at line 197 of file enumerator.c.

Referenced by InitVM_Enumerator(), rb_arith_seq_new(), rb_arithmetic_sequence_extract(), and rb_range_values().

## ◆ rb_cEnumerator

VALUE rb_cEnumerator

Definition at line 126 of file enumerator.c.

Referenced by InitVM_Enumerator(), rb_enumeratorize_with_size(), and rb_enumeratorize_with_size_kw().

## ◆ rb_eStopIteration

VALUE rb_eStopIteration

Definition at line 141 of file enumerator.c.

Referenced by Init_Ractor(), and InitVM_Enumerator().