Ruby  2.4.2p198(2017-09-14revision59899)
Data Structures | Macros | Typedefs | Functions | Variables
enumerator.c File Reference
#include "internal.h"
Include dependency graph for enumerator.c:

Go to the source code of this file.

Data Structures

struct  enumerator
 
struct  generator
 
struct  yielder
 
struct  lazyenum_funcs
 
struct  proc_entry
 

Macros

#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 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_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)
 

Typedefs

typedef struct MEMOlazyenum_proc_func(VALUE, struct MEMO *, VALUE, long)
 
typedef VALUE lazyenum_size_func(VALUE, VALUE)
 

Functions

static VALUE generator_allocate (VALUE klass)
 
static VALUE generator_init (VALUE obj, VALUE proc)
 
static void enumerator_mark (void *p)
 
static size_t enumerator_memsize (const void *p)
 
static struct enumeratorenumerator_ptr (VALUE obj)
 
static void proc_entry_mark (void *p)
 
static size_t proc_entry_memsize (const void *p)
 
static struct proc_entryproc_entry_ptr (VALUE proc_entry)
 
static VALUE obj_to_enum (int argc, VALUE *argv, VALUE obj)
 
static VALUE enumerator_allocate (VALUE klass)
 
static VALUE enumerator_init (VALUE enum_obj, VALUE obj, VALUE meth, int argc, const VALUE *argv, rb_enumerator_size_func *size_fn, VALUE size)
 
static VALUE enumerator_initialize (int argc, VALUE *argv, VALUE obj)
 
static VALUE enumerator_init_copy (VALUE obj, VALUE orig)
 
VALUE rb_enumeratorize (VALUE obj, VALUE meth, int argc, const VALUE *argv)
 
static VALUE lazy_to_enum_i (VALUE self, VALUE meth, int argc, const VALUE *argv, rb_enumerator_size_func *size_fn)
 
VALUE rb_enumeratorize_with_size (VALUE obj, VALUE meth, int argc, const VALUE *argv, rb_enumerator_size_func *size_fn)
 
static VALUE enumerator_block_call (VALUE obj, rb_block_call_func *func, VALUE arg)
 
static VALUE enumerator_each (int argc, VALUE *argv, VALUE obj)
 
static VALUE enumerator_with_index_i (RB_BLOCK_CALL_FUNC_ARGLIST(val, m))
 
static VALUE enumerator_size (VALUE obj)
 
static VALUE enumerator_enum_size (VALUE obj, VALUE args, VALUE eobj)
 
static VALUE enumerator_with_index (int argc, VALUE *argv, VALUE obj)
 
static VALUE enumerator_each_with_index (VALUE obj)
 
static VALUE enumerator_with_object_i (RB_BLOCK_CALL_FUNC_ARGLIST(val, memo))
 
static VALUE enumerator_with_object (VALUE obj, VALUE memo)
 
static VALUE next_ii (RB_BLOCK_CALL_FUNC_ARGLIST(i, obj))
 
static VALUE next_i (VALUE curr, VALUE obj)
 
static void next_init (VALUE obj, struct enumerator *e)
 
static VALUE get_next_values (VALUE obj, struct enumerator *e)
 
static VALUE enumerator_next_values (VALUE obj)
 
static VALUE ary2sv (VALUE args, int dup)
 
static VALUE enumerator_next (VALUE obj)
 
static VALUE enumerator_peek_values (VALUE obj)
 
static VALUE enumerator_peek_values_m (VALUE obj)
 
static VALUE enumerator_peek (VALUE obj)
 
static VALUE enumerator_feed (VALUE obj, VALUE v)
 
static VALUE enumerator_rewind (VALUE obj)
 
static struct generatorgenerator_ptr (VALUE obj)
 
static VALUE append_method (VALUE obj, VALUE str, ID default_method, VALUE default_args)
 
static VALUE inspect_enumerator (VALUE obj, VALUE dummy, int recur)
 
static VALUE enumerator_inspect (VALUE obj)
 
static void yielder_mark (void *p)
 
static size_t yielder_memsize (const void *p)
 
static struct yielderyielder_ptr (VALUE obj)
 
static VALUE yielder_allocate (VALUE klass)
 
static VALUE yielder_init (VALUE obj, VALUE proc)
 
static VALUE yielder_initialize (VALUE obj)
 
static VALUE yielder_yield (VALUE obj, VALUE args)
 
static VALUE yielder_yield_push (VALUE obj, VALUE args)
 
static VALUE yielder_yield_i (RB_BLOCK_CALL_FUNC_ARGLIST(obj, memo))
 
static VALUE yielder_new (void)
 
static void generator_mark (void *p)
 
static size_t generator_memsize (const void *p)
 
static VALUE generator_initialize (int argc, VALUE *argv, VALUE obj)
 
static VALUE generator_init_copy (VALUE obj, VALUE orig)
 
static VALUE generator_each (int argc, VALUE *argv, VALUE obj)
 
static VALUE enum_size (VALUE self)
 
static VALUE lazyenum_size (VALUE self, VALUE args, VALUE eobj)
 
static VALUE lazy_size (VALUE self)
 
static VALUE lazy_receiver_size (VALUE generator, VALUE args, VALUE lazy)
 
static VALUE lazy_init_iterator (RB_BLOCK_CALL_FUNC_ARGLIST(val, m))
 
static VALUE lazy_init_block_i (RB_BLOCK_CALL_FUNC_ARGLIST(val, m))
 
static VALUE lazy_init_yielder (VALUE val, VALUE m, int argc, VALUE *argv)
 
static VALUE lazy_init_block (VALUE val, VALUE m, int argc, VALUE *argv)
 
static VALUE lazy_generator_init (VALUE enumerator, VALUE procs)
 
static VALUE lazy_initialize (int argc, VALUE *argv, VALUE self)
 
static void lazy_set_args (VALUE lazy, VALUE args)
 
static VALUE lazy_set_method (VALUE lazy, VALUE args, rb_enumerator_size_func *size_fn)
 
static VALUE lazy_add_method (VALUE obj, int argc, VALUE *argv, VALUE args, VALUE memo, const lazyenum_funcs *fn)
 
static VALUE enumerable_lazy (VALUE obj)
 
static VALUE lazy_to_enum (int argc, VALUE *argv, VALUE self)
 
static VALUE lazyenum_yield (VALUE proc_entry, struct MEMO *result)
 
static VALUE lazyenum_yield_values (VALUE proc_entry, struct MEMO *result)
 
static struct MEMOlazy_map_proc (VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
 
static VALUE lazy_map_size (VALUE entry, VALUE receiver)
 
static VALUE lazy_map (VALUE obj)
 
static VALUE lazy_flat_map_i (RB_BLOCK_CALL_FUNC_ARGLIST(i, yielder))
 
static VALUE lazy_flat_map_each (VALUE obj, VALUE yielder)
 
static VALUE lazy_flat_map_to_ary (VALUE obj, VALUE yielder)
 
static VALUE lazy_flat_map_proc (RB_BLOCK_CALL_FUNC_ARGLIST(val, m))
 
static VALUE lazy_flat_map (VALUE obj)
 
static struct MEMOlazy_select_proc (VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
 
static VALUE lazy_select (VALUE obj)
 
static struct MEMOlazy_reject_proc (VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
 
static VALUE lazy_reject (VALUE obj)
 
static struct MEMOlazy_grep_proc (VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
 
static struct MEMOlazy_grep_iter_proc (VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
 
static VALUE lazy_grep (VALUE obj, VALUE pattern)
 
static VALUE lazy_grep_v_func (RB_BLOCK_CALL_FUNC_ARGLIST(val, m))
 
static VALUE lazy_grep_v_iter (RB_BLOCK_CALL_FUNC_ARGLIST(val, m))
 
static VALUE lazy_grep_v (VALUE obj, VALUE pattern)
 
static VALUE call_next (VALUE obj)
 
static VALUE next_stopped (VALUE obj)
 
static VALUE lazy_zip_arrays_func (RB_BLOCK_CALL_FUNC_ARGLIST(val, arrays))
 
static VALUE lazy_zip_func (RB_BLOCK_CALL_FUNC_ARGLIST(val, zip_args))
 
static VALUE lazy_zip (int argc, VALUE *argv, VALUE obj)
 
static struct MEMOlazy_take_proc (VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
 
static VALUE lazy_take_size (VALUE entry, VALUE receiver)
 
static VALUE lazy_take (VALUE obj, VALUE n)
 
static struct MEMOlazy_take_while_proc (VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
 
static VALUE lazy_take_while (VALUE obj)
 
static VALUE lazy_drop_size (VALUE proc_entry, VALUE receiver)
 
static struct MEMOlazy_drop_proc (VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
 
static VALUE lazy_drop (VALUE obj, VALUE n)
 
static struct MEMOlazy_drop_while_proc (VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
 
static VALUE lazy_drop_while (VALUE obj)
 
static VALUE lazy_uniq_i (VALUE i, VALUE hash, int argc, const VALUE *argv, VALUE yielder)
 
static VALUE lazy_uniq_func (RB_BLOCK_CALL_FUNC_ARGLIST(i, hash))
 
static VALUE lazy_uniq_iter (RB_BLOCK_CALL_FUNC_ARGLIST(i, hash))
 
static VALUE lazy_uniq (VALUE obj)
 
static VALUE lazy_super (int argc, VALUE *argv, VALUE lazy)
 
static VALUE lazy_lazy (VALUE obj)
 
static VALUE stop_result (VALUE self)
 
void InitVM_Enumerator (void)
 
void Init_Enumerator (void)
 

Variables

VALUE rb_cEnumerator
 
VALUE rb_cLazy
 
static ID id_rewind
 
static ID id_each
 
static ID id_new
 
static ID id_initialize
 
static ID id_yield
 
static ID id_call
 
static ID id_size
 
static ID id_to_enum
 
static ID id_eqq
 
static ID id_next
 
static ID id_result
 
static ID id_lazy
 
static ID id_receiver
 
static ID id_arguments
 
static ID id_memo
 
static ID id_method
 
static ID id_force
 
static VALUE sym_each
 
static VALUE sym_cycle
 
VALUE rb_eStopIteration
 
static VALUE rb_cGenerator
 
static VALUE rb_cYielder
 
static const rb_data_type_t enumerator_data_type
 
static const rb_data_type_t proc_entry_data_type
 
static const rb_data_type_t yielder_data_type
 
static const rb_data_type_t generator_data_type
 
static const lazyenum_funcs lazy_map_funcs
 
static const lazyenum_funcs lazy_select_funcs
 
static const lazyenum_funcs lazy_reject_funcs
 
static const lazyenum_funcs lazy_grep_iter_funcs
 
static const lazyenum_funcs lazy_grep_funcs
 
static const lazyenum_funcs lazy_take_funcs
 
static const lazyenum_funcs lazy_take_while_funcs
 
static const lazyenum_funcs lazy_drop_funcs
 
static const lazyenum_funcs lazy_drop_while_funcs
 

Macro Definition Documentation

◆ enumerator_free

#define enumerator_free   RUBY_TYPED_DEFAULT_FREE

Definition at line 170 of file enumerator.c.

◆ generator_free

#define generator_free   RUBY_TYPED_DEFAULT_FREE

Definition at line 1261 of file enumerator.c.

◆ LAZY_MEMO_BREAK

#define LAZY_MEMO_BREAK   1

Definition at line 1445 of file enumerator.c.

◆ LAZY_MEMO_BREAK_P

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

Definition at line 1447 of file enumerator.c.

Referenced by lazy_init_yielder().

◆ LAZY_MEMO_PACKED

#define LAZY_MEMO_PACKED   2

Definition at line 1446 of file enumerator.c.

Referenced by lazy_init_yielder().

◆ LAZY_MEMO_PACKED_P

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

Definition at line 1448 of file enumerator.c.

Referenced by lazyenum_yield_values().

◆ LAZY_MEMO_RESET_PACKED

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

Definition at line 1452 of file enumerator.c.

Referenced by lazy_grep_iter_proc(), and lazy_map_proc().

◆ LAZY_MEMO_SET_BREAK

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

Definition at line 1449 of file enumerator.c.

Referenced by lazy_take_proc(), and lazy_take_while_proc().

◆ LAZY_MEMO_SET_PACKED

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

Definition at line 1451 of file enumerator.c.

◆ LAZY_MEMO_SET_VALUE

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

Definition at line 1450 of file enumerator.c.

Referenced by lazy_grep_iter_proc(), and lazy_map_proc().

◆ memo_flags

#define memo_flags   u3.state

Definition at line 1444 of file enumerator.c.

◆ memo_value

#define memo_value   v2

Definition at line 1443 of file enumerator.c.

◆ proc_entry_free

#define proc_entry_free   RUBY_TYPED_DEFAULT_FREE

Definition at line 208 of file enumerator.c.

◆ yielder_free

#define yielder_free   RUBY_TYPED_DEFAULT_FREE

Definition at line 1153 of file enumerator.c.

Typedef Documentation

◆ lazyenum_proc_func

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

Definition at line 136 of file enumerator.c.

◆ lazyenum_size_func

typedef VALUE lazyenum_size_func(VALUE, VALUE)

Definition at line 137 of file enumerator.c.

Function Documentation

◆ append_method()

static VALUE append_method ( VALUE  obj,
VALUE  str,
ID  default_method,
VALUE  default_args 
)
static

◆ ary2sv()

static VALUE ary2sv ( VALUE  args,
int  dup 
)
static

Definition at line 779 of file enumerator.c.

References enumerator::args, Qnil, RARRAY_AREF, RARRAY_LEN, rb_ary_dup(), RB_TYPE_P, and T_ARRAY.

Referenced by enumerator_next(), and enumerator_peek().

◆ call_next()

static VALUE call_next ( VALUE  obj)
static

Definition at line 1975 of file enumerator.c.

References id_next, and rb_funcall().

Referenced by lazy_zip_func().

◆ enum_size()

static VALUE enum_size ( VALUE  self)
static

Definition at line 1386 of file enumerator.c.

References id_size, Qnil, Qundef, and rb_check_funcall().

Referenced by lazy_size(), and lazyenum_size().

◆ enumerable_lazy()

static VALUE enumerable_lazy ( VALUE  obj)
static

Definition at line 1668 of file enumerator.c.

References id_method, lazy_to_enum_i(), lazyenum_size(), Qfalse, rb_ivar_set(), result, and sym_each.

Referenced by InitVM_Enumerator(), and lazy_super().

◆ enumerator_allocate()

static VALUE enumerator_allocate ( VALUE  klass)
static

◆ enumerator_block_call()

static VALUE enumerator_block_call ( VALUE  obj,
rb_block_call_func func,
VALUE  arg 
)
static

◆ enumerator_each()

static VALUE enumerator_each ( int  argc,
VALUE argv,
VALUE  obj 
)
static

◆ enumerator_each_with_index()

static VALUE enumerator_each_with_index ( VALUE  obj)
static

Definition at line 603 of file enumerator.c.

References enumerator_with_index(), and NULL.

Referenced by InitVM_Enumerator().

◆ enumerator_enum_size()

static VALUE enumerator_enum_size ( VALUE  obj,
VALUE  args,
VALUE  eobj 
)
static

Definition at line 561 of file enumerator.c.

References enumerator_size().

Referenced by enumerator_with_index(), and enumerator_with_object().

◆ enumerator_feed()

static VALUE enumerator_feed ( VALUE  obj,
VALUE  v 
)
static

Definition at line 948 of file enumerator.c.

References enumerator_ptr(), enumerator::feedvalue, Qnil, Qundef, rb_eTypeError, and rb_raise().

Referenced by InitVM_Enumerator().

◆ enumerator_init()

static VALUE enumerator_init ( VALUE  enum_obj,
VALUE  obj,
VALUE  meth,
int  argc,
const VALUE argv,
rb_enumerator_size_func size_fn,
VALUE  size 
)
static

◆ enumerator_init_copy()

static VALUE enumerator_init_copy ( VALUE  obj,
VALUE  orig 
)
static

◆ enumerator_initialize()

static VALUE enumerator_initialize ( int  argc,
VALUE argv,
VALUE  obj 
)
static

◆ enumerator_inspect()

static VALUE enumerator_inspect ( VALUE  obj)
static

Definition at line 1090 of file enumerator.c.

References inspect_enumerator(), and rb_exec_recursive().

Referenced by InitVM_Enumerator().

◆ enumerator_mark()

static void enumerator_mark ( void *  p)
static

◆ enumerator_memsize()

static size_t enumerator_memsize ( const void *  p)
static

Definition at line 173 of file enumerator.c.

◆ enumerator_next()

static VALUE enumerator_next ( VALUE  obj)
static

Definition at line 821 of file enumerator.c.

References ary2sv(), and enumerator_next_values().

Referenced by InitVM_Enumerator().

◆ enumerator_next_values()

static VALUE enumerator_next_values ( VALUE  obj)
static

Definition at line 764 of file enumerator.c.

References enumerator_ptr(), get_next_values(), enumerator::lookahead, and Qundef.

Referenced by enumerator_next(), and InitVM_Enumerator().

◆ enumerator_peek()

static VALUE enumerator_peek ( VALUE  obj)
static

Definition at line 895 of file enumerator.c.

References ary2sv(), and enumerator_peek_values().

Referenced by InitVM_Enumerator().

◆ enumerator_peek_values()

static VALUE enumerator_peek_values ( VALUE  obj)
static

◆ enumerator_peek_values_m()

static VALUE enumerator_peek_values_m ( VALUE  obj)
static

Definition at line 867 of file enumerator.c.

References enumerator_peek_values(), and rb_ary_dup().

Referenced by InitVM_Enumerator().

◆ enumerator_ptr()

static struct enumerator* enumerator_ptr ( VALUE  obj)
static

◆ enumerator_rewind()

static VALUE enumerator_rewind ( VALUE  obj)
static

◆ enumerator_size()

static VALUE enumerator_size ( VALUE  obj)
static

◆ enumerator_with_index()

static VALUE enumerator_with_index ( int  argc,
VALUE argv,
VALUE  obj 
)
static

◆ enumerator_with_index_i()

static VALUE enumerator_with_index_i ( RB_BLOCK_CALL_FUNC_ARGLIST(val, m)  )
static

◆ enumerator_with_object()

static VALUE enumerator_with_object ( VALUE  obj,
VALUE  memo 
)
static

◆ enumerator_with_object_i()

static VALUE enumerator_with_object_i ( RB_BLOCK_CALL_FUNC_ARGLIST(val, memo)  )
static

Definition at line 609 of file enumerator.c.

References rb_ary_new4, rb_yield_values(), and val.

Referenced by enumerator_with_object().

◆ generator_allocate()

static VALUE generator_allocate ( VALUE  klass)
static

◆ generator_each()

static VALUE generator_each ( int  argc,
VALUE argv,
VALUE  obj 
)
static

◆ generator_init()

static VALUE generator_init ( VALUE  obj,
VALUE  proc 
)
static

◆ generator_init_copy()

static VALUE generator_init_copy ( VALUE  obj,
VALUE  orig 
)
static

◆ generator_initialize()

static VALUE generator_initialize ( int  argc,
VALUE argv,
VALUE  obj 
)
static

◆ generator_mark()

static void generator_mark ( void *  p)
static

Definition at line 1254 of file enumerator.c.

References generator::obj, generator::proc, and rb_gc_mark().

◆ generator_memsize()

static size_t generator_memsize ( const void *  p)
static

Definition at line 1264 of file enumerator.c.

◆ generator_ptr()

static struct generator * generator_ptr ( VALUE  obj)
static

◆ get_next_values()

static VALUE get_next_values ( VALUE  obj,
struct enumerator e 
)
static

◆ Init_Enumerator()

void Init_Enumerator ( void  )

◆ InitVM_Enumerator()

void InitVM_Enumerator ( void  )

◆ inspect_enumerator()

static VALUE inspect_enumerator ( VALUE  obj,
VALUE  dummy,
int  recur 
)
static

◆ lazy_add_method()

static VALUE lazy_add_method ( VALUE  obj,
int  argc,
VALUE argv,
VALUE  args,
VALUE  memo,
const lazyenum_funcs fn 
)
static

◆ lazy_drop()

static VALUE lazy_drop ( VALUE  obj,
VALUE  n 
)
static

Definition at line 2189 of file enumerator.c.

References lazy_add_method(), len, NUM2LONG, rb_ary_new3, rb_eArgError, rb_raise(), and sym_each.

Referenced by InitVM_Enumerator().

◆ lazy_drop_proc()

static struct MEMO* lazy_drop_proc ( VALUE  proc_entry,
struct MEMO result,
VALUE  memos,
long  memo_index 
)
static

◆ lazy_drop_size()

static VALUE lazy_drop_size ( VALUE  proc_entry,
VALUE  receiver 
)
static

◆ lazy_drop_while()

static VALUE lazy_drop_while ( VALUE  obj)
static

Definition at line 2226 of file enumerator.c.

References lazy_add_method(), Qfalse, Qnil, rb_block_given_p(), rb_eArgError, and rb_raise().

Referenced by InitVM_Enumerator().

◆ lazy_drop_while_proc()

static struct MEMO* lazy_drop_while_proc ( VALUE  proc_entry,
struct MEMO result,
VALUE  memos,
long  memo_index 
)
static

◆ lazy_flat_map()

static VALUE lazy_flat_map ( VALUE  obj)
static

◆ lazy_flat_map_each()

static VALUE lazy_flat_map_each ( VALUE  obj,
VALUE  yielder 
)
static

Definition at line 1779 of file enumerator.c.

References id_each, lazy_flat_map_i(), Qnil, and rb_block_call().

Referenced by lazy_flat_map_proc().

◆ lazy_flat_map_i()

static VALUE lazy_flat_map_i ( RB_BLOCK_CALL_FUNC_ARGLIST(i, yielder )
static

Definition at line 1773 of file enumerator.c.

References id_yield, and rb_funcallv.

Referenced by lazy_flat_map_each().

◆ lazy_flat_map_proc()

static VALUE lazy_flat_map_proc ( RB_BLOCK_CALL_FUNC_ARGLIST(val, m)  )
static

◆ lazy_flat_map_to_ary()

static VALUE lazy_flat_map_to_ary ( VALUE  obj,
VALUE  yielder 
)
static

Definition at line 1786 of file enumerator.c.

References id_yield, NIL_P, Qnil, RARRAY_AREF, RARRAY_LEN, rb_check_array_type(), and rb_funcall().

Referenced by lazy_flat_map_proc().

◆ lazy_generator_init()

static VALUE lazy_generator_init ( VALUE  enumerator,
VALUE  procs 
)
static

◆ lazy_grep()

static VALUE lazy_grep ( VALUE  obj,
VALUE  pattern 
)
static

◆ lazy_grep_iter_proc()

static struct MEMO* lazy_grep_iter_proc ( VALUE  proc_entry,
struct MEMO result,
VALUE  memos,
long  memo_index 
)
static

◆ lazy_grep_proc()

static struct MEMO* lazy_grep_proc ( VALUE  proc_entry,
struct MEMO result,
VALUE  memos,
long  memo_index 
)
static

Definition at line 1902 of file enumerator.c.

References id_eqq, proc_entry::memo, proc_entry_ptr(), rb_funcall(), result, and RTEST.

◆ lazy_grep_v()

static VALUE lazy_grep_v ( VALUE  obj,
VALUE  pattern 
)
static

◆ lazy_grep_v_func()

static VALUE lazy_grep_v_func ( RB_BLOCK_CALL_FUNC_ARGLIST(val, m)  )
static

Definition at line 1941 of file enumerator.c.

References id_eqq, id_yield, Qnil, rb_enum_values_pack(), rb_funcall(), result, and RTEST.

Referenced by lazy_grep_v().

◆ lazy_grep_v_iter()

static VALUE lazy_grep_v_iter ( RB_BLOCK_CALL_FUNC_ARGLIST(val, m)  )
static

Definition at line 1953 of file enumerator.c.

References id_eqq, id_yield, Qnil, rb_enum_values_pack(), rb_funcall(), rb_yield(), result, and RTEST.

Referenced by lazy_grep_v().

◆ lazy_init_block()

static VALUE lazy_init_block ( VALUE  val,
VALUE  m,
int  argc,
VALUE argv 
)
static

◆ lazy_init_block_i()

static VALUE lazy_init_block_i ( RB_BLOCK_CALL_FUNC_ARGLIST(val, m)  )
static

Definition at line 1437 of file enumerator.c.

References id_each, lazy_init_iterator(), Qnil, rb_block_call(), and val.

Referenced by lazy_initialize().

◆ lazy_init_iterator()

static VALUE lazy_init_iterator ( RB_BLOCK_CALL_FUNC_ARGLIST(val, m)  )
static

◆ lazy_init_yielder()

static VALUE lazy_init_yielder ( VALUE  val,
VALUE  m,
int  argc,
VALUE argv 
)
static

◆ lazy_initialize()

static VALUE lazy_initialize ( int  argc,
VALUE argv,
VALUE  self 
)
static

◆ lazy_lazy()

static VALUE lazy_lazy ( VALUE  obj)
static

Definition at line 2277 of file enumerator.c.

References enumerator::obj.

Referenced by InitVM_Enumerator().

◆ lazy_map()

static VALUE lazy_map ( VALUE  obj)
static

Definition at line 1763 of file enumerator.c.

References lazy_add_method(), Qnil, rb_block_given_p(), rb_eArgError, and rb_raise().

Referenced by InitVM_Enumerator().

◆ lazy_map_proc()

static struct MEMO* lazy_map_proc ( VALUE  proc_entry,
struct MEMO result,
VALUE  memos,
long  memo_index 
)
static

◆ lazy_map_size()

static VALUE lazy_map_size ( VALUE  entry,
VALUE  receiver 
)
static

Definition at line 1753 of file enumerator.c.

◆ lazy_receiver_size()

static VALUE lazy_receiver_size ( VALUE  generator,
VALUE  args,
VALUE  lazy 
)
static

Definition at line 1405 of file enumerator.c.

References lazy_size().

Referenced by lazy_zip().

◆ lazy_reject()

static VALUE lazy_reject ( VALUE  obj)
static

Definition at line 1892 of file enumerator.c.

References lazy_add_method(), Qnil, rb_block_given_p(), rb_eArgError, and rb_raise().

Referenced by InitVM_Enumerator().

◆ lazy_reject_proc()

static struct MEMO* lazy_reject_proc ( VALUE  proc_entry,
struct MEMO result,
VALUE  memos,
long  memo_index 
)
static

Definition at line 1880 of file enumerator.c.

References lazyenum_yield(), result, and RTEST.

◆ lazy_select()

static VALUE lazy_select ( VALUE  obj)
static

Definition at line 1870 of file enumerator.c.

References lazy_add_method(), Qnil, rb_block_given_p(), rb_eArgError, and rb_raise().

Referenced by InitVM_Enumerator().

◆ lazy_select_proc()

static struct MEMO* lazy_select_proc ( VALUE  proc_entry,
struct MEMO result,
VALUE  memos,
long  memo_index 
)
static

Definition at line 1858 of file enumerator.c.

References lazyenum_yield(), result, and RTEST.

◆ lazy_set_args()

static void lazy_set_args ( VALUE  lazy,
VALUE  args 
)
static

Definition at line 1574 of file enumerator.c.

References ID2SYM, id_arguments, id_method, NIL_P, Qfalse, rb_frame_this_func(), and rb_ivar_set().

Referenced by lazy_add_method(), and lazy_set_method().

◆ lazy_set_method()

static VALUE lazy_set_method ( VALUE  lazy,
VALUE  args,
rb_enumerator_size_func size_fn 
)
static

Definition at line 1588 of file enumerator.c.

References enumerator_ptr(), lazy_set_args(), and enumerator::size_fn.

Referenced by lazy_flat_map(), lazy_grep_v(), lazy_uniq(), and lazy_zip().

◆ lazy_size()

static VALUE lazy_size ( VALUE  self)
static

Definition at line 1399 of file enumerator.c.

References enum_size(), id_receiver, and rb_ivar_get().

Referenced by lazy_receiver_size().

◆ lazy_super()

static VALUE lazy_super ( int  argc,
VALUE argv,
VALUE  lazy 
)
static

Definition at line 2271 of file enumerator.c.

References enumerable_lazy(), and rb_call_super().

Referenced by InitVM_Enumerator().

◆ lazy_take()

static VALUE lazy_take ( VALUE  obj,
VALUE  n 
)
static

Definition at line 2107 of file enumerator.c.

References INT2NUM, lazy_add_method(), len, NUM2LONG, rb_ary_new3, rb_eArgError, rb_raise(), and sym_cycle.

Referenced by InitVM_Enumerator().

◆ lazy_take_proc()

static struct MEMO* lazy_take_proc ( VALUE  proc_entry,
struct MEMO result,
VALUE  memos,
long  memo_index 
)
static

◆ lazy_take_size()

static VALUE lazy_take_size ( VALUE  entry,
VALUE  receiver 
)
static

Definition at line 2094 of file enumerator.c.

References FIX2LONG, FIXNUM_P, id_arguments, len, LONG2NUM, NIL_P, NUM2LONG, RARRAY_AREF, and rb_ivar_get().

◆ lazy_take_while()

static VALUE lazy_take_while ( VALUE  obj)
static

Definition at line 2142 of file enumerator.c.

References lazy_add_method(), Qnil, rb_block_given_p(), rb_eArgError, and rb_raise().

Referenced by InitVM_Enumerator().

◆ lazy_take_while_proc()

static struct MEMO* lazy_take_while_proc ( VALUE  proc_entry,
struct MEMO result,
VALUE  memos,
long  memo_index 
)
static

Definition at line 2127 of file enumerator.c.

References LAZY_MEMO_SET_BREAK, lazyenum_yield_values(), result, and RTEST.

◆ lazy_to_enum()

static VALUE lazy_to_enum ( int  argc,
VALUE argv,
VALUE  self 
)
static

◆ lazy_to_enum_i()

static VALUE lazy_to_enum_i ( VALUE  self,
VALUE  meth,
int  argc,
const VALUE argv,
rb_enumerator_size_func size_fn 
)
static

◆ lazy_uniq()

static VALUE lazy_uniq ( VALUE  obj)
static

◆ lazy_uniq_func()

static VALUE lazy_uniq_func ( RB_BLOCK_CALL_FUNC_ARGLIST(i, hash )
static

Definition at line 2244 of file enumerator.c.

References argc, hash(), lazy_uniq_i(), and rb_enum_values_pack().

Referenced by lazy_uniq().

◆ lazy_uniq_i()

static VALUE lazy_uniq_i ( VALUE  i,
VALUE  hash,
int  argc,
const VALUE argv,
VALUE  yielder 
)
static

Definition at line 2236 of file enumerator.c.

References id_yield, Qfalse, Qnil, rb_funcallv, and rb_hash_add_new_element().

Referenced by lazy_uniq_func(), and lazy_uniq_iter().

◆ lazy_uniq_iter()

static VALUE lazy_uniq_iter ( RB_BLOCK_CALL_FUNC_ARGLIST(i, hash )
static

Definition at line 2252 of file enumerator.c.

References argc, hash(), lazy_uniq_i(), and rb_yield_values2().

Referenced by lazy_uniq().

◆ lazy_zip()

static VALUE lazy_zip ( int  argc,
VALUE argv,
VALUE  obj 
)
static

◆ lazy_zip_arrays_func()

static VALUE lazy_zip_arrays_func ( RB_BLOCK_CALL_FUNC_ARGLIST(val, arrays)  )
static

◆ lazy_zip_func()

static VALUE lazy_zip_func ( RB_BLOCK_CALL_FUNC_ARGLIST(val, zip_args)  )
static

◆ lazyenum_size()

static VALUE lazyenum_size ( VALUE  self,
VALUE  args,
VALUE  eobj 
)
static

Definition at line 1393 of file enumerator.c.

References enum_size().

Referenced by enumerable_lazy().

◆ lazyenum_yield()

static VALUE lazyenum_yield ( VALUE  proc_entry,
struct MEMO result 
)
static

Definition at line 1723 of file enumerator.c.

References proc_entry::proc, proc_entry_ptr(), Qnil, and rb_proc_call_with_block().

Referenced by lazy_reject_proc(), and lazy_select_proc().

◆ lazyenum_yield_values()

static VALUE lazyenum_yield_values ( VALUE  proc_entry,
struct MEMO result 
)
static

◆ next_i()

static VALUE next_i ( VALUE  curr,
VALUE  obj 
)
static

◆ next_ii()

static VALUE next_ii ( RB_BLOCK_CALL_FUNC_ARGLIST(i, obj)  )
static

Definition at line 656 of file enumerator.c.

References enumerator::args, enumerator_ptr(), enumerator::feedvalue, Qnil, Qundef, rb_ary_new4, and rb_fiber_yield().

Referenced by next_i().

◆ next_init()

static void next_init ( VALUE  obj,
struct enumerator e 
)
static

◆ next_stopped()

static VALUE next_stopped ( VALUE  obj)
static

Definition at line 1981 of file enumerator.c.

References Qnil.

Referenced by lazy_zip_func().

◆ obj_to_enum()

static VALUE obj_to_enum ( int  argc,
VALUE argv,
VALUE  obj 
)
static

◆ proc_entry_mark()

static void proc_entry_mark ( void *  p)
static

Definition at line 201 of file enumerator.c.

References proc_entry::memo, proc_entry::proc, and rb_gc_mark().

◆ proc_entry_memsize()

static size_t proc_entry_memsize ( const void *  p)
static

Definition at line 211 of file enumerator.c.

◆ proc_entry_ptr()

static struct proc_entry* proc_entry_ptr ( VALUE  proc_entry)
static

◆ rb_enumeratorize()

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

◆ rb_enumeratorize_with_size()

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

◆ stop_result()

static VALUE stop_result ( VALUE  self)
static

Definition at line 2330 of file enumerator.c.

References id_result, and rb_attr_get().

Referenced by InitVM_Enumerator().

◆ yielder_allocate()

static VALUE yielder_allocate ( VALUE  klass)
static

Definition at line 1185 of file enumerator.c.

References enumerator::obj, yielder::proc, Qundef, and TypedData_Make_Struct.

Referenced by InitVM_Enumerator(), and yielder_new().

◆ yielder_init()

static VALUE yielder_init ( VALUE  obj,
VALUE  proc 
)
static

◆ yielder_initialize()

static VALUE yielder_initialize ( VALUE  obj)
static

Definition at line 1214 of file enumerator.c.

References rb_block_proc(), rb_need_block(), and yielder_init().

Referenced by InitVM_Enumerator().

◆ yielder_mark()

static void yielder_mark ( void *  p)
static

Definition at line 1147 of file enumerator.c.

References yielder::proc, and rb_gc_mark().

◆ yielder_memsize()

static size_t yielder_memsize ( const void *  p)
static

Definition at line 1156 of file enumerator.c.

◆ yielder_new()

static VALUE yielder_new ( void  )
static

Definition at line 1245 of file enumerator.c.

References rb_cYielder, rb_proc_new(), yielder_allocate(), yielder_init(), and yielder_yield_i().

Referenced by generator_each().

◆ yielder_ptr()

static struct yielder* yielder_ptr ( VALUE  obj)
static

Definition at line 1172 of file enumerator.c.

References yielder::proc, Qundef, rb_eArgError, rb_raise(), and TypedData_Get_Struct.

Referenced by yielder_yield().

◆ yielder_yield()

static VALUE yielder_yield ( VALUE  obj,
VALUE  args 
)
static

Definition at line 1223 of file enumerator.c.

References yielder::proc, rb_proc_call(), and yielder_ptr().

Referenced by InitVM_Enumerator(), and yielder_yield_push().

◆ yielder_yield_i()

static VALUE yielder_yield_i ( RB_BLOCK_CALL_FUNC_ARGLIST(obj, memo)  )
static

Definition at line 1239 of file enumerator.c.

References rb_yield_values2().

Referenced by yielder_new().

◆ yielder_yield_push()

static VALUE yielder_yield_push ( VALUE  obj,
VALUE  args 
)
static

Definition at line 1232 of file enumerator.c.

References enumerator::obj, and yielder_yield().

Referenced by InitVM_Enumerator().

Variable Documentation

◆ enumerator_data_type

const rb_data_type_t enumerator_data_type
static
Initial value:
= {
"enumerator",
{
},
}
static void enumerator_mark(void *p)
Definition: enumerator.c:156
#define RUBY_TYPED_FREE_IMMEDIATELY
Definition: ruby.h:1145
#define enumerator_free
Definition: enumerator.c:170
static size_t enumerator_memsize(const void *p)
Definition: enumerator.c:173

Definition at line 178 of file enumerator.c.

◆ generator_data_type

const rb_data_type_t generator_data_type
static
Initial value:
= {
"generator",
{
},
}
#define RUBY_TYPED_FREE_IMMEDIATELY
Definition: ruby.h:1145
static void generator_mark(void *p)
Definition: enumerator.c:1254
static size_t generator_memsize(const void *p)
Definition: enumerator.c:1264
#define generator_free
Definition: enumerator.c:1261

Definition at line 1269 of file enumerator.c.

◆ id_arguments

ID id_arguments
static

◆ id_call

ID id_call
static

Definition at line 105 of file enumerator.c.

Referenced by enumerator_initialize(), enumerator_size(), and Init_Enumerator().

◆ id_each

ID id_each
static

◆ id_eqq

ID id_eqq
static

◆ id_force

ID id_force
static

Definition at line 106 of file enumerator.c.

Referenced by Init_Enumerator(), and lazy_flat_map_proc().

◆ id_initialize

ID id_initialize
static

Definition at line 105 of file enumerator.c.

Referenced by Init_Enumerator(), lazy_generator_init(), and lazy_initialize().

◆ id_lazy

ID id_lazy
static

Definition at line 106 of file enumerator.c.

Referenced by Init_Enumerator().

◆ id_memo

ID id_memo
static

◆ id_method

ID id_method
static

◆ id_new

ID id_new
static

◆ id_next

ID id_next
static

Definition at line 106 of file enumerator.c.

Referenced by call_next(), and Init_Enumerator().

◆ id_receiver

ID id_receiver
static

Definition at line 106 of file enumerator.c.

Referenced by Init_Enumerator(), inspect_enumerator(), lazy_initialize(), and lazy_size().

◆ id_result

ID id_result
static

Definition at line 106 of file enumerator.c.

Referenced by Init_Enumerator(), next_i(), and stop_result().

◆ id_rewind

ID id_rewind
static

Definition at line 105 of file enumerator.c.

Referenced by enumerator_rewind(), and Init_Enumerator().

◆ id_size

ID id_size
static

Definition at line 105 of file enumerator.c.

Referenced by enum_size(), enumerator_size(), and Init_Enumerator().

◆ id_to_enum

ID id_to_enum
static

Definition at line 105 of file enumerator.c.

Referenced by Init_Enumerator(), and lazy_zip_func().

◆ id_yield

ID id_yield
static

◆ lazy_drop_funcs

const lazyenum_funcs lazy_drop_funcs
static
Initial value:
= {
}
static struct MEMO * lazy_drop_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
Definition: enumerator.c:2165
static VALUE lazy_drop_size(VALUE proc_entry, VALUE receiver)
Definition: enumerator.c:2152

Definition at line 2184 of file enumerator.c.

◆ lazy_drop_while_funcs

const lazyenum_funcs lazy_drop_while_funcs
static
Initial value:
= {
}
static struct MEMO * lazy_drop_while_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
Definition: enumerator.c:2204

Definition at line 2221 of file enumerator.c.

◆ lazy_grep_funcs

const lazyenum_funcs lazy_grep_funcs
static
Initial value:
= {
}
static struct MEMO * lazy_grep_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
Definition: enumerator.c:1902

Definition at line 1928 of file enumerator.c.

Referenced by lazy_grep().

◆ lazy_grep_iter_funcs

const lazyenum_funcs lazy_grep_iter_funcs
static
Initial value:
= {
}
static struct MEMO * lazy_grep_iter_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
Definition: enumerator.c:1911

Definition at line 1924 of file enumerator.c.

Referenced by lazy_grep().

◆ lazy_map_funcs

const lazyenum_funcs lazy_map_funcs
static
Initial value:
= {
}
static struct MEMO * lazy_map_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
Definition: enumerator.c:1744
static VALUE lazy_map_size(VALUE entry, VALUE receiver)
Definition: enumerator.c:1753

Definition at line 1758 of file enumerator.c.

◆ lazy_reject_funcs

const lazyenum_funcs lazy_reject_funcs
static
Initial value:
= {
}
static struct MEMO * lazy_reject_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
Definition: enumerator.c:1880

Definition at line 1887 of file enumerator.c.

◆ lazy_select_funcs

const lazyenum_funcs lazy_select_funcs
static
Initial value:
= {
}
static struct MEMO * lazy_select_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
Definition: enumerator.c:1858

Definition at line 1865 of file enumerator.c.

◆ lazy_take_funcs

const lazyenum_funcs lazy_take_funcs
static
Initial value:
= {
}
static VALUE lazy_take_size(VALUE entry, VALUE receiver)
Definition: enumerator.c:2094
static struct MEMO * lazy_take_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
Definition: enumerator.c:2072

Definition at line 2102 of file enumerator.c.

◆ lazy_take_while_funcs

const lazyenum_funcs lazy_take_while_funcs
static
Initial value:
= {
}
static struct MEMO * lazy_take_while_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
Definition: enumerator.c:2127

Definition at line 2137 of file enumerator.c.

◆ proc_entry_data_type

const rb_data_type_t proc_entry_data_type
static
Initial value:
= {
"proc_entry",
{
},
}
static size_t proc_entry_memsize(const void *p)
Definition: enumerator.c:211
#define proc_entry_free
Definition: enumerator.c:208
static void proc_entry_mark(void *p)
Definition: enumerator.c:201

Definition at line 216 of file enumerator.c.

Referenced by lazy_add_method(), and proc_entry_ptr().

◆ rb_cEnumerator

VALUE rb_cEnumerator

◆ rb_cGenerator

VALUE rb_cGenerator
static

◆ rb_cLazy

VALUE rb_cLazy

◆ rb_cYielder

VALUE rb_cYielder
static

Definition at line 125 of file enumerator.c.

Referenced by InitVM_Enumerator(), and yielder_new().

◆ rb_eStopIteration

VALUE rb_eStopIteration

◆ sym_cycle

VALUE sym_cycle
static

Definition at line 107 of file enumerator.c.

Referenced by Init_Enumerator(), and lazy_take().

◆ sym_each

VALUE sym_each
static

◆ yielder_data_type

const rb_data_type_t yielder_data_type
static
Initial value:
= {
"yielder",
{
},
}
#define RUBY_TYPED_FREE_IMMEDIATELY
Definition: ruby.h:1145
static void yielder_mark(void *p)
Definition: enumerator.c:1147
static size_t yielder_memsize(const void *p)
Definition: enumerator.c:1156
#define yielder_free
Definition: enumerator.c:1153

Definition at line 1161 of file enumerator.c.