summaryrefslogtreecommitdiff
path: root/struct.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-08-20 04:29:58 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-08-20 04:29:58 +0000
commitc7868668121470b56f173a596b750e8a27fe9e18 (patch)
tree96b130e912efefc888dd4f84dc35ca5de9077776 /struct.c
parent772ed5507e569d7697841492a37d7607adbc9385 (diff)
* range.c (range_step): 'iter' here should be an array.
* marshal.c (w_object): should retrieve __member__ data from non-singleton class. * variable.c (rb_cvar_get): class variable override check added. * variable.c (rb_cvar_set): ditto * variable.c (rb_cvar_declare): ditto. * parse.y (parse_regx): handle backslash escaping of delimiter here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'struct.c')
-rw-r--r--struct.c32
1 files changed, 11 insertions, 21 deletions
diff --git a/struct.c b/struct.c
index f8e6b6f3e0..d489026b3f 100644
--- a/struct.c
+++ b/struct.c
@@ -17,16 +17,6 @@ VALUE rb_cStruct;
static VALUE struct_alloc _((int, VALUE*, VALUE));
static VALUE
-class_of(obj)
- VALUE obj;
-{
- obj = CLASS_OF(obj);
- if (FL_TEST(obj, FL_SINGLETON))
- return RCLASS(obj)->super;
- return obj;
-}
-
-static VALUE
iv_get(obj, name)
VALUE obj;
char *name;
@@ -68,7 +58,7 @@ static VALUE
rb_struct_members(obj)
VALUE obj;
{
- return rb_struct_s_members(class_of(obj));
+ return rb_struct_s_members(rb_obj_class(obj));
}
VALUE
@@ -79,7 +69,7 @@ rb_struct_getmember(obj, id)
VALUE member, slot;
long i;
- member = iv_get(class_of(obj), "__member__");
+ member = iv_get(rb_obj_class(obj), "__member__");
if (NIL_P(member)) {
rb_bug("uninitialized struct");
}
@@ -140,7 +130,7 @@ rb_struct_set(obj, val)
VALUE member, slot;
long i;
- member = iv_get(class_of(obj), "__member__");
+ member = iv_get(rb_obj_class(obj), "__member__");
if (NIL_P(member)) {
rb_bug("non-initialized struct");
}
@@ -260,7 +250,7 @@ static VALUE
rb_struct_initialize(self, values)
VALUE self, values;
{
- VALUE klass = CLASS_OF(self);
+ VALUE klass = rb_obj_class(self);
VALUE size;
long n;
@@ -349,7 +339,7 @@ static VALUE
rb_struct_to_s(s)
VALUE s;
{
- char *cname = rb_class2name(CLASS_OF(s));
+ char *cname = rb_class2name(rb_obj_class(s));
VALUE str = rb_str_new(0, strlen(cname) + 4);
sprintf(RSTRING(str)->ptr, "#<%s>", cname);
@@ -361,11 +351,11 @@ static VALUE
inspect_struct(s)
VALUE s;
{
- char *cname = rb_class2name(CLASS_OF(s));
+ char *cname = rb_class2name(rb_obj_class(s));
VALUE str, member;
long i;
- member = iv_get(CLASS_OF(s), "__member__");
+ member = iv_get(rb_obj_class(s), "__member__");
if (NIL_P(member)) {
rb_bug("non-initialized struct");
}
@@ -398,7 +388,7 @@ rb_struct_inspect(s)
VALUE s;
{
if (rb_inspecting_p(s)) {
- char *cname = rb_class2name(CLASS_OF(s));
+ char *cname = rb_class2name(rb_obj_class(s));
VALUE str = rb_str_new(0, strlen(cname) + 8);
sprintf(RSTRING(str)->ptr, "#<%s:...>", cname);
@@ -436,7 +426,7 @@ rb_struct_aref_id(s, id)
VALUE member;
long i, len;
- member = iv_get(CLASS_OF(s), "__member__");
+ member = iv_get(rb_obj_class(s), "__member__");
if (NIL_P(member)) {
rb_bug("non-initialized struct");
}
@@ -480,7 +470,7 @@ rb_struct_aset_id(s, id, val)
VALUE member;
long i, len;
- member = iv_get(CLASS_OF(s), "__member__");
+ member = iv_get(rb_obj_class(s), "__member__");
if (NIL_P(member)) {
rb_bug("non-initialized struct");
}
@@ -527,7 +517,7 @@ rb_struct_equal(s, s2)
long i;
if (TYPE(s2) != T_STRUCT) return Qfalse;
- if (CLASS_OF(s) != CLASS_OF(s2)) return Qfalse;
+ if (rb_obj_class(s) != rb_obj_class(s2)) return Qfalse;
if (RSTRUCT(s)->len != RSTRUCT(s2)->len) {
rb_bug("inconsistent struct"); /* should never happen */
}