mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
class.c: instance method conditions
* class.c (ins_methods_i, ins_methods_prot_i, ins_methods_priv_i), (ins_methods_pub_i): check for each conditions to match. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
393ecc9f10
commit
d9a6f701bf
1 changed files with 23 additions and 18 deletions
41
class.c
41
class.c
|
@ -1090,46 +1090,51 @@ rb_mod_ancestors(VALUE mod)
|
||||||
return ary;
|
return ary;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static void
|
||||||
ins_methods_push(ID name, rb_method_visibility_t visi, VALUE ary, rb_method_visibility_t expected_visi)
|
ins_methods_push(st_data_t name, st_data_t ary)
|
||||||
{
|
{
|
||||||
if (visi == METHOD_VISI_UNDEF) return ST_CONTINUE;
|
rb_ary_push((VALUE)ary, ID2SYM((ID)name));
|
||||||
|
}
|
||||||
|
|
||||||
switch (expected_visi) {
|
static int
|
||||||
|
ins_methods_i(st_data_t name, st_data_t type, st_data_t ary)
|
||||||
|
{
|
||||||
|
switch ((rb_method_visibility_t)type) {
|
||||||
case METHOD_VISI_UNDEF:
|
case METHOD_VISI_UNDEF:
|
||||||
if (visi != METHOD_VISI_PRIVATE) rb_ary_push(ary, ID2SYM(name));
|
|
||||||
break;
|
|
||||||
case METHOD_VISI_PRIVATE:
|
case METHOD_VISI_PRIVATE:
|
||||||
case METHOD_VISI_PROTECTED:
|
break;
|
||||||
case METHOD_VISI_PUBLIC:
|
default: /* everything but private */
|
||||||
if (visi == expected_visi) rb_ary_push(ary, ID2SYM(name));
|
ins_methods_push(name, ary);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
ins_methods_i(st_data_t name, st_data_t type, st_data_t ary)
|
|
||||||
{
|
|
||||||
return ins_methods_push((ID)name, (rb_method_visibility_t)type, (VALUE)ary, METHOD_VISI_UNDEF); /* everything but private */
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ins_methods_prot_i(st_data_t name, st_data_t type, st_data_t ary)
|
ins_methods_prot_i(st_data_t name, st_data_t type, st_data_t ary)
|
||||||
{
|
{
|
||||||
return ins_methods_push((ID)name, (rb_method_visibility_t)type, (VALUE)ary, METHOD_VISI_PROTECTED);
|
if ((rb_method_visibility_t)type == METHOD_VISI_PROTECTED) {
|
||||||
|
ins_methods_push(name, ary);
|
||||||
|
}
|
||||||
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ins_methods_priv_i(st_data_t name, st_data_t type, st_data_t ary)
|
ins_methods_priv_i(st_data_t name, st_data_t type, st_data_t ary)
|
||||||
{
|
{
|
||||||
return ins_methods_push((ID)name, (rb_method_visibility_t)type, (VALUE)ary, METHOD_VISI_PRIVATE);
|
if ((rb_method_visibility_t)type == METHOD_VISI_PRIVATE) {
|
||||||
|
ins_methods_push(name, ary);
|
||||||
|
}
|
||||||
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ins_methods_pub_i(st_data_t name, st_data_t type, st_data_t ary)
|
ins_methods_pub_i(st_data_t name, st_data_t type, st_data_t ary)
|
||||||
{
|
{
|
||||||
return ins_methods_push((ID)name, (rb_method_visibility_t)type, (VALUE)ary, METHOD_VISI_PUBLIC);
|
if ((rb_method_visibility_t)type == METHOD_VISI_PUBLIC) {
|
||||||
|
ins_methods_push(name, ary);
|
||||||
|
}
|
||||||
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct method_entry_arg {
|
struct method_entry_arg {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue