Ruby: include/ruby/internal/intern/enumerator.h File Reference

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

Data Structures | Macros | Typedefs | Functions
enumerator.h File Reference

Public APIs related to rb_cEnumerator. More...

`#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

## Macros
#define | rb_enumeratorize_with_size(obj, id, argc, argv, size_fn) rb_enumeratorize_with_size(obj, id, argc, argv, (rb_enumerator_size_func *)(size_fn))
#define | rb_enumeratorize_with_size_kw(obj, id, argc, argv, size_fn, kw_splat) rb_enumeratorize_with_size_kw(obj, id, argc, argv, (rb_enumerator_size_func *)(size_fn), kw_splat)
#define | SIZED_ENUMERATOR(obj, argc, argv, size_fn)
#define | SIZED_ENUMERATOR_KW(obj, argc, argv, size_fn, kw_splat)
#define | RETURN_SIZED_ENUMERATOR(obj, argc, argv, size_fn)
#define | RETURN_SIZED_ENUMERATOR_KW(obj, argc, argv, size_fn, kw_splat)
#define | RETURN_ENUMERATOR(obj, argc, argv) RETURN_SIZED_ENUMERATOR(obj, argc, argv, 0)
#define | RETURN_ENUMERATOR_KW(obj, argc, argv, kw_splat) RETURN_SIZED_ENUMERATOR_KW(obj, argc, argv, 0, kw_splat)

## Typedefs
typedef VALUE | rb_enumerator_size_func(VALUE, VALUE, VALUE)

## Functions
VALUE | rb_enumeratorize (VALUE, VALUE, int, const VALUE *)
VALUE | rb_enumeratorize_with_size (VALUE, VALUE, int, const VALUE *, rb_enumerator_size_func *)
VALUE | rb_enumeratorize_with_size_kw (VALUE, VALUE, int, const VALUE *, rb_enumerator_size_func *, int)
int | rb_arithmetic_sequence_extract (VALUE, rb_arithmetic_sequence_components_t *)
VALUE | rb_arithmetic_sequence_beg_len_step (VALUE, long *begp, long *lenp, long *stepp, long len, int err)

## Detailed Description

Public APIs related to rb_cEnumerator.

Author
  Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org

Copyright
  This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.

Warning
  Symbols prefixed with either `RBIMPL` or `rbimpl` are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will.

Note
  To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance `__VA_ARGS__` is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98.

Definition in file enumerator.h.

## Macro Definition Documentation

## ◆ rb_enumeratorize_with_size

#define rb_enumeratorize_with_size | ( |  | obj,
|  |  | id,
|  |  | argc,
|  |  | argv,
|  |  | size_fn
| ) |  | rb_enumeratorize_with_size(obj, id, argc, argv, (rb_enumerator_size_func *)(size_fn))

Definition at line 50 of file enumerator.h.

## ◆ rb_enumeratorize_with_size_kw

#define rb_enumeratorize_with_size_kw | ( |  | obj,
|  |  | id,
|  |  | argc,
|  |  | argv,
|  |  | size_fn,
|  |  | kw_splat
| ) |  | rb_enumeratorize_with_size_kw(obj, id, argc, argv, (rb_enumerator_size_func *)(size_fn), kw_splat)

Definition at line 52 of file enumerator.h.

## ◆ RETURN_ENUMERATOR

#define RETURN_ENUMERATOR | ( |  | obj,
|  |  | argc,
|  |  | argv
| ) |  | RETURN_SIZED_ENUMERATOR(obj, argc, argv, 0)

Definition at line 74 of file enumerator.h.

## ◆ RETURN_ENUMERATOR_KW

#define RETURN_ENUMERATOR_KW | ( |  | obj,
|  |  | argc,
|  |  | argv,
|  |  | kw_splat
| ) |  | RETURN_SIZED_ENUMERATOR_KW(obj, argc, argv, 0, kw_splat)

Definition at line 77 of file enumerator.h.

## ◆ RETURN_SIZED_ENUMERATOR

#define RETURN_SIZED_ENUMERATOR | ( |  | obj,
|  |  | argc,
|  |  | argv,
|  |  | size_fn
| ) |  |

Value:
do { \
if (!rb_block_given_p()) \
return SIZED_ENUMERATOR(obj, argc, argv, size_fn); \
} while (0)
rb_block_given_p
int rb_block_given_p(void)
Determines if the current method is given a block.
Definition: eval.c:935
SIZED_ENUMERATOR
#define SIZED_ENUMERATOR(obj, argc, argv, size_fn)
Definition: enumerator.h:56
argc
int argc
Definition: ruby.c:240
argv
char ** argv
Definition: ruby.c:241

Definition at line 64 of file enumerator.h.

## ◆ RETURN_SIZED_ENUMERATOR_KW

#define RETURN_SIZED_ENUMERATOR_KW | ( |  | obj,
|  |  | argc,
|  |  | argv,
|  |  | size_fn,
|  |  | kw_splat
| ) |  |

Value:
do { \
if (!rb_block_given_p()) \
return SIZED_ENUMERATOR_KW(obj, argc, argv, size_fn, kw_splat); \
} while (0)
SIZED_ENUMERATOR_KW
#define SIZED_ENUMERATOR_KW(obj, argc, argv, size_fn, kw_splat)
Definition: enumerator.h:60

Definition at line 69 of file enumerator.h.

## ◆ SIZED_ENUMERATOR

#define SIZED_ENUMERATOR | ( |  | obj,
|  |  | argc,
|  |  | argv,
|  |  | size_fn
| ) |  |

Value:
rb_enumeratorize_with_size((obj), ID2SYM(rb_frame_this_func()), \
(argc), (argv), (size_fn))
rb_frame_this_func
ID rb_frame_this_func(void)
The original name of the current method.
Definition: eval.c:1216
rb_enumeratorize_with_size
#define rb_enumeratorize_with_size(obj, id, argc, argv, size_fn)
Definition: enumerator.h:50
ID2SYM
#define ID2SYM
Definition: symbol.h:44

Definition at line 56 of file enumerator.h.

## ◆ SIZED_ENUMERATOR_KW

#define SIZED_ENUMERATOR_KW | ( |  | obj,
|  |  | argc,
|  |  | argv,
|  |  | size_fn,
|  |  | kw_splat
| ) |  |

Value:
rb_enumeratorize_with_size_kw((obj), ID2SYM(rb_frame_this_func()), \
(argc), (argv), (size_fn), (kw_splat))
rb_enumeratorize_with_size_kw
#define rb_enumeratorize_with_size_kw(obj, id, argc, argv, size_fn, kw_splat)
Definition: enumerator.h:52

Definition at line 60 of file enumerator.h.

## Typedef Documentation

## ◆ rb_enumerator_size_func

typedef VALUE rb_enumerator_size_func(VALUE, VALUE, VALUE)

Definition at line 31 of file enumerator.h.

## Function Documentation

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