summaryrefslogtreecommitdiff
path: root/marshal.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-15 02:27:56 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-15 02:27:56 +0000
commit87025fdd4345f48821236ff19090976bfc11a2bd (patch)
tree3f70b2c935c7b86d4111cd6c7e4310ea4a550eea /marshal.c
parent0c25b62505c64973876e6281193ea6141d396564 (diff)
* marshal.c (w_object): dump extended modules as well.
* marshal.c (r_object0): TYPE_USRMARSHAL should restore extended modules before invoking marshal_load. these two fixes are done by Masatoshi Seki <m_seki@mva.biglobe.ne.jp>. * parse.y (yylex): argument parentheses preceded by spaces should be warned; not error. [ruby-talk:84103] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'marshal.c')
-rw-r--r--marshal.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/marshal.c b/marshal.c
index 387b3052f0..76ab4cafe8 100644
--- a/marshal.c
+++ b/marshal.c
@@ -483,8 +483,7 @@ w_object(obj, arg, limit)
VALUE v;
v = rb_funcall(obj, s_mdump, 0, 0);
- w_byte(TYPE_USRMARSHAL, arg);
- w_unique(rb_class2name(CLASS_OF(obj)), arg);
+ w_class(TYPE_USRMARSHAL, obj, arg);
w_object(v, arg, limit);
if (ivtbl) w_ivar(0, &c_arg);
return;
@@ -953,10 +952,11 @@ path2module(path)
}
static VALUE
-r_object0(arg, proc, ivp)
+r_object0(arg, proc, ivp, extended)
struct load_arg *arg;
VALUE proc;
int *ivp;
+ VALUE extended;
{
VALUE v = Qnil;
int type = r_byte(arg);
@@ -975,7 +975,7 @@ r_object0(arg, proc, ivp)
{
int ivar = Qtrue;
- v = r_object0(arg, 0, &ivar);
+ v = r_object0(arg, 0, &ivar, extended);
if (ivar) r_ivar(v, arg);
}
break;
@@ -984,8 +984,14 @@ r_object0(arg, proc, ivp)
{
VALUE m = path2module(r_unique(arg));
- v = r_object0(arg, 0, 0);
- rb_extend_object(v, m);
+ if (NIL_P(extended)) extended = rb_ary_new2(0);
+ rb_ary_push(extended, m);
+
+ v = r_object0(arg, 0, 0, extended);
+ while (RARRAY(extended)->len > 0) {
+ m = rb_ary_pop(extended);
+ rb_extend_object(v, m);
+ }
}
break;
@@ -996,7 +1002,7 @@ r_object0(arg, proc, ivp)
if (FL_TEST(c, FL_SINGLETON)) {
rb_raise(rb_eTypeError, "singleton can't be loaded");
}
- v = r_object0(arg, 0, 0);
+ v = r_object0(arg, 0, 0, extended);
if (rb_special_const_p(v) || TYPE(v) == T_OBJECT || TYPE(v) == T_CLASS) {
format_error:
rb_raise(rb_eArgError, "dump format error (user class)");
@@ -1200,6 +1206,12 @@ r_object0(arg, proc, ivp)
VALUE data;
v = rb_obj_alloc(klass);
+ if (! NIL_P(extended)) {
+ while (RARRAY(extended)->len > 0) {
+ VALUE m = rb_ary_pop(extended);
+ rb_extend_object(v, m);
+ }
+ }
if (!rb_respond_to(v, s_mload)) {
rb_raise(rb_eTypeError, "instance of %s needs to have method `marshal_load'",
rb_class2name(klass));
@@ -1246,7 +1258,7 @@ r_object0(arg, proc, ivp)
"class %s needs to have instance method `_load_data'",
rb_class2name(klass));
}
- rb_funcall(v, s_load_data, 1, r_object0(arg, 0, 0));
+ rb_funcall(v, s_load_data, 1, r_object0(arg, 0, 0, extended));
}
break;
@@ -1298,7 +1310,7 @@ static VALUE
r_object(arg)
struct load_arg *arg;
{
- return r_object0(arg, arg->proc, 0);
+ return r_object0(arg, arg->proc, 0, Qnil);
}
static VALUE