From 83cd51e3fe6e1e2be1375602274caa6ae0ac2a86 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 30 Jul 2015 04:20:00 +0000 Subject: variable.c: Module#deprecate_constant * variable.c (rb_const_get_0): warn deprecated constant reference. * variable.c (rb_mod_deprecate_constant): mark constants to be warned as deprecated. [Feature #11398] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- constant.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'constant.h') diff --git a/constant.h b/constant.h index c7de5da533..23d17ac24c 100644 --- a/constant.h +++ b/constant.h @@ -12,15 +12,21 @@ #define CONSTANT_H typedef enum { + CONST_DEPRECATED = 0x100, + + CONST_VISIBILITY_MASK = 0xff, CONST_PUBLIC = 0x00, CONST_PRIVATE, CONST_VISIBILITY_MAX } rb_const_flag_t; #define RB_CONST_PRIVATE_P(ce) \ - ((ce)->flag == CONST_PRIVATE) + (((ce)->flag & CONST_VISIBILITY_MASK) == CONST_PRIVATE) #define RB_CONST_PUBLIC_P(ce) \ - ((ce)->flag == CONST_PUBLIC) + (((ce)->flag & CONST_VISIBILITY_MASK) == CONST_PUBLIC) + +#define RB_CONST_DEPRECATED_P(ce) \ + ((ce)->flag & CONST_DEPRECATED) typedef struct rb_const_entry_struct { rb_const_flag_t flag; @@ -31,6 +37,7 @@ typedef struct rb_const_entry_struct { VALUE rb_mod_private_constant(int argc, const VALUE *argv, VALUE obj); VALUE rb_mod_public_constant(int argc, const VALUE *argv, VALUE obj); +VALUE rb_mod_deprecate_constant(int argc, const VALUE *argv, VALUE obj); void rb_free_const_table(st_table *tbl); VALUE rb_public_const_get(VALUE klass, ID id); VALUE rb_public_const_get_at(VALUE klass, ID id); -- cgit v1.2.1