1#ifndef INTERNAL_ARRAY_H                                  
    2#define INTERNAL_ARRAY_H 
   11#include "ruby/internal/config.h" 
   13#include "internal/static_assert.h"  
   18# define ARRAY_DEBUG (0+RUBY_DEBUG) 
   21#define RARRAY_SHARED_FLAG      ELTS_SHARED 
   22#define RARRAY_SHARED_ROOT_FLAG FL_USER12 
   23#define RARRAY_PTR_IN_USE_FLAG  FL_USER14 
   28void rb_ary_set_len(
VALUE, 
long);
 
   32size_t rb_ary_memsize(
VALUE);
 
   35void rb_ary_cancel_sharing(
VALUE ary);
 
   36size_t rb_ary_size_as_embedded(
VALUE ary);
 
   37void rb_ary_make_embedded(
VALUE ary);
 
   38bool rb_ary_embeddable_p(
VALUE ary);
 
   42static inline VALUE rb_ary_entry_internal(
VALUE ary, 
long offset);
 
   43static inline bool ARY_PTR_USING_P(
VALUE ary);
 
   55rb_ary_entry_internal(
VALUE ary, 
long offset)
 
   62        if (offset < 0) 
return Qnil;
 
   64    else if (
len <= offset) {
 
   71ARY_PTR_USING_P(
VALUE ary)
 
   78ary_should_not_be_shared_and_embedded(
VALUE ary)
 
   80    return !
FL_ALL_RAW(ary, RARRAY_SHARED_FLAG|RARRAY_EMBED_FLAG);
 
   84ARY_SHARED_P(
VALUE ary)
 
   87    assert(ary_should_not_be_shared_and_embedded(ary));
 
   95    assert(ary_should_not_be_shared_and_embedded(ary));
 
  100ARY_SHARED_ROOT(
VALUE ary)
 
  102    assert(ARY_SHARED_P(ary));
 
  103    return RARRAY(ary)->as.heap.aux.shared_root;
 
  107ARY_SHARED_ROOT_P(
VALUE ary)
 
  114ARY_SHARED_ROOT_REFCNT(
VALUE ary)
 
  116    assert(ARY_SHARED_ROOT_P(ary));
 
  117    return RARRAY(ary)->as.heap.aux.capa;
 
  120#undef rb_ary_new_from_args 
  121#if RBIMPL_HAS_WARNING("-Wgnu-zero-variadic-macro-arguments") 
  123#elif defined(__GNUC__) && defined(HAVE_VA_ARGS_MACRO) 
  124#define rb_ary_new_from_args(n, ...) \ 
  126        const VALUE args_to_new_ary[] = {__VA_ARGS__}; \ 
  127        if (__builtin_constant_p(n)) { \ 
  128            STATIC_ASSERT(rb_ary_new_from_args, numberof(args_to_new_ary) == (n)); \ 
  130        rb_ary_new_from_values(numberof(args_to_new_ary), args_to_new_ary); \ 
  146#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ == 13 
#define RBIMPL_ATTR_ARTIFICIAL()
Wraps (or simulates) __attribute__((artificial))
#define RUBY_ASSERT(...)
Asserts that the given expression is truthy if and only if RUBY_DEBUG is truthy.
#define RUBY_EXTERN
Declaration of externally visible global variables.
#define FL_TEST_RAW
Old name of RB_FL_TEST_RAW.
#define Qnil
Old name of RUBY_Qnil.
#define T_ARRAY
Old name of RUBY_T_ARRAY.
#define FL_ALL_RAW
Old name of RB_FL_ALL_RAW.
int capa
Designed capacity of the buffer.
int len
Length of the buffer.
#define RBIMPL_ATTR_MAYBE_UNUSED()
Wraps (or simulates) [[maybe_unused]]
#define inline
Old Visual Studio versions do not support the inline keyword, so we need to define it to be __inline.
#define RBIMPL_ATTR_PURE_UNLESS_DEBUG()
Enables RBIMPL_ATTR_PURE if and only if.
#define RARRAY_LEN
Just another name of rb_array_len.
#define RARRAY(obj)
Convenient casting macro.
#define RARRAY_AREF(a, i)
#define RARRAY_CONST_PTR
Just another name of rb_array_const_ptr.
uintptr_t VALUE
Type that represents a Ruby object.
static bool RB_TYPE_P(VALUE obj, enum ruby_value_type t)
Queries if the given object is of given type.
#define RBIMPL_WARNING_IGNORED(flag)
Suppresses a warning.
#define RBIMPL_WARNING_PUSH()
Pushes compiler warning state.
#define RBIMPL_WARNING_POP()
Pops compiler warning state.