GetName() public method

public GetName ( RubyContext context ) : string
context RubyContext
return string
Example #1
0
        private static void DefineMethod(RubyScope /*!*/ scope, RubyModule /*!*/ self, string /*!*/ methodName, RubyMemberInfo /*!*/ info,
                                         RubyModule /*!*/ targetConstraint)
        {
            var visibility = GetDefinedMethodVisibility(scope, self, methodName);

            using (self.Context.ClassHierarchyLocker()) {
                // MRI 1.8 does the check when the method is called, 1.9 checks it upfront as we do:
                if (!self.HasAncestorNoLock(targetConstraint))
                {
                    throw RubyExceptions.CreateTypeError(
                              "bind argument must be a subclass of {0}", targetConstraint.GetName(scope.RubyContext)
                              );
                }

                self.SetDefinedMethodNoEventNoLock(self.Context, methodName, info, visibility);
            }

            self.MethodAdded(methodName);
        }
Example #2
0
        private static void DefineMethod(RubyScope/*!*/ scope, RubyModule/*!*/ self, string/*!*/ methodName, RubyMemberInfo/*!*/ info,
            RubyModule/*!*/ targetConstraint) {

            // MRI: doesn't create a singleton method if module_function is used in the scope, however the the private visibility is applied
            var attributesScope = scope.GetMethodAttributesDefinitionScope();
            bool isModuleFunction = (attributesScope.MethodAttributes & RubyMethodAttributes.ModuleFunction) == RubyMethodAttributes.ModuleFunction;
            var visibility = isModuleFunction ? RubyMethodVisibility.Private : attributesScope.Visibility;

            using (self.Context.ClassHierarchyLocker()) {
                // MRI 1.8 does the check when the method is called, 1.9 checks it upfront as we do:
                if (!self.HasAncestorNoLock(targetConstraint)) {
                    throw RubyExceptions.CreateTypeError(
                        String.Format("bind argument must be a subclass of {0}", targetConstraint.GetName(scope.RubyContext))
                    );
                }

                self.SetDefinedMethodNoEventNoLock(self.Context, methodName, info, visibility);
            }

            self.Context.MethodAdded(self, methodName);
        }
Example #3
0
        private static void DefineMethod(RubyScope/*!*/ scope, RubyModule/*!*/ self, string/*!*/ methodName, RubyMemberInfo/*!*/ info,
            RubyModule/*!*/ targetConstraint) {

            var visibility = GetDefinedMethodVisibility(scope, self, methodName);
            using (self.Context.ClassHierarchyLocker()) {
                // MRI 1.8 does the check when the method is called, 1.9 checks it upfront as we do:
                if (!self.HasAncestorNoLock(targetConstraint)) {
                    throw RubyExceptions.CreateTypeError(
                        "bind argument must be a subclass of {0}", targetConstraint.GetName(scope.RubyContext)
                    );
                }

                self.SetDefinedMethodNoEventNoLock(self.Context, methodName, info, visibility);
            }

            self.MethodAdded(methodName);
        }
Example #4
0
        internal static MutableString/*!*/ ToS(RubyContext/*!*/ context, string/*!*/ methodName, RubyModule/*!*/ declaringModule, RubyModule/*!*/ targetModule, 
            string/*!*/ classDisplayName) {

            MutableString result = MutableString.CreateMutable();
            result.Append("#<");
            result.Append(classDisplayName);
            result.Append(": ");

            if (ReferenceEquals(targetModule, declaringModule)) {
                result.Append(declaringModule.GetName(context));
            } else {
                result.Append(targetModule.GetName(context));
                result.Append('(');
                result.Append(declaringModule.GetName(context));
                result.Append(')');
            }

            result.Append('#');
            result.Append(methodName);
            result.Append('>');
            return result; 
        }