Feature #2170 ยป 0001--proc.c-Add-Method-UnboundMethod-visibility-predic.patch
| proc.c | ||
|---|---|---|
|
/*
|
||
|
* call-seq:
|
||
|
* meth.private? => true or false
|
||
|
*
|
||
|
* Returns true if meth is a private method.
|
||
|
*/
|
||
|
static VALUE
|
||
|
method_private_p(VALUE obj)
|
||
|
{
|
||
|
struct METHOD *data;
|
||
|
TypedData_Get_Struct(obj, struct METHOD, &method_data_type, data);
|
||
|
if ((data->me.flag & NOEX_MASK) == NOEX_PRIVATE) return Qtrue;
|
||
|
return Qfalse;
|
||
|
}
|
||
|
/*
|
||
|
* call-seq:
|
||
|
* meth.public? => true or false
|
||
|
*
|
||
|
* Returns true if meth is a public method.
|
||
|
*/
|
||
|
static VALUE
|
||
|
method_public_p(VALUE obj)
|
||
|
{
|
||
|
struct METHOD *data;
|
||
|
TypedData_Get_Struct(obj, struct METHOD, &method_data_type, data);
|
||
|
if ((data->me.flag & NOEX_MASK) == NOEX_PUBLIC) return Qtrue;
|
||
|
return Qfalse;
|
||
|
}
|
||
|
/*
|
||
|
* call-seq:
|
||
|
* meth.protected? => true or false
|
||
|
*
|
||
|
* Returns true if meth is a protected method.
|
||
|
*/
|
||
|
static VALUE
|
||
|
method_protected_p(VALUE obj)
|
||
|
{
|
||
|
struct METHOD *data;
|
||
|
TypedData_Get_Struct(obj, struct METHOD, &method_data_type, data);
|
||
|
if ((data->me.flag & NOEX_MASK) == NOEX_PROTECTED) return Qtrue;
|
||
|
return Qfalse;
|
||
|
}
|
||
|
/*
|
||
|
* call-seq:
|
||
|
* obj.method(sym) => method
|
||
|
*
|
||
|
* Looks up the named method as a receiver in <i>obj</i>, returning a
|
||
| ... | ... | |
|
rb_define_method(rb_cMethod, "unbind", method_unbind, 0);
|
||
|
rb_define_method(rb_cMethod, "source_location", rb_method_location, 0);
|
||
|
rb_define_method(rb_cMethod, "parameters", rb_method_parameters, 0);
|
||
|
rb_define_method(rb_cMethod, "public?", method_public_p, 0);
|
||
|
rb_define_method(rb_cMethod, "private?", method_private_p, 0);
|
||
|
rb_define_method(rb_cMethod, "protected?", method_protected_p, 0);
|
||
|
rb_define_method(rb_mKernel, "method", rb_obj_method, 1);
|
||
|
rb_define_method(rb_mKernel, "public_method", rb_obj_public_method, 1);
|
||
| ... | ... | |
|
rb_define_method(rb_cUnboundMethod, "bind", umethod_bind, 1);
|
||
|
rb_define_method(rb_cUnboundMethod, "source_location", rb_method_location, 0);
|
||
|
rb_define_method(rb_cUnboundMethod, "parameters", rb_method_parameters, 0);
|
||
|
rb_define_method(rb_cUnboundMethod, "public?", method_public_p, 0);
|
||
|
rb_define_method(rb_cUnboundMethod, "private?", method_private_p, 0);
|
||
|
rb_define_method(rb_cUnboundMethod, "protected?", method_protected_p, 0);
|
||
|
/* Module#*_method */
|
||
|
rb_define_method(rb_cModule, "instance_method", rb_mod_instance_method, 1);
|
||