90 if( !h )
return value;
127#if defined(MRBC_ALLOC_VMID)
137 mrbc_set_vm_id( h, 0 );
142 mrbc_clear_vm_id(p1++);
157 if( size <= 0 ) size = 1;
192 if( idx < h->n_stored ) {
197 for(
int i = h->
n_stored; i < idx; i++ ) {
203 h->
data[idx] = *set_val;
220 if( idx < 0 ) idx = h->
n_stored + idx;
238 if( idx < 0 ) idx = h->
n_stored + idx;
239 if( idx < 0 || idx >= h->
n_stored )
return NULL;
241 return &h->
data[idx];
369 if( idx < h->n_stored ) {
370 memmove(h->
data + idx + 1, h->
data + idx,
375 h->
data[idx] = *set_val;
380 for(
int i = h->
n_stored-1; i < idx; i++ ) {
401 if( idx < 0 ) idx = h->
n_stored + idx;
406 if( idx < h->n_stored ) {
407 memmove(h->
data + idx, h->
data + idx + 1,
445 for(
int i = 0; ; i++ ) {
451 if( res != 0 )
return res;
468 *pp_min_value = NULL;
469 *pp_max_value = NULL;
476 for(
int i = 1; i < h->
n_stored; i++ ) {
478 p_min_value = &h->
data[i];
481 p_max_value = &h->
data[i];
485 *pp_min_value = p_min_value;
486 *pp_max_value = p_max_value;
502 if( dv.
array == NULL )
return dv;
532 if( pos < 0 ) pos = 0;
533 int new_size = ha_s->
n_stored - pos;
534 if( new_size < 0 ) new_size = 0;
535 int remain_size = ha_s->
n_stored - new_size;
538 if( ret.
array == NULL )
return ret;
559 for(
int i = 0; i < n; i++ ) {
593 for(
int i = 0; i < size-1; i++ ) {
594 for(
int j = i+1; j < size; j++ ) {
598 int rest = --size - j;
599 if( rest == 0 )
break;
616static void c_array_new(
struct VM *vm,
mrbc_value v[],
int argc)
623 if( ret.
array == NULL )
return;
635 if( ret.
array == NULL )
return;
650 if( ret.
array == NULL )
return;
652 for(
int i = 0; i < num; i++ ) {
670static void c_array_add(
struct VM *vm,
mrbc_value v[],
int argc)
681 if( value.
array == NULL )
return;
703static void c_array_get(
struct VM *vm,
mrbc_value v[],
int argc)
710 if( ret.
array == NULL )
return;
713 for(
int i = 1; i <= argc; i++ ) {
738 if( idx < 0 ) idx += len;
739 if( idx < 0 )
goto RETURN_NIL;
743 if( size < 0 )
goto RETURN_NIL;
746 if( ret.
array == NULL )
return;
748 for(
int i = 0; i < size; i++ ) {
772static void c_array_set(
struct VM *vm,
mrbc_value v[],
int argc)
804 }
else if( pos > v[0].array->n_stored ) {
812 if( pos+len > v[0].array->n_stored ) {
821 for(
int i = 0; i < len; i++ ) {
856static void c_array_clear(
struct VM *vm,
mrbc_value v[],
int argc)
865static void c_array_delete_at(
struct VM *vm,
mrbc_value v[],
int argc)
879static void c_array_empty(
struct VM *vm,
mrbc_value v[],
int argc)
894static void c_array_size(
struct VM *vm,
mrbc_value v[],
int argc)
905static void c_array_include(
struct VM *vm,
mrbc_value v[],
int argc)
914static void c_array_and(
struct VM *vm,
mrbc_value v[],
int argc)
935static void c_array_or(
struct VM *vm,
mrbc_value v[],
int argc)
964static void c_array_first(
struct VM *vm,
mrbc_value v[],
int argc)
975static void c_array_last(
struct VM *vm,
mrbc_value v[],
int argc)
986static void c_array_push(
struct VM *vm,
mrbc_value v[],
int argc)
996static void c_array_pop(
struct VM *vm,
mrbc_value v[],
int argc)
1024static void c_array_unshift(
struct VM *vm,
mrbc_value v[],
int argc)
1034static void c_array_shift(
struct VM *vm,
mrbc_value v[],
int argc)
1072static void c_array_dup(
struct VM *vm,
mrbc_value v[],
int argc)
1081static void c_array_min(
struct VM *vm,
mrbc_value v[],
int argc)
1088 if( p_min_value == NULL ) {
1101static void c_array_max(
struct VM *vm,
mrbc_value v[],
int argc)
1108 if( p_max_value == NULL ) {
1121static void c_array_minmax(
struct VM *vm,
mrbc_value v[],
int argc)
1130 if( p_min_value == NULL ) p_min_value = &nil;
1131 if( p_max_value == NULL ) p_max_value = &nil;
1145static void c_array_uniq(
struct VM *vm,
mrbc_value v[],
int argc)
1162static void c_array_uniq_self(
struct VM *vm,
mrbc_value v[],
int argc)
1180static void c_array_inspect(
struct VM *vm,
mrbc_value v[],
int argc)
1188 if( !ret.
string )
goto RETURN_NIL;
1212static void c_array_join_1(
struct VM *vm,
mrbc_value v[],
int argc,
1219 while( !flag_error ) {
1221 c_array_join_1(vm, v, argc, &src->
array->
data[i], ret, separator);
1232static void c_array_join(
struct VM *vm,
mrbc_value v[],
int argc)
1235 if( !ret.
string )
goto RETURN_NIL;
1238 mrbc_send( vm, v, argc, &v[1],
"to_s", 0 );
1240 c_array_join_1(vm, v, argc, &v[0], &ret, &separator );
1291#include "_autogen_class_array.h"
void * mrbc_raw_realloc(void *ptr, unsigned int size)
void mrbc_raw_free(void *ptr)
int mrbc_array_push(mrbc_value *ary, mrbc_value *set_val)
mrbc_value mrbc_array_pop(mrbc_value *ary)
int mrbc_array_set(mrbc_value *ary, int idx, mrbc_value *set_val)
mrbc_value mrbc_array_get(const mrbc_value *ary, int idx)
mrbc_value * mrbc_array_get_p(const mrbc_value *ary, int idx)
mrbc_value mrbc_array_divide(struct VM *vm, mrbc_value *src, int pos)
mrbc_value mrbc_array_new(struct VM *vm, int size)
mrbc_value mrbc_array_remove(mrbc_value *ary, int idx)
int mrbc_array_uniq_self(mrbc_value *ary)
void mrbc_array_minmax(mrbc_value *ary, mrbc_value **pp_min_value, mrbc_value **pp_max_value)
int mrbc_array_resize(mrbc_value *ary, int size)
mrbc_value mrbc_array_uniq(struct VM *vm, const mrbc_value *ary)
mrbc_value mrbc_array_shift(mrbc_value *ary)
void mrbc_array_clear(mrbc_value *ary)
int mrbc_array_insert(mrbc_value *ary, int idx, mrbc_value *set_val)
mrbc_value mrbc_array_dup(struct VM *vm, const mrbc_value *ary)
int mrbc_array_push_m(mrbc_value *ary, mrbc_value *set_val)
int mrbc_array_unshift(mrbc_value *ary, mrbc_value *set_val)
int mrbc_array_index(const mrbc_value *ary, const mrbc_value *val)
int mrbc_array_compare(const mrbc_value *v1, const mrbc_value *v2)
void mrbc_array_delete(mrbc_value *ary)
static void mrbc_array_delete_handle(mrbc_value *ary)
static int mrbc_array_size(const mrbc_value *ary)
struct RArray mrbc_array
Array object.
static int mrbc_array_include(const mrbc_value *ary, const mrbc_value *val)
void mrbc_string_delete(mrbc_value *str)
int mrbc_string_append(mrbc_value *s1, const mrbc_value *s2)
mrbc_value mrbc_string_new(struct VM *vm, const void *src, int len)
static mrbc_value mrbc_string_new_cstr(struct VM *vm, const char *src)
static int mrbc_string_append_cstr(mrbc_value *s1, const char *s2)
mrbc_value mrbc_send(struct VM *vm, mrbc_value *v, int argc, mrbc_value *recv, const char *method_name, int n_params,...)
void mrbc_raise(struct VM *vm, struct RClass *exc_cls, const char *msg)
void mrbc_raisef(struct VM *vm, struct RClass *exc_cls, const char *fstr,...)
Include at once the necessary header files.
uint16_t n_stored
num of stored.
uint16_t data_size
data buffer size.
mrbc_value * data
pointer to allocated memory.
const char * mrbc_symid_to_str(mrbc_sym sym_id)
int mrbc_compare(const mrbc_value *v1, const mrbc_value *v2)
static void mrbc_decref(mrbc_value *v)
#define MRBC_INIT_OBJECT_HEADER(p, t)
#define SET_BOOL_RETURN(n)
#define SET_INT_RETURN(n)
static void mrbc_decref_empty(mrbc_value *v)
static void mrbc_incref(mrbc_value *v)
#define SET_TRUE_RETURN()
@ MRBC_TT_INTEGER
Integer.
struct RObject mrbc_value
#define SET_FALSE_RETURN()
static int mrbc_c_block_given(struct VM *vm, mrbc_value v[], int argc)
Global configuration of mruby/c VM's.