diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-01 13:16:09 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-01 13:16:09 +0000 |
commit | ac761cda209ded2ef48bec9fcc54a979bc6caafc (patch) | |
tree | 8000b2085994162b5fb597dc3c14c609681408f9 /numeric.c | |
parent | b0acbc4c9afd41602ec9f4b0ee6914b4461ccd32 (diff) |
* numeric.c (num_sadded): prohibit singleton method definition for
Numerics. fill yet another gap between Fixnum and Bignum.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -159,6 +159,19 @@ rb_num_coerce_relop(x, y) } static VALUE +num_sadded(x, name) + VALUE x, name; +{ + ruby_frame = ruby_frame->prev; /* pop frame for "singleton_method_added" */ + /* Numerics should be values; singleton_methods should not be added to them */ + rb_raise(rb_eTypeError, + "can't define singleton method \"%s\" for %s", + rb_id2name(rb_to_id(name)), + rb_obj_classname(x)); + return Qnil; /* not reached */ +} + +static VALUE num_init_copy(x, y) VALUE x, y; { @@ -1820,6 +1833,7 @@ Init_Numeric() rb_eFloatDomainError = rb_define_class("FloatDomainError", rb_eRangeError); rb_cNumeric = rb_define_class("Numeric", rb_cObject); + rb_define_method(rb_cNumeric, "singleton_method_added", num_sadded, 1); rb_include_module(rb_cNumeric, rb_mComparable); rb_define_method(rb_cNumeric, "initialize_copy", num_init_copy, 1); rb_define_method(rb_cNumeric, "coerce", num_coerce, 1); |