mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ruby.h (struct RArray): embed small arrays.
(RARRAY_LEN): defined for accessing array members. (RARRAY_PTR): ditto. * array.c: use RARRAY_LEN and RARRAY_PTR. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8581164ea6
commit
2156870525
39 changed files with 804 additions and 684 deletions
|
@ -1,3 +1,11 @@
|
|||
Sat Sep 2 23:37:29 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* ruby.h (struct RArray): embed small arrays.
|
||||
(RARRAY_LEN): defined for accessing array members.
|
||||
(RARRAY_PTR): ditto.
|
||||
|
||||
* array.c: use RARRAY_LEN and RARRAY_PTR.
|
||||
|
||||
Sat Sep 2 13:23:01 2006 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* common.mk (ia64.o): use the compiler driver to assemble ia64.s
|
||||
|
|
2
dir.c
2
dir.c
|
@ -1630,7 +1630,7 @@ dir_s_glob(int argc, VALUE *argv, VALUE obj)
|
|||
}
|
||||
else {
|
||||
volatile VALUE v = ary;
|
||||
ary = dir_globs(RARRAY(ary)->len, RARRAY(ary)->ptr, flags);
|
||||
ary = dir_globs(RARRAY_LEN(ary), RARRAY_PTR(ary), flags);
|
||||
}
|
||||
|
||||
if (rb_block_given_p()) {
|
||||
|
|
16
enum.c
16
enum.c
|
@ -644,21 +644,21 @@ enum_sort_by(VALUE obj)
|
|||
RETURN_ENUMERATOR(obj, 0, 0);
|
||||
|
||||
if (TYPE(obj) == T_ARRAY) {
|
||||
ary = rb_ary_new2(RARRAY(obj)->len);
|
||||
ary = rb_ary_new2(RARRAY_LEN(obj));
|
||||
}
|
||||
else {
|
||||
ary = rb_ary_new();
|
||||
}
|
||||
RBASIC(ary)->klass = 0;
|
||||
rb_block_call(obj, id_each, 0, 0, sort_by_i, ary);
|
||||
if (RARRAY(ary)->len > 1) {
|
||||
ruby_qsort(RARRAY(ary)->ptr, RARRAY(ary)->len, sizeof(VALUE), sort_by_cmp, 0);
|
||||
if (RARRAY_LEN(ary) > 1) {
|
||||
ruby_qsort(RARRAY_PTR(ary), RARRAY_LEN(ary), sizeof(VALUE), sort_by_cmp, 0);
|
||||
}
|
||||
if (RBASIC(ary)->klass) {
|
||||
rb_raise(rb_eRuntimeError, "sort_by reentered");
|
||||
}
|
||||
for (i=0; i<RARRAY(ary)->len; i++) {
|
||||
RARRAY(ary)->ptr[i] = RNODE(RARRAY(ary)->ptr[i])->u2.value;
|
||||
for (i=0; i<RARRAY_LEN(ary); i++) {
|
||||
RARRAY_PTR(ary)[i] = RNODE(RARRAY_PTR(ary)[i])->u2.value;
|
||||
}
|
||||
RBASIC(ary)->klass = rb_cArray;
|
||||
return ary;
|
||||
|
@ -1131,10 +1131,10 @@ zip_i(VALUE val, VALUE *memo)
|
|||
VALUE tmp;
|
||||
int i;
|
||||
|
||||
tmp = rb_ary_new2(RARRAY(args)->len + 1);
|
||||
tmp = rb_ary_new2(RARRAY_LEN(args) + 1);
|
||||
rb_ary_store(tmp, 0, val);
|
||||
for (i=0; i<RARRAY(args)->len; i++) {
|
||||
rb_ary_push(tmp, rb_ary_entry(RARRAY(args)->ptr[i], idx));
|
||||
for (i=0; i<RARRAY_LEN(args); i++) {
|
||||
rb_ary_push(tmp, rb_ary_entry(RARRAY_PTR(args)[i], idx));
|
||||
}
|
||||
if (rb_block_given_p()) {
|
||||
rb_yield(tmp);
|
||||
|
|
16
enumerator.c
16
enumerator.c
|
@ -122,7 +122,7 @@ each_slice_i(VALUE val, VALUE *memo)
|
|||
|
||||
rb_ary_push(ary, val);
|
||||
|
||||
if (RARRAY(ary)->len == size) {
|
||||
if (RARRAY_LEN(ary) == size) {
|
||||
rb_yield(ary);
|
||||
memo[0] = rb_ary_new2(size);
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ enum_each_slice(VALUE obj, VALUE n)
|
|||
rb_block_call(obj, rb_intern("each"), 0, 0, each_slice_i, (VALUE)args);
|
||||
|
||||
ary = args[0];
|
||||
if (RARRAY(ary)->len > 0) rb_yield(ary);
|
||||
if (RARRAY_LEN(ary) > 0) rb_yield(ary);
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
@ -183,11 +183,11 @@ each_cons_i(VALUE val, VALUE *memo)
|
|||
VALUE ary = memo[0];
|
||||
long size = (long)memo[1];
|
||||
|
||||
if (RARRAY(ary)->len == size) {
|
||||
if (RARRAY_LEN(ary) == size) {
|
||||
rb_ary_shift(ary);
|
||||
}
|
||||
rb_ary_push(ary, val);
|
||||
if (RARRAY(ary)->len == size) {
|
||||
if (RARRAY_LEN(ary) == size) {
|
||||
rb_yield(rb_ary_dup(ary));
|
||||
}
|
||||
return Qnil;
|
||||
|
@ -321,8 +321,8 @@ enumerator_each(VALUE obj)
|
|||
if (!rb_block_given_p()) return obj;
|
||||
e = enumerator_ptr(obj);
|
||||
if (e->args) {
|
||||
argc = RARRAY(e->args)->len;
|
||||
argv = RARRAY(e->args)->ptr;
|
||||
argc = RARRAY_LEN(e->args);
|
||||
argv = RARRAY_PTR(e->args);
|
||||
}
|
||||
return rb_block_call(e->method, rb_intern("call"), argc, argv, e->iter, (VALUE)e);
|
||||
}
|
||||
|
@ -352,8 +352,8 @@ enumerator_with_index(VALUE obj)
|
|||
VALUE *argv = 0;
|
||||
|
||||
if (e->args) {
|
||||
argc = RARRAY(e->args)->len;
|
||||
argv = RARRAY(e->args)->ptr;
|
||||
argc = RARRAY_LEN(e->args);
|
||||
argv = RARRAY_PTR(e->args);
|
||||
}
|
||||
return rb_block_call(e->method, rb_intern("call"), argc, argv,
|
||||
enumerator_with_index_i, (VALUE)&memo);
|
||||
|
|
4
error.c
4
error.c
|
@ -443,8 +443,8 @@ check_backtrace(VALUE bt)
|
|||
if (t != T_ARRAY) {
|
||||
rb_raise(rb_eTypeError, err);
|
||||
}
|
||||
for (i=0;i<RARRAY(bt)->len;i++) {
|
||||
if (TYPE(RARRAY(bt)->ptr[i]) != T_STRING) {
|
||||
for (i=0;i<RARRAY_LEN(bt);i++) {
|
||||
if (TYPE(RARRAY_PTR(bt)[i]) != T_STRING) {
|
||||
rb_raise(rb_eTypeError, err);
|
||||
}
|
||||
}
|
||||
|
|
121
eval.c
121
eval.c
|
@ -1238,11 +1238,11 @@ error_print(void)
|
|||
else
|
||||
warn_printf("%d", ruby_sourceline);
|
||||
}
|
||||
else if (RARRAY(errat)->len == 0) {
|
||||
else if (RARRAY_LEN(errat) == 0) {
|
||||
error_pos();
|
||||
}
|
||||
else {
|
||||
VALUE mesg = RARRAY(errat)->ptr[0];
|
||||
VALUE mesg = RARRAY_PTR(errat)[0];
|
||||
|
||||
if (NIL_P(mesg)) error_pos();
|
||||
else {
|
||||
|
@ -1298,21 +1298,19 @@ error_print(void)
|
|||
|
||||
if (!NIL_P(errat)) {
|
||||
long i;
|
||||
struct RArray *ep = RARRAY(errat);
|
||||
|
||||
#define TRACE_MAX (TRACE_HEAD+TRACE_TAIL+5)
|
||||
#define TRACE_HEAD 8
|
||||
#define TRACE_TAIL 5
|
||||
|
||||
ep = RARRAY(errat);
|
||||
for (i=1; i<ep->len; i++) {
|
||||
if (TYPE(ep->ptr[i]) == T_STRING) {
|
||||
warn_printf("\tfrom %s\n", RSTRING_PTR(ep->ptr[i]));
|
||||
for (i=1; i<RARRAY_LEN(errat); i++) {
|
||||
if (TYPE(RARRAY_PTR(errat)[i]) == T_STRING) {
|
||||
warn_printf("\tfrom %s\n", RSTRING_PTR(RARRAY_PTR(errat)[i]));
|
||||
}
|
||||
if (i == TRACE_HEAD && ep->len > TRACE_MAX) {
|
||||
if (i == TRACE_HEAD && RARRAY_LEN(errat) > TRACE_MAX) {
|
||||
warn_printf("\t ... %ld levels...\n",
|
||||
ep->len - TRACE_HEAD - TRACE_TAIL);
|
||||
i = ep->len - TRACE_TAIL;
|
||||
RARRAY_LEN(errat) - TRACE_HEAD - TRACE_TAIL);
|
||||
i = RARRAY_LEN(errat) - TRACE_TAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1793,7 +1791,7 @@ rb_eval_cmd(VALUE cmd, VALUE arg, int level)
|
|||
ruby_safe_level = level;
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
val = rb_funcall2(cmd, rb_intern("yield"),
|
||||
RARRAY(arg)->len, RARRAY(arg)->ptr);
|
||||
RARRAY_LEN(arg), RARRAY_PTR(arg));
|
||||
}
|
||||
ruby_safe_level = safe;
|
||||
POP_TAG();
|
||||
|
@ -1889,7 +1887,7 @@ rb_mod_nesting(void)
|
|||
if (!NIL_P(cbase->nd_clss)) rb_ary_push(ary, cbase->nd_clss);
|
||||
cbase = cbase->nd_next;
|
||||
}
|
||||
if (ruby_wrapper && RARRAY(ary)->len == 0) {
|
||||
if (ruby_wrapper && RARRAY_LEN(ary) == 0) {
|
||||
rb_ary_push(ary, ruby_wrapper);
|
||||
}
|
||||
return ary;
|
||||
|
@ -2185,9 +2183,9 @@ copy_node_scope(NODE *node, NODE *rval)
|
|||
VALUE args = rb_eval(self,n);\
|
||||
if (TYPE(args) != T_ARRAY)\
|
||||
args = rb_ary_to_ary(args);\
|
||||
argc = RARRAY(args)->len;\
|
||||
argc = RARRAY_LEN(args);\
|
||||
argv = TMP_ALLOC(argc+extra);\
|
||||
MEMCPY(argv, RARRAY(args)->ptr, VALUE, argc);\
|
||||
MEMCPY(argv, RARRAY_PTR(args), VALUE, argc);\
|
||||
}\
|
||||
if (bpass) {\
|
||||
volatile VALUE save_block = rb_eval(self, bpass->nd_body); \
|
||||
|
@ -2201,11 +2199,11 @@ copy_node_scope(NODE *node, NODE *rval)
|
|||
argc = ruby_frame->argc;\
|
||||
if (argc && DMETHOD_P()) {\
|
||||
if (TYPE(RBASIC(ruby_scope)->klass) != T_ARRAY ||\
|
||||
RARRAY(RBASIC(ruby_scope)->klass)->len != argc) {\
|
||||
RARRAY_LEN(RBASIC(ruby_scope)->klass) != argc) {\
|
||||
rb_raise(rb_eRuntimeError, \
|
||||
"super: specify arguments explicitly");\
|
||||
}\
|
||||
argv = RARRAY(RBASIC(ruby_scope)->klass)->ptr;\
|
||||
argv = RARRAY_PTR(RBASIC(ruby_scope)->klass);\
|
||||
}\
|
||||
else {\
|
||||
argv = ruby_scope->local_vars + 2;\
|
||||
|
@ -2713,8 +2711,8 @@ when_check(NODE *tag, VALUE val, VALUE self)
|
|||
break;
|
||||
case NODE_SPLAT:
|
||||
elm = svalue_to_avalue(rb_eval(self, tag->nd_head));
|
||||
for (i=0; i<RARRAY(elm)->len; i++) {
|
||||
if (when_cond(val, RARRAY(elm)->ptr[i])) {
|
||||
for (i=0; i<RARRAY_LEN(elm); i++) {
|
||||
if (when_cond(val, RARRAY_PTR(elm)[i])) {
|
||||
return Qtrue;
|
||||
}
|
||||
}
|
||||
|
@ -3624,8 +3622,7 @@ rb_eval(VALUE self, NODE *n)
|
|||
i = node->nd_alen;
|
||||
ary = rb_ary_new2(i);
|
||||
for (i=0;node;node=node->nd_next) {
|
||||
RARRAY(ary)->ptr[i++] = rb_eval(self, node->nd_head);
|
||||
RARRAY(ary)->len = i;
|
||||
rb_ary_push(ary, rb_eval(self, node->nd_head));
|
||||
}
|
||||
|
||||
result = ary;
|
||||
|
@ -3640,8 +3637,7 @@ rb_eval(VALUE self, NODE *n)
|
|||
i = node->nd_alen;
|
||||
val = rb_ary_new2(i);
|
||||
for (i=0;node;node=node->nd_next) {
|
||||
RARRAY(val)->ptr[i++] = rb_eval(self, node->nd_head);
|
||||
RARRAY(val)->len = i;
|
||||
rb_ary_push(val, rb_eval(self, node->nd_head));
|
||||
}
|
||||
|
||||
result = val;
|
||||
|
@ -4746,16 +4742,16 @@ rb_yield_0(VALUE val, VALUE self, VALUE klass /* OK */, int flags)
|
|||
if (TYPE(val) != T_ARRAY) {
|
||||
rb_raise(rb_eArgError, "wrong number of arguments (1 for 0)");
|
||||
}
|
||||
else if (RARRAY(val)->len != 0) {
|
||||
else if (RARRAY_LEN(val) != 0) {
|
||||
rb_raise(rb_eArgError, "wrong number of arguments (%ld for 0)",
|
||||
RARRAY(val)->len);
|
||||
RARRAY_LEN(val));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (var == (NODE*)2) {
|
||||
if (TYPE(val) == T_ARRAY && RARRAY(val)->len != 0) {
|
||||
if (TYPE(val) == T_ARRAY && RARRAY_LEN(val) != 0) {
|
||||
rb_raise(rb_eArgError, "wrong number of arguments (%ld for 0)",
|
||||
RARRAY(val)->len);
|
||||
RARRAY_LEN(val));
|
||||
}
|
||||
}
|
||||
else if (!bvar && nd_type(var) == NODE_BLOCK_PASS) {
|
||||
|
@ -4765,7 +4761,7 @@ rb_yield_0(VALUE val, VALUE self, VALUE klass /* OK */, int flags)
|
|||
}
|
||||
else if (nd_type(var) == NODE_ARGS) {
|
||||
if (!ary_args) val = svalue_to_avalue(val);
|
||||
formal_assign(self, var, RARRAY(val)->len, RARRAY(val)->ptr, 0);
|
||||
formal_assign(self, var, RARRAY_LEN(val), RARRAY_PTR(val), 0);
|
||||
}
|
||||
else if (nd_type(var) == NODE_BLOCK) {
|
||||
if (var->nd_next) {
|
||||
|
@ -4782,16 +4778,16 @@ rb_yield_0(VALUE val, VALUE self, VALUE klass /* OK */, int flags)
|
|||
if (val == Qundef) {
|
||||
rb_raise(rb_eArgError, "wrong number of arguments (0 for 1)");
|
||||
}
|
||||
if (TYPE(val) == T_ARRAY && RARRAY(val)->len != 1) {
|
||||
if (TYPE(val) == T_ARRAY && RARRAY_LEN(val) != 1) {
|
||||
rb_raise(rb_eArgError, "wrong number of arguments (%ld for 1)",
|
||||
RARRAY(val)->len);
|
||||
RARRAY_LEN(val));
|
||||
}
|
||||
}
|
||||
if (ary_args) {
|
||||
if (RARRAY(val)->len == 0)
|
||||
if (RARRAY_LEN(val) == 0)
|
||||
val = Qnil;
|
||||
else
|
||||
val = RARRAY(val)->ptr[0];
|
||||
val = RARRAY_PTR(val)[0];
|
||||
}
|
||||
assign(self, var, val, lambda);
|
||||
}
|
||||
|
@ -4811,11 +4807,11 @@ rb_yield_0(VALUE val, VALUE self, VALUE klass /* OK */, int flags)
|
|||
POP_TAG();
|
||||
if (state) goto pop_state;
|
||||
}
|
||||
else if (lambda && ary_args && RARRAY(val)->len != 0 &&
|
||||
else if (lambda && ary_args && RARRAY_LEN(val) != 0 &&
|
||||
(!node || nd_type(node) != NODE_IFUNC ||
|
||||
node->nd_cfnc != bmcall)) {
|
||||
rb_raise(rb_eArgError, "wrong number of arguments (%ld for 0)",
|
||||
RARRAY(val)->len);
|
||||
RARRAY_LEN(val));
|
||||
}
|
||||
if (!node) {
|
||||
state = 0;
|
||||
|
@ -4939,9 +4935,8 @@ rb_yield_values(int n, ...)
|
|||
val = rb_ary_new2(n);
|
||||
va_start(args, n);
|
||||
for (i=0; i<n; i++) {
|
||||
RARRAY(val)->ptr[i] = va_arg(args, VALUE);
|
||||
rb_ary_push(val, va_arg(args, VALUE));
|
||||
}
|
||||
RARRAY(val)->len = n;
|
||||
va_end(args);
|
||||
return rb_yield_0(val, 0, 0, 0);
|
||||
}
|
||||
|
@ -4989,8 +4984,8 @@ massign(VALUE self, NODE *node, VALUE val, int pcall)
|
|||
len = (val == Qundef) ? 0 : 1;
|
||||
}
|
||||
else {
|
||||
argv = RARRAY(tmp)->ptr;
|
||||
len = RARRAY(tmp)->len;
|
||||
argv = RARRAY_PTR(tmp);
|
||||
len = RARRAY_LEN(tmp);
|
||||
}
|
||||
}
|
||||
list = node->nd_head;
|
||||
|
@ -5112,7 +5107,7 @@ assign(VALUE self, NODE *lhs, VALUE val, int pcall)
|
|||
ruby_current_node = lhs;
|
||||
SET_CURRENT_SOURCE();
|
||||
rb_call(CLASS_OF(recv), recv, lhs->nd_mid,
|
||||
RARRAY(args)->len, RARRAY(args)->ptr, 0, scope,0);
|
||||
RARRAY_LEN(args), RARRAY_PTR(args), 0, scope,0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -5127,18 +5122,18 @@ assign(VALUE self, NODE *lhs, VALUE val, int pcall)
|
|||
assign(self, lhs->nd_args, val, 0);
|
||||
}
|
||||
cnt = lhs->nd_head->nd_alen;
|
||||
if (RARRAY(val)->len < cnt) {
|
||||
if (RARRAY_LEN(val) < cnt) {
|
||||
if (pcall) {
|
||||
rb_raise(rb_eArgError, "wrong number of arguments");
|
||||
}
|
||||
else {
|
||||
while (RARRAY(val)->len < cnt) {
|
||||
while (RARRAY_LEN(val) < cnt) {
|
||||
v = v->nd_next;
|
||||
cnt--;
|
||||
}
|
||||
}
|
||||
}
|
||||
p = RARRAY(val)->ptr + RARRAY(val)->len - cnt;
|
||||
p = RARRAY_PTR(val) + RARRAY_LEN(val) - cnt;
|
||||
while (cnt--) {
|
||||
assign(self, v->nd_head, *p++, 0);
|
||||
v = v->nd_next;
|
||||
|
@ -5505,10 +5500,10 @@ method_missing(VALUE obj, ID id, int argc, const VALUE *argv,
|
|||
|
||||
argc = -argc-1;
|
||||
tmp = svalue_to_avalue(argv[argc]);
|
||||
nargv = ALLOCA_N(VALUE, argc + RARRAY(tmp)->len + 1);
|
||||
nargv = ALLOCA_N(VALUE, argc + RARRAY_LEN(tmp) + 1);
|
||||
MEMCPY(nargv+1, argv, VALUE, argc);
|
||||
MEMCPY(nargv+1+argc, RARRAY(tmp)->ptr, VALUE, RARRAY(tmp)->len);
|
||||
argc += RARRAY(tmp)->len;
|
||||
MEMCPY(nargv+1+argc, RARRAY_PTR(tmp), VALUE, RARRAY_LEN(tmp));
|
||||
argc += RARRAY_LEN(tmp);
|
||||
|
||||
}
|
||||
else {
|
||||
|
@ -5614,7 +5609,7 @@ formal_assign(VALUE recv, NODE *node, int argc, const VALUE *argv, VALUE *local_
|
|||
rb_bug("no argument-node");
|
||||
}
|
||||
|
||||
i = node->nd_frml ? RARRAY(node->nd_frml)->len : 0;
|
||||
i = node->nd_frml ? RARRAY_LEN(node->nd_frml) : 0;
|
||||
if (i > argc) {
|
||||
rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)", argc, i);
|
||||
}
|
||||
|
@ -5641,7 +5636,7 @@ formal_assign(VALUE recv, NODE *node, int argc, const VALUE *argv, VALUE *local_
|
|||
VALUE a = node->nd_frml;
|
||||
|
||||
for (j=0; j<i; j++) {
|
||||
dvar_asgn_curr(SYM2ID(RARRAY(a)->ptr[j]), argv[j]);
|
||||
dvar_asgn_curr(SYM2ID(RARRAY_PTR(a)[j]), argv[j]);
|
||||
}
|
||||
}
|
||||
argv += i; argc -= i;
|
||||
|
@ -5722,11 +5717,11 @@ rb_call0(VALUE klass, VALUE recv, ID id, ID oid,
|
|||
|
||||
argc %= 256;
|
||||
tmp = svalue_to_avalue(argv[argc]);
|
||||
nargv = TMP_ALLOC(argc + RARRAY(tmp)->len + n);
|
||||
nargv = TMP_ALLOC(argc + RARRAY_LEN(tmp) + n);
|
||||
MEMCPY(nargv, argv, VALUE, argc);
|
||||
MEMCPY(nargv+argc, RARRAY(tmp)->ptr, VALUE, RARRAY(tmp)->len);
|
||||
MEMCPY(nargv + argc + RARRAY(tmp)->len, argv + argc + 1, VALUE, n);
|
||||
argc += RARRAY(tmp)->len + n;
|
||||
MEMCPY(nargv+argc, RARRAY_PTR(tmp), VALUE, RARRAY_LEN(tmp));
|
||||
MEMCPY(nargv + argc + RARRAY_LEN(tmp), argv + argc + 1, VALUE, n);
|
||||
argc += RARRAY_LEN(tmp) + n;
|
||||
argv = nargv;
|
||||
}
|
||||
switch (nd_type(body)) {
|
||||
|
@ -5988,9 +5983,9 @@ rb_apply(VALUE recv, ID mid, VALUE args)
|
|||
int argc;
|
||||
VALUE *argv;
|
||||
|
||||
argc = RARRAY(args)->len; /* Assigns LONG, but argc is INT */
|
||||
argc = RARRAY_LEN(args); /* Assigns LONG, but argc is INT */
|
||||
argv = ALLOCA_N(VALUE, argc);
|
||||
MEMCPY(argv, RARRAY(args)->ptr, VALUE, argc);
|
||||
MEMCPY(argv, RARRAY_PTR(args), VALUE, argc);
|
||||
return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 0, CALLING_FUNCALL, 0);
|
||||
}
|
||||
|
||||
|
@ -6217,8 +6212,8 @@ rb_backtrace(void)
|
|||
VALUE ary;
|
||||
|
||||
ary = backtrace(-1);
|
||||
for (i=0; i<RARRAY(ary)->len; i++) {
|
||||
printf("\tfrom %s\n", RSTRING_PTR(RARRAY(ary)->ptr[i]));
|
||||
for (i=0; i<RARRAY_LEN(ary); i++) {
|
||||
printf("\tfrom %s\n", RSTRING_PTR(RARRAY_PTR(ary)[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6355,9 +6350,9 @@ eval(VALUE self, VALUE src, VALUE scope, const char *file, int line)
|
|||
if (!NIL_P(errat) && TYPE(errat) == T_ARRAY) {
|
||||
if (!NIL_P(mesg) && TYPE(mesg) == T_STRING) {
|
||||
rb_str_update(mesg, 0, 0, rb_str_new2(": "));
|
||||
rb_str_update(mesg, 0, 0, RARRAY(errat)->ptr[0]);
|
||||
rb_str_update(mesg, 0, 0, RARRAY_PTR(errat)[0]);
|
||||
}
|
||||
RARRAY(errat)->ptr[0] = RARRAY(backtrace(-2))->ptr[0];
|
||||
RARRAY_PTR(errat)[0] = RARRAY_PTR(backtrace(-2))[0];
|
||||
}
|
||||
}
|
||||
rb_exc_raise(ruby_errinfo);
|
||||
|
@ -6841,8 +6836,8 @@ rb_feature_p(const char *feature, const char *ext, int rb)
|
|||
len = strlen(feature);
|
||||
elen = 0;
|
||||
}
|
||||
for (i = 0; i < RARRAY(rb_features)->len; ++i) {
|
||||
v = RARRAY(rb_features)->ptr[i];
|
||||
for (i = 0; i < RARRAY_LEN(rb_features); ++i) {
|
||||
v = RARRAY_PTR(rb_features)[i];
|
||||
f = StringValuePtr(v);
|
||||
if (strncmp(f, feature, len) != 0) continue;
|
||||
if (!*(e = f + len)) {
|
||||
|
@ -8465,7 +8460,7 @@ proc_invoke(VALUE proc, VALUE args /* OK */, VALUE self, VALUE klass, int call)
|
|||
_block.block_obj = bvar;
|
||||
if (self != Qundef) _block.frame.self = self;
|
||||
if (klass) _block.frame.this_class = klass;
|
||||
_block.frame.argc = call ? RARRAY(args)->len : 1;
|
||||
_block.frame.argc = call ? RARRAY_LEN(args) : 1;
|
||||
_block.frame.flags = ruby_frame->flags;
|
||||
if (_block.frame.argc && (ruby_frame->flags & FRAME_DMETH)) {
|
||||
NEWOBJ(scope, struct SCOPE);
|
||||
|
@ -9248,7 +9243,7 @@ rb_node_arity(NODE *body)
|
|||
if (nd_type(body) == NODE_BLOCK)
|
||||
body = body->nd_head;
|
||||
if (!body) return 0;
|
||||
n = body->nd_frml ? RARRAY(body->nd_frml)->len : 0;
|
||||
n = body->nd_frml ? RARRAY_LEN(body->nd_frml) : 0;
|
||||
if (body->nd_opt)
|
||||
return -n-1;
|
||||
if (body->nd_rest) {
|
||||
|
@ -9399,7 +9394,7 @@ bmcall(VALUE args, VALUE method)
|
|||
VALUE ret;
|
||||
|
||||
a = svalue_to_avalue(args);
|
||||
ret = rb_method_call(RARRAY(a)->len, RARRAY(a)->ptr, method);
|
||||
ret = rb_method_call(RARRAY_LEN(a), RARRAY_PTR(a), method);
|
||||
a = Qnil; /* prevent tail call */
|
||||
return ret;
|
||||
}
|
||||
|
@ -11115,7 +11110,7 @@ rb_thread_join(rb_thread_t th, double limit)
|
|||
VALUE errat = make_backtrace();
|
||||
VALUE errinfo = rb_obj_dup(th->errinfo);
|
||||
|
||||
if (TYPE(oldbt) == T_ARRAY && RARRAY(oldbt)->len > 0) {
|
||||
if (TYPE(oldbt) == T_ARRAY && RARRAY_LEN(oldbt) > 0) {
|
||||
rb_ary_unshift(errat, rb_ary_entry(oldbt, 0));
|
||||
}
|
||||
set_backtrace(errinfo, errat);
|
||||
|
@ -12010,7 +12005,7 @@ rb_thread_start_1(void)
|
|||
if ((state = EXEC_TAG()) == 0) {
|
||||
if (THREAD_SAVE_CONTEXT(th) == 0) {
|
||||
new_thread.thread = 0;
|
||||
th->result = rb_proc_yield(RARRAY(arg)->len, RARRAY(arg)->ptr, proc);
|
||||
th->result = rb_proc_yield(RARRAY_LEN(arg), RARRAY_PTR(arg), proc);
|
||||
}
|
||||
th = th_save;
|
||||
}
|
||||
|
|
|
@ -72,8 +72,8 @@ Win32API_initialize(self, dllname, proc, import, export)
|
|||
case T_NIL:
|
||||
break;
|
||||
case T_ARRAY:
|
||||
ptr = RARRAY(import)->ptr;
|
||||
for (i = 0, len = RARRAY(import)->len; i < len; i++) {
|
||||
ptr = RARRAY_PTR(import);
|
||||
for (i = 0, len = RARRAY_LEN(import); i < len; i++) {
|
||||
SafeStringValue(ptr[i]);
|
||||
switch (*(char *)RSTRING_PTR(ptr[i])) {
|
||||
case 'N': case 'n': case 'L': case 'l':
|
||||
|
@ -107,8 +107,8 @@ Win32API_initialize(self, dllname, proc, import, export)
|
|||
break;
|
||||
}
|
||||
|
||||
if (16 < RARRAY(a_import)->len) {
|
||||
rb_raise(rb_eRuntimeError, "too many parameters: %d\n", RARRAY(a_import)->len);
|
||||
if (16 < RARRAY_LEN(a_import)) {
|
||||
rb_raise(rb_eRuntimeError, "too many parameters: %d\n", RARRAY_LEN(a_import));
|
||||
}
|
||||
|
||||
rb_iv_set(self, "__import__", a_import);
|
||||
|
@ -159,7 +159,7 @@ Win32API_Call(argc, argv, obj)
|
|||
VALUE obj_export = rb_iv_get(obj, "__export__");
|
||||
FARPROC ApiFunction = (FARPROC)NUM2ULONG(obj_proc);
|
||||
int items = rb_scan_args(argc, argv, "0*", &args);
|
||||
int nimport = RARRAY(obj_import)->len;
|
||||
int nimport = RARRAY_LEN(obj_import);
|
||||
|
||||
|
||||
if (items != nimport)
|
||||
|
|
|
@ -345,8 +345,8 @@ fdbm_delete_if(VALUE obj)
|
|||
GetDBM2(obj, dbmp, dbm);
|
||||
}
|
||||
|
||||
for (i = 0; i < RARRAY(ary)->len; i++) {
|
||||
keystr = RARRAY(ary)->ptr[i];
|
||||
for (i = 0; i < RARRAY_LEN(ary); i++) {
|
||||
keystr = RARRAY_PTR(ary)[i];
|
||||
StringValue(keystr);
|
||||
key.dptr = RSTRING_PTR(keystr);
|
||||
key.dsize = RSTRING_LEN(keystr);
|
||||
|
@ -355,7 +355,7 @@ fdbm_delete_if(VALUE obj)
|
|||
}
|
||||
}
|
||||
if (status) rb_jump_tag(status);
|
||||
if (n > 0) dbmp->di_size = n - RARRAY(ary)->len;
|
||||
if (n > 0) dbmp->di_size = n - RARRAY_LEN(ary);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
@ -405,10 +405,10 @@ static VALUE
|
|||
update_i(VALUE pair, VALUE dbm)
|
||||
{
|
||||
Check_Type(pair, T_ARRAY);
|
||||
if (RARRAY(pair)->len < 2) {
|
||||
if (RARRAY_LEN(pair) < 2) {
|
||||
rb_raise(rb_eArgError, "pair must be [key, value]");
|
||||
}
|
||||
fdbm_store(dbm, RARRAY(pair)->ptr[0], RARRAY(pair)->ptr[1]);
|
||||
fdbm_store(dbm, RARRAY_PTR(pair)[0], RARRAY_PTR(pair)[1]);
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ rb_dlcfunc_inspect(VALUE self)
|
|||
# define DECL_FUNC_CDECL(f,ret,args) ret (FUNC_CDECL(*f))(args)
|
||||
# define DECL_FUNC_STDCALL(f,ret,args) ret (FUNC_STDCALL(*f))(args)
|
||||
|
||||
#define CALL_CASE switch( RARRAY(ary)->len ){ \
|
||||
#define CALL_CASE switch( RARRAY_LEN(ary) ){ \
|
||||
CASE(0); break; \
|
||||
CASE(1); break; CASE(2); break; CASE(3); break; CASE(4); break; CASE(5); break; \
|
||||
CASE(6); break; CASE(7); break; CASE(8); break; CASE(9); break; CASE(10);break; \
|
||||
|
@ -256,11 +256,11 @@ rb_dlcfunc_call(VALUE self, VALUE ary)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
for( i = 0; i < RARRAY(ary)->len; i++ ){
|
||||
for( i = 0; i < RARRAY_LEN(ary); i++ ){
|
||||
if( i >= DLSTACK_SIZE ){
|
||||
rb_raise(rb_eDLError, "too many arguments (stack overflow)");
|
||||
}
|
||||
stack[i] = NUM2LONG(RARRAY(ary)->ptr[i]);
|
||||
stack[i] = NUM2LONG(RARRAY_PTR(ary)[i]);
|
||||
}
|
||||
|
||||
/* calltype == CFUNC_CDECL */
|
||||
|
|
|
@ -414,10 +414,10 @@ fgdbm_delete_if(VALUE obj)
|
|||
GetDBM2(obj, dbmp, dbm);
|
||||
}
|
||||
|
||||
for (i = 0; i < RARRAY(ary)->len; i++)
|
||||
rb_gdbm_delete(obj, RARRAY(ary)->ptr[i]);
|
||||
for (i = 0; i < RARRAY_LEN(ary); i++)
|
||||
rb_gdbm_delete(obj, RARRAY_PTR(ary)[i]);
|
||||
if (status) rb_jump_tag(status);
|
||||
if (n > 0) dbmp->di_size = n - RARRAY(ary)->len;
|
||||
if (n > 0) dbmp->di_size = n - RARRAY_LEN(ary);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
@ -508,10 +508,10 @@ static VALUE
|
|||
update_i(VALUE pair, VALUE dbm)
|
||||
{
|
||||
Check_Type(pair, T_ARRAY);
|
||||
if (RARRAY(pair)->len < 2) {
|
||||
if (RARRAY_LEN(pair) < 2) {
|
||||
rb_raise(rb_eArgError, "pair must be [key, value]");
|
||||
}
|
||||
fgdbm_store(dbm, RARRAY(pair)->ptr[0], RARRAY(pair)->ptr[1]);
|
||||
fgdbm_store(dbm, RARRAY_PTR(pair)[0], RARRAY_PTR(pair)[1]);
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
|
|
|
@ -350,7 +350,7 @@ iconv_convert(iconv_t cd, VALUE str, int start, int length, struct iconv_env_t*
|
|||
unsigned int i;
|
||||
rescue = iconv_fail(error, Qnil, Qnil, env, 0);
|
||||
if (TYPE(rescue) == T_ARRAY) {
|
||||
str = RARRAY(rescue)->len > 0 ? RARRAY(rescue)->ptr[0] : Qnil;
|
||||
str = RARRAY_LEN(rescue) > 0 ? RARRAY_PTR(rescue)[0] : Qnil;
|
||||
}
|
||||
if (FIXNUM_P(str) && (i = FIX2INT(str)) <= 0xff) {
|
||||
char c = i;
|
||||
|
@ -434,9 +434,9 @@ iconv_convert(iconv_t cd, VALUE str, int start, int length, struct iconv_env_t*
|
|||
str = rb_str_derive(str, inptr, inlen);
|
||||
rescue = iconv_fail(error, ret, str, env, errmsg);
|
||||
if (TYPE(rescue) == T_ARRAY) {
|
||||
if ((len = RARRAY(rescue)->len) > 0)
|
||||
rb_str_concat(ret, RARRAY(rescue)->ptr[0]);
|
||||
if (len > 1 && !NIL_P(str = RARRAY(rescue)->ptr[1])) {
|
||||
if ((len = RARRAY_LEN(rescue)) > 0)
|
||||
rb_str_concat(ret, RARRAY_PTR(rescue)[0]);
|
||||
if (len > 1 && !NIL_P(str = RARRAY_PTR(rescue)[1])) {
|
||||
StringValue(str);
|
||||
inlen = length = RSTRING_LEN(str);
|
||||
instart = inptr = RSTRING_PTR(str);
|
||||
|
|
|
@ -59,7 +59,7 @@ ossl_x509_ary2sk0(VALUE ary)
|
|||
sk = sk_X509_new_null();
|
||||
if (!sk) ossl_raise(eOSSLError, NULL);
|
||||
|
||||
for (i = 0; i < RARRAY(ary)->len; i++) {
|
||||
for (i = 0; i < RARRAY_LEN(ary); i++) {
|
||||
val = rb_ary_entry(ary, i);
|
||||
if (!rb_obj_is_kind_of(val, cX509Cert)) {
|
||||
sk_X509_pop_free(sk, X509_free);
|
||||
|
|
|
@ -461,8 +461,8 @@ ossl_ocspbres_add_status(VALUE self, VALUE cid, VALUE status,
|
|||
if(!NIL_P(ext)){
|
||||
/* All ary's members should be X509Extension */
|
||||
Check_Type(ext, T_ARRAY);
|
||||
for (i = 0; i < RARRAY(ext)->len; i++)
|
||||
OSSL_Check_Kind(RARRAY(ext)->ptr[i], cX509Ext);
|
||||
for (i = 0; i < RARRAY_LEN(ext); i++)
|
||||
OSSL_Check_Kind(RARRAY_PTR(ext)[i], cX509Ext);
|
||||
}
|
||||
|
||||
error = 0;
|
||||
|
@ -490,8 +490,8 @@ ossl_ocspbres_add_status(VALUE self, VALUE cid, VALUE status,
|
|||
X509_EXTENSION *x509ext;
|
||||
sk_X509_EXTENSION_pop_free(single->singleExtensions, X509_EXTENSION_free);
|
||||
single->singleExtensions = NULL;
|
||||
for(i = 0; i < RARRAY(ext)->len; i++){
|
||||
x509ext = DupX509ExtPtr(RARRAY(ext)->ptr[i]);
|
||||
for(i = 0; i < RARRAY_LEN(ext); i++){
|
||||
x509ext = DupX509ExtPtr(RARRAY_PTR(ext)[i]);
|
||||
if(!OCSP_SINGLERESP_add_ext(single, x509ext, -1)){
|
||||
X509_EXTENSION_free(x509ext);
|
||||
error = 1;
|
||||
|
|
|
@ -349,8 +349,8 @@ ossl_sslctx_setup(VALUE self)
|
|||
val = ossl_sslctx_get_client_ca(self);
|
||||
if(!NIL_P(val)){
|
||||
if(TYPE(val) == T_ARRAY){
|
||||
for(i = 0; i < RARRAY(val)->len; i++){
|
||||
client_ca = GetX509CertPtr(RARRAY(val)->ptr[i]);
|
||||
for(i = 0; i < RARRAY_LEN(val); i++){
|
||||
client_ca = GetX509CertPtr(RARRAY_PTR(val)[i]);
|
||||
if (!SSL_CTX_add_client_CA(ctx, client_ca)){
|
||||
/* Copies X509_NAME => FREE it. */
|
||||
ossl_raise(eSSLError, "SSL_CTX_add_client_CA");
|
||||
|
@ -459,12 +459,12 @@ ossl_sslctx_set_ciphers(VALUE self, VALUE v)
|
|||
return v;
|
||||
else if (TYPE(v) == T_ARRAY) {
|
||||
str = rb_str_new(0, 0);
|
||||
for (i = 0; i < RARRAY(v)->len; i++) {
|
||||
for (i = 0; i < RARRAY_LEN(v); i++) {
|
||||
elem = rb_ary_entry(v, i);
|
||||
if (TYPE(elem) == T_ARRAY) elem = rb_ary_entry(elem, 0);
|
||||
elem = rb_String(elem);
|
||||
rb_str_append(str, elem);
|
||||
if (i < RARRAY(v)->len-1) rb_str_cat2(str, ":");
|
||||
if (i < RARRAY_LEN(v)-1) rb_str_cat2(str, ":");
|
||||
}
|
||||
} else {
|
||||
str = v;
|
||||
|
|
|
@ -557,14 +557,14 @@ ossl_x509_set_extensions(VALUE self, VALUE ary)
|
|||
|
||||
Check_Type(ary, T_ARRAY);
|
||||
/* All ary's members should be X509Extension */
|
||||
for (i=0; i<RARRAY(ary)->len; i++) {
|
||||
OSSL_Check_Kind(RARRAY(ary)->ptr[i], cX509Ext);
|
||||
for (i=0; i<RARRAY_LEN(ary); i++) {
|
||||
OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Ext);
|
||||
}
|
||||
GetX509(self, x509);
|
||||
sk_X509_EXTENSION_pop_free(x509->cert_info->extensions, X509_EXTENSION_free);
|
||||
x509->cert_info->extensions = NULL;
|
||||
for (i=0; i<RARRAY(ary)->len; i++) {
|
||||
ext = DupX509ExtPtr(RARRAY(ary)->ptr[i]);
|
||||
for (i=0; i<RARRAY_LEN(ary); i++) {
|
||||
ext = DupX509ExtPtr(RARRAY_PTR(ary)[i]);
|
||||
|
||||
if (!X509_add_ext(x509, ext, -1)) { /* DUPs ext - FREE it */
|
||||
X509_EXTENSION_free(ext);
|
||||
|
|
|
@ -287,14 +287,14 @@ ossl_x509crl_set_revoked(VALUE self, VALUE ary)
|
|||
|
||||
Check_Type(ary, T_ARRAY);
|
||||
/* All ary members should be X509 Revoked */
|
||||
for (i=0; i<RARRAY(ary)->len; i++) {
|
||||
OSSL_Check_Kind(RARRAY(ary)->ptr[i], cX509Rev);
|
||||
for (i=0; i<RARRAY_LEN(ary); i++) {
|
||||
OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Rev);
|
||||
}
|
||||
GetX509CRL(self, crl);
|
||||
sk_X509_REVOKED_pop_free(crl->crl->revoked, X509_REVOKED_free);
|
||||
crl->crl->revoked = NULL;
|
||||
for (i=0; i<RARRAY(ary)->len; i++) {
|
||||
rev = DupX509RevokedPtr(RARRAY(ary)->ptr[i]);
|
||||
for (i=0; i<RARRAY_LEN(ary); i++) {
|
||||
rev = DupX509RevokedPtr(RARRAY_PTR(ary)[i]);
|
||||
if (!X509_CRL_add0_revoked(crl, rev)) { /* NO DUP - don't free! */
|
||||
ossl_raise(eX509CRLError, NULL);
|
||||
}
|
||||
|
@ -461,14 +461,14 @@ ossl_x509crl_set_extensions(VALUE self, VALUE ary)
|
|||
|
||||
Check_Type(ary, T_ARRAY);
|
||||
/* All ary members should be X509 Extensions */
|
||||
for (i=0; i<RARRAY(ary)->len; i++) {
|
||||
OSSL_Check_Kind(RARRAY(ary)->ptr[i], cX509Ext);
|
||||
for (i=0; i<RARRAY_LEN(ary); i++) {
|
||||
OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Ext);
|
||||
}
|
||||
GetX509CRL(self, crl);
|
||||
sk_X509_EXTENSION_pop_free(crl->crl->extensions, X509_EXTENSION_free);
|
||||
crl->crl->extensions = NULL;
|
||||
for (i=0; i<RARRAY(ary)->len; i++) {
|
||||
ext = DupX509ExtPtr(RARRAY(ary)->ptr[i]);
|
||||
for (i=0; i<RARRAY_LEN(ary); i++) {
|
||||
ext = DupX509ExtPtr(RARRAY_PTR(ary)[i]);
|
||||
if(!X509_CRL_add_ext(crl, ext, -1)) { /* DUPs ext - FREE it */
|
||||
X509_EXTENSION_free(ext);
|
||||
ossl_raise(eX509CRLError, NULL);
|
||||
|
|
|
@ -403,14 +403,14 @@ ossl_x509req_set_attributes(VALUE self, VALUE ary)
|
|||
VALUE item;
|
||||
|
||||
Check_Type(ary, T_ARRAY);
|
||||
for (i=0;i<RARRAY(ary)->len; i++) {
|
||||
OSSL_Check_Kind(RARRAY(ary)->ptr[i], cX509Attr);
|
||||
for (i=0;i<RARRAY_LEN(ary); i++) {
|
||||
OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Attr);
|
||||
}
|
||||
GetX509Req(self, req);
|
||||
sk_X509_ATTRIBUTE_pop_free(req->req_info->attributes, X509_ATTRIBUTE_free);
|
||||
req->req_info->attributes = NULL;
|
||||
for (i=0;i<RARRAY(ary)->len; i++) {
|
||||
item = RARRAY(ary)->ptr[i];
|
||||
for (i=0;i<RARRAY_LEN(ary); i++) {
|
||||
item = RARRAY_PTR(ary)[i];
|
||||
attr = DupX509AttrPtr(item);
|
||||
if (!X509_REQ_add1_attr(req, attr)) {
|
||||
ossl_raise(eX509ReqError, NULL);
|
||||
|
|
|
@ -175,14 +175,14 @@ ossl_x509revoked_set_extensions(VALUE self, VALUE ary)
|
|||
VALUE item;
|
||||
|
||||
Check_Type(ary, T_ARRAY);
|
||||
for (i=0; i<RARRAY(ary)->len; i++) {
|
||||
OSSL_Check_Kind(RARRAY(ary)->ptr[i], cX509Ext);
|
||||
for (i=0; i<RARRAY_LEN(ary); i++) {
|
||||
OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Ext);
|
||||
}
|
||||
GetX509Rev(self, rev);
|
||||
sk_X509_EXTENSION_pop_free(rev->extensions, X509_EXTENSION_free);
|
||||
rev->extensions = NULL;
|
||||
for (i=0; i<RARRAY(ary)->len; i++) {
|
||||
item = RARRAY(ary)->ptr[i];
|
||||
for (i=0; i<RARRAY_LEN(ary); i++) {
|
||||
item = RARRAY_PTR(ary)[i];
|
||||
ext = DupX509ExtPtr(item);
|
||||
if(!X509_REVOKED_add_ext(rev, ext, -1)) {
|
||||
ossl_raise(eX509RevError, NULL);
|
||||
|
|
|
@ -88,7 +88,7 @@ num_to_long(VALUE n)
|
|||
}
|
||||
|
||||
#define AREF(s, idx) \
|
||||
((0 <= idx && idx < RARRAY(s)->len) ? RARRAY(s)->ptr[idx] : Qnil)
|
||||
((0 <= idx && idx < RARRAY_LEN(s)) ? RARRAY_PTR(s)[idx] : Qnil)
|
||||
|
||||
/* -----------------------------------------------------------------------
|
||||
Parser Stack Interfaces
|
||||
|
@ -101,8 +101,8 @@ static VALUE
|
|||
get_stack_tail(VALUE stack, long len)
|
||||
{
|
||||
if (len < 0) return Qnil; /* system error */
|
||||
if (len > RARRAY(stack)->len) len = RARRAY(stack)->len;
|
||||
return rb_ary_new4(len, RARRAY(stack)->ptr + RARRAY(stack)->len - len);
|
||||
if (len > RARRAY_LEN(stack)) len = RARRAY_LEN(stack);
|
||||
return rb_ary_new4(len, RARRAY_PTR(stack) + RARRAY_LEN(stack) - len);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -116,10 +116,10 @@ cut_stack_tail(VALUE stack, long len)
|
|||
|
||||
#define STACK_INIT_LEN 64
|
||||
#define NEW_STACK() rb_ary_new2(STACK_INIT_LEN)
|
||||
#define PUSH(s, i) rb_ary_store(s, RARRAY(s)->len, i)
|
||||
#define PUSH(s, i) rb_ary_store(s, RARRAY_LEN(s), i)
|
||||
#define POP(s) rb_ary_pop(s)
|
||||
#define LAST_I(s) \
|
||||
((RARRAY(s)->len > 0) ? RARRAY(s)->ptr[RARRAY(s)->len - 1] : Qnil)
|
||||
((RARRAY_LEN(s) > 0) ? RARRAY_PTR(s)[RARRAY_LEN(s) - 1] : Qnil)
|
||||
#define GET_TAIL(s, len) get_stack_tail(s, len)
|
||||
#define CUT_TAIL(s, len) cut_stack_tail(s, len)
|
||||
|
||||
|
@ -329,23 +329,23 @@ initialize_params(VALUE vparams, VALUE parser, VALUE arg, VALUE lexer, VALUE lex
|
|||
v->debug = RTEST(rb_ivar_get(parser, id_yydebug));
|
||||
|
||||
Check_Type(arg, T_ARRAY);
|
||||
if (!(13 <= RARRAY(arg)->len && RARRAY(arg)->len <= 14))
|
||||
rb_raise(RaccBug, "[Racc Bug] wrong arg.size %ld", RARRAY(arg)->len);
|
||||
v->action_table = assert_array (RARRAY(arg)->ptr[ 0]);
|
||||
v->action_check = assert_array (RARRAY(arg)->ptr[ 1]);
|
||||
v->action_default = assert_array (RARRAY(arg)->ptr[ 2]);
|
||||
v->action_pointer = assert_array (RARRAY(arg)->ptr[ 3]);
|
||||
v->goto_table = assert_array (RARRAY(arg)->ptr[ 4]);
|
||||
v->goto_check = assert_array (RARRAY(arg)->ptr[ 5]);
|
||||
v->goto_default = assert_array (RARRAY(arg)->ptr[ 6]);
|
||||
v->goto_pointer = assert_array (RARRAY(arg)->ptr[ 7]);
|
||||
v->nt_base = assert_integer(RARRAY(arg)->ptr[ 8]);
|
||||
v->reduce_table = assert_array (RARRAY(arg)->ptr[ 9]);
|
||||
v->token_table = assert_hash (RARRAY(arg)->ptr[10]);
|
||||
v->shift_n = assert_integer(RARRAY(arg)->ptr[11]);
|
||||
v->reduce_n = assert_integer(RARRAY(arg)->ptr[12]);
|
||||
if (RARRAY(arg)->len > 13) {
|
||||
v->use_result_var = RTEST(RARRAY(arg)->ptr[13]);
|
||||
if (!(13 <= RARRAY_LEN(arg) && RARRAY_LEN(arg) <= 14))
|
||||
rb_raise(RaccBug, "[Racc Bug] wrong arg.size %ld", RARRAY_LEN(arg));
|
||||
v->action_table = assert_array (RARRAY_PTR(arg)[ 0]);
|
||||
v->action_check = assert_array (RARRAY_PTR(arg)[ 1]);
|
||||
v->action_default = assert_array (RARRAY_PTR(arg)[ 2]);
|
||||
v->action_pointer = assert_array (RARRAY_PTR(arg)[ 3]);
|
||||
v->goto_table = assert_array (RARRAY_PTR(arg)[ 4]);
|
||||
v->goto_check = assert_array (RARRAY_PTR(arg)[ 5]);
|
||||
v->goto_default = assert_array (RARRAY_PTR(arg)[ 6]);
|
||||
v->goto_pointer = assert_array (RARRAY_PTR(arg)[ 7]);
|
||||
v->nt_base = assert_integer(RARRAY_PTR(arg)[ 8]);
|
||||
v->reduce_table = assert_array (RARRAY_PTR(arg)[ 9]);
|
||||
v->token_table = assert_hash (RARRAY_PTR(arg)[10]);
|
||||
v->shift_n = assert_integer(RARRAY_PTR(arg)[11]);
|
||||
v->reduce_n = assert_integer(RARRAY_PTR(arg)[12]);
|
||||
if (RARRAY_LEN(arg) > 13) {
|
||||
v->use_result_var = RTEST(RARRAY_PTR(arg)[13]);
|
||||
}
|
||||
else {
|
||||
v->use_result_var = Qtrue;
|
||||
|
@ -424,12 +424,12 @@ extract_user_token(struct cparse_params *v, VALUE block_args,
|
|||
v->lex_is_iterator ? "yielded" : "returned",
|
||||
rb_class2name(CLASS_OF(block_args)));
|
||||
}
|
||||
if (RARRAY(block_args)->len != 2) {
|
||||
if (RARRAY_LEN(block_args) != 2) {
|
||||
rb_raise(rb_eArgError,
|
||||
"%s() %s wrong size of array (%ld for 2)",
|
||||
v->lex_is_iterator ? rb_id2name(v->lexmid) : "next_token",
|
||||
v->lex_is_iterator ? "yielded" : "returned",
|
||||
RARRAY(block_args)->len);
|
||||
RARRAY_LEN(block_args));
|
||||
}
|
||||
*tok = AREF(block_args, 0);
|
||||
*val = AREF(block_args, 1);
|
||||
|
@ -565,7 +565,7 @@ parse_main(struct cparse_params *v, VALUE tok, VALUE val, int resume)
|
|||
|
||||
accept:
|
||||
if (v->debug) rb_funcall(v->parser, id_d_accept, 0);
|
||||
v->retval = RARRAY(v->vstack)->ptr[0];
|
||||
v->retval = RARRAY_PTR(v->vstack)[0];
|
||||
v->fin = CP_FIN_ACCEPT;
|
||||
return;
|
||||
|
||||
|
@ -625,7 +625,7 @@ parse_main(struct cparse_params *v, VALUE tok, VALUE val, int resume)
|
|||
error_pop:
|
||||
D_puts("(err) act not found: can't handle error token; pop");
|
||||
|
||||
if (RARRAY(v->state)->len <= 1) {
|
||||
if (RARRAY_LEN(v->state) <= 1) {
|
||||
v->retval = Qnil;
|
||||
v->fin = CP_FIN_CANTPOP;
|
||||
return;
|
||||
|
@ -694,9 +694,9 @@ reduce0(VALUE val, VALUE data, VALUE self)
|
|||
VALUE goto_state;
|
||||
|
||||
Data_Get_Struct(data, struct cparse_params, v);
|
||||
reduce_len = RARRAY(v->reduce_table)->ptr[v->ruleno];
|
||||
reduce_to = RARRAY(v->reduce_table)->ptr[v->ruleno+1];
|
||||
method_id = RARRAY(v->reduce_table)->ptr[v->ruleno+2];
|
||||
reduce_len = RARRAY_PTR(v->reduce_table)[v->ruleno];
|
||||
reduce_to = RARRAY_PTR(v->reduce_table)[v->ruleno+1];
|
||||
method_id = RARRAY_PTR(v->reduce_table)[v->ruleno+2];
|
||||
len = NUM2LONG(reduce_len);
|
||||
mid = value_to_id(method_id);
|
||||
|
||||
|
@ -711,10 +711,10 @@ reduce0(VALUE val, VALUE data, VALUE self)
|
|||
else {
|
||||
if (mid != id_noreduce) {
|
||||
tmp_v = GET_TAIL(v->vstack, len);
|
||||
tmp = RARRAY(tmp_v)->ptr[0];
|
||||
tmp = RARRAY_PTR(tmp_v)[0];
|
||||
}
|
||||
else {
|
||||
tmp = RARRAY(v->vstack)->ptr[ RARRAY(v->vstack)->len - len ];
|
||||
tmp = RARRAY_PTR(v->vstack)[ RARRAY_LEN(v->vstack) - len ];
|
||||
}
|
||||
CUT_TAIL(v->vstack, len);
|
||||
if (v->debug) {
|
||||
|
@ -743,7 +743,7 @@ reduce0(VALUE val, VALUE data, VALUE self)
|
|||
}
|
||||
|
||||
/* calculate transition state */
|
||||
if (RARRAY(v->state)->len == 0)
|
||||
if (RARRAY_LEN(v->state) == 0)
|
||||
rb_raise(RaccBug, "state stack unexpectedly empty");
|
||||
k2 = num_to_long(LAST_I(v->state));
|
||||
k1 = num_to_long(reduce_to) - v->nt_base;
|
||||
|
|
|
@ -170,12 +170,12 @@ readline_attempted_completion_function(const char *text, int start, int end)
|
|||
ary = rb_funcall(proc, rb_intern("call"), 1, rb_tainted_str_new2(text));
|
||||
if (TYPE(ary) != T_ARRAY)
|
||||
ary = rb_Array(ary);
|
||||
matches = RARRAY(ary)->len;
|
||||
matches = RARRAY_LEN(ary);
|
||||
if (matches == 0)
|
||||
return NULL;
|
||||
result = ALLOC_N(char *, matches + 2);
|
||||
for (i = 0; i < matches; i++) {
|
||||
temp = rb_obj_as_string(RARRAY(ary)->ptr[i]);
|
||||
temp = rb_obj_as_string(RARRAY_PTR(ary)[i]);
|
||||
result[i + 1] = ALLOC_N(char, RSTRING_LEN(temp) + 1);
|
||||
strcpy(result[i + 1], RSTRING_PTR(temp));
|
||||
}
|
||||
|
@ -661,7 +661,7 @@ filename_completion_proc_call(VALUE self, VALUE str)
|
|||
free(matches[i]);
|
||||
}
|
||||
free(matches);
|
||||
if (RARRAY(result)->len >= 2)
|
||||
if (RARRAY_LEN(result) >= 2)
|
||||
rb_ary_shift(result);
|
||||
}
|
||||
else {
|
||||
|
@ -686,7 +686,7 @@ username_completion_proc_call(VALUE self, VALUE str)
|
|||
free(matches[i]);
|
||||
}
|
||||
free(matches);
|
||||
if (RARRAY(result)->len >= 2)
|
||||
if (RARRAY_LEN(result) >= 2)
|
||||
rb_ary_shift(result);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -323,8 +323,8 @@ fsdbm_delete_if(VALUE obj)
|
|||
GetDBM2(obj, dbmp, dbm);
|
||||
}
|
||||
|
||||
for (i = 0; i < RARRAY(ary)->len; i++) {
|
||||
keystr = RARRAY(ary)->ptr[i];
|
||||
for (i = 0; i < RARRAY_LEN(ary); i++) {
|
||||
keystr = RARRAY_PTR(ary)[i];
|
||||
StringValue(keystr);
|
||||
key.dptr = RSTRING_PTR(keystr);
|
||||
key.dsize = RSTRING_LEN(keystr);
|
||||
|
@ -333,7 +333,7 @@ fsdbm_delete_if(VALUE obj)
|
|||
}
|
||||
}
|
||||
if (status) rb_jump_tag(status);
|
||||
if (n > 0) dbmp->di_size = n - RARRAY(ary)->len;
|
||||
if (n > 0) dbmp->di_size = n - RARRAY_LEN(ary);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
@ -416,10 +416,10 @@ static VALUE
|
|||
update_i(VALUE pair, VALUE dbm)
|
||||
{
|
||||
Check_Type(pair, T_ARRAY);
|
||||
if (RARRAY(pair)->len < 2) {
|
||||
if (RARRAY_LEN(pair) < 2) {
|
||||
rb_raise(rb_eArgError, "pair must be [key, value]");
|
||||
}
|
||||
fsdbm_store(dbm, RARRAY(pair)->ptr[0], RARRAY(pair)->ptr[1]);
|
||||
fsdbm_store(dbm, RARRAY_PTR(pair)[0], RARRAY_PTR(pair)[1]);
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
|
|
|
@ -2991,7 +2991,7 @@ make_addrinfo(struct addrinfo *res0)
|
|||
for (res = res0; res; res = res->ai_next) {
|
||||
ary = ipaddr(res->ai_addr, do_not_reverse_lookup);
|
||||
if (res->ai_canonname) {
|
||||
RARRAY(ary)->ptr[2] = rb_str_new2(res->ai_canonname);
|
||||
RARRAY_PTR(ary)[2] = rb_str_new2(res->ai_canonname);
|
||||
}
|
||||
rb_ary_push(ary, INT2FIX(res->ai_family));
|
||||
rb_ary_push(ary, INT2FIX(res->ai_socktype));
|
||||
|
@ -3232,17 +3232,17 @@ sock_s_getnameinfo(int argc, VALUE *argv)
|
|||
if (!NIL_P(tmp)) {
|
||||
sa = tmp;
|
||||
MEMZERO(&hints, struct addrinfo, 1);
|
||||
if (RARRAY(sa)->len == 3) {
|
||||
af = RARRAY(sa)->ptr[0];
|
||||
port = RARRAY(sa)->ptr[1];
|
||||
host = RARRAY(sa)->ptr[2];
|
||||
if (RARRAY_LEN(sa) == 3) {
|
||||
af = RARRAY_PTR(sa)[0];
|
||||
port = RARRAY_PTR(sa)[1];
|
||||
host = RARRAY_PTR(sa)[2];
|
||||
}
|
||||
else if (RARRAY(sa)->len >= 4) {
|
||||
af = RARRAY(sa)->ptr[0];
|
||||
port = RARRAY(sa)->ptr[1];
|
||||
host = RARRAY(sa)->ptr[3];
|
||||
else if (RARRAY_LEN(sa) >= 4) {
|
||||
af = RARRAY_PTR(sa)[0];
|
||||
port = RARRAY_PTR(sa)[1];
|
||||
host = RARRAY_PTR(sa)[3];
|
||||
if (NIL_P(host)) {
|
||||
host = RARRAY(sa)->ptr[2];
|
||||
host = RARRAY_PTR(sa)[2];
|
||||
}
|
||||
else {
|
||||
/*
|
||||
|
@ -3256,7 +3256,7 @@ sock_s_getnameinfo(int argc, VALUE *argv)
|
|||
}
|
||||
else {
|
||||
rb_raise(rb_eArgError, "array size should be 3 or 4, %ld given",
|
||||
RARRAY(sa)->len);
|
||||
RARRAY_LEN(sa));
|
||||
}
|
||||
/* host */
|
||||
if (NIL_P(host)) {
|
||||
|
|
|
@ -1023,7 +1023,7 @@ syck_const_find(VALUE const_name)
|
|||
VALUE tclass = rb_cObject;
|
||||
VALUE tparts = rb_str_split( const_name, "::" );
|
||||
int i = 0;
|
||||
for ( i = 0; i < RARRAY(tparts)->len; i++ ) {
|
||||
for ( i = 0; i < RARRAY_LEN(tparts); i++ ) {
|
||||
VALUE tpart = rb_to_id( rb_ary_entry( tparts, i ) );
|
||||
if ( !rb_const_defined( tclass, tpart ) ) return Qnil;
|
||||
tclass = rb_const_get( tclass, tpart );
|
||||
|
@ -1059,7 +1059,7 @@ syck_resolver_transfer(VALUE self, VALUE type, VALUE val)
|
|||
VALUE subclass_parts = rb_ary_new();
|
||||
VALUE parts = rb_str_split( type, ":" );
|
||||
|
||||
while ( RARRAY(parts)->len > 1 )
|
||||
while ( RARRAY_LEN(parts) > 1 )
|
||||
{
|
||||
VALUE partial;
|
||||
rb_ary_unshift( subclass_parts, rb_ary_pop( parts ) );
|
||||
|
@ -1077,7 +1077,7 @@ syck_resolver_transfer(VALUE self, VALUE type, VALUE val)
|
|||
if ( ! NIL_P( target_class ) )
|
||||
{
|
||||
subclass = target_class;
|
||||
if ( RARRAY(subclass_parts)->len > 0 && rb_respond_to( target_class, s_tag_subclasses ) &&
|
||||
if ( RARRAY_LEN(subclass_parts) > 0 && rb_respond_to( target_class, s_tag_subclasses ) &&
|
||||
RTEST( rb_funcall( target_class, s_tag_subclasses, 0 ) ) )
|
||||
{
|
||||
VALUE subclass_v;
|
||||
|
@ -1502,7 +1502,7 @@ syck_seq_value_set(VALUE self, VALUE val)
|
|||
if ( !NIL_P( val ) ) {
|
||||
int i;
|
||||
syck_seq_empty( node );
|
||||
for ( i = 0; i < RARRAY( val )->len; i++ )
|
||||
for ( i = 0; i < RARRAY_LEN( val ); i++ )
|
||||
{
|
||||
syck_seq_add( node, rb_ary_entry(val, i) );
|
||||
}
|
||||
|
@ -1587,7 +1587,7 @@ syck_map_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style)
|
|||
}
|
||||
|
||||
keys = rb_funcall( hsh, s_keys, 0 );
|
||||
for ( i = 0; i < RARRAY(keys)->len; i++ )
|
||||
for ( i = 0; i < RARRAY_LEN(keys); i++ )
|
||||
{
|
||||
VALUE key = rb_ary_entry(keys, i);
|
||||
syck_map_add( node, key, rb_hash_aref(hsh, key) );
|
||||
|
@ -1622,7 +1622,7 @@ syck_map_value_set(VALUE self, VALUE val)
|
|||
|
||||
syck_map_empty( node );
|
||||
keys = rb_funcall( hsh, s_keys, 0 );
|
||||
for ( i = 0; i < RARRAY(keys)->len; i++ )
|
||||
for ( i = 0; i < RARRAY_LEN(keys); i++ )
|
||||
{
|
||||
VALUE key = rb_ary_entry(keys, i);
|
||||
syck_map_add( node, key, rb_hash_aref(hsh, key) );
|
||||
|
|
|
@ -1133,15 +1133,15 @@ set_max_block_time(self, time)
|
|||
case T_BIGNUM:
|
||||
/* time is micro-second value */
|
||||
divmod = rb_funcall(time, rb_intern("divmod"), 1, LONG2NUM(1000000));
|
||||
tcl_time.sec = NUM2LONG(RARRAY(divmod)->ptr[0]);
|
||||
tcl_time.usec = NUM2LONG(RARRAY(divmod)->ptr[1]);
|
||||
tcl_time.sec = NUM2LONG(RARRAY_PTR(divmod)[0]);
|
||||
tcl_time.usec = NUM2LONG(RARRAY_PTR(divmod)[1]);
|
||||
break;
|
||||
|
||||
case T_FLOAT:
|
||||
/* time is second value */
|
||||
divmod = rb_funcall(time, rb_intern("divmod"), 1, INT2FIX(1));
|
||||
tcl_time.sec = NUM2LONG(RARRAY(divmod)->ptr[0]);
|
||||
tcl_time.usec = (long)(NUM2DBL(RARRAY(divmod)->ptr[1]) * 1000000);
|
||||
tcl_time.sec = NUM2LONG(RARRAY_PTR(divmod)[0]);
|
||||
tcl_time.usec = (long)(NUM2DBL(RARRAY_PTR(divmod)[1]) * 1000000);
|
||||
|
||||
default:
|
||||
{
|
||||
|
@ -2595,15 +2595,14 @@ ip_ruby_cmd(clientData, interp, argc, argv)
|
|||
|
||||
/* get args */
|
||||
args = rb_ary_new2(argc - 2);
|
||||
RARRAY(args)->len = 0;
|
||||
for(i = 3; i < argc; i++) {
|
||||
#if TCL_MAJOR_VERSION >= 8
|
||||
str = Tcl_GetStringFromObj(argv[i], &len);
|
||||
DUMP2("arg:%s",str);
|
||||
RARRAY(args)->ptr[RARRAY(args)->len++] = rb_tainted_str_new(str, len);
|
||||
rb_ary_push(args, rb_tainted_str_new(str, len));
|
||||
#else /* TCL_MAJOR_VERSION < 8 */
|
||||
DUMP2("arg:%s",argv[i]);
|
||||
RARRAY(args)->ptr[RARRAY(args)->len++] = rb_tainted_str_new2(argv[i]);
|
||||
rb_ary_push(args, rb_tainted_str_new2(argv[i]));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -5516,7 +5515,7 @@ call_queue_handler(evPtr, flags)
|
|||
}
|
||||
|
||||
/* set result */
|
||||
RARRAY(q->result)->ptr[0] = ret;
|
||||
RARRAY_PTR(q->result)[0] = ret;
|
||||
|
||||
/* complete */
|
||||
*(q->done) = -1;
|
||||
|
@ -5586,8 +5585,8 @@ tk_funcall(func, argc, argv, obj)
|
|||
|
||||
/* allocate result obj */
|
||||
result = rb_ary_new2(1);
|
||||
RARRAY(result)->ptr[0] = Qnil;
|
||||
RARRAY(result)->len = 1;
|
||||
RARRAY_PTR(result)[0] = Qnil;
|
||||
RARRAY_LEN(result) = 1;
|
||||
|
||||
/* construct event data */
|
||||
callq->done = alloc_done;
|
||||
|
@ -5614,7 +5613,7 @@ tk_funcall(func, argc, argv, obj)
|
|||
DUMP2("back from handler (current thread:%lx)", current);
|
||||
|
||||
/* get result & free allocated memory */
|
||||
ret = RARRAY(result)->ptr[0];
|
||||
ret = RARRAY_PTR(result)[0];
|
||||
free(alloc_done);
|
||||
if (argv) free(argv);
|
||||
|
||||
|
@ -5834,7 +5833,7 @@ eval_queue_handler(evPtr, flags)
|
|||
}
|
||||
|
||||
/* set result */
|
||||
RARRAY(q->result)->ptr[0] = ret;
|
||||
RARRAY_PTR(q->result)[0] = ret;
|
||||
|
||||
/* complete */
|
||||
*(q->done) = -1;
|
||||
|
@ -5901,8 +5900,8 @@ ip_eval(self, str)
|
|||
|
||||
/* allocate result obj */
|
||||
result = rb_ary_new2(1);
|
||||
RARRAY(result)->ptr[0] = Qnil;
|
||||
RARRAY(result)->len = 1;
|
||||
RARRAY_PTR(result)[0] = Qnil;
|
||||
RARRAY_LEN(result) = 1;
|
||||
|
||||
/* construct event data */
|
||||
evq->done = alloc_done;
|
||||
|
@ -5930,7 +5929,7 @@ ip_eval(self, str)
|
|||
DUMP2("back from handler (current thread:%lx)", current);
|
||||
|
||||
/* get result & free allocated memory */
|
||||
ret = RARRAY(result)->ptr[0];
|
||||
ret = RARRAY_PTR(result)[0];
|
||||
|
||||
free(alloc_done);
|
||||
free(eval_str);
|
||||
|
@ -6911,7 +6910,7 @@ invoke_queue_handler(evPtr, flags)
|
|||
}
|
||||
|
||||
/* set result */
|
||||
RARRAY(q->result)->ptr[0] = ret;
|
||||
RARRAY_PTR(q->result)[0] = ret;
|
||||
|
||||
/* complete */
|
||||
*(q->done) = -1;
|
||||
|
@ -6981,8 +6980,8 @@ ip_invoke_with_position(argc, argv, obj, position)
|
|||
|
||||
/* allocate result obj */
|
||||
result = rb_ary_new2(1);
|
||||
RARRAY(result)->ptr[0] = Qnil;
|
||||
RARRAY(result)->len = 1;
|
||||
RARRAY_PTR(result)[0] = Qnil;
|
||||
RARRAY_LEN(result) = 1;
|
||||
|
||||
/* construct event data */
|
||||
ivq->done = alloc_done;
|
||||
|
@ -7008,7 +7007,7 @@ ip_invoke_with_position(argc, argv, obj, position)
|
|||
DUMP2("back from handler (current thread:%lx)", current);
|
||||
|
||||
/* get result & free allocated memory */
|
||||
ret = RARRAY(result)->ptr[0];
|
||||
ret = RARRAY_PTR(result)[0];
|
||||
free(alloc_done);
|
||||
|
||||
Tcl_Release(ivq);
|
||||
|
@ -7535,11 +7534,9 @@ lib_split_tklist_core(ip_obj, list_str)
|
|||
for(idx = 0; idx < objc; idx++) {
|
||||
elem = get_str_from_obj(objv[idx]);
|
||||
if (taint_flag) OBJ_TAINT(elem);
|
||||
RARRAY(ary)->ptr[idx] = elem;
|
||||
rb_ary_push(ary, elem);
|
||||
}
|
||||
|
||||
RARRAY(ary)->len = objc;
|
||||
|
||||
if (old_gc == Qfalse) rb_gc_enable();
|
||||
|
||||
rb_thread_critical = thr_crit_bup;
|
||||
|
@ -7576,10 +7573,8 @@ lib_split_tklist_core(ip_obj, list_str)
|
|||
elem = rb_str_new2(argv[idx]);
|
||||
}
|
||||
/* rb_ivar_set(elem, ID_at_enc, rb_str_new2("binary")); */
|
||||
RARRAY(ary)->ptr[idx] = elem;
|
||||
rb_ary_push(ary, elem);
|
||||
}
|
||||
RARRAY(ary)->len = argc;
|
||||
|
||||
if (old_gc == Qfalse) rb_gc_enable();
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -863,7 +863,7 @@ ole_val2variant(VALUE val, VARIANT *var)
|
|||
val1 = val;
|
||||
i = 0;
|
||||
while(TYPE(val1) == T_ARRAY) {
|
||||
psab[i].cElements = RARRAY(val1)->len;
|
||||
psab[i].cElements = RARRAY_LEN(val1);
|
||||
psab[i].lLbound = 0;
|
||||
pub[i] = psab[i].cElements;
|
||||
pid[i] = 0;
|
||||
|
@ -1113,7 +1113,7 @@ ole_val2olevariantdata(VALUE val, VARTYPE vtype, struct olevariantdata *pvar)
|
|||
val1 = val;
|
||||
i = 0;
|
||||
while(TYPE(val1) == T_ARRAY) {
|
||||
psab[i].cElements = RARRAY(val1)->len;
|
||||
psab[i].cElements = RARRAY_LEN(val1);
|
||||
psab[i].lLbound = 0;
|
||||
pub[i] = psab[i].cElements;
|
||||
pid[i] = 0;
|
||||
|
@ -2544,7 +2544,7 @@ ole_invoke2(VALUE self, VALUE dispid, VALUE args, VALUE types, USHORT dispkind)
|
|||
VariantInit(&result);
|
||||
OLEData_Get_Struct(self, pole);
|
||||
|
||||
dispParams.cArgs = RARRAY(args)->len;
|
||||
dispParams.cArgs = RARRAY_LEN(args);
|
||||
dispParams.rgvarg = ALLOCA_N(VARIANTARG, dispParams.cArgs);
|
||||
realargs = ALLOCA_N(VARIANTARG, dispParams.cArgs);
|
||||
for (i = 0, j = dispParams.cArgs - 1; i < (int)dispParams.cArgs; i++, j--)
|
||||
|
@ -2575,7 +2575,7 @@ ole_invoke2(VALUE self, VALUE dispid, VALUE args, VALUE types, USHORT dispkind)
|
|||
SAFEARRAYBOUND rgsabound[1];
|
||||
Check_Type(param, T_ARRAY);
|
||||
rgsabound[0].lLbound = 0;
|
||||
rgsabound[0].cElements = RARRAY(param)->len;
|
||||
rgsabound[0].cElements = RARRAY_LEN(param);
|
||||
v = vt & ~(VT_ARRAY | VT_BYREF);
|
||||
V_ARRAY(&realargs[i]) = SafeArrayCreate(v, 1, rgsabound);
|
||||
V_VT(&realargs[i]) = VT_ARRAY | v;
|
||||
|
@ -4060,7 +4060,7 @@ foletypelib_initialize(VALUE self, VALUE args)
|
|||
VALUE retval;
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
len = RARRAY(args)->len;
|
||||
len = RARRAY_LEN(args);
|
||||
if (len < 1 || len > 3) {
|
||||
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1..3)", len);
|
||||
}
|
||||
|
@ -6233,7 +6233,7 @@ ole_search_event_at(VALUE ary, VALUE ev)
|
|||
long i, len;
|
||||
long ret = -1;
|
||||
def_event = Qnil;
|
||||
len = RARRAY(ary)->len;
|
||||
len = RARRAY_LEN(ary);
|
||||
for(i = 0; i < len; i++) {
|
||||
event = rb_ary_entry(ary, i);
|
||||
event_name = rb_ary_entry(event, 1);
|
||||
|
@ -6260,7 +6260,7 @@ ole_search_event(VALUE ary, VALUE ev, BOOL *is_default)
|
|||
int i, len;
|
||||
*is_default = FALSE;
|
||||
def_event = Qnil;
|
||||
len = RARRAY(ary)->len;
|
||||
len = RARRAY_LEN(ary);
|
||||
for(i = 0; i < len; i++) {
|
||||
event = rb_ary_entry(ary, i);
|
||||
event_name = rb_ary_entry(event, 1);
|
||||
|
@ -6283,7 +6283,7 @@ ary2ptr_dispparams(VALUE ary, DISPPARAMS *pdispparams)
|
|||
int i;
|
||||
VALUE v;
|
||||
VARIANT *pvar;
|
||||
for(i = 0; i < RARRAY(ary)->len && (unsigned int) i < pdispparams->cArgs; i++) {
|
||||
for(i = 0; i < RARRAY_LEN(ary) && (unsigned int) i < pdispparams->cArgs; i++) {
|
||||
v = rb_ary_entry(ary, i);
|
||||
pvar = &pdispparams->rgvarg[pdispparams->cArgs-i-1];
|
||||
ole_val2ptr_variant(v, pvar);
|
||||
|
@ -6825,7 +6825,7 @@ folevariant_initialize(VALUE self, VALUE args)
|
|||
VARTYPE vt;
|
||||
struct olevariantdata *pvar;
|
||||
|
||||
len = RARRAY(args)->len;
|
||||
len = RARRAY_LEN(args);
|
||||
if (len < 1 || len > 3) {
|
||||
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1..3)", len);
|
||||
}
|
||||
|
|
29
file.c
29
file.c
|
@ -125,15 +125,14 @@ apply2files(void (*func)(const char *, void *), VALUE vargs, void *arg)
|
|||
{
|
||||
long i;
|
||||
VALUE path;
|
||||
struct RArray *args = RARRAY(vargs);
|
||||
|
||||
rb_secure(4);
|
||||
for (i=0; i<args->len; i++) {
|
||||
path = rb_get_path(args->ptr[i]);
|
||||
for (i=0; i<RARRAY_LEN(vargs); i++) {
|
||||
path = rb_get_path(RARRAY_PTR(vargs)[i]);
|
||||
(*func)(StringValueCStr(path), arg);
|
||||
}
|
||||
|
||||
return args->len;
|
||||
return RARRAY_LEN(vargs);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2875,12 +2874,12 @@ rb_file_join(VALUE ary, VALUE sep)
|
|||
VALUE result, tmp;
|
||||
char *name, *tail;
|
||||
|
||||
if (RARRAY(ary)->len == 0) return rb_str_new(0, 0);
|
||||
if (RARRAY_LEN(ary) == 0) return rb_str_new(0, 0);
|
||||
|
||||
len = 1;
|
||||
for (i=0; i<RARRAY(ary)->len; i++) {
|
||||
if (TYPE(RARRAY(ary)->ptr[i]) == T_STRING) {
|
||||
len += RSTRING_LEN(RARRAY(ary)->ptr[i]);
|
||||
for (i=0; i<RARRAY_LEN(ary); i++) {
|
||||
if (TYPE(RARRAY_PTR(ary)[i]) == T_STRING) {
|
||||
len += RSTRING_LEN(RARRAY_PTR(ary)[i]);
|
||||
}
|
||||
else {
|
||||
len += 10;
|
||||
|
@ -2888,12 +2887,12 @@ rb_file_join(VALUE ary, VALUE sep)
|
|||
}
|
||||
if (!NIL_P(sep)) {
|
||||
StringValue(sep);
|
||||
len += RSTRING_LEN(sep) * RARRAY(ary)->len - 1;
|
||||
len += RSTRING_LEN(sep) * RARRAY_LEN(ary) - 1;
|
||||
}
|
||||
result = rb_str_buf_new(len);
|
||||
OBJ_INFECT(result, ary);
|
||||
for (i=0; i<RARRAY(ary)->len; i++) {
|
||||
tmp = RARRAY(ary)->ptr[i];
|
||||
for (i=0; i<RARRAY_LEN(ary); i++) {
|
||||
tmp = RARRAY_PTR(ary)[i];
|
||||
switch (TYPE(tmp)) {
|
||||
case T_STRING:
|
||||
break;
|
||||
|
@ -4174,8 +4173,8 @@ rb_find_file_ext(VALUE *filep, const char *const *ext)
|
|||
if (!rb_load_path) return 0;
|
||||
|
||||
Check_Type(rb_load_path, T_ARRAY);
|
||||
for (i=0;i<RARRAY(rb_load_path)->len;i++) {
|
||||
VALUE str = RARRAY(rb_load_path)->ptr[i];
|
||||
for (i=0;i<RARRAY_LEN(rb_load_path);i++) {
|
||||
VALUE str = RARRAY_PTR(rb_load_path)[i];
|
||||
|
||||
FilePathValue(str);
|
||||
if (RSTRING_LEN(str) == 0) continue;
|
||||
|
@ -4235,8 +4234,8 @@ rb_find_file(VALUE path)
|
|||
|
||||
Check_Type(rb_load_path, T_ARRAY);
|
||||
tmp = rb_ary_new();
|
||||
for (i=0;i<RARRAY(rb_load_path)->len;i++) {
|
||||
VALUE str = RARRAY(rb_load_path)->ptr[i];
|
||||
for (i=0;i<RARRAY_LEN(rb_load_path);i++) {
|
||||
VALUE str = RARRAY_PTR(rb_load_path)[i];
|
||||
FilePathValue(str);
|
||||
if (RSTRING_LEN(str) > 0) {
|
||||
rb_ary_push(tmp, str);
|
||||
|
|
28
gc.c
28
gc.c
|
@ -926,12 +926,12 @@ gc_mark_children(VALUE ptr, int lev)
|
|||
|
||||
case T_ARRAY:
|
||||
if (FL_TEST(obj, ELTS_SHARED)) {
|
||||
ptr = obj->as.array.aux.shared;
|
||||
ptr = obj->as.array.as.heap.aux.shared;
|
||||
goto again;
|
||||
}
|
||||
else {
|
||||
long i, len = obj->as.array.len;
|
||||
VALUE *ptr = obj->as.array.ptr;
|
||||
long i, len = RARRAY_LEN(obj);
|
||||
VALUE *ptr = RARRAY_PTR(obj);
|
||||
|
||||
for (i=0; i < len; i++) {
|
||||
gc_mark(*ptr++, lev);
|
||||
|
@ -945,9 +945,8 @@ gc_mark_children(VALUE ptr, int lev)
|
|||
goto again;
|
||||
|
||||
case T_STRING:
|
||||
#define STR_NOEMBED FL_USER1 /* copied from string.c */
|
||||
#define STR_ASSOC FL_USER3 /* copied from string.c */
|
||||
if (FL_TEST(obj, STR_NOEMBED) && FL_ANY(obj, ELTS_SHARED|STR_ASSOC)) {
|
||||
if (FL_TEST(obj, RSTRING_NOEMBED) && FL_ANY(obj, ELTS_SHARED|STR_ASSOC)) {
|
||||
ptr = obj->as.string.as.heap.aux.shared;
|
||||
goto again;
|
||||
}
|
||||
|
@ -1175,14 +1174,15 @@ obj_free(VALUE obj)
|
|||
}
|
||||
break;
|
||||
case T_STRING:
|
||||
if (FL_TEST(obj, STR_NOEMBED) &&
|
||||
if (FL_TEST(obj, RSTRING_NOEMBED) &&
|
||||
RANY(obj)->as.string.as.heap.ptr && !FL_TEST(obj, ELTS_SHARED)) {
|
||||
RUBY_CRITICAL(free(RANY(obj)->as.string.as.heap.ptr));
|
||||
}
|
||||
break;
|
||||
case T_ARRAY:
|
||||
if (RANY(obj)->as.array.ptr && !FL_TEST(obj, ELTS_SHARED)) {
|
||||
RUBY_CRITICAL(free(RANY(obj)->as.array.ptr));
|
||||
if (FL_TEST(obj, RARRAY_NOEMBED) &&
|
||||
RANY(obj)->as.array.as.heap.ptr && !FL_TEST(obj, ELTS_SHARED)) {
|
||||
RUBY_CRITICAL(free(RANY(obj)->as.array.as.heap.ptr));
|
||||
}
|
||||
break;
|
||||
case T_HASH:
|
||||
|
@ -1833,17 +1833,17 @@ run_final(VALUE obj)
|
|||
rb_thread_critical = Qtrue;
|
||||
args[1] = 0;
|
||||
args[2] = (VALUE)ruby_safe_level;
|
||||
for (i=0; i<RARRAY(finalizers)->len; i++) {
|
||||
args[0] = RARRAY(finalizers)->ptr[i];
|
||||
for (i=0; i<RARRAY_LEN(finalizers); i++) {
|
||||
args[0] = RARRAY_PTR(finalizers)[i];
|
||||
if (!args[1]) args[1] = rb_ary_new3(1, objid);
|
||||
rb_protect((VALUE(*)(VALUE))run_single_final, (VALUE)args, &status);
|
||||
}
|
||||
if (finalizer_table && st_delete(finalizer_table, (st_data_t*)&obj, &table)) {
|
||||
for (i=0; i<RARRAY(table)->len; i++) {
|
||||
VALUE final = RARRAY(table)->ptr[i];
|
||||
args[0] = RARRAY(final)->ptr[1];
|
||||
for (i=0; i<RARRAY_LEN(table); i++) {
|
||||
VALUE final = RARRAY_PTR(table)[i];
|
||||
args[0] = RARRAY_PTR(final)[1];
|
||||
if (!args[1]) args[1] = rb_ary_new3(1, objid);
|
||||
args[2] = FIX2INT(RARRAY(final)->ptr[0]);
|
||||
args[2] = FIX2INT(RARRAY_PTR(final)[0]);
|
||||
rb_protect((VALUE(*)(VALUE))run_single_final, (VALUE)args, &status);
|
||||
}
|
||||
}
|
||||
|
|
34
hash.c
34
hash.c
|
@ -1828,8 +1828,8 @@ env_each_key(VALUE ehash)
|
|||
RETURN_ENUMERATOR(ehash, 0, 0);
|
||||
rb_secure(4);
|
||||
keys = env_keys();
|
||||
for (i=0; i<RARRAY(keys)->len; i++) {
|
||||
rb_yield(RARRAY(keys)->ptr[i]);
|
||||
for (i=0; i<RARRAY_LEN(keys); i++) {
|
||||
rb_yield(RARRAY_PTR(keys)[i]);
|
||||
}
|
||||
return ehash;
|
||||
}
|
||||
|
@ -1863,8 +1863,8 @@ env_each_value(VALUE ehash)
|
|||
RETURN_ENUMERATOR(ehash, 0, 0);
|
||||
rb_secure(4);
|
||||
values = env_values();
|
||||
for (i=0; i<RARRAY(values)->len; i++) {
|
||||
rb_yield(RARRAY(values)->ptr[i]);
|
||||
for (i=0; i<RARRAY_LEN(values); i++) {
|
||||
rb_yield(RARRAY_PTR(values)[i]);
|
||||
}
|
||||
return ehash;
|
||||
}
|
||||
|
@ -1889,12 +1889,12 @@ env_each_i(VALUE ehash, int values)
|
|||
}
|
||||
FREE_ENVIRON(environ);
|
||||
|
||||
for (i=0; i<RARRAY(ary)->len; i+=2) {
|
||||
for (i=0; i<RARRAY_LEN(ary); i+=2) {
|
||||
if (values) {
|
||||
rb_yield_values(2, RARRAY(ary)->ptr[i], RARRAY(ary)->ptr[i+1]);
|
||||
rb_yield_values(2, RARRAY_PTR(ary)[i], RARRAY_PTR(ary)[i+1]);
|
||||
}
|
||||
else {
|
||||
rb_yield(rb_assoc_new(RARRAY(ary)->ptr[i], RARRAY(ary)->ptr[i+1]));
|
||||
rb_yield(rb_assoc_new(RARRAY_PTR(ary)[i], RARRAY_PTR(ary)[i+1]));
|
||||
}
|
||||
}
|
||||
return ehash;
|
||||
|
@ -1923,12 +1923,12 @@ env_reject_bang(void)
|
|||
|
||||
rb_secure(4);
|
||||
keys = env_keys();
|
||||
for (i=0; i<RARRAY(keys)->len; i++) {
|
||||
VALUE val = rb_f_getenv(Qnil, RARRAY(keys)->ptr[i]);
|
||||
for (i=0; i<RARRAY_LEN(keys); i++) {
|
||||
VALUE val = rb_f_getenv(Qnil, RARRAY_PTR(keys)[i]);
|
||||
if (!NIL_P(val)) {
|
||||
if (RTEST(rb_yield_values(2, RARRAY(keys)->ptr[i], val))) {
|
||||
FL_UNSET(RARRAY(keys)->ptr[i], FL_TAINT);
|
||||
env_delete(Qnil, RARRAY(keys)->ptr[i]);
|
||||
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]);
|
||||
del++;
|
||||
}
|
||||
}
|
||||
|
@ -1992,10 +1992,10 @@ env_clear(void)
|
|||
|
||||
rb_secure(4);
|
||||
keys = env_keys();
|
||||
for (i=0; i<RARRAY(keys)->len; i++) {
|
||||
VALUE val = rb_f_getenv(Qnil, RARRAY(keys)->ptr[i]);
|
||||
for (i=0; i<RARRAY_LEN(keys); i++) {
|
||||
VALUE val = rb_f_getenv(Qnil, RARRAY_PTR(keys)[i]);
|
||||
if (!NIL_P(val)) {
|
||||
env_delete(Qnil, RARRAY(keys)->ptr[i]);
|
||||
env_delete(Qnil, RARRAY_PTR(keys)[i]);
|
||||
}
|
||||
}
|
||||
return envtbl;
|
||||
|
@ -2239,8 +2239,8 @@ env_replace(VALUE env, VALUE hash)
|
|||
hash = to_hash(hash);
|
||||
rb_hash_foreach(hash, env_replace_i, keys);
|
||||
|
||||
for (i=0; i<RARRAY(keys)->len; i++) {
|
||||
env_delete(env, RARRAY(keys)->ptr[i]);
|
||||
for (i=0; i<RARRAY_LEN(keys); i++) {
|
||||
env_delete(env, RARRAY_PTR(keys)[i]);
|
||||
}
|
||||
return env;
|
||||
}
|
||||
|
|
46
io.c
46
io.c
|
@ -3163,10 +3163,10 @@ rb_io_s_popen(int argc, VALUE *argv, VALUE klass)
|
|||
}
|
||||
tmp = rb_check_array_type(pname);
|
||||
if (!NIL_P(tmp)) {
|
||||
VALUE *argv = ALLOCA_N(VALUE, RARRAY(tmp)->len);
|
||||
VALUE *argv = ALLOCA_N(VALUE, RARRAY_LEN(tmp));
|
||||
|
||||
MEMCPY(argv, RARRAY(tmp)->ptr, VALUE, RARRAY(tmp)->len);
|
||||
port = pipe_open(RARRAY(tmp)->len, argv, mode);
|
||||
MEMCPY(argv, RARRAY_PTR(tmp), VALUE, RARRAY_LEN(tmp));
|
||||
port = pipe_open(RARRAY_LEN(tmp), argv, mode);
|
||||
pname = tmp;
|
||||
}
|
||||
else {
|
||||
|
@ -3784,8 +3784,8 @@ io_puts_ary(VALUE ary, VALUE out, int recur)
|
|||
VALUE tmp;
|
||||
long i;
|
||||
|
||||
for (i=0; i<RARRAY(ary)->len; i++) {
|
||||
tmp = RARRAY(ary)->ptr[i];
|
||||
for (i=0; i<RARRAY_LEN(ary); i++) {
|
||||
tmp = RARRAY_PTR(ary)[i];
|
||||
if (recur) {
|
||||
tmp = rb_str_new2("[...]");
|
||||
}
|
||||
|
@ -4233,7 +4233,7 @@ next_argv(void)
|
|||
}
|
||||
|
||||
if (init_p == 0) {
|
||||
if (RARRAY(rb_argv)->len > 0) {
|
||||
if (RARRAY_LEN(rb_argv) > 0) {
|
||||
next_p = 1;
|
||||
}
|
||||
else {
|
||||
|
@ -4246,7 +4246,7 @@ next_argv(void)
|
|||
if (next_p == 1) {
|
||||
next_p = 0;
|
||||
retry:
|
||||
if (RARRAY(rb_argv)->len > 0) {
|
||||
if (RARRAY_LEN(rb_argv) > 0) {
|
||||
filename = rb_ary_shift(rb_argv);
|
||||
fn = StringValuePtr(filename);
|
||||
if (strlen(fn) == 1 && fn[0] == '-') {
|
||||
|
@ -4549,8 +4549,8 @@ 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(read)->len; i++) {
|
||||
GetOpenFile(rb_io_get_io(RARRAY(read)->ptr[i]), fptr);
|
||||
for (i=0; i<RARRAY_LEN(read); i++) {
|
||||
GetOpenFile(rb_io_get_io(RARRAY_PTR(read)[i]), fptr);
|
||||
rb_fd_set(fptr->fd, &fds[0]);
|
||||
if (READ_DATA_PENDING(fptr)) { /* check for buffered data */
|
||||
pending++;
|
||||
|
@ -4569,8 +4569,8 @@ 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(write)->len; i++) {
|
||||
GetOpenFile(rb_io_get_io(RARRAY(write)->ptr[i]), fptr);
|
||||
for (i=0; i<RARRAY_LEN(write); i++) {
|
||||
GetOpenFile(rb_io_get_io(RARRAY_PTR(write)[i]), fptr);
|
||||
rb_fd_set(fptr->fd, &fds[1]);
|
||||
if (max < fptr->fd) max = fptr->fd;
|
||||
}
|
||||
|
@ -4581,8 +4581,8 @@ 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(except)->len; i++) {
|
||||
GetOpenFile(rb_io_get_io(RARRAY(except)->ptr[i]), fptr);
|
||||
for (i=0; i<RARRAY_LEN(except); i++) {
|
||||
GetOpenFile(rb_io_get_io(RARRAY_PTR(except)[i]), fptr);
|
||||
rb_fd_set(fptr->fd, &fds[2]);
|
||||
if (max < fptr->fd) max = fptr->fd;
|
||||
}
|
||||
|
@ -4607,9 +4607,9 @@ select_internal(VALUE read, VALUE write, VALUE except, struct timeval *tp, rb_fd
|
|||
|
||||
if (interrupt_flag == 0) {
|
||||
if (rp) {
|
||||
list = RARRAY(res)->ptr[0];
|
||||
for (i=0; i< RARRAY(read)->len; i++) {
|
||||
GetOpenFile(rb_io_get_io(RARRAY(read)->ptr[i]), fptr);
|
||||
list = RARRAY_PTR(res)[0];
|
||||
for (i=0; i< RARRAY_LEN(read); i++) {
|
||||
GetOpenFile(rb_io_get_io(RARRAY_PTR(read)[i]), fptr);
|
||||
if (rb_fd_isset(fptr->fd, &fds[0]) ||
|
||||
rb_fd_isset(fptr->fd, &fds[3])) {
|
||||
rb_ary_push(list, rb_ary_entry(read, i));
|
||||
|
@ -4618,9 +4618,9 @@ select_internal(VALUE read, VALUE write, VALUE except, struct timeval *tp, rb_fd
|
|||
}
|
||||
|
||||
if (wp) {
|
||||
list = RARRAY(res)->ptr[1];
|
||||
for (i=0; i< RARRAY(write)->len; i++) {
|
||||
GetOpenFile(rb_io_get_io(RARRAY(write)->ptr[i]), fptr);
|
||||
list = RARRAY_PTR(res)[1];
|
||||
for (i=0; i< RARRAY_LEN(write); i++) {
|
||||
GetOpenFile(rb_io_get_io(RARRAY_PTR(write)[i]), fptr);
|
||||
if (rb_fd_isset(fptr->fd, &fds[1])) {
|
||||
rb_ary_push(list, rb_ary_entry(write, i));
|
||||
}
|
||||
|
@ -4628,9 +4628,9 @@ select_internal(VALUE read, VALUE write, VALUE except, struct timeval *tp, rb_fd
|
|||
}
|
||||
|
||||
if (ep) {
|
||||
list = RARRAY(res)->ptr[2];
|
||||
for (i=0; i< RARRAY(except)->len; i++) {
|
||||
GetOpenFile(rb_io_get_io(RARRAY(except)->ptr[i]), fptr);
|
||||
list = RARRAY_PTR(res)[2];
|
||||
for (i=0; i< RARRAY_LEN(except); i++) {
|
||||
GetOpenFile(rb_io_get_io(RARRAY_PTR(except)[i]), fptr);
|
||||
if (rb_fd_isset(fptr->fd, &fds[2])) {
|
||||
rb_ary_push(list, rb_ary_entry(except, i));
|
||||
}
|
||||
|
@ -5328,7 +5328,7 @@ argf_readpartial(int argc, VALUE *argv)
|
|||
}
|
||||
argf_close(current_file);
|
||||
next_p = 1;
|
||||
if (RARRAY(rb_argv)->len == 0)
|
||||
if (RARRAY_LEN(rb_argv) == 0)
|
||||
rb_eof_error();
|
||||
if (NIL_P(str))
|
||||
str = rb_str_new(NULL, 0);
|
||||
|
|
14
marshal.c
14
marshal.c
|
@ -552,8 +552,8 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
|
|||
w_uclass(obj, rb_cArray, arg);
|
||||
w_byte(TYPE_ARRAY, arg);
|
||||
{
|
||||
long len = RARRAY(obj)->len;
|
||||
VALUE *ptr = RARRAY(obj)->ptr;
|
||||
long len = RARRAY_LEN(obj);
|
||||
VALUE *ptr = RARRAY_PTR(obj);
|
||||
|
||||
w_long(len, arg);
|
||||
while (len--) {
|
||||
|
@ -592,7 +592,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(mem)->ptr[i]), arg);
|
||||
w_symbol(SYM2ID(RARRAY_PTR(mem)[i]), arg);
|
||||
w_object(RSTRUCT_PTR(obj)[i], arg, limit);
|
||||
}
|
||||
}
|
||||
|
@ -963,7 +963,7 @@ r_object0(struct load_arg *arg, VALUE proc, int *ivp, VALUE extmod)
|
|||
rb_ary_push(extmod, m);
|
||||
|
||||
v = r_object0(arg, 0, 0, extmod);
|
||||
while (RARRAY(extmod)->len > 0) {
|
||||
while (RARRAY_LEN(extmod) > 0) {
|
||||
m = rb_ary_pop(extmod);
|
||||
rb_extend_object(v, m);
|
||||
}
|
||||
|
@ -1145,11 +1145,11 @@ r_object0(struct load_arg *arg, VALUE proc, int *ivp, VALUE extmod)
|
|||
for (i=0; i<len; i++) {
|
||||
slot = r_symbol(arg);
|
||||
|
||||
if (RARRAY(mem)->ptr[i] != ID2SYM(slot)) {
|
||||
if (RARRAY_PTR(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(mem)->ptr[i])));
|
||||
rb_id2name(SYM2ID(RARRAY_PTR(mem)[i])));
|
||||
}
|
||||
rb_struct_aset(v, LONG2FIX(i), r_object(arg));
|
||||
}
|
||||
|
@ -1182,7 +1182,7 @@ r_object0(struct load_arg *arg, VALUE proc, int *ivp, VALUE extmod)
|
|||
|
||||
v = rb_obj_alloc(klass);
|
||||
if (! NIL_P(extmod)) {
|
||||
while (RARRAY(extmod)->len > 0) {
|
||||
while (RARRAY_LEN(extmod) > 0) {
|
||||
VALUE m = rb_ary_pop(extmod);
|
||||
rb_extend_object(v, m);
|
||||
}
|
||||
|
|
|
@ -132,15 +132,15 @@ do_coerce(VALUE *x, VALUE *y, int err)
|
|||
a[0] = *x; a[1] = *y;
|
||||
|
||||
ary = rb_rescue(coerce_body, (VALUE)a, err?coerce_rescue:0, (VALUE)a);
|
||||
if (TYPE(ary) != T_ARRAY || RARRAY(ary)->len != 2) {
|
||||
if (TYPE(ary) != T_ARRAY || RARRAY_LEN(ary) != 2) {
|
||||
if (err) {
|
||||
rb_raise(rb_eTypeError, "coerce must return [x, y]");
|
||||
}
|
||||
return Qfalse;
|
||||
}
|
||||
|
||||
*x = RARRAY(ary)->ptr[0];
|
||||
*y = RARRAY(ary)->ptr[1];
|
||||
*x = RARRAY_PTR(ary)[0];
|
||||
*y = RARRAY_PTR(ary)[1];
|
||||
return Qtrue;
|
||||
}
|
||||
|
||||
|
|
8
object.c
8
object.c
|
@ -1057,13 +1057,13 @@ sym_call(VALUE args, VALUE sym)
|
|||
{
|
||||
VALUE obj;
|
||||
|
||||
if (RARRAY(args)->len < 1) {
|
||||
if (RARRAY_LEN(args) < 1) {
|
||||
rb_raise(rb_eArgError, "no receiver given");
|
||||
}
|
||||
obj = RARRAY(args)->ptr[0];
|
||||
obj = RARRAY_PTR(args)[0];
|
||||
return rb_funcall3(obj, (ID)sym,
|
||||
RARRAY(args)->len - 1,
|
||||
RARRAY(args)->ptr + 1);
|
||||
RARRAY_LEN(args) - 1,
|
||||
RARRAY_PTR(args) + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
18
pack.c
18
pack.c
|
@ -452,12 +452,12 @@ pack_pack(VALUE ary, VALUE fmt)
|
|||
pend = p + RSTRING_LEN(fmt);
|
||||
res = rb_str_buf_new(0);
|
||||
|
||||
items = RARRAY(ary)->len;
|
||||
items = RARRAY_LEN(ary);
|
||||
idx = 0;
|
||||
|
||||
#define TOO_FEW (rb_raise(rb_eArgError, toofew), 0)
|
||||
#define THISFROM (items > 0 ? RARRAY(ary)->ptr[idx] : TOO_FEW)
|
||||
#define NEXTFROM (items-- > 0 ? RARRAY(ary)->ptr[idx++] : TOO_FEW)
|
||||
#define THISFROM (items > 0 ? RARRAY_PTR(ary)[idx] : TOO_FEW)
|
||||
#define NEXTFROM (items-- > 0 ? RARRAY_PTR(ary)[idx++] : TOO_FEW)
|
||||
|
||||
while (p < pend) {
|
||||
if (RSTRING_PTR(fmt) + RSTRING_LEN(fmt) != pend) {
|
||||
|
@ -949,9 +949,9 @@ pack_pack(VALUE ary, VALUE fmt)
|
|||
VALUE big128 = rb_uint2big(128);
|
||||
while (TYPE(from) == T_BIGNUM) {
|
||||
from = rb_big_divmod(from, big128);
|
||||
c = NUM2INT(RARRAY(from)->ptr[1]) | 0x80; /* mod */
|
||||
c = NUM2INT(RARRAY_PTR(from)[1]) | 0x80; /* mod */
|
||||
rb_str_buf_cat(buf, &c, sizeof(char));
|
||||
from = RARRAY(from)->ptr[0]; /* div */
|
||||
from = RARRAY_PTR(from)[0]; /* div */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1868,8 +1868,8 @@ pack_unpack(VALUE str, VALUE fmt)
|
|||
if (!(a = rb_str_associated(str))) {
|
||||
rb_raise(rb_eArgError, "no associated pointer");
|
||||
}
|
||||
p = RARRAY(a)->ptr;
|
||||
pend = p + RARRAY(a)->len;
|
||||
p = RARRAY_PTR(a);
|
||||
pend = p + RARRAY_LEN(a);
|
||||
while (p < pend) {
|
||||
if (TYPE(*p) == T_STRING && RSTRING_PTR(*p) == t) {
|
||||
if (len < RSTRING_LEN(*p)) {
|
||||
|
@ -1913,8 +1913,8 @@ pack_unpack(VALUE str, VALUE fmt)
|
|||
if (!(a = rb_str_associated(str))) {
|
||||
rb_raise(rb_eArgError, "no associated pointer");
|
||||
}
|
||||
p = RARRAY(a)->ptr;
|
||||
pend = p + RARRAY(a)->len;
|
||||
p = RARRAY_PTR(a);
|
||||
pend = p + RARRAY_LEN(a);
|
||||
while (p < pend) {
|
||||
if (TYPE(*p) == T_STRING && RSTRING_PTR(*p) == t) {
|
||||
tmp = *p;
|
||||
|
|
12
process.c
12
process.c
|
@ -1167,11 +1167,11 @@ rb_check_argv(int argc, VALUE *argv)
|
|||
prog = 0;
|
||||
tmp = rb_check_array_type(argv[0]);
|
||||
if (!NIL_P(tmp)) {
|
||||
if (RARRAY(tmp)->len != 2) {
|
||||
if (RARRAY_LEN(tmp) != 2) {
|
||||
rb_raise(rb_eArgError, "wrong first argument");
|
||||
}
|
||||
prog = RARRAY(tmp)->ptr[0];
|
||||
argv[0] = RARRAY(tmp)->ptr[1];
|
||||
prog = RARRAY_PTR(tmp)[0];
|
||||
argv[0] = RARRAY_PTR(tmp)[1];
|
||||
SafeStringValue(prog);
|
||||
}
|
||||
for (i = 0; i < argc; i++) {
|
||||
|
@ -2647,14 +2647,14 @@ proc_setgroups(VALUE obj, VALUE ary)
|
|||
|
||||
Check_Type(ary, T_ARRAY);
|
||||
|
||||
ngroups = RARRAY(ary)->len;
|
||||
ngroups = RARRAY_LEN(ary);
|
||||
if (ngroups > maxgroups)
|
||||
rb_raise(rb_eArgError, "too many groups, %lu max", (unsigned long)maxgroups);
|
||||
|
||||
groups = ALLOCA_N(rb_gid_t, ngroups);
|
||||
|
||||
for (i = 0; i < ngroups && i < RARRAY(ary)->len; i++) {
|
||||
VALUE g = RARRAY(ary)->ptr[i];
|
||||
for (i = 0; i < ngroups && i < RARRAY_LEN(ary); i++) {
|
||||
VALUE g = RARRAY_PTR(ary)[i];
|
||||
|
||||
if (FIXNUM_P(g)) {
|
||||
groups[i] = FIX2INT(g);
|
||||
|
|
6
ruby.c
6
ruby.c
|
@ -390,8 +390,8 @@ process_sflag(void)
|
|||
long n;
|
||||
VALUE *args;
|
||||
|
||||
n = RARRAY(rb_argv)->len;
|
||||
args = RARRAY(rb_argv)->ptr;
|
||||
n = RARRAY_LEN(rb_argv);
|
||||
args = RARRAY_PTR(rb_argv);
|
||||
while (n > 0) {
|
||||
VALUE v = *args++;
|
||||
char *s = StringValuePtr(v);
|
||||
|
@ -434,7 +434,7 @@ process_sflag(void)
|
|||
}
|
||||
rb_gv_set(s, v);
|
||||
}
|
||||
n = RARRAY(rb_argv)->len - n;
|
||||
n = RARRAY_LEN(rb_argv) - n;
|
||||
while (n--) {
|
||||
rb_ary_shift(rb_argv);
|
||||
}
|
||||
|
|
18
ruby.h
18
ruby.h
|
@ -390,15 +390,33 @@ struct RString {
|
|||
RSTRING(str)->as.ary : \
|
||||
RSTRING(str)->as.heap.ptr)
|
||||
|
||||
#define RARRAY_EMBED_LEN_MAX 3
|
||||
struct RArray {
|
||||
struct RBasic basic;
|
||||
union {
|
||||
struct {
|
||||
long len;
|
||||
union {
|
||||
long capa;
|
||||
VALUE shared;
|
||||
} aux;
|
||||
VALUE *ptr;
|
||||
} heap;
|
||||
VALUE ary[RARRAY_EMBED_LEN_MAX];
|
||||
} as;
|
||||
};
|
||||
#define RARRAY_NOEMBED FL_USER3
|
||||
#define RARRAY_EMBED_LEN_MASK (FL_USER4|FL_USER5)
|
||||
#define RARRAY_EMBED_LEN_SHIFT (FL_USHIFT+4)
|
||||
#define RARRAY_LEN(a) \
|
||||
(!(RBASIC(a)->flags & RARRAY_NOEMBED) ? \
|
||||
(long)((RBASIC(a)->flags >> RARRAY_EMBED_LEN_SHIFT) & \
|
||||
(RARRAY_EMBED_LEN_MASK >> RARRAY_EMBED_LEN_SHIFT)) : \
|
||||
RARRAY(a)->as.heap.len)
|
||||
#define RARRAY_PTR(a) \
|
||||
(!(RBASIC(a)->flags & RARRAY_NOEMBED) ? \
|
||||
RARRAY(a)->as.ary : \
|
||||
RARRAY(a)->as.heap.ptr)
|
||||
|
||||
struct RRegexp {
|
||||
struct RBasic basic;
|
||||
|
|
11
string.c
11
string.c
|
@ -43,6 +43,7 @@ VALUE rb_cString;
|
|||
FL_SET(str, STR_NOEMBED);\
|
||||
STR_SET_EMBED_LEN(str, 0);\
|
||||
} while (0)
|
||||
#define STR_SET_EMBED(str) FL_UNSET(str, STR_NOEMBED)
|
||||
#define STR_EMBED_P(str) (!FL_TEST(str, STR_NOEMBED))
|
||||
#define STR_SET_EMBED_LEN(str, n) do { \
|
||||
long tmp_n = (n);\
|
||||
|
@ -299,7 +300,7 @@ rb_str_shared_replace(VALUE str, VALUE str2)
|
|||
rb_str_modify(str);
|
||||
if (OBJ_TAINTED(str2)) OBJ_TAINT(str);
|
||||
if (RSTRING_LEN(str2) <= RSTRING_EMBED_LEN_MAX) {
|
||||
FL_UNSET(str, STR_NOEMBED);
|
||||
STR_SET_EMBED(str);
|
||||
memcpy(RSTRING_PTR(str), RSTRING_PTR(str2), RSTRING_LEN(str2)+1);
|
||||
STR_SET_EMBED_LEN(str, RSTRING_LEN(str2));
|
||||
return;
|
||||
|
@ -482,7 +483,7 @@ static VALUE
|
|||
rb_str_format_m(VALUE str, VALUE arg)
|
||||
{
|
||||
if (TYPE(arg) == T_ARRAY) {
|
||||
return rb_str_format(RARRAY(arg)->len, RARRAY(arg)->ptr, str);
|
||||
return rb_str_format(RARRAY_LEN(arg), RARRAY_PTR(arg), str);
|
||||
}
|
||||
return rb_str_format(1, &arg, str);
|
||||
}
|
||||
|
@ -2301,7 +2302,7 @@ rb_str_clear(VALUE str)
|
|||
if (str_independent(str)) {
|
||||
free(RSTRING_PTR(str));
|
||||
}
|
||||
FL_UNSET(str, STR_NOEMBED);
|
||||
STR_SET_EMBED(str);
|
||||
STR_SET_EMBED_LEN(str, 0);
|
||||
RSTRING_PTR(str)[0] = 0;
|
||||
return str;
|
||||
|
@ -3505,8 +3506,8 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str)
|
|||
rb_ary_push(result, tmp);
|
||||
}
|
||||
if (NIL_P(limit) && lim == 0) {
|
||||
while (RARRAY(result)->len > 0 &&
|
||||
RSTRING_LEN(RARRAY(result)->ptr[RARRAY(result)->len-1]) == 0)
|
||||
while (RARRAY_LEN(result) > 0 &&
|
||||
RSTRING_LEN(RARRAY_PTR(result)[RARRAY_LEN(result)-1]) == 0)
|
||||
rb_ary_pop(result);
|
||||
}
|
||||
|
||||
|
|
54
struct.c
54
struct.c
|
@ -47,9 +47,9 @@ rb_struct_members(VALUE s)
|
|||
{
|
||||
VALUE members = rb_struct_s_members(rb_obj_class(s));
|
||||
|
||||
if (RSTRUCT_LEN(s) != RARRAY(members)->len) {
|
||||
if (RSTRUCT_LEN(s) != RARRAY_LEN(members)) {
|
||||
rb_raise(rb_eTypeError, "struct size differs (%ld required %ld given)",
|
||||
RARRAY(members)->len, RSTRUCT_LEN(s));
|
||||
RARRAY_LEN(members), RSTRUCT_LEN(s));
|
||||
}
|
||||
return members;
|
||||
}
|
||||
|
@ -61,8 +61,8 @@ rb_struct_s_members_m(VALUE klass)
|
|||
VALUE *p, *pend;
|
||||
|
||||
members = rb_struct_s_members(klass);
|
||||
ary = rb_ary_new2(RARRAY(members)->len);
|
||||
p = RARRAY(members)->ptr; pend = p + RARRAY(members)->len;
|
||||
ary = rb_ary_new2(RARRAY_LEN(members));
|
||||
p = RARRAY_PTR(members); pend = p + RARRAY_LEN(members);
|
||||
while (p < pend) {
|
||||
rb_ary_push(ary, rb_str_new2(rb_id2name(SYM2ID(*p))));
|
||||
p++;
|
||||
|
@ -97,8 +97,8 @@ rb_struct_getmember(VALUE obj, ID id)
|
|||
|
||||
members = rb_struct_members(obj);
|
||||
slot = ID2SYM(id);
|
||||
for (i=0; i<RARRAY(members)->len; i++) {
|
||||
if (RARRAY(members)->ptr[i] == slot) {
|
||||
for (i=0; i<RARRAY_LEN(members); i++) {
|
||||
if (RARRAY_PTR(members)[i] == slot) {
|
||||
return RSTRUCT_PTR(obj)[i];
|
||||
}
|
||||
}
|
||||
|
@ -154,8 +154,8 @@ rb_struct_set(VALUE obj, VALUE val)
|
|||
|
||||
members = rb_struct_members(obj);
|
||||
rb_struct_modify(obj);
|
||||
for (i=0; i<RARRAY(members)->len; i++) {
|
||||
slot = RARRAY(members)->ptr[i];
|
||||
for (i=0; i<RARRAY_LEN(members); i++) {
|
||||
slot = RARRAY_PTR(members)[i];
|
||||
if (rb_id_attrset(SYM2ID(slot)) == rb_frame_this_func()) {
|
||||
return RSTRUCT_PTR(obj)[i] = val;
|
||||
}
|
||||
|
@ -191,15 +191,15 @@ make_struct(VALUE name, VALUE members, VALUE klass)
|
|||
}
|
||||
nstr = rb_define_class_under(klass, rb_id2name(id), klass);
|
||||
}
|
||||
rb_iv_set(nstr, "__size__", LONG2NUM(RARRAY(members)->len));
|
||||
rb_iv_set(nstr, "__size__", LONG2NUM(RARRAY_LEN(members)));
|
||||
rb_iv_set(nstr, "__members__", members);
|
||||
|
||||
rb_define_alloc_func(nstr, struct_alloc);
|
||||
rb_define_singleton_method(nstr, "new", rb_class_new_instance, -1);
|
||||
rb_define_singleton_method(nstr, "[]", rb_class_new_instance, -1);
|
||||
rb_define_singleton_method(nstr, "members", rb_struct_s_members_m, 0);
|
||||
for (i=0; i< RARRAY(members)->len; i++) {
|
||||
ID id = SYM2ID(RARRAY(members)->ptr[i]);
|
||||
for (i=0; i< RARRAY_LEN(members); i++) {
|
||||
ID id = SYM2ID(RARRAY_PTR(members)[i]);
|
||||
if (rb_is_local_id(id) || rb_is_const_id(id)) {
|
||||
if (i < N_REF_FUNC) {
|
||||
rb_define_method_id(nstr, id, ref_func[i], 0);
|
||||
|
@ -278,9 +278,9 @@ rb_struct_s_def(int argc, VALUE *argv, VALUE klass)
|
|||
ID id;
|
||||
|
||||
rb_scan_args(argc, argv, "1*", &name, &rest);
|
||||
for (i=0; i<RARRAY(rest)->len; i++) {
|
||||
id = rb_to_id(RARRAY(rest)->ptr[i]);
|
||||
RARRAY(rest)->ptr[i] = ID2SYM(id);
|
||||
for (i=0; i<RARRAY_LEN(rest); i++) {
|
||||
id = rb_to_id(RARRAY_PTR(rest)[i]);
|
||||
RARRAY_PTR(rest)[i] = ID2SYM(id);
|
||||
}
|
||||
if (!NIL_P(name)) {
|
||||
VALUE tmp = rb_check_string_type(name);
|
||||
|
@ -312,13 +312,13 @@ rb_struct_initialize(VALUE self, VALUE values)
|
|||
rb_struct_modify(self);
|
||||
size = rb_struct_iv_get(klass, "__size__");
|
||||
n = FIX2LONG(size);
|
||||
if (n < RARRAY(values)->len) {
|
||||
if (n < RARRAY_LEN(values)) {
|
||||
rb_raise(rb_eArgError, "struct size differs");
|
||||
}
|
||||
MEMCPY(RSTRUCT_PTR(self), RARRAY(values)->ptr, VALUE, RARRAY(values)->len);
|
||||
if (n > RARRAY(values)->len) {
|
||||
rb_mem_clear(RSTRUCT_PTR(self)+RARRAY(values)->len,
|
||||
n-RARRAY(values)->len);
|
||||
MEMCPY(RSTRUCT_PTR(self), RARRAY_PTR(values), VALUE, RARRAY_LEN(values));
|
||||
if (n > RARRAY_LEN(values)) {
|
||||
rb_mem_clear(RSTRUCT_PTR(self)+RARRAY_LEN(values),
|
||||
n-RARRAY_LEN(values));
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
|
@ -351,7 +351,7 @@ struct_alloc(VALUE klass)
|
|||
VALUE
|
||||
rb_struct_alloc(VALUE klass, VALUE values)
|
||||
{
|
||||
return rb_class_new_instance(RARRAY(values)->len, RARRAY(values)->ptr, klass);
|
||||
return rb_class_new_instance(RARRAY_LEN(values), RARRAY_PTR(values), klass);
|
||||
}
|
||||
|
||||
VALUE
|
||||
|
@ -456,7 +456,7 @@ inspect_struct(VALUE s, VALUE dummy, int recur)
|
|||
if (i > 0) {
|
||||
rb_str_cat2(str, ", ");
|
||||
}
|
||||
slot = RARRAY(members)->ptr[i];
|
||||
slot = RARRAY_PTR(members)[i];
|
||||
id = SYM2ID(slot);
|
||||
if (rb_is_local_id(id) || rb_is_const_id(id)) {
|
||||
p = rb_id2name(id);
|
||||
|
@ -535,9 +535,9 @@ rb_struct_aref_id(VALUE s, ID id)
|
|||
long i, len;
|
||||
|
||||
members = rb_struct_members(s);
|
||||
len = RARRAY(members)->len;
|
||||
len = RARRAY_LEN(members);
|
||||
for (i=0; i<len; i++) {
|
||||
if (SYM2ID(RARRAY(members)->ptr[i]) == id) {
|
||||
if (SYM2ID(RARRAY_PTR(members)[i]) == id) {
|
||||
return RSTRUCT_PTR(s)[i];
|
||||
}
|
||||
}
|
||||
|
@ -592,13 +592,13 @@ rb_struct_aset_id(VALUE s, ID id, VALUE val)
|
|||
|
||||
members = rb_struct_members(s);
|
||||
rb_struct_modify(s);
|
||||
len = RARRAY(members)->len;
|
||||
if (RSTRUCT_LEN(s) != RARRAY(members)->len) {
|
||||
len = RARRAY_LEN(members);
|
||||
if (RSTRUCT_LEN(s) != RARRAY_LEN(members)) {
|
||||
rb_raise(rb_eTypeError, "struct size differs (%ld required %ld given)",
|
||||
RARRAY(members)->len, RSTRUCT_LEN(s));
|
||||
RARRAY_LEN(members), RSTRUCT_LEN(s));
|
||||
}
|
||||
for (i=0; i<len; i++) {
|
||||
if (SYM2ID(RARRAY(members)->ptr[i]) == id) {
|
||||
if (SYM2ID(RARRAY_PTR(members)[i]) == id) {
|
||||
RSTRUCT_PTR(s)[i] = val;
|
||||
return val;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue