mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* object.c (rb_mod_le): returns nil if two classes/modules are not
in class-superclass relationship. * object.c (rb_mod_cmp): uses new rb_mod_le() behavior. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3802 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
42fd4ff686
commit
068170e47a
3 changed files with 35 additions and 19 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,10 @@
|
|||
Thu May 15 16:55:16 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* object.c (rb_mod_le): returns nil if two classes/modules are not
|
||||
in class-superclass relationship.
|
||||
|
||||
* object.c (rb_mod_cmp): uses new rb_mod_le() behavior.
|
||||
|
||||
Thu May 15 07:45:30 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
|
||||
|
||||
* ext/ruby/ext/syck/rubyext.c, lib/implicit.re: timestamp repairs to
|
||||
|
@ -7,6 +14,9 @@ Thu May 15 07:45:30 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
|
|||
|
||||
Thu May 15 13:26:48 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* class.c (rb_class_instance_methods): default will be changed in
|
||||
1.8.1.
|
||||
|
||||
* io.c (set_stdio): better message.
|
||||
|
||||
Thu May 15 13:18:11 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
|
20
class.c
20
class.c
|
@ -564,8 +564,8 @@ rb_class_instance_methods(argc, argv, mod)
|
|||
|
||||
rb_scan_args(argc, argv, "01", &recur);
|
||||
if (argc == 0) {
|
||||
#if RUBY_RELEASE_CODE < 20040101
|
||||
rb_warn("instance_methods parameter will default to 'true' in Jan 2004");
|
||||
#if RUBY_VERSION_CODE < 181
|
||||
rb_warn("instance_methods parameter will default to 'true' after 1.8.1");
|
||||
#else
|
||||
recur = Qtrue;
|
||||
#endif
|
||||
|
@ -583,8 +583,8 @@ rb_class_protected_instance_methods(argc, argv, mod)
|
|||
|
||||
rb_scan_args(argc, argv, "01", &recur);
|
||||
if (argc == 0) {
|
||||
#if RUBY_RELEASE_CODE < 20040101
|
||||
rb_warn("protected_instance_methods parameter will default to 'true' in Jan 2004");
|
||||
#if RUBY_VERSION_CODE < 181
|
||||
rb_warn("protected_instance_methods parameter will default to 'true' after 1.8.1");
|
||||
#else
|
||||
recur = Qtrue;
|
||||
#endif
|
||||
|
@ -602,8 +602,8 @@ rb_class_private_instance_methods(argc, argv, mod)
|
|||
|
||||
rb_scan_args(argc, argv, "01", &recur);
|
||||
if (argc == 0) {
|
||||
#if RUBY_RELEASE_CODE < 20040101
|
||||
rb_warn("private_instance_methods parameter will default to 'true' in Jan 2004");
|
||||
#if RUBY_VERSION_CODE < 181
|
||||
rb_warn("private_instance_methods parameter will default to 'true' after 1.8.1");
|
||||
#else
|
||||
recur = Qtrue;
|
||||
#endif
|
||||
|
@ -621,8 +621,8 @@ rb_class_public_instance_methods(argc, argv, mod)
|
|||
|
||||
rb_scan_args(argc, argv, "01", &recur);
|
||||
if (argc == 0) {
|
||||
#if RUBY_RELEASE_CODE < 20040101
|
||||
rb_warn("public_instance_methods parameter will default to 'true' in Jan 2004");
|
||||
#if RUBY_VERSION_CODE < 181
|
||||
rb_warn("public_instance_methods parameter will default to 'true' after 1.8.1");
|
||||
#else
|
||||
recur = Qtrue;
|
||||
#endif
|
||||
|
@ -641,8 +641,8 @@ rb_obj_singleton_methods(argc, argv, obj)
|
|||
|
||||
rb_scan_args(argc, argv, "01", &recur);
|
||||
if (argc == 0) {
|
||||
#if RUBY_RELEASE_CODE < 20040101
|
||||
rb_warn("singleton_methods parameter will default to 'true' in Jan 2004");
|
||||
#if RUBY_VERSION_CODE < 181
|
||||
rb_warn("singleton_methods parameter will default to 'true' after 1.8.1");
|
||||
#else
|
||||
recur = Qtrue;
|
||||
#endif
|
||||
|
|
24
object.c
24
object.c
|
@ -597,6 +597,8 @@ static VALUE
|
|||
rb_mod_le(mod, arg)
|
||||
VALUE mod, arg;
|
||||
{
|
||||
VALUE start = mod;
|
||||
|
||||
if (mod == arg) return Qtrue;
|
||||
switch (TYPE(arg)) {
|
||||
case T_MODULE:
|
||||
|
@ -611,7 +613,13 @@ rb_mod_le(mod, arg)
|
|||
return Qtrue;
|
||||
mod = RCLASS(mod)->super;
|
||||
}
|
||||
return Qfalse;
|
||||
/* not mod < arg; check if mod > arg */
|
||||
while (arg) {
|
||||
if (RCLASS(arg)->m_tbl == RCLASS(start)->m_tbl)
|
||||
return Qfalse;
|
||||
arg = RCLASS(arg)->super;
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -650,6 +658,7 @@ rb_mod_cmp(mod, arg)
|
|||
VALUE mod, arg;
|
||||
{
|
||||
VALUE start = mod;
|
||||
VALUE cmp;
|
||||
|
||||
if (mod == arg) return INT2FIX(0);
|
||||
switch (TYPE(arg)) {
|
||||
|
@ -660,16 +669,13 @@ rb_mod_cmp(mod, arg)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
if (rb_mod_le(mod, arg)) {
|
||||
cmp = rb_mod_le(mod, arg);
|
||||
|
||||
if (cmp) {
|
||||
return INT2FIX(-1);
|
||||
}
|
||||
|
||||
while (arg) {
|
||||
if (RCLASS(arg)->m_tbl == RCLASS(start)->m_tbl)
|
||||
return INT2FIX(1);
|
||||
arg = RCLASS(arg)->super;
|
||||
}
|
||||
return Qnil;
|
||||
if (NIL_P(cmp)) return Qnil;
|
||||
return INT2FIX(1);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
|
Loading…
Reference in a new issue