Ruby  3.4.0dev (2024-11-05 revision 348a53415339076afc4a02fcd09f3ae36e9c4c61)
Functions
range.h File Reference

(348a53415339076afc4a02fcd09f3ae36e9c4c61)

Public APIs related to rb_cRange. More...

#include "ruby/internal/attr/nonnull.h"
#include "ruby/internal/dllexport.h"
#include "ruby/internal/value.h"
Include dependency graph for range.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

VALUE rb_range_new (VALUE beg, VALUE end, int excl)
 Creates a new Range. More...
 
VALUE rb_range_beg_len (VALUE range, long *begp, long *lenp, long len, int err)
 Deconstructs a numerical range. More...
 
int rb_range_values (VALUE range, VALUE *begp, VALUE *endp, int *exclp)
 Deconstructs a range into its components. More...
 

Detailed Description

Public APIs related to rb_cRange.

Author
Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org
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 range.h.

Function Documentation

◆ rb_range_beg_len()

VALUE rb_range_beg_len ( VALUE  range,
long *  begp,
long *  lenp,
long  len,
int  err 
)

Deconstructs a numerical range.

As the arguments are long based, it expects everything are in the long domain.

Parameters
[in]rangeA range of numerical endpoints.
[out]begpReturn value buffer.
[out]lenpReturn value buffer.
[in]lenUpdated length.
[in]errIn case len is out of range...
Exceptions
rb_eTypeErrorrange is not a numerical range.
rb_eRangeErrorrange cannot fit into long.
Return values
RUBY_Qfalserange is not an rb_cRange.
RUBY_Qnillen is out of range but err is zero.
RUBY_QtrueOtherwise.
Postcondition
beg is the (possibly updated) left endpoint.
len is the (possibly updated) length of the range.

Definition at line 1842 of file range.c.

◆ rb_range_new()

VALUE rb_range_new ( VALUE  beg,
VALUE  end,
int  excl 
)

Creates a new Range.

Parameters
[in]beg"Left" or "lowest" endpoint of the range.
[in]end"Right" or "highest" endpoint of the range.
[in]exclWhether the range is open-ended.
Exceptions
rb_eArgErrorbeg and end are not comparable.
Note
These days both endpoints can be RUBY_Qnil, which means that endpoint is unbound.

Definition at line 68 of file range.c.

◆ rb_range_values()

int rb_range_values ( VALUE  range,
VALUE begp,
VALUE endp,
int *  exclp 
)

Deconstructs a range into its components.

Parameters
[in]rangeRange or range-ish object.
[out]begpReturn value buffer.
[out]endpReturn value buffer.
[out]exclpReturn value buffer.
Return values
RUBY_Qfalserange is not an instance of rb_cRange.
RUBY_QtrueArgument pointers are updated.
Postcondition
*begp is the left endpoint of the range.
*endp is the right endpoint of the range.
*exclp is whether the range is open-ended or not.

Definition at line 1754 of file range.c.

Referenced by rb_arithmetic_sequence_extract(), and rb_range_beg_len().