internal MappingProxy(CodeContext context, PythonType /*!*/ dt) { Debug.Assert(dt != null); Dictionary = dt.GetMemberDictionary(context, false); }
public int __len__(CodeContext context) { return(_dt.GetMemberDictionary(context, false).Count); }
public static void Set__bases__(CodeContext/*!*/ context, PythonType/*!*/ type, object value) { // validate we got a tuple... PythonTuple t = value as PythonTuple; if (t == null) throw PythonOps.TypeError("expected tuple of types or old-classes, got '{0}'", PythonTypeOps.GetName(value)); List<PythonType> ldt = new List<PythonType>(); foreach (object o in t) { // gather all the type objects... PythonType adt = o as PythonType; if (adt == null) { OldClass oc = o as OldClass; if (oc == null) { throw PythonOps.TypeError("expected tuple of types, got '{0}'", PythonTypeOps.GetName(o)); } adt = oc.TypeObject; } ldt.Add(adt); } // Ensure that we are not switching the CLI type Type newType = NewTypeMaker.GetNewType(type.Name, t, type.GetMemberDictionary(DefaultContext.Default)); if (type.UnderlyingSystemType != newType) throw PythonOps.TypeErrorForIncompatibleObjectLayout("__bases__ assignment", type, newType); // set bases & the new resolution order List<PythonType> mro = CalculateMro(type, ldt); type.BaseTypes = ldt; type._resolutionOrder = mro; }