|
Ruby 4.1.0dev (2026-11-09 revision 0e258742221c81dddb807e48a5691ce44b46dadd)
|
Defines struct RArray. More...
#include "ruby/internal/arithmetic/len_t.h"#include "ruby/internal/attr/artificial.h"#include "ruby/internal/attr/constexpr.h"#include "ruby/internal/attr/maybe_unused.h"#include "ruby/internal/attr/pure.h"#include "ruby/internal/cast.h"#include "ruby/internal/core/rbasic.h"#include "ruby/internal/dllexport.h"#include "ruby/internal/fl_type.h"#include "ruby/internal/gc.h"#include "ruby/internal/stdbool.h"#include "ruby/internal/value.h"#include "ruby/internal/value_type.h"#include "ruby/assert.h"

Go to the source code of this file.
Data Structures | |
| struct | RArray |
| Ruby's array. More... | |
Macros | |
| #define | RARRAY(obj) RBIMPL_CAST((struct RArray *)(obj)) |
| Convenient casting macro. | |
| #define | RARRAY_LEN rb_array_len |
| Just another name of rb_array_len. | |
| #define | RARRAY_CONST_PTR rb_array_const_ptr |
| Just another name of rb_array_const_ptr. | |
| #define | RBIMPL_RARRAY_STMT(ary, var, expr) |
| This is an implementation detail of RARRAY_PTR_USE. | |
| #define | RARRAY_PTR_USE(ary, ptr_name, expr) RBIMPL_RARRAY_STMT(ary, ptr_name, expr) |
| Declares a section of code where raw pointers are used. | |
| #define | RARRAY_AREF(a, i) (*RBIMPL_AREF_PTR(a, i)) |
| References an object in an array. | |
Enumerations | |
| enum | ruby_rarray_consts { RARRAY_EMBED_LEN_SHIFT = RUBY_FL_USHIFT + 3 } |
| This is an enum because GDB wants it (rather than a macro). More... | |
Functions | |
| static rb_len_t | RARRAY_EMBED_LEN (VALUE ary) |
| Queries the length of the array. | |
| static rb_len_t | rb_array_len (VALUE a) |
| Queries the length of the array. | |
| static int | RARRAY_LENINT (VALUE ary) |
| Identical to rb_array_len(), except it differs for the return type. | |
| static VALUE * | RARRAY_PTR (VALUE ary) |
| Wild use of a C pointer. | |
| static void | RARRAY_ASET (VALUE ary, rb_len_t i, VALUE v) |
| Assigns an object in an array. | |
Defines struct RArray.
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. __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 rarray.h.
| #define RARRAY | ( | obj | ) | RBIMPL_CAST((struct RArray *)(obj)) |
| #define RARRAY_AREF | ( | a, | |
| i | |||
| ) | (*RBIMPL_AREF_PTR(a, i)) |
| #define RARRAY_CONST_PTR rb_array_const_ptr |
| #define RARRAY_LEN rb_array_len |
Just another name of rb_array_len.
| #define RARRAY_PTR_USE | ( | ary, | |
| ptr_name, | |||
| expr | |||
| ) | RBIMPL_RARRAY_STMT(ary, ptr_name, expr) |
Declares a section of code where raw pointers are used.
In case you need to touch the raw C array instead of polite CAPIs, then that operation shall be wrapped using this macro.
| ary | An object of RArray. |
| ptr_name | A variable name which points the C array in expr. |
| expr | The expression that touches ptr_name. |
| #define RBIMPL_RARRAY_STMT | ( | ary, | |
| var, | |||
| expr | |||
| ) |
This is an implementation detail of RARRAY_PTR_USE.
People do not use it directly.
| enum ruby_rarray_consts |
Assigns an object in an array.
| [out] | ary | Destination array object. |
| [in] | i | Index of ary. |
| [in] | v | Arbitrary ruby object. |
ary must be an instance of RArray. ary's length must be longer than or equal to i. i must be greater than or equal to zero. ary's ith element is set to v. Queries the length of the array.
| [in] | ary | Array in question. |
ary must be an instance of RArray, and must has its RARRAY_EMBED_FLAG flag set. Definition at line 234 of file rarray.h.
Referenced by rb_array_len().
|
inlinestatic |
Identical to rb_array_len(), except it differs for the return type.
| [in] | ary | Array in question. |
| rb_eRangeError | Too long. |
ary must be an instance of RArray. Definition at line 280 of file rarray.h.
Referenced by rb_apply(), rb_eval_cmd_kw(), rb_struct_alloc(), rb_struct_initialize(), rb_yield_splat(), and rb_yield_splat_kw().
Wild use of a C pointer.
This function accesses the backend storage directly. This is slower than RARRAY_PTR_USE. It exercises extra manoeuvres to protect our generational GC. Use of this function is considered archaic. Use a modern way instead.
| [in] | ary | An object of RArray. |
Definition at line 365 of file rarray.h.
Referenced by rb_proc_call_kw(), and rb_struct_new().