ruby-changes:5159
From: nobu <ko1@a...>
Date: Wed, 28 May 2008 12:53:05 +0900 (JST)
Subject: [ruby-changes:5159] Ruby:r16654 (ruby_1_8, trunk): * marshal.c (w_object, marshal_dump, r_object0, marshal_load): search
nobu 2008-05-28 12:52:44 +0900 (Wed, 28 May 2008) New Revision: 16654 Modified files: branches/ruby_1_8/ChangeLog branches/ruby_1_8/marshal.c branches/ruby_1_8/object.c trunk/ChangeLog trunk/marshal.c trunk/object.c Log: * marshal.c (w_object, marshal_dump, r_object0, marshal_load): search private methods too. [ruby-dev:34671] * object.c (convert_type): ditto. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ChangeLog?r1=16654&r2=16653&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16654&r2=16653&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/marshal.c?r1=16654&r2=16653&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/object.c?r1=16654&r2=16653&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/marshal.c?r1=16654&r2=16653&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/object.c?r1=16654&r2=16653&diff_format=u Index: ChangeLog =================================================================== --- ChangeLog (revision 16653) +++ ChangeLog (revision 16654) @@ -1,3 +1,10 @@ +Wed May 28 12:52:41 2008 Nobuyoshi Nakada <nobu@r...> + + * marshal.c (w_object, marshal_dump, r_object0, marshal_load): search + private methods too. [ruby-dev:34671] + + * object.c (convert_type): ditto. + Wed May 28 08:42:51 2008 Tanaka Akira <akr@f...> * numeric.c: "%" is required before PRI?VALUE. Index: object.c =================================================================== --- object.c (revision 16653) +++ object.c (revision 16654) @@ -1892,7 +1892,7 @@ ID m; m = rb_intern(method); - if (!rb_respond_to(val, m)) { + if (!rb_obj_respond_to(val, m, Qtrue)) { if (raise) { rb_raise(rb_eTypeError, "can't convert %s into %s", NIL_P(val) ? "nil" : Index: marshal.c =================================================================== --- marshal.c (revision 16653) +++ marshal.c (revision 16654) @@ -582,7 +582,7 @@ else { if (OBJ_TAINTED(obj)) arg->taint = Qtrue; - if (rb_respond_to(obj, s_mdump)) { + if (rb_obj_respond_to(obj, s_mdump, Qtrue)) { volatile VALUE v; st_add_direct(arg->data, obj, arg->data->num_entries); @@ -594,7 +594,7 @@ if (hasiv) w_ivar(obj, 0, &c_arg); return; } - if (rb_respond_to(obj, s_dump)) { + if (rb_obj_respond_to(obj, s_dump, Qtrue)) { VALUE v; st_table *ivtbl2 = 0; int hasiv2; @@ -758,7 +758,7 @@ { VALUE v; - if (!rb_respond_to(obj, s_dump_data)) { + if (!rb_obj_respond_to(obj, s_dump_data, Qtrue)) { rb_raise(rb_eTypeError, "no marshal_dump is defined for class %s", rb_obj_classname(obj)); @@ -855,13 +855,13 @@ } arg.dest = 0; if (!NIL_P(port)) { - if (!rb_respond_to(port, s_write)) { + if (!rb_obj_respond_to(port, s_write, Qtrue)) { type_error: rb_raise(rb_eTypeError, "instance of IO needed"); } arg.str = rb_str_buf_new(0); arg.dest = port; - if (rb_respond_to(port, s_binmode)) { + if (rb_obj_respond_to(port, s_binmode, Qtrue)) { rb_funcall2(port, s_binmode, 0, 0); } } @@ -1419,7 +1419,7 @@ VALUE klass = path2class(r_unique(arg)); VALUE data; - if (!rb_respond_to(klass, s_load)) { + if (!rb_obj_respond_to(klass, s_load, Qtrue)) { rb_raise(rb_eTypeError, "class %s needs to have method `_load'", rb_class2name(klass)); } @@ -1447,7 +1447,7 @@ rb_extend_object(v, m); } } - if (!rb_respond_to(v, s_mload)) { + if (!rb_obj_respond_to(v, s_mload, Qtrue)) { rb_raise(rb_eTypeError, "instance of %s needs to have method `marshal_load'", rb_class2name(klass)); } @@ -1474,7 +1474,7 @@ case TYPE_DATA: { VALUE klass = path2class(r_unique(arg)); - if (rb_respond_to(klass, s_alloc)) { + if (rb_obj_respond_to(klass, s_alloc, Qtrue)) { static int warn = Qtrue; if (warn) { rb_warn("define `allocate' instead of `_alloc'"); @@ -1490,7 +1490,7 @@ rb_raise(rb_eArgError, "dump format error"); } v = r_entry(v, arg); - if (!rb_respond_to(v, s_load_data)) { + if (!rb_obj_respond_to(v, s_load_data, Qtrue)) { rb_raise(rb_eTypeError, "class %s needs to have instance method `_load_data'", rb_class2name(klass)); @@ -1590,12 +1590,13 @@ struct load_arg arg; rb_scan_args(argc, argv, "11", &port, &proc); - if (rb_respond_to(port, rb_intern("to_str"))) { + v = rb_check_string_type(port); + if (!NIL_P(v)) { arg.taint = OBJ_TAINTED(port); /* original taintedness */ - StringValue(port); /* possible conversion */ + port = v; } - else if (rb_respond_to(port, s_getbyte) && rb_respond_to(port, s_read)) { - if (rb_respond_to(port, s_binmode)) { + else if (rb_obj_respond_to(port, s_getbyte, Qtrue) && rb_obj_respond_to(port, s_read, Qtrue)) { + if (rb_obj_respond_to(port, s_binmode, Qtrue)) { rb_funcall2(port, s_binmode, 0, 0); } arg.taint = Qtrue; Index: ruby_1_8/ChangeLog =================================================================== --- ruby_1_8/ChangeLog (revision 16653) +++ ruby_1_8/ChangeLog (revision 16654) @@ -1,3 +1,10 @@ +Wed May 28 12:52:41 2008 Nobuyoshi Nakada <nobu@r...> + + * marshal.c (w_object, marshal_dump, r_object0, marshal_load): search + private methods too. [ruby-dev:34671] + + * object.c (convert_type): ditto. + Tue May 27 20:19:22 2008 Akinori MUSHA <knu@i...> * array.c (rb_ary_slice_bang): Return an empty array instead of Index: ruby_1_8/object.c =================================================================== --- ruby_1_8/object.c (revision 16653) +++ ruby_1_8/object.c (revision 16654) @@ -2193,7 +2193,7 @@ ID m; m = rb_intern(method); - if (!rb_respond_to(val, m)) { + if (!rb_obj_respond_to(val, m, Qtrue)) { if (raise) { rb_raise(rb_eTypeError, "can't convert %s into %s", NIL_P(val) ? "nil" : Index: ruby_1_8/marshal.c =================================================================== --- ruby_1_8/marshal.c (revision 16653) +++ ruby_1_8/marshal.c (revision 16654) @@ -511,7 +511,7 @@ if (OBJ_TAINTED(obj)) arg->taint = Qtrue; st_add_direct(arg->data, obj, arg->data->num_entries); - if (rb_respond_to(obj, s_mdump)) { + if (rb_obj_respond_to(obj, s_mdump, Qtrue)) { volatile VALUE v; v = rb_funcall(obj, s_mdump, 0, 0); @@ -521,7 +521,7 @@ if (ivtbl) w_ivar(0, &c_arg); return; } - if (rb_respond_to(obj, s_dump)) { + if (rb_obj_respond_to(obj, s_dump, Qtrue)) { VALUE v; v = rb_funcall(obj, s_dump, 1, INT2NUM(limit)); @@ -664,7 +664,7 @@ { VALUE v; - if (!rb_respond_to(obj, s_dump_data)) { + if (!rb_obj_respond_to(obj, s_dump_data, Qtrue)) { rb_raise(rb_eTypeError, "no marshal_dump is defined for class %s", rb_obj_classname(obj)); @@ -765,12 +765,12 @@ arg.str = rb_str_buf_new(0); RBASIC(arg.str)->klass = 0; if (!NIL_P(port)) { - if (!rb_respond_to(port, s_write)) { + if (!rb_obj_respond_to(port, s_write, Qtrue)) { type_error: rb_raise(rb_eTypeError, "instance of IO needed"); } arg.dest = port; - if (rb_respond_to(port, s_binmode)) { + if (rb_obj_respond_to(port, s_binmode, Qtrue)) { rb_funcall2(port, s_binmode, 0, 0); reentrant_check(arg.str, s_dump_data); } @@ -1245,7 +1245,7 @@ VALUE klass = path2class(r_unique(arg)); VALUE data; - if (!rb_respond_to(klass, s_load)) { + if (!rb_obj_respond_to(klass, s_load, Qtrue)) { rb_raise(rb_eTypeError, "class %s needs to have method `_load'", rb_class2name(klass)); } @@ -1272,7 +1272,7 @@ rb_extend_object(v, m); } } - if (!rb_respond_to(v, s_mload)) { + if (!rb_obj_respond_to(v, s_mload, Qtrue)) { rb_raise(rb_eTypeError, "instance of %s needs to have method `marshal_load'", rb_class2name(klass)); } @@ -1299,7 +1299,7 @@ case TYPE_DATA: { VALUE klass = path2class(r_unique(arg)); - if (rb_respond_to(klass, s_alloc)) { + if (rb_obj_respond_to(klass, s_alloc, Qtrue)) { static int warn = Qtrue; if (warn) { rb_warn("define `allocate' instead of `_alloc'"); @@ -1315,7 +1315,7 @@ rb_raise(rb_eArgError, "dump format error"); } r_entry(v, arg); - if (!rb_respond_to(v, s_load_data)) { + if (!rb_obj_respond_to(v, s_load_data, Qtrue)) { rb_raise(rb_eTypeError, "class %s needs to have instance method `_load_data'", rb_class2name(klass)); @@ -1415,12 +1415,13 @@ struct load_arg arg; rb_scan_args(argc, argv, "11", &port, &proc); - if (rb_respond_to(port, rb_intern("to_str"))) { + v = rb_check_string_type(port); + if (!NIL_P(v)) { arg.taint = OBJ_TAINTED(port); /* original taintedness */ - StringValue(port); /* possible conversion */ + port = v; } - else if (rb_respond_to(port, s_getc) && rb_respond_to(port, s_read)) { - if (rb_respond_to(port, s_binmode)) { + else if (rb_obj_respond_to(port, s_getc, Qtrue) && rb_obj_respond_to(port, s_read, Qtrue)) { + if (rb_obj_respond_to(port, s_binmode, Qtrue)) { rb_funcall2(port, s_binmode, 0, 0); } arg.taint = Qtrue; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/