summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-11-29 15:57:25 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-11-29 15:57:25 +0000
commit23303b8a63df927cd81b9947dd48e1b416e2a39c (patch)
treedd7c8c1a9bb43c226ca5e1702b418f11a94ffd3e /object.c
parent080aa35bbaa08513e47ef4e7952da5fb4cc0b685 (diff)
* string.c (rb_str_equal): object with to_str must be treated as a
string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r--object.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/object.c b/object.c
index 73ae3d4..4020f54 100644
--- a/object.c
+++ b/object.c
@@ -876,6 +876,26 @@ rb_convert_type(val, type, tname, method)
return val;
}
+VALUE
+rb_check_convert_type(val, type, tname, method)
+ VALUE val;
+ int type;
+ const char *tname, *method;
+{
+ struct arg_to arg1, arg2;
+
+ if (TYPE(val) == type) return val;
+ arg1.val = arg2.val = val;
+ arg1.s = method;
+ arg2.s = tname;
+ val = rb_rescue(to_type, (VALUE)&arg1, 0, 0);
+ if (!NIL_P(val) && TYPE(val) != type) {
+ rb_raise(rb_eTypeError, "%s#%s should return %s",
+ rb_class2name(CLASS_OF(arg1.val)), method, tname);
+ }
+ return val;
+}
+
static VALUE
rb_to_integer(val, method)
VALUE val;