internal static RubyMethod FindMethodForClass(Class klass, Receiver receiverStyle, Frame caller, string methodId, out Class origin) { RubyMethod method; if (klass == null) { origin = null; return null; } if (klass.get_method(methodId, out method, out origin) && method != null) { if (method is MethodAlias) origin = method.definingClass; if (method.access == Access.Private && receiverStyle == Receiver.Explicit) { if (caller != null) caller.call_status = CallStatus.Private; return null; } if (method.access == Access.Protected && receiverStyle == Receiver.Explicit) { Class outerScope = Ruby.Runtime.Init.rb_cObject; if (caller != null) { //Class[] nesting = caller.nesting(); //if (nesting != null && nesting.Length > 0) // outerScope = nesting[0]; outerScope = caller.lastClass(); } if (!outerScope.is_kind_of(method.definingClass)) { if (caller != null) caller.call_status = CallStatus.Protected; return null; } } return method; } else { return null; } }
// In CRuby this is not just a handy abstraction, but does the method caching. (kjg) internal static bool rb_method_boundp(Class klass, string name, bool acceptPrivate) { RubyMethod meth = null; if (klass.get_method(name, out meth)) return (meth.access != Access.Private || acceptPrivate); else return false; }