constant.h: constant visibilities
* constant.h (RB_CONST_PRIVATE_P, RB_CONST_PUBLIC_P): macros to predicate constant visibilities. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1ba17d0e91
commit
02fe713b46
@ -13,9 +13,15 @@
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CONST_PUBLIC = 0x00,
|
CONST_PUBLIC = 0x00,
|
||||||
CONST_PRIVATE = 0x01
|
CONST_PRIVATE,
|
||||||
|
CONST_VISIBILITY_MAX
|
||||||
} rb_const_flag_t;
|
} rb_const_flag_t;
|
||||||
|
|
||||||
|
#define RB_CONST_PRIVATE_P(ce) \
|
||||||
|
((ce)->flag == CONST_PRIVATE)
|
||||||
|
#define RB_CONST_PUBLIC_P(ce) \
|
||||||
|
((ce)->flag == CONST_PUBLIC)
|
||||||
|
|
||||||
typedef struct rb_const_entry_struct {
|
typedef struct rb_const_entry_struct {
|
||||||
rb_const_flag_t flag;
|
rb_const_flag_t flag;
|
||||||
int line;
|
int line;
|
||||||
|
@ -1836,7 +1836,7 @@ rb_const_get_0(VALUE klass, ID id, int exclude, int recurse, int visibility)
|
|||||||
rb_const_entry_t *ce;
|
rb_const_entry_t *ce;
|
||||||
|
|
||||||
while ((ce = rb_const_lookup(tmp, id))) {
|
while ((ce = rb_const_lookup(tmp, id))) {
|
||||||
if (visibility && ce->flag == CONST_PRIVATE) {
|
if (visibility && RB_CONST_PRIVATE_P(ce)) {
|
||||||
rb_name_error(id, "private constant %"PRIsVALUE"::%"PRIsVALUE" referenced",
|
rb_name_error(id, "private constant %"PRIsVALUE"::%"PRIsVALUE" referenced",
|
||||||
rb_class_name(klass), QUOTE_ID(id));
|
rb_class_name(klass), QUOTE_ID(id));
|
||||||
}
|
}
|
||||||
@ -2029,7 +2029,7 @@ list_i(st_data_t key, st_data_t value, VALUE ary)
|
|||||||
{
|
{
|
||||||
ID sym = (ID)key;
|
ID sym = (ID)key;
|
||||||
rb_const_entry_t *ce = (rb_const_entry_t *)value;
|
rb_const_entry_t *ce = (rb_const_entry_t *)value;
|
||||||
if (ce->flag != CONST_PRIVATE) rb_ary_push(ary, ID2SYM(sym));
|
if (RB_CONST_PUBLIC_P(ce)) rb_ary_push(ary, ID2SYM(sym));
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2093,7 +2093,7 @@ rb_const_defined_0(VALUE klass, ID id, int exclude, int recurse, int visibility)
|
|||||||
retry:
|
retry:
|
||||||
while (tmp) {
|
while (tmp) {
|
||||||
if ((ce = rb_const_lookup(tmp, id))) {
|
if ((ce = rb_const_lookup(tmp, id))) {
|
||||||
if (visibility && ce->flag == CONST_PRIVATE) {
|
if (visibility && RB_CONST_PRIVATE_P(ce)) {
|
||||||
return (int)Qfalse;
|
return (int)Qfalse;
|
||||||
}
|
}
|
||||||
if (ce->value == Qundef && !check_autoload_required(tmp, id, 0) && !rb_autoloading_value(tmp, id, 0))
|
if (ce->value == Qundef && !check_autoload_required(tmp, id, 0) && !rb_autoloading_value(tmp, id, 0))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user