* include/ruby/ruby.h (ROBJECT_NUMIV): renamed from ROBJECT_LEN.

(ROBJECT_IVPTR): renamed from ROBJECT_PTR.

* variable.c: follow the above renaming.

* object.c: ditto.

* gc.c: ditto.

* marshal.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2008-02-25 16:18:18 +00:00
Родитель f0ca4e868d
Коммит b58e36da4a
6 изменённых файлов: 51 добавлений и 38 удалений

Просмотреть файл

@ -1,3 +1,16 @@
Tue Feb 26 01:16:01 2008 Tanaka Akira <akr@fsij.org>
* include/ruby/ruby.h (ROBJECT_NUMIV): renamed from ROBJECT_LEN.
(ROBJECT_IVPTR): renamed from ROBJECT_PTR.
* variable.c: follow the above renaming.
* object.c: ditto.
* gc.c: ditto.
* marshal.c: ditto.
Mon Feb 25 17:30:29 2008 Technorama Ltd. <oss-ruby@technorama.net>
* ext/openssl/digest.c ext/openssl/lib/openssl/digest.rb:

8
gc.c
Просмотреть файл

@ -1065,8 +1065,8 @@ gc_mark_children(VALUE ptr, int lev)
case T_OBJECT:
{
long i, len = ROBJECT_LEN(obj);
VALUE *ptr = ROBJECT_PTR(obj);
long i, len = ROBJECT_NUMIV(obj);
VALUE *ptr = ROBJECT_IVPTR(obj);
for (i = 0; i < len; i++) {
gc_mark(*ptr++, lev);
}
@ -1274,8 +1274,8 @@ obj_free(VALUE obj)
switch (RANY(obj)->as.basic.flags & T_MASK) {
case T_OBJECT:
if (!(RANY(obj)->as.basic.flags & ROBJECT_EMBED) &&
RANY(obj)->as.object.as.heap.ptr) {
RUBY_CRITICAL(free(RANY(obj)->as.object.as.heap.ptr));
RANY(obj)->as.object.as.heap.ivptr) {
RUBY_CRITICAL(free(RANY(obj)->as.object.as.heap.ivptr));
}
break;
case T_MODULE:

Просмотреть файл

@ -396,22 +396,22 @@ struct RObject {
struct RBasic basic;
union {
struct {
long len;
VALUE *ptr;
long numiv;
VALUE *ivptr;
struct st_table *iv_index_tbl; /* shortcut for RCLASS_IV_INDEX_TBL(rb_obj_class(obj)) */
} heap;
VALUE ary[ROBJECT_EMBED_LEN_MAX];
} as;
};
#define ROBJECT_EMBED FL_USER1
#define ROBJECT_LEN(o) \
#define ROBJECT_NUMIV(o) \
((RBASIC(o)->flags & ROBJECT_EMBED) ? \
ROBJECT_EMBED_LEN_MAX : \
ROBJECT(o)->as.heap.len)
#define ROBJECT_PTR(o) \
ROBJECT(o)->as.heap.numiv)
#define ROBJECT_IVPTR(o) \
((RBASIC(o)->flags & ROBJECT_EMBED) ? \
ROBJECT(o)->as.ary : \
ROBJECT(o)->as.heap.ptr)
ROBJECT(o)->as.heap.ivptr)
#define ROBJECT_IV_INDEX_TBL(o) \
((RBASIC(o)->flags & ROBJECT_EMBED) ? \
RCLASS_IV_INDEX_TBL(rb_obj_class(o)) : \

Просмотреть файл

@ -505,8 +505,8 @@ w_objivar(VALUE obj, struct dump_call_arg *arg)
VALUE *ptr;
long i, len, num;
len = ROBJECT_LEN(obj);
ptr = ROBJECT_PTR(obj);
len = ROBJECT_NUMIV(obj);
ptr = ROBJECT_IVPTR(obj);
num = 0;
for (i = 0; i < len; i++)
if (ptr[i] != Qundef)

Просмотреть файл

@ -166,10 +166,10 @@ init_copy(VALUE dest, VALUE obj)
rb_gc_copy_finalizer(dest, obj);
switch (TYPE(obj)) {
case T_OBJECT:
if (!(RBASIC(dest)->flags & ROBJECT_EMBED) && ROBJECT_PTR(dest)) {
xfree(ROBJECT_PTR(dest));
ROBJECT(dest)->as.heap.ptr = 0;
ROBJECT(dest)->as.heap.len = 0;
if (!(RBASIC(dest)->flags & ROBJECT_EMBED) && ROBJECT_IVPTR(dest)) {
xfree(ROBJECT_IVPTR(dest));
ROBJECT(dest)->as.heap.ivptr = 0;
ROBJECT(dest)->as.heap.numiv = 0;
ROBJECT(dest)->as.heap.iv_index_tbl = 0;
}
if (RBASIC(obj)->flags & ROBJECT_EMBED) {
@ -177,11 +177,11 @@ init_copy(VALUE dest, VALUE obj)
RBASIC(dest)->flags |= ROBJECT_EMBED;
}
else {
long len = ROBJECT(obj)->as.heap.len;
long len = ROBJECT(obj)->as.heap.numiv;
VALUE *ptr = ALLOC_N(VALUE, len);
MEMCPY(ptr, ROBJECT(obj)->as.heap.ptr, VALUE, len);
ROBJECT(dest)->as.heap.ptr = ptr;
ROBJECT(dest)->as.heap.len = len;
MEMCPY(ptr, ROBJECT(obj)->as.heap.ivptr, VALUE, len);
ROBJECT(dest)->as.heap.ivptr = ptr;
ROBJECT(dest)->as.heap.numiv = len;
ROBJECT(dest)->as.heap.iv_index_tbl = ROBJECT(obj)->as.heap.iv_index_tbl;
RBASIC(dest)->flags &= ~ROBJECT_EMBED;
}
@ -374,8 +374,8 @@ rb_obj_inspect(VALUE obj)
if (TYPE(obj) == T_OBJECT) {
int has_ivar = 0;
VALUE *ptr = ROBJECT_PTR(obj);
long len = ROBJECT_LEN(obj);
VALUE *ptr = ROBJECT_IVPTR(obj);
long len = ROBJECT_NUMIV(obj);
long i;
for (i = 0; i < len; i++) {

Просмотреть файл

@ -939,8 +939,8 @@ ivar_get(VALUE obj, ID id, int warn)
switch (TYPE(obj)) {
case T_OBJECT:
len = ROBJECT_LEN(obj);
ptr = ROBJECT_PTR(obj);
len = ROBJECT_NUMIV(obj);
ptr = ROBJECT_IVPTR(obj);
iv_index_tbl = ROBJECT_IV_INDEX_TBL(obj);
if (!iv_index_tbl) break;
if (!st_lookup(iv_index_tbl, id, &index)) break;
@ -1004,9 +1004,9 @@ rb_ivar_set(VALUE obj, ID id, VALUE val)
st_add_direct(iv_index_tbl, id, index);
ivar_extended = 1;
}
len = ROBJECT_LEN(obj);
len = ROBJECT_NUMIV(obj);
if (len <= index) {
VALUE *ptr = ROBJECT_PTR(obj);
VALUE *ptr = ROBJECT_IVPTR(obj);
if (index < ROBJECT_EMBED_LEN_MAX) {
RBASIC(obj)->flags |= ROBJECT_EMBED;
ptr = ROBJECT(obj)->as.ary;
@ -1025,19 +1025,19 @@ rb_ivar_set(VALUE obj, ID id, VALUE val)
newptr = ALLOC_N(VALUE, newsize);
MEMCPY(newptr, ptr, VALUE, len);
RBASIC(obj)->flags &= ~ROBJECT_EMBED;
ROBJECT(obj)->as.heap.ptr = newptr;
ROBJECT(obj)->as.heap.ivptr = newptr;
}
else {
REALLOC_N(ROBJECT(obj)->as.heap.ptr, VALUE, newsize);
newptr = ROBJECT(obj)->as.heap.ptr;
REALLOC_N(ROBJECT(obj)->as.heap.ivptr, VALUE, newsize);
newptr = ROBJECT(obj)->as.heap.ivptr;
}
for (; len < newsize; len++)
newptr[len] = Qundef;
ROBJECT(obj)->as.heap.len = newsize;
ROBJECT(obj)->as.heap.numiv = newsize;
ROBJECT(obj)->as.heap.iv_index_tbl = iv_index_tbl;
}
}
ROBJECT_PTR(obj)[index] = val;
ROBJECT_IVPTR(obj)[index] = val;
break;
case T_CLASS:
case T_MODULE:
@ -1062,8 +1062,8 @@ rb_ivar_defined(VALUE obj, ID id)
iv_index_tbl = ROBJECT_IV_INDEX_TBL(obj);
if (!iv_index_tbl) break;
if (!st_lookup(iv_index_tbl, id, &index)) break;
if (ROBJECT_LEN(obj) <= index) break;
val = ROBJECT_PTR(obj)[index];
if (ROBJECT_NUMIV(obj) <= index) break;
val = ROBJECT_IVPTR(obj)[index];
if (val != Qundef)
return Qtrue;
break;
@ -1089,8 +1089,8 @@ struct obj_ivar_tag {
static int
obj_ivar_i(ID key, VALUE index, struct obj_ivar_tag *data)
{
if (index < ROBJECT_LEN(data->obj)) {
VALUE val = ROBJECT_PTR(data->obj)[index];
if (index < ROBJECT_NUMIV(data->obj)) {
VALUE val = ROBJECT_IVPTR(data->obj)[index];
if (val != Qundef) {
return (data->func)(key, val, data->arg);
}
@ -1218,10 +1218,10 @@ rb_obj_remove_instance_variable(VALUE obj, VALUE name)
iv_index_tbl = ROBJECT_IV_INDEX_TBL(obj);
if (!iv_index_tbl) break;
if (!st_lookup(iv_index_tbl, id, &index)) break;
if (ROBJECT_LEN(obj) <= index) break;
val = ROBJECT_PTR(obj)[index];
if (ROBJECT_NUMIV(obj) <= index) break;
val = ROBJECT_IVPTR(obj)[index];
if (val != Qundef) {
ROBJECT_PTR(obj)[index] = Qundef;
ROBJECT_IVPTR(obj)[index] = Qundef;
return val;
}
break;