diff --git a/ChangeLog b/ChangeLog index a3139aff22..a3428beaa2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Jun 16 23:05:57 2004 Yukihiro Matsumoto + + * object.c (rb_mod_freeze): prepare string representation before + freezing. [ruby-talk:103646] + Wed Jun 16 19:57:24 2004 Michal Rokos * test/ruby/test_array.rb: extend testcase to check #first, #last, diff --git a/class.c b/class.c index bf0457bb75..6a21cb66d9 100644 --- a/class.c +++ b/class.c @@ -652,8 +652,8 @@ class_instance_method_list(argc, argv, mod, func) * end * * A.instance_methods #=> ["method1"] - * B.instance_methods #=> ["method2"] - * C.instance_methods #=> ["method3"] + * B.instance_methods(false) #=> ["method2"] + * C.instance_methods(false) #=> ["method3"] * C.instance_methods(true).length #=> 43 */ @@ -756,8 +756,8 @@ rb_class_public_instance_methods(argc, argv, mod) * end * * Single.singleton_methods #=> ["four"] - * a.singleton_methods #=> ["two", "one"] - * a.singleton_methods(true) #=> ["two", "one", "three"] + * a.singleton_methods(false) #=> ["two", "one"] + * a.singleton_methods #=> ["two", "one", "three"] */ VALUE @@ -809,11 +809,7 @@ rb_define_method(klass, name, func, argc) VALUE (*func)(); int argc; { - ID id = rb_intern(name); - int ex = NOEX_PUBLIC; - - - rb_add_method(klass, id, NEW_CFUNC(func, argc), ex); + rb_add_method(klass, rb_intern(name), NEW_CFUNC(func, argc), NOEX_PUBLIC); } void diff --git a/eval.c b/eval.c index 76178c998b..2d8eca0ab7 100644 --- a/eval.c +++ b/eval.c @@ -8011,8 +8011,6 @@ static int block_orphan(data) struct BLOCK *data; { - struct tag *tt; - if (data->scope->flags & SCOPE_NOSTACK) { return 1; } diff --git a/numeric.c b/numeric.c index 763e4d2ba6..1c89e11806 100644 --- a/numeric.c +++ b/numeric.c @@ -12,6 +12,7 @@ #include "ruby.h" #include "env.h" +#include #include #include diff --git a/object.c b/object.c index f2c8c5f522..c3554b38f0 100644 --- a/object.c +++ b/object.c @@ -1213,6 +1213,21 @@ rb_mod_to_s(klass) return rb_str_dup(rb_class_name(klass)); } +/* + * call-seq: + * mod.freeze + * + * Prevents further modifications to mod. + */ + +static VALUE +rb_mod_freeze(mod) + VALUE mod; +{ + rb_mod_to_s(mod); + return rb_obj_freeze(mod); +} + /* * call-seq: * mod === obj => true or false @@ -2597,6 +2612,7 @@ Init_Object() rb_define_method(rb_cSymbol, "id2name", sym_to_s, 0); rb_define_method(rb_cSymbol, "to_sym", sym_to_sym, 0); + rb_define_method(rb_cModule, "freeze", rb_mod_freeze, 0); rb_define_method(rb_cModule, "===", rb_mod_eqq, 1); rb_define_method(rb_cModule, "==", rb_obj_equal, 1); rb_define_method(rb_cModule, "<=>", rb_mod_cmp, 1);