summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-09-09 03:02:22 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-09-09 03:02:22 (GMT)
commite6a260ecdbe57d14ae01e6c03977775af574b132 (patch)
tree09e71e76839e96e2887100ebcd47e95c990748ff /variable.c
parent6054e6d65e1da1362971ee2f7eaa11ea018a0663 (diff)
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
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/variable.c b/variable.c
index 2465212..e924505 100644
--- a/variable.c
+++ b/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