Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

Data Structures | Macros | Functions | Variables
enum.c File Reference
`#include "ruby/encoding.h"`
`#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_div idDiv
#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 | COUNT_BIGNUM IMEMO_FL_USER0
#define | MEMO_V3_SET(m, v) RB_OBJ_WRITE((m), &(m)->u3.value, (v))
#define | SORT_BY_BUFSIZE 16
#define | ENUMFUNC(name) argc ? name##_eqq : rb_block_given_p() ? name##_iter_i : name##_i
#define | MEMO_ENUM_NEW(v1) (rb_check_arity(argc, 0, 1), MEMO_NEW((v1), (argc ? *argv : 0), 0))
#define | DEFINE_ENUMFUNCS(name)
#define | WARN_UNUSED_BLOCK(argc)
#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

## ◆ COUNT_BIGNUM

#define COUNT_BIGNUM IMEMO_FL_USER0

Definition at line 145 of file enum.c.

## ◆ 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 \
name##_eqq(RB_BLOCK_CALL_FUNC_ARGLIST(i, memo)) \
{ \
ENUM_WANT_SVALUE(); \
return enum_##name##_func(rb_funcallv(MEMO_CAST(memo)->v2, id_eqq, 1, &i), MEMO_CAST(memo)); \
} \
\
static VALUE \
enum_##name##_func(VALUE result, struct MEMO *memo)

Definition at line 1278 of file enum.c.

## ◆ dont_recycle_block_arg

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

Definition at line 2503 of file enum.c.

## ◆ ENUM_WANT_SVALUE

#define ENUM_WANT_SVALUE | ( |  | ) |

Value:
do { \
i = rb_enum_values_pack(argc, argv); \
} while (0)

Definition at line 40 of file enum.c.

## ◆ ENUMFUNC

#define ENUMFUNC | ( |  | name | ) | argc ? name##_eqq : rb_block_given_p() ? name##_iter_i : name##_i

Definition at line 1274 of file enum.c.

## ◆ GETPTR

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

## ◆ id_call

#define id_call idCall

Definition at line 29 of file enum.c.

## ◆ id_cmp

#define id_cmp idCmp

Definition at line 27 of file enum.c.

## ◆ id_div

#define id_div idDiv

Definition at line 24 of file enum.c.

## ◆ id_each

#define id_each idEach

Definition at line 25 of file enum.c.

## ◆ id_eqq

#define id_eqq idEqq

Definition at line 26 of file enum.c.

## ◆ id_lshift

#define id_lshift idLTLT

Definition at line 28 of file enum.c.

## ◆ id_size

#define id_size idSize

Definition at line 30 of file enum.c.

## ◆ MEMO_ENUM_NEW

#define MEMO_ENUM_NEW | ( |  | v1 | ) | (rb_check_arity(argc, 0, 1), MEMO_NEW((v1), (argc ? *argv : 0), 0))

Definition at line 1276 of file enum.c.

## ◆ MEMO_V3_SET

#define MEMO_V3_SET | ( |  | m,
|  |  | v
| ) |  | RB_OBJ_WRITE((m), &(m)->u3.value, (v))

Definition at line 146 of file enum.c.

## ◆ rb_cmpint

#define rb_cmpint | ( |  | cmp,
|  |  | a,
|  |  | b
| ) |  | 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 1095 of file enum.c.

## ◆ SWAP

#define SWAP | ( |  | i,
|  |  | j
| ) |  |

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)

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

## ◆ WARN_UNUSED_BLOCK

#define WARN_UNUSED_BLOCK | ( |  | argc | ) |

Value:
do { \
if ((argc) > 0 && rb_block_given_p()) { \
rb_warn("given block not used"); \
} \
} while (0)

Definition at line 1303 of file enum.c.

## Function Documentation

## ◆ DEFINE_ENUMFUNCS() [1/4]

DEFINE_ENUMFUNCS | ( | all |  | ) |

Definition at line 1309 of file enum.c.

References RTEST.

## ◆ DEFINE_ENUMFUNCS() [2/4]

DEFINE_ENUMFUNCS | ( | any |  | ) |

Definition at line 1351 of file enum.c.

References RTEST.

## ◆ DEFINE_ENUMFUNCS() [3/4]

DEFINE_ENUMFUNCS | ( | none |  | ) |

Definition at line 1666 of file enum.c.

References RTEST.

## ◆ DEFINE_ENUMFUNCS() [4/4]

DEFINE_ENUMFUNCS | ( | one |  | ) |

Definition at line 1393 of file enum.c.

## ◆ Init_Enumerable()

void Init_Enumerable | ( | void |  | ) |

Definition at line 4144 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 33 of file enum.c.

References argc, argv, 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 1568 of file enum.c.

## Variable Documentation

## ◆ rb_mEnumerable

VALUE rb_mEnumerable

Definition at line 20 of file enum.c.

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

rb_block_given_p
int rb_block_given_p(void)
Determines if the current method is given a block.
Definition: eval.c:897
VALUE
unsigned long VALUE
Definition: ruby.h:102
MEMO
MEMO.
Definition: internal.h:1278
RB_BLOCK_CALL_FUNC_ARGLIST
#define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg)
Definition: ruby.h:1964
rb_funcallv
#define rb_funcallv(recv, mid, argc, argv)
Definition: rb_mjit_min_header-2.7.0.h:7899
rb_enum_values_pack
VALUE rb_enum_values_pack(int argc, const VALUE *argv)
Definition: enum.c:33
i
uint32_t i
Definition: rb_mjit_min_header-2.7.0.h:5464
rb_yield_values2
VALUE rb_yield_values2(int n, const VALUE *argv)
Definition: vm_eval.c:1271
id_eqq
#define id_eqq
Definition: enum.c:26
MEMO_CAST
#define MEMO_CAST(m)
Definition: internal.h:1294
argv
char ** argv
Definition: ruby.c:223
GETPTR
#define GETPTR(i)
argc
int argc
Definition: ruby.c:222
name
const char * name
Definition: nkf.c:208