mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
variable.c: rb_deprecate_constant
* variable.c (rb_deprecate_constant): new function to deprecate a constant by the name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6054e6d65e
commit
e6a260ecdb
2 changed files with 17 additions and 0 deletions
|
@ -1498,6 +1498,7 @@ VALUE rb_search_class_path(VALUE);
|
|||
VALUE rb_attr_delete(VALUE, ID);
|
||||
VALUE rb_ivar_lookup(VALUE obj, ID id, VALUE undef);
|
||||
void rb_autoload_str(VALUE mod, ID id, VALUE file);
|
||||
void rb_deprecate_constant(VALUE mod, const char *name);
|
||||
|
||||
/* version.c */
|
||||
extern const char ruby_engine[];
|
||||
|
|
16
variable.c
16
variable.c
|
@ -2732,6 +2732,22 @@ set_const_visibility(VALUE mod, int argc, const VALUE *argv,
|
|||
rb_clear_constant_cache();
|
||||
}
|
||||
|
||||
void
|
||||
rb_deprecate_constant(VALUE mod, const char *name)
|
||||
{
|
||||
rb_const_entry_t *ce;
|
||||
ID id;
|
||||
long len = strlen(name);
|
||||
|
||||
rb_frozen_class_p(mod);
|
||||
if (!(id = rb_check_id_cstr(name, len, NULL)) ||
|
||||
!(ce = rb_const_lookup(mod, id))) {
|
||||
rb_name_err_raise("constant %2$s::%1$s not defined",
|
||||
mod, rb_fstring_new(name, len));
|
||||
}
|
||||
ce->flag |= CONST_DEPRECATED;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* mod.private_constant(symbol, ...) => mod
|
||||
|
|
Loading…
Reference in a new issue