w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

array.c File Reference
#include <mruby.h>
#include <mruby/array.h>
#include <mruby/class.h>
#include <mruby/string.h>
#include <mruby/range.h>
#include <mruby/proc.h>
#include <mruby/presym.h>
#include "value_array.h"
Include dependency graph for array.c:

Go to the source code of this file.

Macros

#define ARY_DEFAULT_LEN   4
 
#define ARY_SHRINK_RATIO   5 /* must be larger than 2 */
 
#define ARY_C_MAX_SIZE   (SIZE_MAX / sizeof(mrb_value))
 
#define ARY_MAX_SIZE   ((mrb_int)((ARY_C_MAX_SIZE < (size_t)MRB_INT_MAX) ? ARY_C_MAX_SIZE : MRB_INT_MAX-1))
 
#define ARY_REPLACE_SHARED_MIN   20
 
#define ARY_SHIFT_SHARED_MIN   10
 

Functions

static struct RArrayary_new_capa (mrb_state *mrb, mrb_int capa)
 
mrb_value mrb_ary_new_capa (mrb_state *mrb, mrb_int capa)
 
mrb_value mrb_ary_new (mrb_state *mrb)
 
static void array_copy (mrb_value *dst, const mrb_value *src, mrb_int size)
 
static struct RArrayary_new_from_values (mrb_state *mrb, mrb_int size, const mrb_value *vals)
 
mrb_value mrb_ary_new_from_values (mrb_state *mrb, mrb_int size, const mrb_value *vals)
 
mrb_value mrb_assoc_new (mrb_state *mrb, mrb_value car, mrb_value cdr)
 
static void ary_fill_with_nil (mrb_value *ptr, mrb_int size)
 
static void ary_modify_check (mrb_state *mrb, struct RArray *a)
 
static void ary_modify (mrb_state *mrb, struct RArray *a)
 
void mrb_ary_modify (mrb_state *mrb, struct RArray *a)
 
static void ary_make_shared (mrb_state *mrb, struct RArray *a)
 
static void ary_expand_capa (mrb_state *mrb, struct RArray *a, mrb_int len)
 
static void ary_shrink_capa (mrb_state *mrb, struct RArray *a)
 
mrb_value mrb_ary_resize (mrb_state *mrb, mrb_value ary, mrb_int new_len)
 
static mrb_value mrb_ary_s_create (mrb_state *mrb, mrb_value klass)
 
static void ary_replace (mrb_state *, struct RArray *, struct RArray *)
 
static void ary_concat (mrb_state *mrb, struct RArray *a, struct RArray *a2)
 
void mrb_ary_concat (mrb_state *mrb, mrb_value self, mrb_value other)
 
static mrb_value mrb_ary_concat_m (mrb_state *mrb, mrb_value self)
 
static mrb_value mrb_ary_plus (mrb_state *mrb, mrb_value self)
 
void mrb_ary_replace (mrb_state *mrb, mrb_value self, mrb_value other)
 
static mrb_value mrb_ary_replace_m (mrb_state *mrb, mrb_value self)
 
static mrb_value mrb_ary_times (mrb_state *mrb, mrb_value self)
 
static mrb_value mrb_ary_reverse_bang (mrb_state *mrb, mrb_value self)
 
static mrb_value mrb_ary_reverse (mrb_state *mrb, mrb_value self)
 
void mrb_ary_push (mrb_state *mrb, mrb_value ary, mrb_value elem)
 
static mrb_value mrb_ary_push_m (mrb_state *mrb, mrb_value self)
 
mrb_value mrb_ary_pop (mrb_state *mrb, mrb_value ary)
 
mrb_value mrb_ary_shift (mrb_state *mrb, mrb_value self)
 
mrb_value mrb_ary_unshift (mrb_state *mrb, mrb_value self, mrb_value item)
 
static mrb_value mrb_ary_unshift_m (mrb_state *mrb, mrb_value self)
 
mrb_value mrb_ary_ref (mrb_state *mrb, mrb_value ary, mrb_int n)
 
void mrb_ary_set (mrb_state *mrb, mrb_value ary, mrb_int n, mrb_value val)
 
static struct RArrayary_dup (mrb_state *mrb, struct RArray *a)
 
mrb_value mrb_ary_splice (mrb_state *mrb, mrb_value ary, mrb_int head, mrb_int len, mrb_value rpl)
 
void mrb_ary_decref (mrb_state *mrb, mrb_shared_array *shared)
 
static mrb_value ary_subseq (mrb_state *mrb, struct RArray *a, mrb_int beg, mrb_int len)
 
mrb_value mrb_ary_subseq (mrb_state *mrb, mrb_value ary, mrb_int beg, mrb_int len)
 
static mrb_int aget_index (mrb_state *mrb, mrb_value index)
 
static mrb_value mrb_ary_aget (mrb_state *mrb, mrb_value self)
 
static mrb_value mrb_ary_aset (mrb_state *mrb, mrb_value self)
 
static mrb_value mrb_ary_delete_at (mrb_state *mrb, mrb_value self)
 
static mrb_value mrb_ary_first (mrb_state *mrb, mrb_value self)
 
static mrb_value mrb_ary_last (mrb_state *mrb, mrb_value self)
 
static mrb_value mrb_ary_index_m (mrb_state *mrb, mrb_value self)
 
static mrb_value mrb_ary_rindex_m (mrb_state *mrb, mrb_value self)
 
mrb_value mrb_ary_splat (mrb_state *mrb, mrb_value v)
 
static mrb_value mrb_ary_size (mrb_state *mrb, mrb_value self)
 
mrb_value mrb_ary_clear (mrb_state *mrb, mrb_value self)
 
static mrb_value mrb_ary_clear_m (mrb_state *mrb, mrb_value self)
 
static mrb_value mrb_ary_empty_p (mrb_state *mrb, mrb_value self)
 
mrb_value mrb_ary_entry (mrb_value ary, mrb_int offset)
 
static mrb_value join_ary (mrb_state *mrb, mrb_value ary, mrb_value sep, mrb_value list)
 
mrb_value mrb_ary_join (mrb_state *mrb, mrb_value ary, mrb_value sep)
 
static mrb_value mrb_ary_join_m (mrb_state *mrb, mrb_value ary)
 
static mrb_value mrb_ary_eq (mrb_state *mrb, mrb_value ary1)
 
static mrb_value mrb_ary_cmp (mrb_state *mrb, mrb_value ary1)
 
static mrb_value mrb_ary_svalue (mrb_state *mrb, mrb_value ary)
 
void mrb_init_array (mrb_state *mrb)
 

Macro Definition Documentation

◆ ARY_C_MAX_SIZE

#define ARY_C_MAX_SIZE   (SIZE_MAX / sizeof(mrb_value))

Definition at line 18 of file array.c.

◆ ARY_DEFAULT_LEN

#define ARY_DEFAULT_LEN   4

Definition at line 16 of file array.c.

◆ ARY_MAX_SIZE

Definition at line 19 of file array.c.

◆ ARY_REPLACE_SHARED_MIN

#define ARY_REPLACE_SHARED_MIN   20

Definition at line 359 of file array.c.

◆ ARY_SHIFT_SHARED_MIN

#define ARY_SHIFT_SHARED_MIN   10

Definition at line 546 of file array.c.

◆ ARY_SHRINK_RATIO

#define ARY_SHRINK_RATIO   5 /* must be larger than 2 */

Definition at line 17 of file array.c.

Function Documentation

◆ aget_index()

static mrb_int aget_index ( mrb_state mrb,
mrb_value  index 
)
static

Definition at line 824 of file array.c.

References argc, argv, i, mrb_float_p, mrb_get_args(), mrb_integer, and mrb_integer_p.

Referenced by mrb_ary_aget(), and mrb_ary_aset().

◆ array_copy()

◆ ary_concat()

static void ary_concat ( mrb_state mrb,
struct RArray a,
struct RArray a2 
)
static

◆ ary_dup()

static struct RArray* ary_dup ( mrb_state mrb,
struct RArray a 
)
static

Definition at line 695 of file array.c.

References a, ARY_LEN, ary_new_from_values(), and ARY_PTR.

Referenced by mrb_ary_splat(), and mrb_ary_splice().

◆ ary_expand_capa()

◆ ary_fill_with_nil()

static void ary_fill_with_nil ( mrb_value ptr,
mrb_int  size 
)
static

Definition at line 113 of file array.c.

References mrb_nil_value(), nil, ptr, and size.

Referenced by mrb_ary_resize(), mrb_ary_set(), and mrb_ary_splice().

◆ ary_make_shared()

◆ ary_modify()

◆ ary_modify_check()

static void ary_modify_check ( mrb_state mrb,
struct RArray a 
)
static

Definition at line 123 of file array.c.

References a, and mrb_check_frozen().

Referenced by ary_modify(), ary_replace(), mrb_ary_pop(), mrb_ary_shift(), and mrb_ary_unshift_m().

◆ ary_new_capa()

◆ ary_new_from_values()

static struct RArray* ary_new_from_values ( mrb_state mrb,
mrb_int  size,
const mrb_value vals 
)
static

Definition at line 83 of file array.c.

References a, array_copy(), ary_new_capa(), ARY_PTR, ARY_SET_LEN, and size.

Referenced by ary_dup(), and mrb_ary_new_from_values().

◆ ary_replace()

◆ ary_shrink_capa()

static void ary_shrink_capa ( mrb_state mrb,
struct RArray a 
)
static

Definition at line 232 of file array.c.

References a, ARY_DEFAULT_LEN, ARY_EMBED_P, ARY_SHRINK_RATIO, as, RArray::capa, and mrb_realloc().

Referenced by mrb_ary_delete_at(), and mrb_ary_resize().

◆ ary_subseq()

◆ join_ary()

◆ mrb_ary_aget()

◆ mrb_ary_aset()

◆ mrb_ary_clear()

◆ mrb_ary_clear_m()

static mrb_value mrb_ary_clear_m ( mrb_state mrb,
mrb_value  self 
)
static

Definition at line 1139 of file array.c.

References mrb_ary_clear().

Referenced by mrb_init_array().

◆ mrb_ary_cmp()

static mrb_value mrb_ary_cmp ( mrb_state mrb,
mrb_value  ary1 
)
static

Definition at line 1265 of file array.c.

References mrb_array_p, mrb_fixnum_value(), mrb_get_arg1(), mrb_nil_value(), and mrb_obj_equal().

Referenced by mrb_init_array().

◆ mrb_ary_concat()

void mrb_ary_concat ( mrb_state mrb,
mrb_value  self,
mrb_value  other 
)

Definition at line 321 of file array.c.

References a2, ary_concat(), mrb_ary_ptr, and other.

Referenced by mrb_ary_concat_m(), and mrb_vm_exec().

◆ mrb_ary_concat_m()

static mrb_value mrb_ary_concat_m ( mrb_state mrb,
mrb_value  self 
)
static

Definition at line 329 of file array.c.

References RArray::ary, mrb_ary_concat(), and mrb_get_args().

Referenced by mrb_init_array().

◆ mrb_ary_decref()

void mrb_ary_decref ( mrb_state mrb,
mrb_shared_array shared 
)

◆ mrb_ary_delete_at()

static mrb_value mrb_ary_delete_at ( mrb_state mrb,
mrb_value  self 
)
static

◆ mrb_ary_empty_p()

static mrb_value mrb_ary_empty_p ( mrb_state mrb,
mrb_value  self 
)
static

Definition at line 1145 of file array.c.

References a, ARY_LEN, mrb_ary_ptr, and mrb_bool_value().

Referenced by mrb_init_array().

◆ mrb_ary_entry()

mrb_value mrb_ary_entry ( mrb_value  ary,
mrb_int  offset 
)

Definition at line 1153 of file array.c.

References RArray::ary, mrb_nil_value(), offset, RARRAY_LEN, and RARRAY_PTR.

Referenced by mrb_ary_at(), and mrb_obj_ceqq().

◆ mrb_ary_eq()

static mrb_value mrb_ary_eq ( mrb_state mrb,
mrb_value  ary1 
)
static

Definition at line 1251 of file array.c.

References mrb_array_p, mrb_false_value(), mrb_get_arg1(), mrb_obj_equal(), mrb_true_value(), and RARRAY_LEN.

Referenced by mrb_init_array().

◆ mrb_ary_first()

◆ mrb_ary_index_m()

static mrb_value mrb_ary_index_m ( mrb_state mrb,
mrb_value  self 
)
static

Definition at line 1051 of file array.c.

References i, mrb_equal(), mrb_fixnum_value(), mrb_get_arg1(), mrb_nil_value(), RARRAY_LEN, and RARRAY_PTR.

Referenced by mrb_init_array().

◆ mrb_ary_join()

mrb_value mrb_ary_join ( mrb_state mrb,
mrb_value  ary,
mrb_value  sep 
)

Definition at line 1222 of file array.c.

References RArray::ary, join_ary(), mrb_ary_new(), mrb_nil_p, mrb_obj_as_string(), and sep.

Referenced by mrb_ary_join_m().

◆ mrb_ary_join_m()

static mrb_value mrb_ary_join_m ( mrb_state mrb,
mrb_value  ary 
)
static

Definition at line 1242 of file array.c.

References RArray::ary, mrb_ary_join(), mrb_get_args(), mrb_nil_value(), and sep.

Referenced by mrb_init_array().

◆ mrb_ary_last()

◆ mrb_ary_modify()

void mrb_ary_modify ( mrb_state mrb,
struct RArray a 
)

Definition at line 160 of file array.c.

References a, ary_modify(), and mrb_write_barrier().

Referenced by mrb_ary_shuffle_bang(), mrb_ary_slice_bang(), and mrb_gc_unregister().

◆ mrb_ary_new()

◆ mrb_ary_new_capa()

◆ mrb_ary_new_from_values()

◆ mrb_ary_plus()

static mrb_value mrb_ary_plus ( mrb_state mrb,
mrb_value  self 
)
static

◆ mrb_ary_pop()

mrb_value mrb_ary_pop ( mrb_state mrb,
mrb_value  ary 
)

◆ mrb_ary_push()

◆ mrb_ary_push_m()

◆ mrb_ary_ref()

mrb_value mrb_ary_ref ( mrb_state mrb,
mrb_value  ary,
mrb_int  n 
)

Definition at line 657 of file array.c.

References a, RArray::ary, ARY_LEN, ARY_PTR, len, mrb_ary_ptr, mrb_nil_value(), and n.

Referenced by mrb_ary_aget(), mrb_ary_values_at(), mrb_pack_pack(), and mrb_vm_exec().

◆ mrb_ary_replace()

void mrb_ary_replace ( mrb_state mrb,
mrb_value  self,
mrb_value  other 
)

Definition at line 403 of file array.c.

References a1, a2, ary_replace(), mrb_ary_ptr, and other.

Referenced by mrb_ary_replace_m(), mrb_struct_init_copy(), and mrb_struct_s_members_m().

◆ mrb_ary_replace_m()

static mrb_value mrb_ary_replace_m ( mrb_state mrb,
mrb_value  self 
)
static

Definition at line 414 of file array.c.

References mrb_ary_replace(), mrb_get_args(), and other.

Referenced by mrb_init_array().

◆ mrb_ary_resize()

mrb_value mrb_ary_resize ( mrb_state mrb,
mrb_value  ary,
mrb_int  new_len 
)

◆ mrb_ary_reverse()

static mrb_value mrb_ary_reverse ( mrb_state mrb,
mrb_value  self 
)
static

Definition at line 475 of file array.c.

References a, ARY_LEN, ary_new_capa(), ARY_PTR, ARY_SET_LEN, b, e, len, mrb_ary_ptr, mrb_obj_value(), p1, and p2.

Referenced by mrb_init_array().

◆ mrb_ary_reverse_bang()

static mrb_value mrb_ary_reverse_bang ( mrb_state mrb,
mrb_value  self 
)
static

Definition at line 453 of file array.c.

References a, ARY_LEN, ary_modify(), ARY_PTR, len, mrb_ary_ptr, p1, and p2.

Referenced by mrb_init_array().

◆ mrb_ary_rindex_m()

static mrb_value mrb_ary_rindex_m ( mrb_state mrb,
mrb_value  self 
)
static

Definition at line 1065 of file array.c.

References i, len, mrb_equal(), mrb_fixnum_value(), mrb_get_arg1(), mrb_nil_value(), RARRAY_LEN, and RARRAY_PTR.

Referenced by mrb_init_array().

◆ mrb_ary_s_create()

static mrb_value mrb_ary_s_create ( mrb_state mrb,
mrb_value  klass 
)
static

Definition at line 280 of file array.c.

References a, RArray::ary, len, mrb_ary_new_from_values(), mrb_ary_ptr, mrb_class_ptr, mrb_get_args(), and vals.

Referenced by mrb_init_array().

◆ mrb_ary_set()

◆ mrb_ary_shift()

mrb_value mrb_ary_shift ( mrb_state mrb,
mrb_value  self 
)

◆ mrb_ary_size()

static mrb_value mrb_ary_size ( mrb_state mrb,
mrb_value  self 
)
static

Definition at line 1107 of file array.c.

References a, ARY_LEN, mrb_ary_ptr, and mrb_fixnum_value().

Referenced by mrb_init_array().

◆ mrb_ary_splat()

◆ mrb_ary_splice()

◆ mrb_ary_subseq()

mrb_value mrb_ary_subseq ( mrb_state mrb,
mrb_value  ary,
mrb_int  beg,
mrb_int  len 
)

Definition at line 817 of file array.c.

References a, RArray::ary, ary_subseq(), len, and mrb_ary_ptr.

Referenced by mrb_f_send().

◆ mrb_ary_svalue()

static mrb_value mrb_ary_svalue ( mrb_state mrb,
mrb_value  ary 
)
static

Definition at line 1279 of file array.c.

References RArray::ary, mrb_nil_value(), RARRAY_LEN, and RARRAY_PTR.

Referenced by mrb_init_array().

◆ mrb_ary_times()

◆ mrb_ary_unshift()

◆ mrb_ary_unshift_m()

◆ mrb_assoc_new()

mrb_value mrb_assoc_new ( mrb_state mrb,
mrb_value  car,
mrb_value  cdr 
)

◆ mrb_init_array()