Ruby  2.5.0dev(2017-10-22revision60238)
Data Structures | Macros | Functions | Variables
enum.c File Reference
#include "internal.h"
#include "ruby/util.h"
#include "id.h"
#include "symbol.h"
#include <assert.h>

Go to the source code of this file.

Data Structures

struct  sort_by_data
 
struct  nmin_data
 
struct  min_t
 
struct  max_t
 
struct  minmax_t
 
struct  minmax_by_t
 
struct  chunk_arg
 
struct  slicebefore_arg
 
struct  sliceafter_arg
 
struct  slicewhen_arg
 
struct  enum_sum_memo
 

Macros

#define id_each   idEach
 
#define id_eqq   idEqq
 
#define id_cmp   idCmp
 
#define id_lshift   idLTLT
 
#define id_call   idCall
 
#define id_size   idSize
 
#define ENUM_WANT_SVALUE()
 
#define SORT_BY_BUFSIZE   16
 
#define ENUMFUNC(name)   rb_block_given_p() ? name##_iter_i : name##_i
 
#define DEFINE_ENUMFUNCS(name)
 
#define rb_cmpint(cmp, a, b)   rb_cmpint(cmpint_reenter_check(data, (cmp)), a, b)
 
#define GETPTR(i)   (beg+(i)*eltsize)
 
#define SWAP(i, j)
 
#define dont_recycle_block_arg(arity)   ((arity) == 1 || (arity) < 0)
 
#define UPDATE_MEMO   ((void)(memo = MEMO_FOR(struct sliceafter_arg, _memo)))
 
#define UPDATE_MEMO   ((void)(memo = MEMO_FOR(struct slicewhen_arg, _memo)))
 
#define rb_intern(str)   rb_intern_const(str)
 

Functions

VALUE rb_enum_values_pack (int argc, const VALUE *argv)
 
 DEFINE_ENUMFUNCS (all)
 
 DEFINE_ENUMFUNCS (any)
 
 DEFINE_ENUMFUNCS (one)
 
VALUE rb_nmin_run (VALUE obj, VALUE num, int by, int rev, int ary)
 
 DEFINE_ENUMFUNCS (none)
 
void Init_Enumerable (void)
 

Variables

VALUE rb_mEnumerable
 

Macro Definition Documentation

◆ DEFINE_ENUMFUNCS

#define DEFINE_ENUMFUNCS (   name)
Value:
static VALUE enum_##name##_func(VALUE result, struct MEMO *memo); \
\
static VALUE \
name##_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, memo)) \
{ \
return enum_##name##_func(rb_enum_values_pack(argc, argv), MEMO_CAST(memo)); \
} \
\
static VALUE \
name##_iter_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, memo)) \
{ \
return enum_##name##_func(rb_yield_values2(argc, argv), MEMO_CAST(memo)); \
} \
\
static VALUE \
enum_##name##_func(VALUE result, struct MEMO *memo)
#define MEMO_CAST(m)
Definition: internal.h:961
#define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg)
Definition: ruby.h:1851
MEMO.
Definition: internal.h:945
int argc
Definition: ruby.c:187
unsigned long VALUE
Definition: ruby.h:85
VALUE rb_yield_values2(int n, const VALUE *argv)
Definition: vm_eval.c:1007
VALUE rb_enum_values_pack(int argc, const VALUE *argv)
Definition: enum.c:32
const char * name
Definition: nkf.c:208
char ** argv
Definition: ruby.c:188

Definition at line 1155 of file enum.c.

◆ dont_recycle_block_arg

#define dont_recycle_block_arg (   arity)    ((arity) == 1 || (arity) < 0)

Definition at line 2330 of file enum.c.

◆ ENUM_WANT_SVALUE

#define ENUM_WANT_SVALUE ( )
Value:
do { \
} while (0)
int argc
Definition: ruby.c:187
VALUE rb_enum_values_pack(int argc, const VALUE *argv)
Definition: enum.c:32
char ** argv
Definition: ruby.c:188

Definition at line 39 of file enum.c.

◆ ENUMFUNC

#define ENUMFUNC (   name)    rb_block_given_p() ? name##_iter_i : name##_i

Definition at line 1153 of file enum.c.

◆ GETPTR

#define GETPTR (   i)    (beg+(i)*eltsize)

◆ id_call

#define id_call   idCall

Definition at line 28 of file enum.c.

◆ id_cmp

#define id_cmp   idCmp

Definition at line 26 of file enum.c.

◆ id_each

#define id_each   idEach

Definition at line 24 of file enum.c.

◆ id_eqq

#define id_eqq   idEqq

Definition at line 25 of file enum.c.

◆ id_lshift

#define id_lshift   idLTLT

Definition at line 27 of file enum.c.

◆ id_size

#define id_size   idSize

Definition at line 29 of file enum.c.

◆ rb_cmpint

#define rb_cmpint (   cmp,
  a,
 
)    rb_cmpint(cmpint_reenter_check(data, (cmp)), a, b)

◆ rb_intern

#define rb_intern (   str)    rb_intern_const(str)

◆ SORT_BY_BUFSIZE

#define SORT_BY_BUFSIZE   16

Definition at line 976 of file enum.c.

◆ SWAP

#define SWAP (   i,
 
)
Value:
do { \
VALUE tmp[2]; \
memcpy(tmp, GETPTR(i), sizeof(VALUE)*eltsize); \
memcpy(GETPTR(i), GETPTR(j), sizeof(VALUE)*eltsize); \
memcpy(GETPTR(j), tmp, sizeof(VALUE)*eltsize); \
} while (0)
#define GETPTR(i)
unsigned long VALUE
Definition: ruby.h:85

◆ UPDATE_MEMO [1/2]

#define UPDATE_MEMO   ((void)(memo = MEMO_FOR(struct sliceafter_arg, _memo)))

◆ UPDATE_MEMO [2/2]

#define UPDATE_MEMO   ((void)(memo = MEMO_FOR(struct slicewhen_arg, _memo)))

Function Documentation

◆ DEFINE_ENUMFUNCS() [1/4]

DEFINE_ENUMFUNCS ( all  )

Definition at line 1173 of file enum.c.

References RTEST.

◆ DEFINE_ENUMFUNCS() [2/4]

DEFINE_ENUMFUNCS ( any  )

Definition at line 1208 of file enum.c.

References RTEST.

◆ DEFINE_ENUMFUNCS() [3/4]

DEFINE_ENUMFUNCS ( one  )

Definition at line 1243 of file enum.c.

◆ DEFINE_ENUMFUNCS() [4/4]

DEFINE_ENUMFUNCS ( none  )

Definition at line 1505 of file enum.c.

References RTEST.

◆ Init_Enumerable()

void Init_Enumerable ( void  )

Definition at line 3939 of file enum.c.

References rb_define_method(), rb_define_module(), and rb_mEnumerable.

◆ rb_enum_values_pack()

VALUE rb_enum_values_pack ( int  argc,
const VALUE argv 
)

Definition at line 32 of file enum.c.

References Qnil, and rb_ary_new4.

◆ rb_nmin_run()

VALUE rb_nmin_run ( VALUE  obj,
VALUE  num,
int  by,
int  rev,
int  ary 
)

Definition at line 1417 of file enum.c.

Variable Documentation

◆ rb_mEnumerable

VALUE rb_mEnumerable

Definition at line 19 of file enum.c.

Referenced by Init_Array(), Init_Dir(), Init_Enumerable(), Init_stringio(), and InitVM_Struct().