// Module#module_function/private/protected/public: public void SetVisibilityNoEventNoLock(RubyContext/*!*/ callerContext, string/*!*/ name, RubyMemberInfo/*!*/ method, RubyMethodVisibility visibility) { Context.RequiresClassHierarchyLock(); RubyMemberInfo existing; bool skipHidden = false; if (TryGetMethod(name, ref skipHidden, out existing)) { // CLR members: Detaches the member from its underlying type (by creating a copy). SetMethodNoEventNoLock(callerContext, name, method.Copy((RubyMemberFlags)visibility, this)); } else { SetMethodNoEventNoLock(callerContext, name, new SuperForwarderInfo((RubyMemberFlags)visibility, method.DeclaringModule, name)); } }
// Module#module_function: public void SetModuleFunctionNoEventNoLock(RubyContext/*!*/ callerContext, string/*!*/ name, RubyMemberInfo/*!*/ method) { // CLR members: Detaches the member from its underlying type (by creating a copy). // TODO: check for CLR instance members, it should be an error to call module_function on them: SingletonClass.SetMethodNoEventNoLock(callerContext, name, method.Copy(RubyMemberFlags.Public, SingletonClass)); }
// Module#module_function/private/protected/public: public void SetVisibilityNoEventNoLock(RubyContext/*!*/ callerContext, string/*!*/ name, RubyMemberInfo/*!*/ method, RubyMethodVisibility visibility) { Context.RequiresClassHierarchyLock(); RubyMemberInfo existing; bool skipHidden = false; if (TryGetMethod(name, ref skipHidden, out existing)) { SetMethodNoEventNoLock(callerContext, name, method.Copy((RubyMemberFlags)visibility, this)); } else { SetMethodNoEventNoLock(callerContext, name, new RubyMemberInfo((RubyMemberFlags)visibility | RubyMemberFlags.SuperForwarder, method.DeclaringModule)); } }
// Module#define_method: public void SetDefinedMethodNoEventNoLock(RubyContext/*!*/ callerContext, string/*!*/ name, RubyMemberInfo/*!*/ method, RubyMethodVisibility visibility) { // CLR members: Detaches the member from its underlying type (by creating a copy). // Note: Method#== returns false on defined methods and redefining the original method doesn't affect the new one: SetMethodNoEventNoLock(callerContext, name, method.Copy((RubyMemberFlags)visibility, this)); }
// Module#define_method: public void SetDefinedMethodNoEventNoLock(RubyContext/*!*/ callerContext, string/*!*/ name, RubyMemberInfo/*!*/ method, RubyMethodVisibility visibility) { // copy method, Method#== returns false on defined methods and redefining the original method doesn't affect the new one: SetMethodNoEventNoLock(callerContext, name, method.Copy((RubyMemberFlags)visibility, this)); }
public void SetMethodVisibility(string/*!*/ name, RubyMemberInfo/*!*/ method, RubyMethodVisibility visibility) { if (method.Visibility != visibility) { AddMethod(name, method.Copy((RubyMemberFlags)visibility, this)); } }
// adds instance and singleton methods of a module function: public void AddModuleFunction(string/*!*/ name, RubyMemberInfo/*!*/ method) { AddMethod(name, method.Copy(RubyMemberFlags.Private, this)); SingletonClass.AddMethod(name, method.Copy(RubyMemberFlags.Public, SingletonClass)); }
// adds method alias via define_method: public void AddDefinedMethod(string/*!*/ name, RubyMemberInfo/*!*/ method) { // copy method, Method#== returns false on defined methods: AddMethod(name, method.Copy(method.Flags, this)); }
public void SetMethodVisibility(RubyContext/*!*/ callerContext, string/*!*/ name, RubyMemberInfo/*!*/ method, RubyMethodVisibility visibility) { if (method.Visibility != visibility) { AddMethod(callerContext, name, method.Copy((RubyMemberFlags)visibility, this)); } }