HasAncestorNoLock() public méthode

public HasAncestorNoLock ( RubyModule module ) : bool
module RubyModule
Résultat bool
Exemple #1
0
        public static object Comparison(RubyModule /*!*/ self, [NotNull] RubyModule /*!*/ module)
        {
            if (ReferenceEquals(self, module))
            {
                return(ClrInteger.Zero);
            }

            if (self.Context != module.Context)
            {
                return(null);
            }

            using (self.Context.ClassHierarchyLocker()) {
                if (self.HasAncestorNoLock(module))
                {
                    return(ClrInteger.MinusOne);
                }

                if (module.HasAncestorNoLock(self))
                {
                    return(ClrInteger.One);
                }
            }
            return(null);
        }
Exemple #2
0
        public static object IsNotSubclassSameOrIncluded(RubyModule /*!*/ self, [NotNull] RubyModule /*!*/ module)
        {
            if (self.Context != module.Context)
            {
                return(null);
            }

            using (self.Context.ClassHierarchyLocker()) {
                if (module.HasAncestorNoLock(self))
                {
                    return(ScriptingRuntimeHelpers.True);
                }
                return(self.HasAncestorNoLock(module) ? ScriptingRuntimeHelpers.False : null);
            }
        }
Exemple #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);
        }
Exemple #4
0
        public static object Comparison(RubyModule/*!*/ self, [NotNull]RubyModule/*!*/ module) {
            if (ReferenceEquals(self, module)) {
                return ClrInteger.Zero;
            }

            if (self.Context != module.Context) {
                return null;
            }

            using (self.Context.ClassHierarchyLocker()) {
                if (self.HasAncestorNoLock(module)) {
                    return ClrInteger.MinusOne;
                }

                if (module.HasAncestorNoLock(self)) {
                    return ClrInteger.One;
                }
            }
            return null;
        }
Exemple #5
0
 public static object IsNotSubclassSameOrIncluded(RubyModule/*!*/ self, [NotNull]RubyModule/*!*/ module) {
     if (self.Context != module.Context) {
         return null;
     } 
     
     using (self.Context.ClassHierarchyLocker()) {
         if (module.HasAncestorNoLock(self)) {
             return ScriptingRuntimeHelpers.True;
         }
         return self.HasAncestorNoLock(module) ? ScriptingRuntimeHelpers.False : null;
     }
 }
Exemple #6
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);
        }
Exemple #7
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);
        }
Exemple #8
0
        public static object Comparison(RubyModule/*!*/ self, [NotNull]RubyModule/*!*/ module) {
            if (ReferenceEquals(self, module)) {
                return ScriptingRuntimeHelpers.Int32ToObject(0);
            }

            if (self.Context != module.Context) {
                return null;
            }

            using (self.Context.ClassHierarchyLocker()) {
                if (self.HasAncestorNoLock(module)) {
                    return ScriptingRuntimeHelpers.Int32ToObject(-1);
                }

                if (module.HasAncestorNoLock(self)) {
                    return ScriptingRuntimeHelpers.Int32ToObject(1);
                }
            }
            return null;
        }