Ruby 3.4.5p51 (2025-07-16 revision 20cda200d3ce092571d0b5d342dadca69636cb0f)
|
Public APIs related to rb_cEnumerator. More...
#include "ruby/internal/attr/nonnull.h"
#include "ruby/internal/dllexport.h"
#include "ruby/internal/intern/eval.h"
#include "ruby/internal/iterator.h"
#include "ruby/internal/symbol.h"
#include "ruby/internal/value.h"
Go to the source code of this file.
Data Structures | |
struct | rb_arithmetic_sequence_components_t |
Decomposed Enumerator::ArithmeicSequence. More... |
Macros | |
#define | SIZED_ENUMERATOR(obj, argc, argv, size_fn) |
This is an implementation detail of RETURN_SIZED_ENUMERATOR(). | |
#define | SIZED_ENUMERATOR_KW(obj, argc, argv, size_fn, kw_splat) |
This is an implementation detail of RETURN_SIZED_ENUMERATOR_KW(). | |
#define | RETURN_SIZED_ENUMERATOR(obj, argc, argv, size_fn) |
This roughly resembles return enum_for(__callee__) unless block_given?. | |
#define | RETURN_SIZED_ENUMERATOR_KW(obj, argc, argv, size_fn, kw_splat) |
Identical to RETURN_SIZED_ENUMERATOR(), except you can specify how to handle the last element of the given array. | |
#define | RETURN_ENUMERATOR(obj, argc, argv) |
Identical to RETURN_SIZED_ENUMERATOR(), except its size is unknown. | |
#define | RETURN_ENUMERATOR_KW(obj, argc, argv, kw_splat) |
Identical to RETURN_SIZED_ENUMERATOR_KW(), except its size is unknown. |
Typedefs | |
typedef VALUE | rb_enumerator_size_func(VALUE recv, VALUE argv, VALUE eobj) |
This is the type of functions that rb_enumeratorize_with_size() expects. |
Functions | |
VALUE | rb_enumeratorize (VALUE recv, VALUE meth, int argc, const VALUE *argv) |
Constructs an enumerator. | |
VALUE | rb_enumeratorize_with_size (VALUE recv, VALUE meth, int argc, const VALUE *argv, rb_enumerator_size_func *func) |
Identical to rb_enumeratorize(), except you can additionally specify the size function of return value. | |
VALUE | rb_enumeratorize_with_size_kw (VALUE recv, VALUE meth, int argc, const VALUE *argv, rb_enumerator_size_func *func, int kw_splat) |
Identical to rb_enumeratorize_with_func(), except you can specify how to handle the last element of the given array. | |
int | rb_arithmetic_sequence_extract (VALUE as, rb_arithmetic_sequence_components_t *buf) |
Extracts components of the passed arithmetic sequence. | |
VALUE | rb_arithmetic_sequence_beg_len_step (VALUE as, long *begp, long *lenp, long *stepp, long len, int err) |
Identical to rb_range_beg_len(), except it takes an instance of Enumerator::ArithmericSequence. |
Public APIs related to rb_cEnumerator.
Definition in file enumerator.h.
#define RETURN_ENUMERATOR | ( | obj, | |
argc, | |||
argv ) |
Identical to RETURN_SIZED_ENUMERATOR(), except its size is unknown.
[in] | obj | A receiver. |
[in] | argc | Number of objects of argv. |
[in] | argv | Arguments passed to the current method. |
Definition at line 239 of file enumerator.h.
#define RETURN_ENUMERATOR_KW | ( | obj, | |
argc, | |||
argv, | |||
kw_splat ) |
Identical to RETURN_SIZED_ENUMERATOR_KW(), except its size is unknown.
It can also be seen as a routine identical to RETURN_ENUMERATOR(), except you can specify how to handle the last element of the given array.
[in] | obj | A receiver. |
[in] | argc | Number of objects of argv. |
[in] | argv | Arguments passed to the current method. |
[in] | kw_splat | Handling of keyword parameters:
|
Definition at line 256 of file enumerator.h.
#define RETURN_SIZED_ENUMERATOR | ( | obj, | |
argc, | |||
argv, | |||
size_fn ) |
This roughly resembles return enum_for(__callee__) unless block_given?.
[in] | obj | A receiver. |
[in] | argc | Number of objects of argv. |
[in] | argv | Arguments passed to the current method. |
[in] | size_fn | Size calculator. |
Definition at line 206 of file enumerator.h.
Referenced by rb_ary_each(), and rb_hash_delete_if().
#define RETURN_SIZED_ENUMERATOR_KW | ( | obj, | |
argc, | |||
argv, | |||
size_fn, | |||
kw_splat ) |
Identical to RETURN_SIZED_ENUMERATOR(), except you can specify how to handle the last element of the given array.
[in] | obj | A receiver. |
[in] | argc | Number of objects of argv. |
[in] | argv | Arguments passed to the current method. |
[in] | size_fn | Size calculator. |
[in] | kw_splat | Handling of keyword parameters:
|
Definition at line 226 of file enumerator.h.
#define SIZED_ENUMERATOR | ( | obj, | |
argc, | |||
argv, | |||
size_fn ) |
This is an implementation detail of RETURN_SIZED_ENUMERATOR().
You could use it directly, but can hardly be handy.
[in] | obj | A receiver. |
[in] | argc | Number of objects of argv. |
[in] | argv | Arguments passed to the current method. |
[in] | size_fn | Size calculator. |
Definition at line 174 of file enumerator.h.
#define SIZED_ENUMERATOR_KW | ( | obj, | |
argc, | |||
argv, | |||
size_fn, | |||
kw_splat ) |
This is an implementation detail of RETURN_SIZED_ENUMERATOR_KW().
You could use it directly, but can hardly be handy.
[in] | obj | A receiver. |
[in] | argc | Number of objects of argv. |
[in] | argv | Arguments passed to the current method. |
[in] | size_fn | Size calculator. |
[in] | kw_splat | Handling of keyword parameters:
|
Definition at line 193 of file enumerator.h.
This is the type of functions that rb_enumeratorize_with_size() expects.
In theory an enumerator can have indefinite number of elements, but in practice it often is the case we can compute the size of an enumerator beforehand. If your enumerator has such property, supply a function that calculates such values.
[in] | recv | The original receiver of the enumerator. |
[in] | argv | Arguments passed to Object#enum_for etc. |
[in] | eobj | The enumerator object. |
Definition at line 45 of file enumerator.h.
VALUE rb_arithmetic_sequence_beg_len_step | ( | VALUE | as, |
long * | begp, | ||
long * | lenp, | ||
long * | stepp, | ||
long | len, | ||
int | err ) |
Identical to rb_range_beg_len(), except it takes an instance of Enumerator::ArithmericSequence.
[in] | as | An Enumerator::ArithmericSequence instance. |
[out] | begp | Return value buffer. |
[out] | lenp | Return value buffer. |
[out] | stepp | Return value buffer. |
[in] | len | Updated length. |
[in] | err | In case len is out of range...
|
rb_eRangeError | `as` cannot fit into `long`. |
RUBY_Qfalse | as is not Enumerator::ArithmericSequence. |
RUBY_Qnil | len is out of as but err is zero. |
RUBY_Qtrue | Otherwise. |
Definition at line 3848 of file enumerator.c.
int rb_arithmetic_sequence_extract | ( | VALUE | as, |
rb_arithmetic_sequence_components_t * | buf ) |
Extracts components of the passed arithmetic sequence.
This can be seen as an extended version of rb_range_values().
[in] | as | Target instance of Enumerator::ArithmericSequence. |
[out] | buf | Decomposed results buffer. |
Definition at line 3830 of file enumerator.c.
Constructs an enumerator.
This roughly resembles Object#enum_for.
[in] | recv | A receiver of meth. |
[in] | meth | Method ID in a symbol object. |
[in] | argc | Number of objects of argv. |
[in] | argv | Arguments passed to meth. |
rb_eTypeError | `meth` is not an instance of rb_cSymbol. |
Definition at line 524 of file enumerator.c.
VALUE rb_enumeratorize_with_size | ( | VALUE | recv, |
VALUE | meth, | ||
int | argc, | ||
const VALUE * | argv, | ||
rb_enumerator_size_func * | func ) |
Identical to rb_enumeratorize(), except you can additionally specify the size function of return value.
[in] | recv | A receiver of meth. |
[in] | meth | Method ID in a symbol object. |
[in] | argc | Number of objects of argv. |
[in] | argv | Arguments passed to meth. |
[in] | func | Size calculator. |
rb_eTypeError | `meth` is not an instance of rb_cSymbol. |
Definition at line 549 of file enumerator.c.
VALUE rb_enumeratorize_with_size_kw | ( | VALUE | recv, |
VALUE | meth, | ||
int | argc, | ||
const VALUE * | argv, | ||
rb_enumerator_size_func * | func, | ||
int | kw_splat ) |
Identical to rb_enumeratorize_with_func(), except you can specify how to handle the last element of the given array.
[in] | recv | A receiver of meth. |
[in] | meth | Method ID in a symbol object. |
[in] | argc | Number of objects of argv. |
[in] | argv | Arguments passed to meth. |
[in] | func | Size calculator. |
[in] | kw_splat | Handling of keyword parameters:
|
rb_eTypeError | `meth` is not an instance of rb_cSymbol. |
Definition at line 533 of file enumerator.c.