Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)
Data Structures | Macros | Enumerations | Functions
rarray.h File Reference

Defines struct RArray. More...

#include "ruby/internal/arithmetic/long.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/rgengc.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
 

Macros

#define USE_TRANSIENT_HEAP   1
 
#define RARRAY(obj)   RBIMPL_CAST((struct RArray *)(obj))
 
#define RARRAY_EMBED_FLAG   RARRAY_EMBED_FLAG
 
#define RARRAY_EMBED_LEN_MASK   RARRAY_EMBED_LEN_MASK
 
#define RARRAY_EMBED_LEN_MAX   RARRAY_EMBED_LEN_MAX
 
#define RARRAY_EMBED_LEN_SHIFT   RARRAY_EMBED_LEN_SHIFT
 
#define RARRAY_TRANSIENT_FLAG   0
 
#define RARRAY_LEN   rb_array_len
 
#define RARRAY_CONST_PTR   rb_array_const_ptr
 
#define RARRAY_CONST_PTR_TRANSIENT   rb_array_const_ptr_transient
 
#define RBIMPL_RARRAY_STMT(flag, ary, var, expr)
 
#define RARRAY_PTR_USE_START(a)   rb_array_ptr_use_start(a, 0)
 
#define RARRAY_PTR_USE_END(a)   rb_array_ptr_use_end(a, 0)
 
#define RARRAY_PTR_USE(ary, ptr_name, expr)    RBIMPL_RARRAY_STMT(0, ary, ptr_name, expr)
 
#define RARRAY_PTR_USE_START_TRANSIENT(a)   rb_array_ptr_use_start(a, 1)
 
#define RARRAY_PTR_USE_END_TRANSIENT(a)   rb_array_ptr_use_end(a, 1)
 
#define RARRAY_PTR_USE_TRANSIENT(ary, ptr_name, expr)    RBIMPL_RARRAY_STMT(1, ary, ptr_name, expr)
 
#define RARRAY_AREF(a, i)   RARRAY_CONST_PTR_TRANSIENT(a)[i]
 

Enumerations

enum  ruby_rarray_flags { RARRAY_EMBED_FLAG = RUBY_FL_USER1 , RARRAY_EMBED_LEN_MASK = RUBY_FL_USER4 | RUBY_FL_USER3 }
 
enum  ruby_rarray_consts { RARRAY_EMBED_LEN_SHIFT = RUBY_FL_USHIFT + 3 , RARRAY_EMBED_LEN_MAX = RBIMPL_EMBED_LEN_MAX_OF(VALUE) }
 

Functions

VALUErb_ary_ptr_use_start (VALUE ary)
 
void rb_ary_ptr_use_end (VALUE a)
 

Detailed Description

Defines struct RArray.

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 rarray.h.

Macro Definition Documentation

◆ RARRAY

#define RARRAY (   obj)    RBIMPL_CAST((struct RArray *)(obj))

Definition at line 42 of file rarray.h.

◆ RARRAY_AREF

#define RARRAY_AREF (   a,
 
)    RARRAY_CONST_PTR_TRANSIENT(a)[i]

Definition at line 268 of file rarray.h.

◆ RARRAY_CONST_PTR

#define RARRAY_CONST_PTR   rb_array_const_ptr

Definition at line 53 of file rarray.h.

◆ RARRAY_CONST_PTR_TRANSIENT

#define RARRAY_CONST_PTR_TRANSIENT   rb_array_const_ptr_transient

Definition at line 54 of file rarray.h.

◆ RARRAY_EMBED_FLAG

#define RARRAY_EMBED_FLAG   RARRAY_EMBED_FLAG

Definition at line 43 of file rarray.h.

◆ RARRAY_EMBED_LEN_MASK

#define RARRAY_EMBED_LEN_MASK   RARRAY_EMBED_LEN_MASK

Definition at line 44 of file rarray.h.

◆ RARRAY_EMBED_LEN_MAX

#define RARRAY_EMBED_LEN_MAX   RARRAY_EMBED_LEN_MAX

Definition at line 45 of file rarray.h.

◆ RARRAY_EMBED_LEN_SHIFT

#define RARRAY_EMBED_LEN_SHIFT   RARRAY_EMBED_LEN_SHIFT

Definition at line 46 of file rarray.h.

◆ RARRAY_LEN

#define RARRAY_LEN   rb_array_len

Definition at line 52 of file rarray.h.

◆ RARRAY_PTR_USE

#define RARRAY_PTR_USE (   ary,
  ptr_name,
  expr 
)     RBIMPL_RARRAY_STMT(0, ary, ptr_name, expr)

Definition at line 235 of file rarray.h.

◆ RARRAY_PTR_USE_END

#define RARRAY_PTR_USE_END (   a)    rb_array_ptr_use_end(a, 0)

Definition at line 234 of file rarray.h.

◆ RARRAY_PTR_USE_END_TRANSIENT

#define RARRAY_PTR_USE_END_TRANSIENT (   a)    rb_array_ptr_use_end(a, 1)

Definition at line 239 of file rarray.h.

◆ RARRAY_PTR_USE_START

#define RARRAY_PTR_USE_START (   a)    rb_array_ptr_use_start(a, 0)

Definition at line 233 of file rarray.h.

◆ RARRAY_PTR_USE_START_TRANSIENT

#define RARRAY_PTR_USE_START_TRANSIENT (   a)    rb_array_ptr_use_start(a, 1)

Definition at line 238 of file rarray.h.

◆ RARRAY_PTR_USE_TRANSIENT

#define RARRAY_PTR_USE_TRANSIENT (   ary,
  ptr_name,
  expr 
)     RBIMPL_RARRAY_STMT(1, ary, ptr_name, expr)

Definition at line 240 of file rarray.h.

◆ RARRAY_TRANSIENT_FLAG

#define RARRAY_TRANSIENT_FLAG   0

Definition at line 50 of file rarray.h.

◆ RBIMPL_RARRAY_STMT

#define RBIMPL_RARRAY_STMT (   flag,
  ary,
  var,
  expr 
)
Value:
do { \
RBIMPL_ASSERT_TYPE((ary), RUBY_T_ARRAY); \
const VALUE rbimpl_ary = (ary); \
VALUE *var = rb_array_ptr_use_start(rbimpl_ary, (flag)); \
expr; \
rb_array_ptr_use_end(rbimpl_ary, (flag)); \
} while (0)
unsigned long VALUE
Definition: value.h:38
@ RUBY_T_ARRAY
Definition: value_type.h:119

Definition at line 225 of file rarray.h.

◆ USE_TRANSIENT_HEAP

#define USE_TRANSIENT_HEAP   1

Definition at line 39 of file rarray.h.

Enumeration Type Documentation

◆ ruby_rarray_consts

Enumerator
RARRAY_EMBED_LEN_SHIFT 
RARRAY_EMBED_LEN_MAX 

Definition at line 82 of file rarray.h.

◆ ruby_rarray_flags

Enumerator
RARRAY_EMBED_FLAG 
RARRAY_EMBED_LEN_MASK 

Definition at line 72 of file rarray.h.

Function Documentation

◆ rb_ary_ptr_use_end()

void rb_ary_ptr_use_end ( VALUE  a)

Definition at line 252 of file array.c.

◆ rb_ary_ptr_use_start()

VALUE * rb_ary_ptr_use_start ( VALUE  ary)

Definition at line 243 of file array.c.