Permalink
Browse files

* variable.c (rb_obj_classname): new function.

* string.c (rb_str_dup): should preserve original's class (but not
  hidden singleton class).

* string.c (rb_str_substr): ditto.

* parse.y: backout EXPR_CMDARG removal.


git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent 35d0b98 commit a0cf2fde9c6b21c4249f0dbbe928a2dd79cf67b6 matz committed Jan 31, 2003
Showing with 92 additions and 64 deletions.
  1. +11 −4 ChangeLog
  2. +1 −1 bignum.c
  3. +2 −2 class.c
  4. +2 −2 error.c
  5. +14 −14 eval.c
  6. +1 −1 file.c
  7. +2 −2 gc.c
  8. +2 −2 io.c
  9. +4 −4 marshal.c
  10. +5 −5 numeric.c
  11. +10 −10 object.c
  12. +19 −6 parse.y
  13. +1 −1 prec.c
  14. +3 −3 range.c
  15. +1 −0 ruby.h
  16. +1 −1 signal.c
  17. +5 −5 string.c
  18. +1 −1 time.c
  19. +7 −0 variable.c
View
@@ -1,3 +1,14 @@
+Fri Jan 31 12:45:11 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (rb_obj_classname): new function.
+
+ * string.c (rb_str_dup): should preserve original's class (but not
+ hidden singleton class).
+
+ * string.c (rb_str_substr): ditto.
+
+ * parse.y: backout EXPR_CMDARG removal.
+
Fri Jan 31 09:40:07 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* lib/optparse.rb (OptionParser::List::accept): default
@@ -82,10 +93,6 @@ Sun Jan 26 03:37:18 2003 Akinori MUSHA <knu@iDaemons.org>
is used with extra arguments given. Tested with FreeBSD and
Linux by me and mswin32, bccwin32 and mingw by usa.
-Sat Jan 25 21:04:57 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (yylex): remove EXPR_CMDARG according to the RHG book.
-
Fri Jan 24 18:15:33 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y: tMINUS should have lower precedence than tPOW.
View
@@ -1704,7 +1704,7 @@ rb_big_coerce(x, y)
}
else {
rb_raise(rb_eTypeError, "Can't coerce %s to Bignum",
- rb_class2name(CLASS_OF(y)));
+ rb_obj_classname(y));
}
/* not reached */
return Qnil;
View
@@ -293,7 +293,7 @@ rb_define_module(name)
module = rb_const_get(rb_cObject, id);
if (TYPE(module) == T_MODULE)
return module;
- rb_raise(rb_eTypeError, "%s is not a module", rb_class2name(CLASS_OF(module)));
+ rb_raise(rb_eTypeError, "%s is not a module", rb_obj_classname(module));
}
module = rb_define_module_id(id);
st_add_direct(rb_class_tbl, id, module);
@@ -315,7 +315,7 @@ rb_define_module_under(outer, name)
if (TYPE(module) == T_MODULE)
return module;
rb_raise(rb_eTypeError, "%s::%s is not a module",
- rb_class2name(outer), rb_class2name(CLASS_OF(module)));
+ rb_class2name(outer), rb_obj_classname(module));
}
module = rb_define_module_id(id);
rb_const_set(outer, id, module);
View
@@ -230,7 +230,7 @@ rb_check_type(x, t)
etype = RSTRING(rb_obj_as_string(x))->ptr;
}
else {
- etype = rb_class2name(CLASS_OF(x));
+ etype = rb_obj_classname(x);
}
rb_raise(rb_eTypeError, "wrong argument type %s (expected %s)",
etype, type->name);
@@ -724,7 +724,7 @@ void
rb_check_frozen(obj)
VALUE obj;
{
- if (OBJ_FROZEN(obj)) rb_error_frozen(rb_class2name(CLASS_OF(obj)));
+ if (OBJ_FROZEN(obj)) rb_error_frozen(rb_obj_classname(obj));
}
static void
View
28 eval.c
@@ -154,7 +154,7 @@ rb_check_safe_str(x)
rb_secure(4);
if (TYPE(x)!= T_STRING) {
rb_raise(rb_eTypeError, "wrong argument type %s (expected String)",
- rb_class2name(CLASS_OF(x)));
+ rb_obj_classname(x));
}
}
@@ -1555,7 +1555,7 @@ superclass(self, node)
}
if (TYPE(val) != T_CLASS) {
rb_raise(rb_eTypeError, "superclass must be a Class (%s given)",
- rb_class2name(CLASS_OF(val)));
+ rb_obj_classname(val));
}
if (FL_TEST(val, FL_SINGLETON)) {
rb_raise(rb_eTypeError, "can't make subclass of virtual class");
@@ -3255,7 +3255,7 @@ rb_eval(self, n)
rb_raise(rb_eTypeError,
"can't define singleton method \"%s\" for %s",
rb_id2name(node->nd_mid),
- rb_class2name(CLASS_OF(recv)));
+ rb_obj_classname(recv));
}
if (OBJ_FROZEN(recv)) rb_error_frozen("object");
@@ -3389,7 +3389,7 @@ rb_eval(self, n)
result = rb_eval(self, node->nd_recv);
if (FIXNUM_P(result) || SYMBOL_P(result)) {
rb_raise(rb_eTypeError, "no virtual class for %s",
- rb_class2name(CLASS_OF(result)));
+ rb_obj_classname(result));
}
if (ruby_safe_level >= 4 && !OBJ_TAINTED(result))
rb_raise(rb_eSecurityError, "Insecure: can't extend object");
@@ -3678,7 +3678,7 @@ rb_longjmp(tag, mesg)
StringValue(e);
fprintf(stderr, "Exception `%s' at %s:%d - %s\n",
- rb_class2name(CLASS_OF(ruby_errinfo)),
+ rb_obj_classname(ruby_errinfo),
ruby_sourcefile, ruby_sourceline,
RSTRING(e)->ptr);
fflush(stderr);
@@ -4425,7 +4425,7 @@ rb_f_missing(argc, argv, obj)
snprintf(buf, BUFSIZ, format, rb_id2name(id),
desc, noclass ? "" : ":",
- noclass ? "" : rb_class2name(CLASS_OF(obj)));
+ noclass ? "" : rb_obj_classname(obj));
exc = rb_exc_new2(exc, buf);
rb_iv_set(exc, "name", argv[0]);
rb_iv_set(exc, "args", rb_ary_new4(argc-1, argv+1));
@@ -5076,7 +5076,7 @@ eval(self, src, scope, file, line)
if (!NIL_P(scope)) {
if (!rb_obj_is_block(scope)) {
rb_raise(rb_eTypeError, "wrong argument type %s (expected Proc/Binding)",
- rb_class2name(CLASS_OF(scope)));
+ rb_obj_classname(scope));
}
Data_Get_Struct(scope, struct BLOCK, data);
@@ -6607,7 +6607,7 @@ proc_invoke(proc, args, pcall, self)
if (rb_block_given_p() && ruby_frame->last_func) {
rb_warning("block for %s#%s is useless",
- rb_class2name(CLASS_OF(proc)),
+ rb_obj_classname(proc),
rb_id2name(ruby_frame->last_func));
}
@@ -6727,7 +6727,7 @@ proc_to_s(self, other)
{
struct BLOCK *data;
NODE *node;
- char *cname = rb_class2name(CLASS_OF(self));
+ char *cname = rb_obj_classname(self);
const int w = (SIZEOF_LONG * CHAR_BIT) / 4;
long len = strlen(cname)+6+w; /* 6:tags 16:addr */
VALUE str;
@@ -6803,7 +6803,7 @@ block_pass(self, node)
b = rb_check_convert_type(block, T_DATA, "Proc", "to_proc");
if (!rb_obj_is_proc(b)) {
rb_raise(rb_eTypeError, "wrong argument type %s (expected Proc)",
- rb_class2name(CLASS_OF(block)));
+ rb_obj_classname(block));
}
block = b;
}
@@ -7119,7 +7119,7 @@ method_inspect(method)
Data_Get_Struct(method, struct METHOD, data);
str = rb_str_buf_new2("#<");
- s = rb_class2name(CLASS_OF(method));
+ s = rb_obj_classname(method);
rb_str_buf_cat2(str, s);
rb_str_buf_cat2(str, ": ");
@@ -7228,7 +7228,7 @@ rb_mod_define_method(argc, argv, mod)
body = argv[1];
if (!rb_obj_is_kind_of(body, rb_cMethod) && !rb_obj_is_proc(body)) {
rb_raise(rb_eTypeError, "wrong argument type %s (expected Proc/Method)",
- rb_class2name(CLASS_OF(body)));
+ rb_obj_classname(body));
}
}
else {
@@ -7698,7 +7698,7 @@ rb_thread_check(data)
{
if (TYPE(data) != T_DATA || RDATA(data)->dmark != (RUBY_DATA_FUNC)thread_mark) {
rb_raise(rb_eTypeError, "wrong argument type %s (expected Thread)",
- rb_class2name(CLASS_OF(data)));
+ rb_obj_classname(data));
}
return (rb_thread_t)RDATA(data)->data;
}
@@ -9320,7 +9320,7 @@ static VALUE
rb_thread_inspect(thread)
VALUE thread;
{
- char *cname = rb_class2name(CLASS_OF(thread));
+ char *cname = rb_obj_classname(thread);
rb_thread_t th = rb_thread_check(thread);
const char *status = thread_status_name(th->status);
VALUE str;
View
2 file.c
@@ -307,7 +307,7 @@ rb_stat_inspect(self)
};
str = rb_str_buf_new2("#<");
- rb_str_buf_cat2(str, rb_class2name(CLASS_OF(self)));
+ rb_str_buf_cat2(str, rb_obj_classname(self));
rb_str_buf_cat2(str, " ");
for (i = 0; i < sizeof(member)/sizeof(member[0]); i++) {
View
4 gc.c
@@ -1380,7 +1380,7 @@ add_final(os, proc)
rb_warn("ObjectSpace::add_finalizer is deprecated; use define_finalizer");
if (!rb_obj_is_kind_of(proc, rb_cProc)) {
rb_raise(rb_eArgError, "wrong type argument %s (Proc required)",
- rb_class2name(CLASS_OF(proc)));
+ rb_obj_classname(proc));
}
rb_ary_push(finalizers, proc);
return proc;
@@ -1436,7 +1436,7 @@ define_final(argc, argv, os)
}
else if (!rb_obj_is_kind_of(proc, rb_cProc)) {
rb_raise(rb_eArgError, "wrong type argument %s (Proc required)",
- rb_class2name(CLASS_OF(proc)));
+ rb_obj_classname(proc));
}
need_call_final = 1;
FL_SET(obj, FL_FINALIZE);
View
4 io.c
@@ -647,7 +647,7 @@ rb_io_inspect(obj)
fptr = RFILE(rb_io_taint_check(obj))->fptr;
if (!fptr || !(fptr->f || fptr->f2) || !fptr->path) return rb_any_to_s(obj);
- cname = rb_class2name(CLASS_OF(obj));
+ cname = rb_obj_classname(obj);
buf = ALLOCA_N(char, strlen(cname) + strlen(fptr->path) + 5);
sprintf(buf, "#<%s:%s>", cname, fptr->path);
return rb_str_new2(buf);
@@ -2677,7 +2677,7 @@ rb_io_defset(val, id)
{
if (!rb_respond_to(val, id_write)) {
rb_raise(rb_eTypeError, "$> must have write method, %s given",
- rb_class2name(CLASS_OF(val)));
+ rb_obj_classname(val));
}
rb_defout = val;
}
View
@@ -313,7 +313,7 @@ w_uclass(obj, base_klass, arg)
w_extended(klass, arg);
if (klass != base_klass) {
w_byte(TYPE_UCLASS, arg);
- w_unique(rb_class2name(CLASS_OF(obj)), arg);
+ w_unique(rb_obj_classname(obj), arg);
}
}
@@ -518,7 +518,7 @@ w_object(obj, arg, limit)
VALUE mem;
long i;
- w_unique(rb_class2name(CLASS_OF(obj)), arg);
+ w_unique(rb_obj_classname(obj), arg);
w_long(len, arg);
mem = rb_struct_iv_get(rb_obj_class(obj), "__member__");
if (mem == Qnil) {
@@ -544,7 +544,7 @@ w_object(obj, arg, limit)
if (!rb_respond_to(obj, s_dump_data)) {
rb_raise(rb_eTypeError,
"class %s needs to have instance method `_dump_data'",
- rb_class2name(CLASS_OF(obj)));
+ rb_obj_classname(obj));
}
v = rb_funcall(obj, s_dump_data, 0);
w_object(v, arg, limit);
@@ -553,7 +553,7 @@ w_object(obj, arg, limit)
default:
rb_raise(rb_eTypeError, "can't dump %s",
- rb_class2name(CLASS_OF(obj)));
+ rb_obj_classname(obj));
break;
}
}
View
@@ -96,8 +96,8 @@ coerce_rescue(x)
rb_raise(rb_eTypeError, "%s can't be coerced into %s",
rb_special_const_p(x[1])?
RSTRING(rb_inspect(x[1]))->ptr:
- rb_class2name(CLASS_OF(x[1])),
- rb_class2name(CLASS_OF(x[0])));
+ rb_obj_classname(x[1]),
+ rb_obj_classname(x[0]));
return Qnil; /* dummy */
}
@@ -146,7 +146,7 @@ num_copy_object(x, y)
VALUE x, y;
{
/* Numerics are immutable values, which should not be copied */
- rb_raise(rb_eTypeError, "can't copy %s", rb_class2name(CLASS_OF(x)));
+ rb_raise(rb_eTypeError, "can't copy %s", rb_obj_classname(x));
return Qnil; /* not reached */
}
@@ -1127,7 +1127,7 @@ rb_int_induced_from(klass, x)
return rb_funcall(x, id_to_i, 0);
default:
rb_raise(rb_eTypeError, "failed to convert %s into Integer",
- rb_class2name(CLASS_OF(x)));
+ rb_obj_classname(x));
}
}
@@ -1143,7 +1143,7 @@ rb_flo_induced_from(klass, x)
return x;
default:
rb_raise(rb_eTypeError, "failed to convert %s into Float",
- rb_class2name(CLASS_OF(x)));
+ rb_obj_classname(x));
}
}
Oops, something went wrong.

0 comments on commit a0cf2fd

Please sign in to comment.