1 #ifndef RBIMPL_RARRAY_H
2 #define RBIMPL_RARRAY_H
28 #include "ruby/internal/cast.h"
44 #define RARRAY(obj) RBIMPL_CAST((struct RArray *)(obj))
46 #define RARRAY_EMBED_FLAG RARRAY_EMBED_FLAG
47 #define RARRAY_EMBED_LEN_MASK RARRAY_EMBED_LEN_MASK
48 #define RARRAY_EMBED_LEN_MAX RARRAY_EMBED_LEN_MAX
49 #define RARRAY_EMBED_LEN_SHIFT RARRAY_EMBED_LEN_SHIFT
51 #define RARRAY_LEN rb_array_len
52 #define RARRAY_CONST_PTR rb_array_const_ptr
55 #if defined(__fcc__) || defined(__fcc_version) || \
56 defined(__FCC__) || defined(__FCC_VERSION)
58 # define FIX_CONST_VALUE_PTR(x) ((const VALUE *)(x))
60 # define FIX_CONST_VALUE_PTR(x) (x)
63 #define RARRAY_EMBED_LEN RARRAY_EMBED_LEN
64 #define RARRAY_LENINT RARRAY_LENINT
65 #define RARRAY_ASET RARRAY_ASET
66 #define RARRAY_PTR RARRAY_PTR
82 enum ruby_rarray_flags {
161 #if defined(__clang__) || \
162 !defined(__cplusplus) || \
163 (__cplusplus > 199711L)
213 void rb_ary_ptr_use_end(
VALUE a);
241 f &= RARRAY_EMBED_LEN_MASK;
243 return RBIMPL_CAST((
long)f);
263 return RARRAY(a)->as.heap.len;
297 rb_array_const_ptr(
VALUE a)
302 return FIX_CONST_VALUE_PTR(
RARRAY(a)->as.ary);
305 return FIX_CONST_VALUE_PTR(
RARRAY(a)->as.heap.ptr);
315 #define RBIMPL_RARRAY_STMT(ary, var, expr) do { \
316 RBIMPL_ASSERT_TYPE((ary), RUBY_T_ARRAY); \
317 const VALUE rbimpl_ary = (ary); \
318 VALUE *var = rb_ary_ptr_use_start(rbimpl_ary); \
320 rb_ary_ptr_use_end(rbimpl_ary); \
348 #define RARRAY_PTR_USE(ary, ptr_name, expr) \
349 RBIMPL_RARRAY_STMT(ary, ptr_name, expr)
365 static inline VALUE *
403 #define RARRAY_AREF(a, i) RARRAY_CONST_PTR(a)[i]
Defines RBIMPL_ATTR_ARTIFICIAL.
#define RBIMPL_ATTR_ARTIFICIAL()
Wraps (or simulates) __attribute__((artificial))
#define RBIMPL_ASSERT_OR_ASSUME(...)
This is either RUBY_ASSERT or RBIMPL_ASSUME, depending on RUBY_DEBUG.
Tweaking visibility of C variables/functions.
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Defines enum ruby_fl_type.
@ RUBY_FL_USHIFT
Number of bits in ruby_fl_type that are not open to users.
static bool RB_FL_ANY_RAW(VALUE obj, VALUE flags)
This is an implementation detail of RB_FL_ANY().
@ RUBY_FL_USER9
User-defined flag.
@ RUBY_FL_USER8
User-defined flag.
@ RUBY_FL_USER5
User-defined flag.
@ RUBY_FL_USER3
User-defined flag.
@ RUBY_FL_USER7
User-defined flag.
@ RUBY_FL_USER6
User-defined flag.
@ RUBY_FL_USER4
User-defined flag.
@ RUBY_FL_USER1
User-defined flag.
#define RB_OBJ_WRITE(old, slot, young)
Declaration of a "back" pointer.
Registering values to the GC.
#define RB_OBJ_WB_UNPROTECT_FOR(type, obj)
Identical to RB_OBJ_WB_UNPROTECT(), except it can also assert that the given object is of given type.
char * ptr
Pointer to the underlying memory region, of at least capa bytes.
Arithmetic conversion between C's long and Ruby's.
#define rb_long2int
Just another name of rb_long2int_inline.
Defines RBIMPL_ATTR_MAYBE_UNUSED.
#define inline
Old Visual Studio versions do not support the inline keyword, so we need to define it to be __inline.
Defines RBIMPL_ATTR_PURE.
#define RBIMPL_ATTR_PURE_UNLESS_DEBUG()
Enables RBIMPL_ATTR_PURE if and only if.
static VALUE * RARRAY_PTR(VALUE ary)
Wild use of a C pointer.
#define RARRAY_LEN
Just another name of rb_array_len.
static long RARRAY_EMBED_LEN(VALUE ary)
Queries the length of the array.
static long rb_array_len(VALUE a)
Queries the length of the array.
#define RARRAY(obj)
Convenient casting macro.
static int RARRAY_LENINT(VALUE ary)
Identical to rb_array_len(), except it differs for the return type.
static void RARRAY_ASET(VALUE ary, long i, VALUE v)
Assigns an object in an array.
#define RARRAY_PTR_USE(ary, ptr_name, expr)
Declares a section of code where raw pointers are used.
ruby_rarray_consts
This is an enum because GDB wants it (rather than a macro).
@ RARRAY_EMBED_LEN_SHIFT
Where ::RARRAY_EMBED_LEN_MASK resides.
#define RARRAY_CONST_PTR
Just another name of rb_array_const_ptr.
#define RBASIC(obj)
Convenient casting macro.
union RArray::@47 as
Array's specific fields.
struct RBasic basic
Basic part, including flags and class.
struct RArray::@47::@48 heap
Arrays that use separated memory region for elements use this pattern.
const VALUE shared_root
Parent of the array.
const VALUE ary[1]
Embedded elements.
long capa
Capacity of *ptr.
union RArray::@47::@48::@49 aux
Auxiliary info.
long len
Number of elements of the array.
const VALUE * ptr
Pointer to the C array that holds the elements of the array.
Ruby object's base components.
uintptr_t VALUE
Type that represents a Ruby object.
Defines enum ruby_value_type.