* marshal.c (w_object, marshal_dump, r_object0, marshal_load): search
private methods too. [ruby-dev:34671] * object.c (convert_type): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
85f554594a
commit
de9d25c544
@ -1,3 +1,10 @@
|
|||||||
|
Wed May 28 12:52:41 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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@fsij.org>
|
Wed May 28 08:42:51 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* numeric.c: "%" is required before PRI?VALUE.
|
* numeric.c: "%" is required before PRI?VALUE.
|
||||||
|
27
marshal.c
27
marshal.c
@ -582,7 +582,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
|
|||||||
else {
|
else {
|
||||||
if (OBJ_TAINTED(obj)) arg->taint = Qtrue;
|
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;
|
volatile VALUE v;
|
||||||
|
|
||||||
st_add_direct(arg->data, obj, arg->data->num_entries);
|
st_add_direct(arg->data, obj, arg->data->num_entries);
|
||||||
@ -594,7 +594,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
|
|||||||
if (hasiv) w_ivar(obj, 0, &c_arg);
|
if (hasiv) w_ivar(obj, 0, &c_arg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (rb_respond_to(obj, s_dump)) {
|
if (rb_obj_respond_to(obj, s_dump, Qtrue)) {
|
||||||
VALUE v;
|
VALUE v;
|
||||||
st_table *ivtbl2 = 0;
|
st_table *ivtbl2 = 0;
|
||||||
int hasiv2;
|
int hasiv2;
|
||||||
@ -758,7 +758,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
|
|||||||
{
|
{
|
||||||
VALUE v;
|
VALUE v;
|
||||||
|
|
||||||
if (!rb_respond_to(obj, s_dump_data)) {
|
if (!rb_obj_respond_to(obj, s_dump_data, Qtrue)) {
|
||||||
rb_raise(rb_eTypeError,
|
rb_raise(rb_eTypeError,
|
||||||
"no marshal_dump is defined for class %s",
|
"no marshal_dump is defined for class %s",
|
||||||
rb_obj_classname(obj));
|
rb_obj_classname(obj));
|
||||||
@ -855,13 +855,13 @@ marshal_dump(int argc, VALUE *argv)
|
|||||||
}
|
}
|
||||||
arg.dest = 0;
|
arg.dest = 0;
|
||||||
if (!NIL_P(port)) {
|
if (!NIL_P(port)) {
|
||||||
if (!rb_respond_to(port, s_write)) {
|
if (!rb_obj_respond_to(port, s_write, Qtrue)) {
|
||||||
type_error:
|
type_error:
|
||||||
rb_raise(rb_eTypeError, "instance of IO needed");
|
rb_raise(rb_eTypeError, "instance of IO needed");
|
||||||
}
|
}
|
||||||
arg.str = rb_str_buf_new(0);
|
arg.str = rb_str_buf_new(0);
|
||||||
arg.dest = port;
|
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);
|
rb_funcall2(port, s_binmode, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1419,7 +1419,7 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
|
|||||||
VALUE klass = path2class(r_unique(arg));
|
VALUE klass = path2class(r_unique(arg));
|
||||||
VALUE data;
|
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_raise(rb_eTypeError, "class %s needs to have method `_load'",
|
||||||
rb_class2name(klass));
|
rb_class2name(klass));
|
||||||
}
|
}
|
||||||
@ -1447,7 +1447,7 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
|
|||||||
rb_extend_object(v, m);
|
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_raise(rb_eTypeError, "instance of %s needs to have method `marshal_load'",
|
||||||
rb_class2name(klass));
|
rb_class2name(klass));
|
||||||
}
|
}
|
||||||
@ -1474,7 +1474,7 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
|
|||||||
case TYPE_DATA:
|
case TYPE_DATA:
|
||||||
{
|
{
|
||||||
VALUE klass = path2class(r_unique(arg));
|
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;
|
static int warn = Qtrue;
|
||||||
if (warn) {
|
if (warn) {
|
||||||
rb_warn("define `allocate' instead of `_alloc'");
|
rb_warn("define `allocate' instead of `_alloc'");
|
||||||
@ -1490,7 +1490,7 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
|
|||||||
rb_raise(rb_eArgError, "dump format error");
|
rb_raise(rb_eArgError, "dump format error");
|
||||||
}
|
}
|
||||||
v = r_entry(v, arg);
|
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,
|
rb_raise(rb_eTypeError,
|
||||||
"class %s needs to have instance method `_load_data'",
|
"class %s needs to have instance method `_load_data'",
|
||||||
rb_class2name(klass));
|
rb_class2name(klass));
|
||||||
@ -1590,12 +1590,13 @@ marshal_load(int argc, VALUE *argv)
|
|||||||
struct load_arg arg;
|
struct load_arg arg;
|
||||||
|
|
||||||
rb_scan_args(argc, argv, "11", &port, &proc);
|
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 */
|
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)) {
|
else if (rb_obj_respond_to(port, s_getbyte, Qtrue) && rb_obj_respond_to(port, s_read, Qtrue)) {
|
||||||
if (rb_respond_to(port, s_binmode)) {
|
if (rb_obj_respond_to(port, s_binmode, Qtrue)) {
|
||||||
rb_funcall2(port, s_binmode, 0, 0);
|
rb_funcall2(port, s_binmode, 0, 0);
|
||||||
}
|
}
|
||||||
arg.taint = Qtrue;
|
arg.taint = Qtrue;
|
||||||
|
2
object.c
2
object.c
@ -1892,7 +1892,7 @@ convert_type(VALUE val, const char *tname, const char *method, int raise)
|
|||||||
ID m;
|
ID m;
|
||||||
|
|
||||||
m = rb_intern(method);
|
m = rb_intern(method);
|
||||||
if (!rb_respond_to(val, m)) {
|
if (!rb_obj_respond_to(val, m, Qtrue)) {
|
||||||
if (raise) {
|
if (raise) {
|
||||||
rb_raise(rb_eTypeError, "can't convert %s into %s",
|
rb_raise(rb_eTypeError, "can't convert %s into %s",
|
||||||
NIL_P(val) ? "nil" :
|
NIL_P(val) ? "nil" :
|
||||||
|
Loading…
x
Reference in New Issue
Block a user