diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | class.c | 14 | ||||
-rw-r--r-- | eval.c | 2 | ||||
-rw-r--r-- | numeric.c | 1 | ||||
-rw-r--r-- | object.c | 16 |
5 files changed, 27 insertions, 11 deletions
@@ -1,3 +1,8 @@ +Wed Jun 16 23:05:57 2004 Yukihiro Matsumoto <matz@ruby-lang.org> + + * object.c (rb_mod_freeze): prepare string representation before + freezing. [ruby-talk:103646] + Wed Jun 16 19:57:24 2004 Michal Rokos <michal@ruby-lang.org> * test/ruby/test_array.rb: extend testcase to check #first, #last, @@ -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 @@ -8011,8 +8011,6 @@ static int block_orphan(data) struct BLOCK *data; { - struct tag *tt; - if (data->scope->flags & SCOPE_NOSTACK) { return 1; } @@ -12,6 +12,7 @@ #include "ruby.h" #include "env.h" +#include <ctype.h> #include <math.h> #include <stdio.h> @@ -1215,6 +1215,21 @@ rb_mod_to_s(klass) /* * call-seq: + * mod.freeze + * + * Prevents further modifications to <i>mod</i>. + */ + +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 * * Case Equality---Returns <code>true</code> if <i>anObject</i> is an @@ -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); |