Beispiel #1
0
        public override Type GetTypesToExtend(out IList <Type> interfacesToExtend)
        {
            interfacesToExtend = new List <Type>();
            foreach (object b in bases)
            {
                if (b is OldClass)
                {
                    continue;
                }

                PythonType   baseType = b as PythonType;
                IList <Type> baseTypeInterfaces;
                baseType.GetTypesToExtend(out baseTypeInterfaces);
                foreach (Type baseTypeInterface in baseTypeInterfaces)
                {
                    interfacesToExtend.Add(baseTypeInterface);
                }
            }
            // We dont use type.GetInterfaces() as it contains all the interfaces that are added by NewTypeMaker,
            // as well as all the interfaces implemented by type.BaseType. Instead, we only want the new set of
            // interfaces that need to be implemented by the new instance type.
            Debug.Assert(interfacesToExtend.Count < type.GetInterfaces().Length);

            // "type" is the instance type used for instances of this type. This will be a type created by NewTypeMaker.
            Debug.Assert(NewTypeMaker.IsInstanceType(type));
            // Its BaseType will the CLI type that needs to be inherited by instance types used by other UserTypes inheriting
            // from the current UserType. For pure Python types, this will be System.Object.
            Debug.Assert(!NewTypeMaker.IsInstanceType(type.BaseType));

            return(type.BaseType);
        }