예제 #1
0
        /// <summary>
        /// Set up the type
        /// </summary>
        /// <param name="resetType">Is an existing type being reset?</param>
        void InitializeUserType(Tuple bases, bool resetType)
        {
            if (resetType)
            {
                foreach (object baseTypeObj in BaseClasses)
                {
                    if (baseTypeObj is OldClass)
                    {
                        continue;
                    }
                    PythonType baseType = baseTypeObj as PythonType;
                    baseType.RemoveSubclass(this);
                }
            }

            this.bases = EnsureBaseType(bases);

            for (int i = 0; i < this.bases.Count; i++)
            {
                for (int j = 0; j < this.bases.Count; j++)
                {
                    if (i != j && this.bases[i] == this.bases[j])
                    {
                        throw Ops.TypeError("duplicate base class {0}", ((DynamicType)this.bases[i]).__name__);
                    }
                }
            }

            foreach (object baseTypeObj in BaseClasses)
            {
                if (baseTypeObj is OldClass)
                {
                    continue;
                }
                PythonType baseType = baseTypeObj as PythonType;
                baseType.AddSubclass(this);
            }

            if (!resetType)
            {
                Initialize();
            }
        }