зеркало из https://github.com/github/ruby.git
* eval.c: remove specialized version of rb_Array(). use simple
one defined in object.c. * object.c (Init_Object): remove Kernel#to_a. * enum.c (enum_zip): use "to_a" instead of "to_ary". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
ab6963043d
Коммит
bfb47068b0
|
@ -1,3 +1,12 @@
|
|||
Thu Mar 18 15:27:25 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c: remove specialized version of rb_Array(). use simple
|
||||
one defined in object.c.
|
||||
|
||||
* object.c (Init_Object): remove Kernel#to_a.
|
||||
|
||||
* enum.c (enum_zip): use "to_a" instead of "to_ary".
|
||||
|
||||
Wed Mar 17 00:22:03 2004 Kazuo Saito <ksaito@uranus.dti.ne.jp>
|
||||
|
||||
* oniguruma.h: imported Oniguruma 2.2.5.
|
||||
|
|
2
array.c
2
array.c
|
@ -915,7 +915,7 @@ rb_ary_to_ary(obj)
|
|||
return obj;
|
||||
}
|
||||
if (rb_respond_to(obj, rb_intern("to_ary"))) {
|
||||
return rb_convert_type(obj, T_ARRAY, "Array", "to_ary");
|
||||
return to_ary(obj);
|
||||
}
|
||||
return rb_ary_new3(1, obj);
|
||||
}
|
||||
|
|
2
enum.c
2
enum.c
|
@ -889,7 +889,7 @@ enum_zip(argc, argv, obj)
|
|||
NODE *memo;
|
||||
|
||||
for (i=0; i<argc; i++) {
|
||||
argv[i] = rb_convert_type(argv[i], T_ARRAY, "Array", "to_ary");
|
||||
argv[i] = rb_convert_type(argv[i], T_ARRAY, "Array", "to_a");
|
||||
}
|
||||
result = rb_block_given_p() ? Qnil : rb_ary_new();
|
||||
memo = rb_node_newnode(NODE_MEMO, result, rb_ary_new4(argc, argv), 0);
|
||||
|
|
28
eval.c
28
eval.c
|
@ -2598,34 +2598,6 @@ avalue_splat(v)
|
|||
return v;
|
||||
}
|
||||
|
||||
#if 1
|
||||
VALUE
|
||||
rb_Array(val)
|
||||
VALUE val;
|
||||
{
|
||||
VALUE tmp = rb_check_array_type(val);
|
||||
|
||||
if (NIL_P(tmp)) {
|
||||
/* hack to avoid invoke Object#to_a */
|
||||
VALUE origin;
|
||||
ID id = rb_intern("to_a");
|
||||
|
||||
if (search_method(CLASS_OF(val), id, &origin) &&
|
||||
RCLASS(origin)->m_tbl != RCLASS(rb_mKernel)->m_tbl) { /* exclude Kernel#to_a */
|
||||
val = rb_funcall(val, id, 0);
|
||||
if (TYPE(val) != T_ARRAY) {
|
||||
rb_raise(rb_eTypeError, "`to_a' did not return Array");
|
||||
}
|
||||
return val;
|
||||
}
|
||||
else {
|
||||
return rb_ary_new3(1, val);
|
||||
}
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
#endif
|
||||
|
||||
static VALUE
|
||||
splat_value(v)
|
||||
VALUE v;
|
||||
|
|
|
@ -71,7 +71,7 @@ module RSS
|
|||
class UnknownConversionMethodError < Error
|
||||
attr_reader :to, :from
|
||||
def initialize(to, from)
|
||||
@to = from
|
||||
@to = to
|
||||
@from = from
|
||||
super("can't convert to #{to} from #{from}.")
|
||||
end
|
||||
|
@ -83,7 +83,7 @@ module RSS
|
|||
attr_reader :string, :to, :from
|
||||
def initialize(string, to, from)
|
||||
@string = string
|
||||
@to = from
|
||||
@to = to
|
||||
@from = from
|
||||
super("can't convert #{@string} to #{to} from #{from}.")
|
||||
end
|
||||
|
|
28
object.c
28
object.c
|
@ -178,7 +178,6 @@ rb_obj_type(obj)
|
|||
return rb_class_real(CLASS_OF(obj));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* obj.class => class
|
||||
|
@ -316,30 +315,6 @@ rb_obj_init_copy(obj, orig)
|
|||
return obj;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* obj.to_a -> anArray
|
||||
*
|
||||
* Returns an array representation of <i>obj</i>. For objects of class
|
||||
* <code>Object</code> and others that don't explicitly override the
|
||||
* method, the return value is an array containing <code>self</code>.
|
||||
* However, this latter behavior will soon be obsolete.
|
||||
*
|
||||
* self.to_a #=> -:1: warning: default `to_a' will be obsolete
|
||||
* "hello".to_a #=> ["hello"]
|
||||
* Time.new.to_a #=> [39, 54, 8, 9, 4, 2003, 3, 99, true, "CDT"]
|
||||
*/
|
||||
|
||||
|
||||
static VALUE
|
||||
rb_any_to_a(obj)
|
||||
VALUE obj;
|
||||
{
|
||||
rb_warn("default `to_a' will be obsolete");
|
||||
return rb_ary_new3(1, obj);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* obj.to_s => string
|
||||
|
@ -2322,7 +2297,6 @@ rb_f_string(obj, arg)
|
|||
return rb_String(arg);
|
||||
}
|
||||
|
||||
#if 0
|
||||
VALUE
|
||||
rb_Array(val)
|
||||
VALUE val;
|
||||
|
@ -2345,7 +2319,6 @@ rb_Array(val)
|
|||
}
|
||||
return tmp;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
|
@ -2507,7 +2480,6 @@ Init_Object()
|
|||
rb_define_method(rb_mKernel, "freeze", rb_obj_freeze, 0);
|
||||
rb_define_method(rb_mKernel, "frozen?", rb_obj_frozen_p, 0);
|
||||
|
||||
rb_define_method(rb_mKernel, "to_a", rb_any_to_a, 0); /* to be removed */
|
||||
rb_define_method(rb_mKernel, "to_s", rb_any_to_s, 0);
|
||||
rb_define_method(rb_mKernel, "inspect", rb_obj_inspect, 0);
|
||||
rb_define_method(rb_mKernel, "methods", rb_obj_methods, -1);
|
||||
|
|
Загрузка…
Ссылка в новой задаче