// friend: RubyContext // tracker: non-null => show members declared on the tracker internal RubyClass(RubyContext/*!*/ context, string name, Type type, object singletonClassOf, Action<RubyModule> methodsInitializer, Action<RubyModule> constantsInitializer, Delegate/*!*/[] factories, RubyClass superClass, RubyModule/*!*/[] expandedMixins, TypeTracker tracker, RubyStruct.Info structInfo, bool isRubyClass, bool isSingletonClass, ModuleRestrictions restrictions) : base(context, name, methodsInitializer, constantsInitializer, expandedMixins, type != typeof(object) ? null : context.Namespaces, tracker, restrictions) { Debug.Assert(context.Namespaces != null, "Namespaces should be initialized"); Debug.Assert(superClass != null || structInfo == null, "BasicObject is not a struct"); Debug.Assert(!isRubyClass || tracker == null, "Ruby class cannot have a tracker"); Debug.Assert(singletonClassOf != null || !isSingletonClass, "Singleton classes don't have a type"); Debug.Assert(superClass != this); _underlyingSystemType = type; _superClass = superClass; _isSingletonClass = isSingletonClass; _isRubyClass = isRubyClass; _singletonClassOf = singletonClassOf; _factories = factories ?? Utils.EmptyDelegates; if (superClass != null) { _level = superClass.Level + 1; _structInfo = structInfo ?? superClass._structInfo; } else { _level = 0; } }
internal RubyModule(RubyContext/*!*/ context, string name, Action<RubyModule> methodsInitializer, Action<RubyModule> constantsInitializer, RubyModule/*!*/[] expandedMixins, NamespaceTracker namespaceTracker, TypeTracker typeTracker, ModuleRestrictions restrictions) { Assert.NotNull(context); Debug.Assert(namespaceTracker == null || typeTracker == null || typeTracker.Type == typeof(object)); Debug.Assert(expandedMixins == null || CollectionUtils.TrueForAll(expandedMixins, (m) => m != this && m != null && !m.IsClass && m.Context == context) ); _context = context; _name = name; _methodsInitializer = methodsInitializer; _constantsInitializer = constantsInitializer; _namespaceTracker = namespaceTracker; _typeTracker = typeTracker; _mixins = expandedMixins ?? EmptyArray; _restrictions = restrictions; _weakSelf = new WeakReference(this); Version = new VersionHandle(Interlocked.Increment(ref _globalMethodVersion)); Version.SetName(name); Id = Interlocked.Increment(ref _globalModuleId); }
// friend: RubyContext // tracker: non-null => show members declared on the tracker internal RubyClass(RubyContext/*!*/ context, string name, Type type, object singletonClassOf, Action<RubyModule> methodsInitializer, Action<RubyModule> constantsInitializer, Delegate/*!*/[] factories, RubyClass superClass, RubyModule/*!*/[] expandedMixins, TypeTracker tracker, RubyStruct.Info structInfo, bool isRubyClass, bool isSingletonClass, ModuleRestrictions restrictions) : base(context, name, methodsInitializer, constantsInitializer, expandedMixins, null, tracker, restrictions) { Debug.Assert((superClass == null) == (type == typeof(object)), "All classes have a superclass, except for Object"); Debug.Assert(superClass != null || structInfo == null, "Object is not a struct"); Debug.Assert(!isRubyClass || tracker == null, "Ruby class cannot have a tracker"); Debug.Assert(singletonClassOf != null || !isSingletonClass, "Singleton classes don't have a type"); Debug.Assert(superClass != this); _underlyingSystemType = type; _superClass = superClass; _isSingletonClass = isSingletonClass; _isRubyClass = isRubyClass; _singletonClassOf = singletonClassOf; _factories = factories ?? Utils.EmptyDelegates; if (superClass != null) { _level = superClass.Level + 1; _structInfo = structInfo ?? superClass._structInfo; } else { _level = 0; } _weakSelf = new WeakReference(this); Version = new VersionHandle(Interlocked.Increment(ref _globalVersion)); Version.SetName(name); }
internal RubyModule(RubyContext/*!*/ context, string name, Action<RubyModule> methodsInitializer, Action<RubyModule> constantsInitializer, RubyModule/*!*/[] expandedMixins, NamespaceTracker namespaceTracker, TypeTracker typeTracker, ModuleRestrictions restrictions) { Assert.NotNull(context); Debug.Assert(namespaceTracker == null || typeTracker == null); Debug.Assert(expandedMixins == null || CollectionUtils.TrueForAll(expandedMixins, (m) => m != this && m != null && !m.IsClass && m.Context == context) ); _context = context; _name = name; _methodsInitializer = methodsInitializer; _constantsInitializer = constantsInitializer; _namespaceTracker = namespaceTracker; _typeTracker = typeTracker; _mixins = expandedMixins ?? EmptyArray; _restrictions = restrictions; }