1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* variable.c, intern.h: Add rb_const_remove().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@27051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2010-03-25 18:59:19 +00:00
parent 2292de78b1
commit c36f4b164b
3 changed files with 16 additions and 2 deletions

View file

@ -1,3 +1,7 @@
Fri Mar 26 03:58:37 2010 Akinori MUSHA <knu@iDaemons.org>
* variable.c, intern.h: Add rb_const_remove().
Fri Mar 26 03:09:30 2010 Akinori MUSHA <knu@iDaemons.org>
* object.c (rb_obj_singleton_class): new method

View file

@ -521,6 +521,7 @@ VALUE rb_const_get _((VALUE, ID));
VALUE rb_const_get_at _((VALUE, ID));
VALUE rb_const_get_from _((VALUE, ID));
void rb_const_set _((VALUE, ID, VALUE));
VALUE rb_const_remove _((VALUE, ID));
VALUE rb_mod_constants _((VALUE));
VALUE rb_mod_const_missing _((VALUE,VALUE));
VALUE rb_cvar_defined _((VALUE, ID));

View file

@ -1479,12 +1479,21 @@ rb_mod_remove_const(mod, name)
VALUE mod, name;
{
const ID id = rb_to_id(name);
VALUE val;
st_data_t v, n = id;
if (!rb_is_const_id(id)) {
rb_name_error(id, "`%s' is not allowed as a constant name", rb_id2name(id));
}
return rb_const_remove(mod, id);
}
VALUE
rb_const_remove(mod, id)
VALUE mod;
ID id;
{
VALUE val;
st_data_t v, n = id;
if (!OBJ_TAINTED(mod) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't remove constant");
if (OBJ_FROZEN(mod)) rb_error_frozen("class/module");