diff --git a/ChangeLog b/ChangeLog index 11a2abb77e..d9ce911c38 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Tue Feb 26 01:16:01 2008 Tanaka Akira + + * 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. * ext/openssl/digest.c ext/openssl/lib/openssl/digest.rb: diff --git a/gc.c b/gc.c index 849c15ff69..3ff432fcda 100644 --- a/gc.c +++ b/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: diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 2ba47ab9f5..b8a7bba8c5 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -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)) : \ diff --git a/marshal.c b/marshal.c index 2cf9a19f56..2d54cb8ff5 100644 --- a/marshal.c +++ b/marshal.c @@ -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) diff --git a/object.c b/object.c index 5b2715b798..2dc87610da 100644 --- a/object.c +++ b/object.c @@ -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++) { diff --git a/variable.c b/variable.c index 8639f8b378..6c0ff1b3f5 100644 --- a/variable.c +++ b/variable.c @@ -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;