diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | array.c | 112 | ||||
-rw-r--r-- | compile.c | 10 | ||||
-rw-r--r-- | complex.c | 4 | ||||
-rw-r--r-- | enum.c | 26 | ||||
-rw-r--r-- | enumerator.c | 16 | ||||
-rw-r--r-- | error.c | 2 | ||||
-rw-r--r-- | eval_error.c | 2 | ||||
-rw-r--r-- | file.c | 10 | ||||
-rw-r--r-- | gc.c | 8 | ||||
-rw-r--r-- | hash.c | 34 | ||||
-rw-r--r-- | insns.def | 2 | ||||
-rw-r--r-- | io.c | 14 | ||||
-rw-r--r-- | iseq.c | 2 | ||||
-rw-r--r-- | load.c | 10 | ||||
-rw-r--r-- | marshal.c | 10 | ||||
-rw-r--r-- | numeric.c | 12 | ||||
-rw-r--r-- | pack.c | 8 | ||||
-rw-r--r-- | parse.y | 2 | ||||
-rw-r--r-- | proc.c | 6 | ||||
-rw-r--r-- | process.c | 76 | ||||
-rw-r--r-- | range.c | 2 | ||||
-rw-r--r-- | rational.c | 6 | ||||
-rw-r--r-- | re.c | 2 | ||||
-rw-r--r-- | ruby.c | 4 | ||||
-rw-r--r-- | string.c | 2 | ||||
-rw-r--r-- | struct.c | 2 | ||||
-rw-r--r-- | thread.c | 18 | ||||
-rw-r--r-- | transcode.c | 6 | ||||
-rw-r--r-- | vm.c | 4 | ||||
-rw-r--r-- | vm_dump.c | 2 | ||||
-rw-r--r-- | vm_eval.c | 6 | ||||
-rw-r--r-- | vm_method.c | 4 |
33 files changed, 217 insertions, 212 deletions
@@ -1,3 +1,8 @@ +Mon May 13 18:44:14 2013 Koichi Sasada <[email protected]> + + * *.c, parse.y, insns.def: use RARRAY_AREF/ASET macro + instead of using RARRAY_PTR(). + Mon May 13 16:53:53 2013 Koichi Sasada <[email protected]> * include/ruby/ruby.h: add new utility macros to access @@ -440,7 +440,7 @@ rb_ary_new3(long n, ...) va_start(ar, n); for (i=0; i<n; i++) { - RARRAY_PTR(ary)[i] = va_arg(ar, VALUE); + RARRAY_ASET(ary, i, va_arg(ar, VALUE)); } va_end(ar); @@ -742,7 +742,7 @@ rb_ary_store(VALUE ary, long idx, VALUE val) if (idx >= RARRAY_LEN(ary)) { ARY_SET_LEN(ary, idx + 1); } - RARRAY_PTR(ary)[idx] = val; + RARRAY_ASET(ary, idx, val); } static VALUE @@ -825,7 +825,7 @@ rb_ary_push(VALUE ary, VALUE item) long idx = RARRAY_LEN(ary); ary_ensure_room_for_push(ary, 1); - RARRAY_PTR(ary)[idx] = item; + RARRAY_ASET(ary, idx, item); ARY_SET_LEN(ary, idx + 1); return ary; } @@ -838,7 +838,7 @@ rb_ary_push_1(VALUE ary, VALUE item) if (idx >= ARY_CAPA(ary)) { ary_double_capa(ary, idx); } - RARRAY_PTR(ary)[idx] = item; + RARRAY_ASET(ary, idx, item); ARY_SET_LEN(ary, idx + 1); return ary; } @@ -890,7 +890,7 @@ rb_ary_pop(VALUE ary) } n = RARRAY_LEN(ary)-1; ARY_SET_LEN(ary, n); - return RARRAY_PTR(ary)[n]; + return RARRAY_AREF(ary, n); } /* @@ -933,7 +933,7 @@ rb_ary_shift(VALUE ary) rb_ary_modify_check(ary); if (RARRAY_LEN(ary) == 0) return Qnil; - top = RARRAY_PTR(ary)[0]; + top = RARRAY_AREF(ary, 0); if (!ARY_SHARED_P(ary)) { if (RARRAY_LEN(ary) < ARY_DEFAULT_SIZE) { MEMMOVE(RARRAY_PTR(ary), RARRAY_PTR(ary)+1, VALUE, RARRAY_LEN(ary)-1); @@ -942,11 +942,11 @@ rb_ary_shift(VALUE ary) } assert(!ARY_EMBED_P(ary)); /* ARY_EMBED_LEN_MAX < ARY_DEFAULT_SIZE */ - RARRAY_PTR(ary)[0] = Qnil; + RARRAY_ASET(ary, 0, Qnil); ary_make_shared(ary); } else if (ARY_SHARED_NUM(ARY_SHARED(ary)) == 1) { - RARRAY_PTR(ary)[0] = Qnil; + RARRAY_ASET(ary, 0, Qnil); } ARY_INCREASE_PTR(ary, 1); /* shift ptr */ ARY_INCREASE_LEN(ary, -1); @@ -1095,7 +1095,7 @@ rb_ary_elt(VALUE ary, long offset) if (offset < 0 || RARRAY_LEN(ary) <= offset) { return Qnil; } - return RARRAY_PTR(ary)[offset]; + return RARRAY_AREF(ary, offset); } VALUE @@ -1233,7 +1233,7 @@ rb_ary_first(int argc, VALUE *argv, VALUE ary) { if (argc == 0) { if (RARRAY_LEN(ary) == 0) return Qnil; - return RARRAY_PTR(ary)[0]; + return RARRAY_AREF(ary, 0); } else { return ary_take_first_or_last(argc, argv, ary, ARY_TAKE_FIRST); @@ -1260,7 +1260,7 @@ rb_ary_last(int argc, VALUE *argv, VALUE ary) { if (argc == 0) { if (RARRAY_LEN(ary) == 0) return Qnil; - return RARRAY_PTR(ary)[RARRAY_LEN(ary)-1]; + return RARRAY_AREF(ary, RARRAY_LEN(ary)-1); } else { return ary_take_first_or_last(argc, argv, ary, ARY_TAKE_LAST); @@ -1315,7 +1315,7 @@ rb_ary_fetch(int argc, VALUE *argv, VALUE ary) } return ifnone; } - return RARRAY_PTR(ary)[idx]; + return RARRAY_AREF(ary, idx); } /* @@ -1353,7 +1353,7 @@ rb_ary_index(int argc, VALUE *argv, VALUE ary) if (argc == 0) { RETURN_ENUMERATOR(ary, 0, 0); for (i=0; i<RARRAY_LEN(ary); i++) { - if (RTEST(rb_yield(RARRAY_PTR(ary)[i]))) { + if (RTEST(rb_yield(RARRAY_AREF(ary, i)))) { return LONG2NUM(i); } } @@ -1363,7 +1363,7 @@ rb_ary_index(int argc, VALUE *argv, VALUE ary) if (rb_block_given_p()) rb_warn("given block not used"); for (i=0; i<RARRAY_LEN(ary); i++) { - if (rb_equal(RARRAY_PTR(ary)[i], val)) + if (rb_equal(RARRAY_AREF(ary, i), val)) return LONG2NUM(i); } return Qnil; @@ -1402,7 +1402,7 @@ rb_ary_rindex(int argc, VALUE *argv, VALUE ary) if (argc == 0) { RETURN_ENUMERATOR(ary, 0, 0); while (i--) { - if (RTEST(rb_yield(RARRAY_PTR(ary)[i]))) + if (RTEST(rb_yield(RARRAY_AREF(ary, i)))) return LONG2NUM(i); if (i > RARRAY_LEN(ary)) { i = RARRAY_LEN(ary); @@ -1414,7 +1414,7 @@ rb_ary_rindex(int argc, VALUE *argv, VALUE ary) if (rb_block_given_p()) rb_warn("given block not used"); while (i--) { - if (rb_equal(RARRAY_PTR(ary)[i], val)) + if (rb_equal(RARRAY_AREF(ary, i), val)) return LONG2NUM(i); if (i > RARRAY_LEN(ary)) { i = RARRAY_LEN(ary); @@ -1676,7 +1676,7 @@ rb_ary_each(VALUE array) RETURN_SIZED_ENUMERATOR(ary, 0, 0, rb_ary_length); for (i=0; i<RARRAY_LEN(ary); i++) { - rb_yield(RARRAY_PTR(ary)[i]); + rb_yield(RARRAY_AREF(ary, i)); } return ary; } @@ -1734,7 +1734,7 @@ rb_ary_reverse_each(VALUE ary) RETURN_SIZED_ENUMERATOR(ary, 0, 0, rb_ary_length); len = RARRAY_LEN(ary); while (len--) { - rb_yield(RARRAY_PTR(ary)[len]); + rb_yield(RARRAY_AREF(ary, len)); if (RARRAY_LEN(ary) < len) { len = RARRAY_LEN(ary); } @@ -1819,9 +1819,9 @@ ary_join_0(VALUE ary, VALUE sep, long max, VALUE result) long i; VALUE val; - if (max > 0) rb_enc_copy(result, RARRAY_PTR(ary)[0]); + if (max > 0) rb_enc_copy(result, RARRAY_AREF(ary, 0)); for (i=0; i<max; i++) { - val = RARRAY_PTR(ary)[i]; + val = RARRAY_AREF(ary, i); if (i > 0 && !NIL_P(sep)) rb_str_buf_append(result, sep); rb_str_buf_append(result, val); @@ -1839,7 +1839,7 @@ ary_join_1(VALUE obj, VALUE ary, VALUE sep, long i, VALUE result, int *first) if (i > 0 && !NIL_P(sep)) rb_str_buf_append(result, sep); - val = RARRAY_PTR(ary)[i]; + val = RARRAY_AREF(ary, i); if (RB_TYPE_P(val, T_STRING)) { str_join: rb_str_buf_append(result, val); @@ -1900,7 +1900,7 @@ rb_ary_join(VALUE ary, VALUE sep) len += RSTRING_LEN(sep) * (RARRAY_LEN(ary) - 1); } for (i=0; i<RARRAY_LEN(ary); i++) { - val = RARRAY_PTR(ary)[i]; + val = RARRAY_AREF(ary, i); tmp = rb_check_string_type(val); if (NIL_P(tmp) || tmp != val) { @@ -1961,7 +1961,7 @@ inspect_ary(VALUE ary, VALUE dummy, int recur) if (recur) return rb_usascii_str_new_cstr("[...]"); str = rb_str_buf_new2("["); for (i=0; i<RARRAY_LEN(ary); i++) { - s = rb_inspect(RARRAY_PTR(ary)[i]); + s = rb_inspect(RARRAY_AREF(ary, i)); if (OBJ_TAINTED(s)) tainted = TRUE; if (OBJ_UNTRUSTED(s)) untrust = TRUE; if (i > 0) rb_str_buf_cat2(str, ", "); @@ -2539,7 +2539,7 @@ rb_ary_collect(VALUE ary) RETURN_SIZED_ENUMERATOR(ary, 0, 0, rb_ary_length); collect = rb_ary_new2(RARRAY_LEN(ary)); for (i = 0; i < RARRAY_LEN(ary); i++) { - rb_ary_push(collect, rb_yield(RARRAY_PTR(ary)[i])); + rb_ary_push(collect, rb_yield(RARRAY_AREF(ary, i))); } return collect; } @@ -2572,7 +2572,7 @@ rb_ary_collect_bang(VALUE ary) RETURN_SIZED_ENUMERATOR(ary, 0, 0, rb_ary_length); rb_ary_modify(ary); for (i = 0; i < RARRAY_LEN(ary); i++) { - rb_ary_store(ary, i, rb_yield(RARRAY_PTR(ary)[i])); + rb_ary_store(ary, i, rb_yield(RARRAY_AREF(ary, i))); } return ary; } @@ -2655,7 +2655,7 @@ rb_ary_select(VALUE ary) RETURN_SIZED_ENUMERATOR(ary, 0, 0, rb_ary_length); result = rb_ary_new2(RARRAY_LEN(ary)); for (i = 0; i < RARRAY_LEN(ary); i++) { - if (RTEST(rb_yield(RARRAY_PTR(ary)[i]))) { + if (RTEST(rb_yield(RARRAY_AREF(ary, i)))) { rb_ary_push(result, rb_ary_elt(ary, i)); } } @@ -2686,7 +2686,7 @@ rb_ary_select_bang(VALUE ary) RETURN_SIZED_ENUMERATOR(ary, 0, 0, rb_ary_length); rb_ary_modify(ary); for (i1 = i2 = 0; i1 < RARRAY_LEN(ary); i1++) { - VALUE v = RARRAY_PTR(ary)[i1]; + VALUE v = RARRAY_AREF(ary, i1); if (!RTEST(rb_yield(v))) continue; if (i1 != i2) { rb_ary_store(ary, i2, v); @@ -2764,7 +2764,7 @@ rb_ary_delete(VALUE ary, VALUE item) long i1, i2; for (i1 = i2 = 0; i1 < RARRAY_LEN(ary); i1++) { - VALUE e = RARRAY_PTR(ary)[i1]; + VALUE e = RARRAY_AREF(ary, i1); if (rb_equal(e, item)) { v = e; @@ -2793,7 +2793,7 @@ rb_ary_delete_same(VALUE ary, VALUE item) long i1, i2; for (i1 = i2 = 0; i1 < RARRAY_LEN(ary); i1++) { - VALUE e = RARRAY_PTR(ary)[i1]; + VALUE e = RARRAY_AREF(ary, i1); if (e == item) { continue; @@ -2823,7 +2823,7 @@ rb_ary_delete_at(VALUE ary, long pos) } rb_ary_modify(ary); - del = RARRAY_PTR(ary)[pos]; + del = RARRAY_AREF(ary, pos); MEMMOVE(RARRAY_PTR(ary)+pos, RARRAY_PTR(ary)+pos+1, VALUE, RARRAY_LEN(ary)-pos-1); ARY_INCREASE_LEN(ary, -1); @@ -2930,7 +2930,7 @@ ary_reject(VALUE orig, VALUE result) long i; for (i = 0; i < RARRAY_LEN(orig); i++) { - VALUE v = RARRAY_PTR(orig)[i]; + VALUE v = RARRAY_AREF(orig, i); if (!RTEST(rb_yield(v))) { rb_ary_push_1(result, v); } @@ -2946,7 +2946,7 @@ ary_reject_bang(VALUE ary) rb_ary_modify_check(ary); for (i = 0; i < RARRAY_LEN(ary); ) { - VALUE v = RARRAY_PTR(ary)[i]; + VALUE v = RARRAY_AREF(ary, i); if (RTEST(rb_yield(v))) { rb_ary_delete_at(ary, i); result = ary; @@ -3323,7 +3323,7 @@ rb_ary_fill(int argc, VALUE *argv, VALUE ary) for (i=beg; i<end; i++) { v = rb_yield(LONG2NUM(i)); if (i>=RARRAY_LEN(ary)) break; - RARRAY_PTR(ary)[i] = v; + RARRAY_ASET(ary, i, v); } } else { @@ -3482,9 +3482,9 @@ rb_ary_assoc(VALUE ary, VALUE key) VALUE v; for (i = 0; i < RARRAY_LEN(ary); ++i) { - v = rb_check_array_type(RARRAY_PTR(ary)[i]); + v = rb_check_array_type(RARRAY_AREF(ary, i)); if (!NIL_P(v) && RARRAY_LEN(v) > 0 && - rb_equal(RARRAY_PTR(v)[0], key)) + rb_equal(RARRAY_AREF(v, 0), key)) return v; } return Qnil; @@ -3515,10 +3515,10 @@ rb_ary_rassoc(VALUE ary, VALUE value) VALUE v; for (i = 0; i < RARRAY_LEN(ary); ++i) { - v = RARRAY_PTR(ary)[i]; + v = RARRAY_AREF(ary, i); if (RB_TYPE_P(v, T_ARRAY) && RARRAY_LEN(v) > 1 && - rb_equal(RARRAY_PTR(v)[1], value)) + rb_equal(RARRAY_AREF(v, 1), value)) return v; } return Qnil; @@ -3628,7 +3628,7 @@ recursive_hash(VALUE ary, VALUE dummy, int recur) } else { for (i=0; i<RARRAY_LEN(ary); i++) { - n = rb_hash(RARRAY_PTR(ary)[i]); + n = rb_hash(RARRAY_AREF(ary, i)); h = rb_hash_uint(h, NUM2LONG(n)); } } @@ -3670,7 +3670,7 @@ rb_ary_includes(VALUE ary, VALUE item) long i; for (i=0; i<RARRAY_LEN(ary); i++) { - if (rb_equal(RARRAY_PTR(ary)[i], item)) { + if (rb_equal(RARRAY_AREF(ary, i), item)) { return Qtrue; } } @@ -3745,7 +3745,7 @@ ary_add_hash(VALUE hash, VALUE ary) long i; for (i=0; i<RARRAY_LEN(ary); i++) { - rb_hash_aset(hash, RARRAY_PTR(ary)[i], Qtrue); + rb_hash_aset(hash, RARRAY_AREF(ary, i), Qtrue); } return hash; } @@ -3825,7 +3825,7 @@ rb_ary_diff(VALUE ary1, VALUE ary2) ary3 = rb_ary_new(); for (i=0; i<RARRAY_LEN(ary1); i++) { - if (st_lookup(RHASH_TBL(hash), RARRAY_PTR(ary1)[i], 0)) continue; + if (st_lookup(RHASH_TBL(hash), RARRAY_AREF(ary1, i), 0)) continue; rb_ary_push(ary3, rb_ary_elt(ary1, i)); } ary_recycle_hash(hash); @@ -4158,7 +4158,7 @@ flatten(VALUE ary, int level, int *modified) while (1) { while (i < RARRAY_LEN(ary)) { - elt = RARRAY_PTR(ary)[i++]; + elt = RARRAY_AREF(ary, i++); tmp = rb_check_array_type(elt); if (RBASIC(result)->klass) { rb_raise(rb_eRuntimeError, "flatten reentered"); @@ -4483,7 +4483,7 @@ rb_ary_cycle_size(VALUE self, VALUE args) long mul; VALUE n = Qnil; if (args && (RARRAY_LEN(args) > 0)) { - n = RARRAY_PTR(args)[0]; + n = RARRAY_AREF(args, 0); } if (RARRAY_LEN(self) == 0) return INT2FIX(0); if (n == Qnil) return DBL2NUM(INFINITY); @@ -4531,7 +4531,7 @@ rb_ary_cycle(int argc, VALUE *argv, VALUE ary) while (RARRAY_LEN(ary) > 0 && (n < 0 || 0 < n--)) { for (i=0; i<RARRAY_LEN(ary); i++) { - rb_yield(RARRAY_PTR(ary)[i]); + rb_yield(RARRAY_AREF(ary, i)); } } return Qnil; @@ -4618,7 +4618,7 @@ static VALUE rb_ary_permutation_size(VALUE ary, VALUE args) { long n = RARRAY_LEN(ary); - long k = (args && (RARRAY_LEN(args) > 0)) ? NUM2LONG(RARRAY_PTR(args)[0]) : n; + long k = (args && (RARRAY_LEN(args) > 0)) ? NUM2LONG(RARRAY_AREF(args, 0)) : n; return descending_factorial(n, k); } @@ -4670,7 +4670,7 @@ rb_ary_permutation(int argc, VALUE *argv, VALUE ary) } else if (r == 1) { /* this is a special, easy case */ for (i = 0; i < RARRAY_LEN(ary); i++) { - rb_yield(rb_ary_new3(1, RARRAY_PTR(ary)[i])); + rb_yield(rb_ary_new3(1, RARRAY_AREF(ary, i))); } } else { /* this is the general case */ @@ -4695,7 +4695,7 @@ static VALUE rb_ary_combination_size(VALUE ary, VALUE args) { long n = RARRAY_LEN(ary); - long k = NUM2LONG(RARRAY_PTR(args)[0]); + long k = NUM2LONG(RARRAY_AREF(args, 0)); return binomial_coefficient(k, n); } @@ -4741,7 +4741,7 @@ rb_ary_combination(VALUE ary, VALUE num) } else if (n == 1) { for (i = 0; i < len; i++) { - rb_yield(rb_ary_new3(1, RARRAY_PTR(ary)[i])); + rb_yield(rb_ary_new3(1, RARRAY_AREF(ary, i))); } } else { @@ -4754,9 +4754,9 @@ rb_ary_combination(VALUE ary, VALUE num) MEMZERO(stack, long, n); stack[0] = -1; for (;;) { - chosen[lev] = RARRAY_PTR(ary)[stack[lev+1]]; + chosen[lev] = RARRAY_AREF(ary, stack[lev+1]); for (lev++; lev < n; lev++) { - chosen[lev] = RARRAY_PTR(ary)[stack[lev+1] = stack[lev]+1]; + chosen[lev] = RARRAY_AREF(ary, stack[lev+1] = stack[lev]+1); } rb_yield(rb_ary_new4(n, chosen)); if (RBASIC(t0)->klass) { @@ -4818,7 +4818,7 @@ static VALUE rb_ary_repeated_permutation_size(VALUE ary, VALUE args) { long n = RARRAY_LEN(ary); - long k = NUM2LONG(RARRAY_PTR(args)[0]); + long k = NUM2LONG(RARRAY_AREF(args, 0)); if (k < 0) { return LONG2FIX(0); @@ -4867,7 +4867,7 @@ rb_ary_repeated_permutation(VALUE ary, VALUE num) } else if (r == 1) { /* this is a special, easy case */ for (i = 0; i < RARRAY_LEN(ary); i++) { - rb_yield(rb_ary_new3(1, RARRAY_PTR(ary)[i])); + rb_yield(rb_ary_new3(1, RARRAY_AREF(ary, i))); } } else { /* this is the general case */ @@ -4911,7 +4911,7 @@ static VALUE rb_ary_repeated_combination_size(VALUE ary, VALUE args) { long n = RARRAY_LEN(ary); - long k = NUM2LONG(RARRAY_PTR(args)[0]); + long k = NUM2LONG(RARRAY_AREF(args, 0)); if (k == 0) { return LONG2FIX(1); } @@ -4961,7 +4961,7 @@ rb_ary_repeated_combination(VALUE ary, VALUE num) } else if (n == 1) { for (i = 0; i < len; i++) { - rb_yield(rb_ary_new3(1, RARRAY_PTR(ary)[i])); + rb_yield(rb_ary_new3(1, RARRAY_AREF(ary, i))); } } else if (len == 0) { @@ -5139,7 +5139,7 @@ rb_ary_take_while(VALUE ary) RETURN_ENUMERATOR(ary, 0, 0); for (i = 0; i < RARRAY_LEN(ary); i++) { - if (!RTEST(rb_yield(RARRAY_PTR(ary)[i]))) break; + if (!RTEST(rb_yield(RARRAY_AREF(ary, i)))) break; } return rb_ary_take(ary, LONG2FIX(i)); } @@ -5199,7 +5199,7 @@ rb_ary_drop_while(VALUE ary) RETURN_ENUMERATOR(ary, 0, 0); for (i = 0; i < RARRAY_LEN(ary); i++) { - if (!RTEST(rb_yield(RARRAY_PTR(ary)[i]))) break; + if (!RTEST(rb_yield(RARRAY_AREF(ary, i)))) break; } return rb_ary_drop(ary, LONG2FIX(i)); } @@ -223,7 +223,7 @@ r_value(VALUE value) do { \ if ((event) == RUBY_EVENT_LINE && iseq->coverage && \ (line) != iseq->compile_data->last_coverable_line) { \ - RARRAY_PTR(iseq->coverage)[(line) - 1] = INT2FIX(0); \ + RARRAY_ASET(iseq->coverage, (line) - 1, INT2FIX(0)); \ iseq->compile_data->last_coverable_line = (line); \ ADD_INSN1((seq), (line), trace, INT2FIX(RUBY_EVENT_COVERAGE)); \ } \ @@ -1209,7 +1209,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args) keywords = required; } for (j = 0; j < i; j++) { - iseq->arg_keyword_table[j] = FIX2INT(RARRAY_PTR(keywords)[j]); + iseq->arg_keyword_table[j] = FIX2INT(RARRAY_AREF(keywords, j)); } ADD_INSN(optargs, nd_line(args->kw_args), pop); } @@ -5571,7 +5571,7 @@ iseq_build_from_ary_exception(rb_iseq_t *iseq, struct st_table *labels_table, LABEL *lstart, *lend, *lcont; int sp; - RB_GC_GUARD(v) = rb_convert_type(RARRAY_PTR(exception)[i], T_ARRAY, + RB_GC_GUARD(v) = rb_convert_type(RARRAY_AREF(exception, i), T_ARRAY, "Array", "to_ary"); if (RARRAY_LEN(v) != 6) { rb_raise(rb_eSyntaxError, "wrong exception entry"); @@ -5663,7 +5663,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *anchor, st_data_t insn_id; VALUE insn; - insn = (argc < 0) ? Qnil : RARRAY_PTR(obj)[0]; + insn = (argc < 0) ? Qnil : RARRAY_AREF(obj, 0); if (st_lookup(insn_table, (st_data_t)insn, &insn_id) == 0) { /* TODO: exception */ RB_GC_GUARD(insn) = rb_inspect(insn); @@ -5794,7 +5794,7 @@ rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args, iseq->local_size = iseq->local_table_size + 1; for (i=0; i<RARRAY_LEN(locals); i++) { - VALUE lv = RARRAY_PTR(locals)[i]; + VALUE lv = RARRAY_AREF(locals, i); tbl[i] = FIXNUM_P(lv) ? (ID)FIX2LONG(lv) : SYM2ID(CHECK_SYMBOL(lv)); } @@ -1357,8 +1357,8 @@ nucomp_marshal_load(VALUE self, VALUE a) Check_Type(a, T_ARRAY); if (RARRAY_LEN(a) != 2) rb_raise(rb_eArgError, "marshaled complex must have an array whose length is 2 but %ld", RARRAY_LEN(a)); - rb_ivar_set(self, id_i_real, RARRAY_PTR(a)[0]); - rb_ivar_set(self, id_i_imag, RARRAY_PTR(a)[1]); + rb_ivar_set(self, id_i_real, RARRAY_AREF(a, 0)); + rb_ivar_set(self, id_i_imag, RARRAY_AREF(a, 1)); return self; } @@ -817,8 +817,8 @@ sort_by_i(VALUE i, VALUE _data, int argc, VALUE *argv) rb_raise(rb_eRuntimeError, "sort_by reentered"); } - RARRAY_PTR(data->buf)[data->n*2] = v; - RARRAY_PTR(data->buf)[data->n*2+1] = i; + RARRAY_ASET(data->buf, data->n*2, v); + RARRAY_ASET(data->buf, data->n*2+1, i); data->n++; if (data->n == SORT_BY_BUFSIZE) { rb_ary_concat(ary, data->buf); @@ -955,7 +955,7 @@ enum_sort_by(VALUE obj) rb_raise(rb_eRuntimeError, "sort_by reentered"); } for (i=1; i<RARRAY_LEN(ary); i+=2) { - RARRAY_PTR(ary)[i/2] = RARRAY_PTR(ary)[i]; + RARRAY_ASET(ary, i/2, RARRAY_AREF(ary, i)); } rb_ary_resize(ary, RARRAY_LEN(ary)/2); RBASIC(ary)->klass = rb_cArray; @@ -1725,7 +1725,7 @@ enum_reverse_each(int argc, VALUE *argv, VALUE obj) ary = enum_to_a(argc, argv, obj); for (i = RARRAY_LEN(ary); --i >= 0; ) { - rb_yield(RARRAY_PTR(ary)[i]); + rb_yield(RARRAY_AREF(ary, i)); } return obj; @@ -1800,7 +1800,7 @@ static VALUE enum_each_slice_size(VALUE obj, VALUE args) { VALUE n, size; - long slice_size = NUM2LONG(RARRAY_PTR(args)[0]); + long slice_size = NUM2LONG(RARRAY_AREF(args, 0)); if (slice_size <= 0) rb_raise(rb_eArgError, "invalid slice size"); size = enum_size(obj, 0); @@ -1867,7 +1867,7 @@ static VALUE enum_each_cons_size(VALUE obj, VALUE args) { VALUE n, size; - long cons_size = NUM2LONG(RARRAY_PTR(args)[0]); + long cons_size = NUM2LONG(RARRAY_AREF(args, 0)); if (cons_size <= 0) rb_raise(rb_eArgError, "invalid size"); size = enum_size(obj, 0); @@ -1955,13 +1955,13 @@ zip_ary(VALUE val, NODE *memo, int argc, VALUE *argv) tmp = rb_ary_new2(RARRAY_LEN(args) + 1); rb_ary_store(tmp, 0, rb_enum_values_pack(argc, argv)); for (i=0; i<RARRAY_LEN(args); i++) { - VALUE e = RARRAY_PTR(args)[i]; + VALUE e = RARRAY_AREF(args, i); if (RARRAY_LEN(e) <= n) { rb_ary_push(tmp, Qnil); } else { - rb_ary_push(tmp, RARRAY_PTR(e)[n]); + rb_ary_push(tmp, RARRAY_AREF(e, n)); } } if (NIL_P(result)) { @@ -1996,16 +1996,16 @@ zip_i(VALUE val, NODE *memo, int argc, VALUE *argv) tmp = rb_ary_new2(RARRAY_LEN(args) + 1); rb_ary_store(tmp, 0, rb_enum_values_pack(argc, argv)); for (i=0; i<RARRAY_LEN(args); i++) { - if (NIL_P(RARRAY_PTR(args)[i])) { + if (NIL_P(RARRAY_AREF(args, i))) { rb_ary_push(tmp, Qnil); } else { VALUE v[2]; - v[1] = RARRAY_PTR(args)[i]; + v[1] = RARRAY_AREF(args, i); rb_rescue2(call_next, (VALUE)v, call_stop, (VALUE)v, rb_eStopIteration, (VALUE)0); if (v[0] == Qundef) { - RARRAY_PTR(args)[i] = Qnil; + RARRAY_ASET(args, i, Qnil); v[0] = Qnil; } rb_ary_push(tmp, v[0]); @@ -2262,7 +2262,7 @@ enum_cycle_size(VALUE self, VALUE args) if (size == Qnil) return Qnil; if (args && (RARRAY_LEN(args) > 0)) { - n = RARRAY_PTR(args)[0]; + n = RARRAY_AREF(args, 0); } if (n == Qnil) return DBL2NUM(INFINITY); mul = NUM2LONG(n); @@ -2315,7 +2315,7 @@ enum_cycle(int argc, VALUE *argv, VALUE obj) if (len == 0) return Qnil; while (n < 0 || 0 < --n) { for (i=0; i<len; i++) { - rb_yield(RARRAY_PTR(ary)[i]); + rb_yield(RARRAY_AREF(ary, i)); } } return Qnil; diff --git a/enumerator.c b/enumerator.c index 44c574728b..340aa75318 100644 --- a/enumerator.c +++ b/enumerator.c @@ -696,7 +696,7 @@ ary2sv(VALUE args, int dup) return Qnil; case 1: - return RARRAY_PTR(args)[0]; + return RARRAY_AREF(args, 0); default: if (dup) @@ -1474,7 +1474,7 @@ lazy_flat_map_to_ary(VALUE obj, VALUE yielder) else { long i; for (i = 0; i < RARRAY_LEN(ary); i++) { - rb_funcall(yielder, id_yield, 1, RARRAY_PTR(ary)[i]); + rb_funcall(yielder, id_yield, 1, RARRAY_AREF(ary, i)); } } return Qnil; @@ -1487,7 +1487,7 @@ lazy_flat_map_func(VALUE val, VALUE m, int argc, VALUE *argv) if (RB_TYPE_P(result, T_ARRAY)) { long i; for (i = 0; i < RARRAY_LEN(result); i++) { - rb_funcall(argv[0], id_yield, 1, RARRAY_PTR(result)[i]); + rb_funcall(argv[0], id_yield, 1, RARRAY_AREF(result, i)); } } else { @@ -1641,7 +1641,7 @@ lazy_zip_arrays_func(VALUE val, VALUE arrays, int argc, VALUE *argv) ary = rb_ary_new2(RARRAY_LEN(arrays) + 1); rb_ary_push(ary, argv[1]); for (i = 0; i < RARRAY_LEN(arrays); i++) { - rb_ary_push(ary, rb_ary_entry(RARRAY_PTR(arrays)[i], count)); + rb_ary_push(ary, rb_ary_entry(RARRAY_AREF(arrays, i), count)); } rb_funcall(yielder, id_yield, 1, ary); rb_ivar_set(yielder, id_memo, LONG2NUM(++count)); @@ -1659,7 +1659,7 @@ lazy_zip_func(VALUE val, VALUE zip_args, int argc, VALUE *argv) if (NIL_P(arg)) { arg = rb_ary_new2(RARRAY_LEN(zip_args)); for (i = 0; i < RARRAY_LEN(zip_args); i++) { - rb_ary_push(arg, rb_funcall(RARRAY_PTR(zip_args)[i], id_to_enum, 0)); + rb_ary_push(arg, rb_funcall(RARRAY_AREF(zip_args, i), id_to_enum, 0)); } rb_ivar_set(yielder, id_memo, arg); } @@ -1667,7 +1667,7 @@ lazy_zip_func(VALUE val, VALUE zip_args, int argc, VALUE *argv) ary = rb_ary_new2(RARRAY_LEN(arg) + 1); rb_ary_push(ary, argv[1]); for (i = 0; i < RARRAY_LEN(arg); i++) { - v = rb_rescue2(call_next, RARRAY_PTR(arg)[i], next_stopped, 0, + v = rb_rescue2(call_next, RARRAY_AREF(arg, i), next_stopped, 0, rb_eStopIteration, (VALUE)0); rb_ary_push(ary, v); } @@ -1731,7 +1731,7 @@ static VALUE lazy_take_size(VALUE generator, VALUE args, VALUE lazy) { VALUE receiver = lazy_size(lazy); - long len = NUM2LONG(RARRAY_PTR(rb_ivar_get(lazy, id_arguments))[0]); + long len = NUM2LONG(RARRAY_AREF(rb_ivar_get(lazy, id_arguments), 0)); if (NIL_P(receiver) || (FIXNUM_P(receiver) && FIX2LONG(receiver) < len)) return receiver; return LONG2NUM(len); @@ -1780,7 +1780,7 @@ lazy_take_while(VALUE obj) static VALUE lazy_drop_size(VALUE generator, VALUE args, VALUE lazy) { - long len = NUM2LONG(RARRAY_PTR(rb_ivar_get(lazy, id_arguments))[0]); + long len = NUM2LONG(RARRAY_AREF(rb_ivar_get(lazy, id_arguments), 0)); VALUE receiver = lazy_size(lazy); if (NIL_P(receiver)) return receiver; @@ -723,7 +723,7 @@ rb_check_backtrace(VALUE bt) rb_raise(rb_eTypeError, err); } for (i=0;i<RARRAY_LEN(bt);i++) { - if (!RB_TYPE_P(RARRAY_PTR(bt)[i], T_STRING)) { + if (!RB_TYPE_P(RARRAY_AREF(bt, i), T_STRING)) { rb_raise(rb_eTypeError, err); } } diff --git a/eval_error.c b/eval_error.c index c7ccf82a0a..3ad2915ccc 100644 --- a/eval_error.c +++ b/eval_error.c @@ -112,7 +112,7 @@ error_print(void) error_pos(); } else { - VALUE mesg = RARRAY_PTR(errat)[0]; + VALUE mesg = RARRAY_AREF(errat, 0); if (NIL_P(mesg)) error_pos(); @@ -252,7 +252,7 @@ apply2files(void (*func)(const char *, VALUE, void *), VALUE vargs, void *arg) rb_secure(4); for (i=0; i<RARRAY_LEN(vargs); i++) { const char *s; - path = rb_get_path(RARRAY_PTR(vargs)[i]); + path = rb_get_path(RARRAY_AREF(vargs, i)); path = rb_str_encode_ospath(path); s = RSTRING_PTR(path); (*func)(s, path, arg); @@ -3999,7 +3999,7 @@ rb_file_join(VALUE ary, VALUE sep) len = 1; for (i=0; i<RARRAY_LEN(ary); i++) { - tmp = RARRAY_PTR(ary)[i]; + tmp = RARRAY_AREF(ary, i); if (RB_TYPE_P(tmp, T_STRING)) { check_path_encoding(tmp); len += RSTRING_LEN(tmp); @@ -4016,7 +4016,7 @@ rb_file_join(VALUE ary, VALUE sep) RBASIC(result)->klass = 0; OBJ_INFECT(result, ary); for (i=0; i<RARRAY_LEN(ary); i++) { - tmp = RARRAY_PTR(ary)[i]; + tmp = RARRAY_AREF(ary, i); switch (TYPE(tmp)) { case T_STRING: if (!checked) check_path_encoding(tmp); @@ -5367,7 +5367,7 @@ rb_find_file_ext_safe(VALUE *filep, const char *const *ext, int safe_level) for (j=0; ext[j]; j++) { rb_str_cat2(fname, ext[j]); for (i = 0; i < RARRAY_LEN(load_path); i++) { - VALUE str = RARRAY_PTR(load_path)[i]; + VALUE str = RARRAY_AREF(load_path, i); RB_GC_GUARD(str) = rb_get_path_check(str, safe_level); if (RSTRING_LEN(str) == 0) continue; @@ -5428,7 +5428,7 @@ rb_find_file_safe(VALUE path, int safe_level) tmp = rb_str_tmp_new(MAXPATHLEN + 2); rb_enc_associate_index(tmp, rb_usascii_encindex()); for (i = 0; i < RARRAY_LEN(load_path); i++) { - VALUE str = RARRAY_PTR(load_path)[i]; + VALUE str = RARRAY_AREF(load_path, i); RB_GC_GUARD(str) = rb_get_path_check(str, safe_level); if (RSTRING_LEN(str) > 0) { rb_file_expand_path_internal(path, str, 0, 0, tmp); @@ -1387,9 +1387,9 @@ run_finalizer(rb_objspace_t *objspace, VALUE obj, VALUE table) args[2] = (VALUE)rb_safe_level(); for (i=0; i<RARRAY_LEN(table); i++) { - VALUE final = RARRAY_PTR(table)[i]; - args[0] = RARRAY_PTR(final)[1]; - args[2] = FIX2INT(RARRAY_PTR(final)[0]); + VALUE final = RARRAY_AREF(table, i); + args[0] = RARRAY_AREF(final, 1); + args[2] = FIX2INT(RARRAY_AREF(final, 0)); status = 0; rb_protect(run_single_final, (VALUE)args, &status); if (status) @@ -3834,7 +3834,7 @@ wmap_finalize(VALUE self, VALUE objid) if (st_delete(w->obj2wmap, &orig, &data)) { rids = (VALUE)data; for (i = 0; i < RARRAY_LEN(rids); ++i) { - wmap = (st_data_t)RARRAY_PTR(rids)[i]; + wmap = (st_data_t)RARRAY_AREF(rids, i); st_delete(w->wmap2obj, &wmap, NULL); } } @@ -411,7 +411,7 @@ rb_hash_s_create(int argc, VALUE *argv, VALUE klass) hash = hash_alloc(klass); for (i = 0; i < RARRAY_LEN(tmp); ++i) { - VALUE e = RARRAY_PTR(tmp)[i]; + VALUE e = RARRAY_AREF(tmp, i); VALUE v = rb_check_array_type(e); VALUE key, val = Qnil; @@ -433,9 +433,9 @@ rb_hash_s_create(int argc, VALUE *argv, VALUE klass) rb_raise(rb_eArgError, "invalid number of elements (%ld for 1..2)", RARRAY_LEN(v)); case 2: - val = RARRAY_PTR(v)[1]; + val = RARRAY_AREF(v, 1); case 1: - key = RARRAY_PTR(v)[0]; + key = RARRAY_AREF(v, 0); rb_hash_aset(hash, key, val); } } @@ -2597,7 +2597,7 @@ env_each_key(VALUE ehash) RETURN_SIZED_ENUMERATOR(ehash, 0, 0, rb_env_size); keys = env_keys(); /* rb_secure(4); */ for (i=0; i<RARRAY_LEN(keys); i++) { - rb_yield(RARRAY_PTR(keys)[i]); + rb_yield(RARRAY_AREF(keys, i)); } return ehash; } @@ -2646,7 +2646,7 @@ env_each_value(VALUE ehash) RETURN_SIZED_ENUMERATOR(ehash, 0, 0, rb_env_size); values = env_values(); /* rb_secure(4); */ for (i=0; i<RARRAY_LEN(values); i++) { - rb_yield(RARRAY_PTR(values)[i]); + rb_yield(RARRAY_AREF(values, i)); } return ehash; } @@ -2685,7 +2685,7 @@ env_each_pair(VALUE ehash) FREE_ENVIRON(environ); for (i=0; i<RARRAY_LEN(ary); i+=2) { - rb_yield(rb_assoc_new(RARRAY_PTR(ary)[i], RARRAY_PTR(ary)[i+1])); + rb_yield(rb_assoc_new(RARRAY_AREF(ary, i), RARRAY_AREF(ary, i+1))); } return ehash; } @@ -2710,11 +2710,11 @@ env_reject_bang(VALUE ehash) keys = env_keys(); /* rb_secure(4); */ RBASIC(keys)->klass = 0; for (i=0; i<RARRAY_LEN(keys); i++) { - VALUE val = rb_f_getenv(Qnil, RARRAY_PTR(keys)[i]); + VALUE val = rb_f_getenv(Qnil, RARRAY_AREF(keys, i)); if (!NIL_P(val)) { - if (RTEST(rb_yield_values(2, RARRAY_PTR(keys)[i], val))) { - FL_UNSET(RARRAY_PTR(keys)[i], FL_TAINT); - env_delete(Qnil, RARRAY_PTR(keys)[i]); + if (RTEST(rb_yield_values(2, RARRAY_AREF(keys, i), val))) { + FL_UNSET(RARRAY_AREF(keys, i), FL_TAINT); + env_delete(Qnil, RARRAY_AREF(keys, i)); del++; } } @@ -2814,11 +2814,11 @@ env_select_bang(VALUE ehash) keys = env_keys(); /* rb_secure(4); */ RBASIC(keys)->klass = 0; for (i=0; i<RARRAY_LEN(keys); i++) { - VALUE val = rb_f_getenv(Qnil, RARRAY_PTR(keys)[i]); + VALUE val = rb_f_getenv(Qnil, RARRAY_AREF(keys, i)); if (!NIL_P(val)) { - if (!RTEST(rb_yield_values(2, RARRAY_PTR(keys)[i], val))) { - FL_UNSET(RARRAY_PTR(keys)[i], FL_TAINT); - env_delete(Qnil, RARRAY_PTR(keys)[i]); + if (!RTEST(rb_yield_values(2, RARRAY_AREF(keys, i), val))) { + FL_UNSET(RARRAY_AREF(keys, i), FL_TAINT); + env_delete(Qnil, RARRAY_AREF(keys, i)); del++; } } @@ -2858,9 +2858,9 @@ rb_env_clear(void) keys = env_keys(); /* rb_secure(4); */ for (i=0; i<RARRAY_LEN(keys); i++) { - VALUE val = rb_f_getenv(Qnil, RARRAY_PTR(keys)[i]); + VALUE val = rb_f_getenv(Qnil, RARRAY_AREF(keys, i)); if (!NIL_P(val)) { - env_delete(Qnil, RARRAY_PTR(keys)[i]); + env_delete(Qnil, RARRAY_AREF(keys, i)); } } return envtbl; @@ -3263,7 +3263,7 @@ env_replace(VALUE env, VALUE hash) rb_hash_foreach(hash, env_replace_i, keys); for (i=0; i<RARRAY_LEN(keys); i++) { - env_delete(env, RARRAY_PTR(keys)[i]); + env_delete(env, RARRAY_AREF(keys, i)); } return env; } @@ -818,7 +818,7 @@ checkmatch if (flag & VM_CHECKMATCH_ARRAY) { int i; for (i = 0; i < RARRAY_LEN(pattern); i++) { - if (RTEST(check_match(RARRAY_PTR(pattern)[i], target, checkmatch_type))) { + if (RTEST(check_match(RARRAY_AREF(pattern, i), target, checkmatch_type))) { result = Qtrue; break; } @@ -6846,7 +6846,7 @@ io_puts_ary(VALUE ary, VALUE out, int recur) ary = rb_check_array_type(ary); if (NIL_P(ary)) return Qfalse; for (i=0; i<RARRAY_LEN(ary); i++) { - tmp = RARRAY_PTR(ary)[i]; + tmp = RARRAY_AREF(ary, i); rb_io_puts(1, &tmp, out); } return Qtrue; @@ -8096,7 +8096,7 @@ select_internal(VALUE read, VALUE write, VALUE except, struct timeval *tp, rb_fd if (!NIL_P(read)) { Check_Type(read, T_ARRAY); for (i=0; i<RARRAY_LEN(read); i++) { - GetOpenFile(rb_io_get_io(RARRAY_PTR(read)[i]), fptr); + GetOpenFile(rb_io_get_io(RARRAY_AREF(read, i)), fptr); rb_fd_set(fptr->fd, &fds[0]); if (READ_DATA_PENDING(fptr) || READ_CHAR_PENDING(fptr)) { /* check for buffered data */ pending++; @@ -8116,7 +8116,7 @@ select_internal(VALUE read, VALUE write, VALUE except, struct timeval *tp, rb_fd if (!NIL_P(write)) { Check_Type(write, T_ARRAY); for (i=0; i<RARRAY_LEN(write); i++) { - VALUE write_io = GetWriteIO(rb_io_get_io(RARRAY_PTR(write)[i])); + VALUE write_io = GetWriteIO(rb_io_get_io(RARRAY_AREF(write, i))); GetOpenFile(write_io, fptr); rb_fd_set(fptr->fd, &fds[1]); if (max < fptr->fd) max = fptr->fd; @@ -8129,7 +8129,7 @@ select_internal(VALUE read, VALUE write, VALUE except, struct timeval *tp, rb_fd if (!NIL_P(except)) { Check_Type(except, T_ARRAY); for (i=0; i<RARRAY_LEN(except); i++) { - VALUE io = rb_io_get_io(RARRAY_PTR(except)[i]); + VALUE io = rb_io_get_io(RARRAY_AREF(except, i)); VALUE write_io = GetWriteIO(io); GetOpenFile(io, fptr); rb_fd_set(fptr->fd, &fds[2]); @@ -8160,7 +8160,7 @@ select_internal(VALUE read, VALUE write, VALUE except, struct timeval *tp, rb_fd rb_ary_push(res, ep?rb_ary_new():rb_ary_new2(0)); if (rp) { - list = RARRAY_PTR(res)[0]; + list = RARRAY_AREF(res, 0); for (i=0; i< RARRAY_LEN(read); i++) { VALUE obj = rb_ary_entry(read, i); VALUE io = rb_io_get_io(obj); @@ -8173,7 +8173,7 @@ select_internal(VALUE read, VALUE write, VALUE except, struct timeval *tp, rb_fd } if (wp) { - list = RARRAY_PTR(res)[1]; + list = RARRAY_AREF(res, 1); for (i=0; i< RARRAY_LEN(write); i++) { VALUE obj = rb_ary_entry(write, i); VALUE io = rb_io_get_io(obj); @@ -8186,7 +8186,7 @@ select_internal(VALUE read, VALUE write, VALUE except, struct timeval *tp, rb_fd } if (ep) { - list = RARRAY_PTR(res)[2]; + list = RARRAY_AREF(res, 2); for (i=0; i< RARRAY_LEN(except); i++) { VALUE obj = rb_ary_entry(except, i); VALUE io = rb_io_get_io(obj); @@ -1848,7 +1848,7 @@ iseq_data_to_ary(rb_iseq_t *iseq) ti = 0; for (i=0, pos=0; i<RARRAY_LEN(nbody); i++) { - VALUE ary = RARRAY_PTR(nbody)[i]; + VALUE ary = RARRAY_AREF(nbody, i); st_data_t label; if (st_lookup(labels_table, pos, &label)) { @@ -63,7 +63,7 @@ rb_construct_expanded_load_path(int type, int *has_relative, int *has_non_cache) VALUE path, as_str, expanded_path; int is_string, non_cache; char *as_cstr; - as_str = path = RARRAY_PTR(load_path)[i]; + as_str = path = RARRAY_AREF(load_path, i); is_string = RB_TYPE_P(path, T_STRING) ? 1 : 0; non_cache = !is_string ? 1 : 0; as_str = rb_get_path_check_to_string(path, level); @@ -76,7 +76,7 @@ rb_construct_expanded_load_path(int type, int *has_relative, int *has_non_cache) (!as_cstr[0] || as_cstr[0] != '~')) || (type == EXPAND_NON_CACHE)) { /* Use cached expanded path. */ - rb_ary_push(ary, RARRAY_PTR(expanded_load_path)[i]); + rb_ary_push(ary, RARRAY_AREF(expanded_load_path, i)); continue; } } @@ -337,7 +337,7 @@ loaded_feature_path(const char *name, long vlen, const char *feature, long len, (possibly empty) and prefix is some string of length plen. */ for (i = 0; i < RARRAY_LEN(load_path); ++i) { - VALUE p = RARRAY_PTR(load_path)[i]; + VALUE p = RARRAY_AREF(load_path, i); const char *s = StringValuePtr(p); long n = RSTRING_LEN(p); @@ -425,7 +425,7 @@ rb_feature_p(const char *feature, const char *ext, int rb, int expanded, const c long index; if (RB_TYPE_P(this_feature_index, T_ARRAY)) { if (i >= RARRAY_LEN(this_feature_index)) break; - entry = RARRAY_PTR(this_feature_index)[i]; + entry = RARRAY_AREF(this_feature_index, i); } else { if (i > 0) break; @@ -433,7 +433,7 @@ rb_feature_p(const char *feature, const char *ext, int rb, int expanded, const c } index = FIX2LONG(entry); - v = RARRAY_PTR(features)[index]; + v = RARRAY_AREF(features, index); f = StringValuePtr(v); if ((n = RSTRING_LEN(v)) < len) continue; if (strncmp(f, feature, len) != 0) { @@ -783,7 +783,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit) w_long(len, arg); for (i=0; i<RARRAY_LEN(obj); i++) { - w_object(RARRAY_PTR(obj)[i], arg, limit); + w_object(RARRAY_AREF(obj, i), arg, limit); if (len != RARRAY_LEN(obj)) { rb_raise(rb_eRuntimeError, "array modified during dump"); } @@ -820,7 +820,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit) w_long(len, arg); mem = rb_struct_members(obj); for (i=0; i<len; i++) { - w_symbol(SYM2ID(RARRAY_PTR(mem)[i]), arg); + w_symbol(SYM2ID(RARRAY_AREF(mem, i)), arg); w_object(RSTRUCT_PTR(obj)[i], arg, limit); } } @@ -1462,7 +1462,7 @@ append_extmod(VALUE obj, VALUE extmod) { long i = RARRAY_LEN(extmod); while (i > 0) { - VALUE m = RARRAY_PTR(extmod)[--i]; + VALUE m = RARRAY_AREF(extmod, --i); rb_extend_object(obj, m); } return obj; @@ -1756,11 +1756,11 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod) for (i=0; i<len; i++) { slot = r_symbol(arg); - if (RARRAY_PTR(mem)[i] != ID2SYM(slot)) { + if (RARRAY_AREF(mem, i) != ID2SYM(slot)) { rb_raise(rb_eTypeError, "struct %s not compatible (:%s for :%s)", rb_class2name(klass), rb_id2name(slot), - rb_id2name(SYM2ID(RARRAY_PTR(mem)[i]))); + rb_id2name(SYM2ID(RARRAY_AREF(mem, i)))); } rb_ary_push(values, r_object(arg)); arg->readable -= 2; @@ -260,8 +260,8 @@ do_coerce(VALUE *x, VALUE *y, int err) return FALSE; } - *x = RARRAY_PTR(ary)[0]; - *y = RARRAY_PTR(ary)[1]; + *x = RARRAY_AREF(ary, 0); + *y = RARRAY_AREF(ary, 1); return TRUE; } @@ -1846,8 +1846,8 @@ ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl) static VALUE num_step_size(VALUE from, VALUE args) { - VALUE to = RARRAY_PTR(args)[0]; - VALUE step = (RARRAY_LEN(args) > 1) ? RARRAY_PTR(args)[1] : INT2FIX(1); + VALUE to = RARRAY_AREF(args, 0); + VALUE step = (RARRAY_LEN(args) > 1) ? RARRAY_AREF(args, 1) : INT2FIX(1); return ruby_num_interval_step_size(from, to, step, FALSE); } /* @@ -3490,7 +3490,7 @@ fix_size(VALUE fix) static VALUE int_upto_size(VALUE from, VALUE args) { - return ruby_num_interval_step_size(from, RARRAY_PTR(args)[0], INT2FIX(1), FALSE); + return ruby_num_interval_step_size(from, RARRAY_AREF(args, 0), INT2FIX(1), FALSE); } /* @@ -3537,7 +3537,7 @@ int_upto(VALUE from, VALUE to) static VALUE int_downto_size(VALUE from, VALUE args) { - return ruby_num_interval_step_size(from, RARRAY_PTR(args)[0], INT2FIX(-1), FALSE); + return ruby_num_interval_step_size(from, RARRAY_AREF(args, 0), INT2FIX(-1), FALSE); } /* @@ -421,8 +421,8 @@ pack_pack(VALUE ary, VALUE fmt) idx = 0; #define TOO_FEW (rb_raise(rb_eArgError, toofew), 0) -#define THISFROM (items > 0 ? RARRAY_PTR(ary)[idx] : TOO_FEW) -#define NEXTFROM (items-- > 0 ? RARRAY_PTR(ary)[idx++] : TOO_FEW) +#define THISFROM (items > 0 ? RARRAY_AREF(ary, idx) : TOO_FEW) +#define NEXTFROM (items-- > 0 ? RARRAY_AREF(ary, idx++) : TOO_FEW) while (p < pend) { int explicit_endian = 0; @@ -1020,9 +1020,9 @@ pack_pack(VALUE ary, VALUE fmt) VALUE big128 = rb_uint2big(128); while (RB_TYPE_P(from, T_BIGNUM)) { from = rb_big_divmod(from, big128); - c = castchar(NUM2INT(RARRAY_PTR(from)[1]) | 0x80); /* mod */ + c = castchar(NUM2INT(RARRAY_AREF(from, 1)) | 0x80); /* mod */ rb_str_buf_cat(buf, &c, sizeof(char)); - from = RARRAY_PTR(from)[0]; /* div */ + from = RARRAY_AREF(from, 0); /* div */ } } @@ -5299,7 +5299,7 @@ coverage(const char *f, int n) VALUE lines = rb_ary_new2(n); int i; RBASIC(lines)->klass = 0; - for (i = 0; i < n; i++) RARRAY_PTR(lines)[i] = Qnil; + for (i = 0; i < n; i++) RARRAY_ASET(lines, i, Qnil); RARRAY(lines)->as.heap.len = n; rb_hash_aset(coverages, fname, lines); return lines; @@ -2208,9 +2208,9 @@ static VALUE curry(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc) { VALUE proc, passed, arity; - proc = RARRAY_PTR(args)[0]; - passed = RARRAY_PTR(args)[1]; - arity = RARRAY_PTR(args)[2]; + proc = RARRAY_AREF(args, 0); + passed = RARRAY_AREF(args, 1); + arity = RARRAY_AREF(args, 2); passed = rb_ary_plus(passed, rb_ary_new4(argc, argv)); rb_ary_freeze(passed); @@ -1493,7 +1493,7 @@ check_exec_redirect1(VALUE ary, VALUE key, VALUE param) else { int i, n=0; for (i = 0 ; i < RARRAY_LEN(key); i++) { - VALUE v = RARRAY_PTR(key)[i]; + VALUE v = RARRAY_AREF(key, i); VALUE fd = check_exec_redirect_fd(v, !NIL_P(param)); rb_ary_push(ary, hide_obj(rb_assoc_new(fd, param))); n++; @@ -1808,21 +1808,21 @@ check_exec_fds_1(struct rb_execarg *eargp, VALUE h, int maxhint, VALUE ary) if (ary != Qfalse) { for (i = 0; i < RARRAY_LEN(ary); i++) { - VALUE elt = RARRAY_PTR(ary)[i]; - int fd = FIX2INT(RARRAY_PTR(elt)[0]); + VALUE elt = RARRAY_AREF(ary, i); + int fd = FIX2INT(RARRAY_AREF(elt, 0)); if (RTEST(rb_hash_lookup(h, INT2FIX(fd)))) { rb_raise(rb_eArgError, "fd %d specified twice", fd); } if (ary == eargp->fd_open || ary == eargp->fd_dup2) rb_hash_aset(h, INT2FIX(fd), Qtrue); else if (ary == eargp->fd_dup2_child) - rb_hash_aset(h, INT2FIX(fd), RARRAY_PTR(elt)[1]); + rb_hash_aset(h, INT2FIX(fd), RARRAY_AREF(elt, 1)); else /* ary == eargp->fd_close */ rb_hash_aset(h, INT2FIX(fd), INT2FIX(-1)); if (maxhint < fd) maxhint = fd; if (ary == eargp->fd_dup2 || ary == eargp->fd_dup2_child) { - fd = FIX2INT(RARRAY_PTR(elt)[1]); + fd = FIX2INT(RARRAY_AREF(elt, 1)); if (maxhint < fd) maxhint = fd; } @@ -1847,9 +1847,9 @@ check_exec_fds(struct rb_execarg *eargp) if (eargp->fd_dup2_child) { ary = eargp->fd_dup2_child; for (i = 0; i < RARRAY_LEN(ary); i++) { - VALUE elt = RARRAY_PTR(ary)[i]; - int newfd = FIX2INT(RARRAY_PTR(elt)[0]); - int oldfd = FIX2INT(RARRAY_PTR(elt)[1]); + VALUE elt = RARRAY_AREF(ary, i); + int newfd = FIX2INT(RARRAY_AREF(elt, 0)); + int oldfd = FIX2INT(RARRAY_AREF(elt, 1)); int lastfd = oldfd; VALUE val = rb_hash_lookup(h, INT2FIX(lastfd)); long depth = 0; @@ -1945,8 +1945,8 @@ rb_check_argv(int argc, VALUE *argv) if (RARRAY_LEN(tmp) != 2) { rb_raise(rb_eArgError, "wrong first argument"); } - prog = RARRAY_PTR(tmp)[0]; - argv[0] = RARRAY_PTR(tmp)[1]; + prog = RARRAY_AREF(tmp, 0); + argv[0] = RARRAY_AREF(tmp, 1); SafeStringValue(prog); StringValueCStr(prog); prog = rb_str_new_frozen(prog); @@ -2279,9 +2279,9 @@ rb_execarg_fixup(VALUE execarg_obj) st_table *stenv = RHASH_TBL(envtbl); long i; for (i = 0; i < RARRAY_LEN(envopts); i++) { - VALUE pair = RARRAY_PTR(envopts)[i]; - VALUE key = RARRAY_PTR(pair)[0]; - VALUE val = RARRAY_PTR(pair)[1]; + VALUE pair = RARRAY_AREF(envopts, i); + VALUE key = RARRAY_AREF(pair, 0); + VALUE val = RARRAY_AREF(pair, 1); if (NIL_P(val)) { st_data_t stkey = (st_data_t)key; st_delete(stenv, &stkey, NULL); @@ -2560,9 +2560,9 @@ run_exec_dup2(VALUE ary, VALUE tmpbuf, struct rb_execarg *sargp, char *errmsg, s /* initialize oldfd and newfd: O(n) */ for (i = 0; i < n; i++) { - VALUE elt = RARRAY_PTR(ary)[i]; - pairs[i].oldfd = FIX2INT(RARRAY_PTR(elt)[1]); - pairs[i].newfd = FIX2INT(RARRAY_PTR(elt)[0]); /* unique */ + VALUE elt = RARRAY_AREF(ary, i); + pairs[i].oldfd = FIX2INT(RARRAY_AREF(elt, 1)); + pairs[i].newfd = FIX2INT(RARRAY_AREF(elt, 0)); /* unique */ pairs[i].older_index = -1; } @@ -2686,8 +2686,8 @@ run_exec_close(VALUE ary, char *errmsg, size_t errmsg_buflen) int ret; for (i = 0; i < RARRAY_LEN(ary); i++) { - VALUE elt = RARRAY_PTR(ary)[i]; - int fd = FIX2INT(RARRAY_PTR(elt)[0]); + VALUE elt = RARRAY_AREF(ary, i); + int fd = FIX2INT(RARRAY_AREF(elt, 0)); ret = redirect_close(fd); /* async-signal-safe */ if (ret == -1) { ERRMSG("close"); @@ -2705,12 +2705,12 @@ run_exec_open(VALUE ary, struct rb_execarg *sargp, char *errmsg, size_t errmsg_b int ret; for (i = 0; i < RARRAY_LEN(ary);) { - VALUE elt = RARRAY_PTR(ary)[i]; - int fd = FIX2INT(RARRAY_PTR(elt)[0]); - VALUE param = RARRAY_PTR(elt)[1]; - char *path = RSTRING_PTR(RARRAY_PTR(param)[0]); - int flags = NUM2INT(RARRAY_PTR(param)[1]); - int perm = NUM2INT(RARRAY_PTR(param)[2]); + VALUE elt = RARRAY_AREF(ary, i); + int fd = FIX2INT(RARRAY_AREF(elt, 0)); + VALUE param = RARRAY_AREF(elt, 1); + char *path = RSTRING_PTR(RARRAY_AREF(param, 0)); + int flags = NUM2INT(RARRAY_AREF(param, 1)); + int perm = NUM2INT(RARRAY_AREF(param, 2)); int need_close = 1; int fd2 = redirect_open(path, flags, perm); /* async-signal-safe */ if (fd2 == -1) { @@ -2719,8 +2719,8 @@ run_exec_open(VALUE ary, struct rb_execarg *sargp, char *errmsg, size_t errmsg_b } rb_update_max_fd(fd2); while (i < RARRAY_LEN(ary) && - (elt = RARRAY_PTR(ary)[i], RARRAY_PTR(elt)[1] == param)) { - fd = FIX2INT(RARRAY_PTR(elt)[0]); + (elt = RARRAY_AREF(ary, i), RARRAY_AREF(elt, 1) == param)) { + fd = FIX2INT(RARRAY_AREF(elt, 0)); if (fd == fd2) { need_close = 0; } @@ -2755,9 +2755,9 @@ run_exec_dup2_child(VALUE ary, struct rb_execarg *sargp, char *errmsg, size_t er int ret; for (i = 0; i < RARRAY_LEN(ary); i++) { - VALUE elt = RARRAY_PTR(ary)[i]; - int newfd = FIX2INT(RARRAY_PTR(elt)[0]); - int oldfd = FIX2INT(RARRAY_PTR(elt)[1]); + VALUE elt = RARRAY_AREF(ary, i); + int newfd = FIX2INT(RARRAY_AREF(elt, 0)); + int oldfd = FIX2INT(RARRAY_AREF(elt, 1)); if (save_redirect_fd(newfd, sargp, errmsg, errmsg_buflen) < 0) /* async-signal-safe */ return -1; @@ -2811,8 +2811,8 @@ run_exec_rlimit(VALUE ary, struct rb_execarg *sargp, char *errmsg, size_t errmsg { long i; for (i = 0; i < RARRAY_LEN(ary); i++) { - VALUE elt = RARRAY_PTR(ary)[i]; - int rtype = NUM2INT(RARRAY_PTR(elt)[0]); + VALUE elt = RARRAY_AREF(ary, i); + int rtype = NUM2INT(RARRAY_AREF(elt, 0)); struct rlimit rlim; if (sargp) { VALUE tmp, newary; @@ -2820,7 +2820,7 @@ run_exec_rlimit(VALUE ary, struct rb_execarg *sargp, char *errmsg, size_t errmsg ERRMSG("getrlimit"); return -1; } - tmp = hide_obj(rb_ary_new3(3, RARRAY_PTR(elt)[0], + tmp = hide_obj(rb_ary_new3(3, RARRAY_AREF(elt, 0), RLIM2NUM(rlim.rlim_cur), RLIM2NUM(rlim.rlim_max))); if (sargp->rlimit_limits == Qfalse) @@ -2829,8 +2829,8 @@ run_exec_rlimit(VALUE ary, struct rb_execarg *sargp, char *errmsg, size_t errmsg newary = sargp->rlimit_limits; rb_ary_push(newary, tmp); } - rlim.rlim_cur = NUM2RLIM(RARRAY_PTR(elt)[1]); - rlim.rlim_max = NUM2RLIM(RARRAY_PTR(elt)[2]); + rlim.rlim_cur = NUM2RLIM(RARRAY_AREF(elt, 1)); + rlim.rlim_max = NUM2RLIM(RARRAY_AREF(elt, 2)); if (setrlimit(rtype, &rlim) == -1) { /* hopefully async-signal-safe */ ERRMSG("setrlimit"); return -1; @@ -2905,9 +2905,9 @@ rb_execarg_run_options(const struct rb_execarg *eargp, struct rb_execarg *sargp, long i; save_env(sargp); for (i = 0; i < RARRAY_LEN(obj); i++) { - VALUE pair = RARRAY_PTR(obj)[i]; - VALUE key = RARRAY_PTR(pair)[0]; - VALUE val = RARRAY_PTR(pair)[1]; + VALUE pair = RARRAY_AREF(obj, i); + VALUE key = RARRAY_AREF(pair, 0); + VALUE val = RARRAY_AREF(pair, 1); if (NIL_P(val)) ruby_setenv(StringValueCStr(key), 0); else @@ -5527,7 +5527,7 @@ proc_setgroups(VALUE obj, VALUE ary) groups = ALLOCA_N(rb_gid_t, ngroups); for (i = 0; i < ngroups; i++) { - VALUE g = RARRAY_PTR(ary)[i]; + VALUE g = RARRAY_AREF(ary, i); groups[i] = OBJ2GID(g); } @@ -327,7 +327,7 @@ range_step_size(VALUE range, VALUE args) VALUE b = RANGE_BEG(range), e = RANGE_END(range); VALUE step = INT2FIX(1); if (args) { - step = RARRAY_PTR(args)[0]; + step = RARRAY_AREF(args, 0); if (!rb_obj_is_kind_of(step, rb_cNumeric)) { step = rb_to_int(step); } diff --git a/rational.c b/rational.c index 7b3e851e7e..bbf1cafcb1 100644 --- a/rational.c +++ b/rational.c @@ -1666,11 +1666,11 @@ nurat_marshal_load(VALUE self, VALUE a) Check_Type(a, T_ARRAY); if (RARRAY_LEN(a) != 2) rb_raise(rb_eArgError, "marshaled rational must have an array whose length is 2 but %ld", RARRAY_LEN(a)); - if (f_zero_p(RARRAY_PTR(a)[1])) + if (f_zero_p(RARRAY_AREF(a, 1))) rb_raise_zerodiv(); - rb_ivar_set(self, id_i_num, RARRAY_PTR(a)[0]); - rb_ivar_set(self, id_i_den, RARRAY_PTR(a)[1]); + rb_ivar_set(self, id_i_num, RARRAY_AREF(a, 0)); + rb_ivar_set(self, id_i_den, RARRAY_AREF(a, 1)); return self; } @@ -2342,7 +2342,7 @@ rb_reg_preprocess_dregexp(VALUE ary, int options) } for (i = 0; i < RARRAY_LEN(ary); i++) { - VALUE str = RARRAY_PTR(ary)[i]; + VALUE str = RARRAY_AREF(ary, i); VALUE buf; char *p, *end; rb_encoding *src_enc; @@ -1442,8 +1442,8 @@ process_options(int argc, char **argv, struct cmdline_options *opt) long i; VALUE load_path = GET_VM()->load_path; for (i = 0; i < RARRAY_LEN(load_path); ++i) { - RARRAY_PTR(load_path)[i] = - rb_enc_associate(rb_str_dup(RARRAY_PTR(load_path)[i]), lenc); + RARRAY_ASET(load_path, i, + rb_enc_associate(rb_str_dup(RARRAY_AREF(load_path, i)), lenc)); } } if (!(opt->disable & DISABLE_BIT(gems))) { @@ -6115,7 +6115,7 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str) if (NIL_P(limit) && lim == 0) { long len; while ((len = RARRAY_LEN(result)) > 0 && - (tmp = RARRAY_PTR(result)[len-1], RSTRING_LEN(tmp) == 0)) + (tmp = RARRAY_AREF(result, len-1), RSTRING_LEN(tmp) == 0)) rb_ary_pop(result); } @@ -354,7 +354,7 @@ rb_struct_s_def(int argc, VALUE *argv, VALUE klass) rest = rb_ary_tmp_new(argc); for (i=0; i<argc; i++) { id = rb_to_id(argv[i]); - RARRAY_PTR(rest)[i] = ID2SYM(id); + RARRAY_ASET(rest, i, ID2SYM(id)); rb_ary_set_len(rest, i+1); } if (NIL_P(name)) { @@ -708,8 +708,8 @@ thread_initialize(VALUE thread, VALUE args) if (!proc || !RTEST(loc = rb_proc_location(proc))) { rb_raise(rb_eThreadError, "already initialized thread"); } - file = RSTRING_PTR(RARRAY_PTR(loc)[0]); - if (NIL_P(line = RARRAY_PTR(loc)[1])) { + file = RSTRING_PTR(RARRAY_AREF(loc, 0)); + if (NIL_P(line = RARRAY_AREF(loc, 1))) { rb_raise(rb_eThreadError, "already initialized thread - %s", file); } @@ -1582,7 +1582,7 @@ rb_threadptr_pending_interrupt_include_p(rb_thread_t *th, VALUE err) { int i; for (i=0; i<RARRAY_LEN(th->pending_interrupt_queue); i++) { - VALUE e = RARRAY_PTR(th->pending_interrupt_queue)[i]; + VALUE e = RARRAY_AREF(th->pending_interrupt_queue, i); if (rb_class_inherited_p(e, err)) { return TRUE; } @@ -1597,7 +1597,7 @@ rb_threadptr_pending_interrupt_deque(rb_thread_t *th, enum handle_interrupt_timi int i; for (i=0; i<RARRAY_LEN(th->pending_interrupt_queue); i++) { - VALUE err = RARRAY_PTR(th->pending_interrupt_queue)[i]; + VALUE err = RARRAY_AREF(th->pending_interrupt_queue, i); enum handle_interrupt_timing mask_timing = rb_threadptr_pending_interrupt_check_mask(th, CLASS_OF(err)); @@ -3869,8 +3869,8 @@ clear_coverage_i(st_data_t key, st_data_t val, st_data_t dummy) VALUE lines = (VALUE)val; for (i = 0; i < RARRAY_LEN(lines); i++) { - if (RARRAY_PTR(lines)[i] != Qnil) { - RARRAY_PTR(lines)[i] = INT2FIX(0); + if (RARRAY_AREF(lines, i) != Qnil) { + RARRAY_ASET(lines, i, INT2FIX(0)); } } return ST_CONTINUE; @@ -5210,12 +5210,12 @@ update_coverage(rb_event_flag_t event, VALUE proc, VALUE self, ID id, VALUE klas if (coverage && RBASIC(coverage)->klass == 0) { long line = rb_sourceline() - 1; long count; - if (RARRAY_PTR(coverage)[line] == Qnil) { + if (RARRAY_AREF(coverage, line) == Qnil) { return; } - count = FIX2LONG(RARRAY_PTR(coverage)[line]) + 1; + count = FIX2LONG(RARRAY_AREF(coverage, line)) + 1; if (POSFIXABLE(count)) { - RARRAY_PTR(coverage)[line] = LONG2FIX(count); + RARRAY_ASET(coverage, line, LONG2FIX(count)); } } } diff --git a/transcode.c b/transcode.c index b03241fcfc..58a4265e0e 100644 --- a/transcode.c +++ b/transcode.c @@ -3057,10 +3057,10 @@ decorate_convpath(VALUE convpath, int ecflags) len = n = RARRAY_LENINT(convpath); if (n != 0) { - VALUE pair = RARRAY_PTR(convpath)[n-1]; + VALUE pair = RARRAY_AREF(convpath, n-1); if (RB_TYPE_P(pair, T_ARRAY)) { - const char *sname = rb_enc_name(rb_to_encoding(RARRAY_PTR(pair)[0])); - const char *dname = rb_enc_name(rb_to_encoding(RARRAY_PTR(pair)[1])); + const char *sname = rb_enc_name(rb_to_encoding(RARRAY_AREF(pair, 0))); + const char *dname = rb_enc_name(rb_to_encoding(RARRAY_AREF(pair, 1))); transcoder_entry_t *entry = get_transcoder_entry(sname, dname); const rb_transcoder *tr = load_transcoder_entry(entry); if (!tr) @@ -2129,7 +2129,7 @@ m_core_hash_from_ary(VALUE self, VALUE ary) assert(RARRAY_LEN(ary) % 2 == 0); for (i=0; i<RARRAY_LEN(ary); i+=2) { - rb_hash_aset(hash, RARRAY_PTR(ary)[i], RARRAY_PTR(ary)[i+1]); + rb_hash_aset(hash, RARRAY_AREF(ary, i), RARRAY_AREF(ary, i+1)); } return hash; @@ -2142,7 +2142,7 @@ m_core_hash_merge_ary(VALUE self, VALUE hash, VALUE ary) assert(RARRAY_LEN(ary) % 2 == 0); for (i=0; i<RARRAY_LEN(ary); i+=2) { - rb_hash_aset(hash, RARRAY_PTR(ary)[i], RARRAY_PTR(ary)[i+1]); + rb_hash_aset(hash, RARRAY_AREF(ary, i), RARRAY_AREF(ary, i+1)); } return hash; @@ -760,7 +760,7 @@ rb_vm_bugreport(void) fprintf(stderr, "\n"); fprintf(stderr, "* Loaded features:\n\n"); for (i=0; i<RARRAY_LEN(vm->loaded_features); i++) { - name = RARRAY_PTR(vm->loaded_features)[i]; + name = RARRAY_AREF(vm->loaded_features, i); if (RB_TYPE_P(name, T_STRING)) { fprintf(stderr, " %4d %.*s\n", i, LIMITED_NAME_LENGTH(name), RSTRING_PTR(name)); @@ -1256,15 +1256,15 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *cref, const char (bt2 = rb_vm_backtrace_str_ary(th, 0, 0), RARRAY_LEN(bt2) > 0)) { if (!NIL_P(mesg) && RB_TYPE_P(mesg, T_STRING) && !RSTRING_LEN(mesg)) { if (OBJ_FROZEN(mesg)) { - VALUE m = rb_str_cat(rb_str_dup(RARRAY_PTR(errat)[0]), ": ", 2); + VALUE m = rb_str_cat(rb_str_dup(RARRAY_AREF(errat, 0)), ": ", 2); rb_ivar_set(errinfo, id_mesg, rb_str_append(m, mesg)); } else { rb_str_update(mesg, 0, 0, rb_str_new2(": ")); - rb_str_update(mesg, 0, 0, RARRAY_PTR(errat)[0]); + rb_str_update(mesg, 0, 0, RARRAY_AREF(errat, 0)); } } - RARRAY_PTR(errat)[0] = RARRAY_PTR(bt2)[0]; + RARRAY_AREF(errat, 0) = RARRAY_AREF(bt2, 0); } } rb_exc_raise(errinfo); diff --git a/vm_method.c b/vm_method.c index 516b87cb3e..3882b98d4e 100644 --- a/vm_method.c +++ b/vm_method.c @@ -1574,8 +1574,8 @@ rb_obj_respond_to(VALUE obj, ID id, int priv) (FL_TEST(klass, FL_SINGLETON) ? '.' : '#'), QUOTE_ID(id)); if (!NIL_P(location)) { - VALUE path = RARRAY_PTR(location)[0]; - VALUE line = RARRAY_PTR(location)[1]; + VALUE path = RARRAY_AREF(location, 0); + VALUE line = RARRAY_AREF(location, 1); if (!NIL_P(path)) { rb_compile_warn(RSTRING_PTR(path), NUM2INT(line), "respond_to? is defined here"); |