public override Dict GetAttrDict(ICallerContext context, object self) { // Get the entries from the type Dict res = new Dict(GetAttrDict(context)); // Add the entries from the instance ISuperDynamicObject sdo = self as ISuperDynamicObject; if (sdo != null) { IAttributesDictionary dict = sdo.GetDict(); if (dict != null) { foreach (KeyValuePair <object, object> val in dict) { object fieldName = val.Key; if (!res.ContainsKey(fieldName)) { res.Add(new KeyValuePair <object, object>(fieldName, val.Value)); } } } } return(res); }
private static IAttributesDictionary GetInitializedDict(ISuperDynamicObject self) { IAttributesDictionary d = self.GetDict(); if (d == null) { d = new FieldIdDict(); self.SetDict(d); } return(d); }
public override List GetAttrNames(ICallerContext context, object self) { // Get the entries from the type List ret = GetAttrNames(context); // Add the entries from the instance ISuperDynamicObject sdo = self as ISuperDynamicObject; if (sdo != null) { if (sdo.GetDict() != null) { ICollection <object> keys = sdo.GetDict().Keys; foreach (object key in keys) { if (!ret.Contains(key)) { ret.AddNoLock(key); } } } } return(ret); }
public static WeakRefTracker GetWeakRefHelper(object self) { ISuperDynamicObject sdo = self as ISuperDynamicObject; if (sdo != null) { IAttributesDictionary dict = sdo.GetDict(); if (dict != null) { object res; if (dict.TryGetValue(SymbolTable.WeakRef, out res)) { return(res as WeakRefTracker); } } } return(null); }
//!!! private would be better, only called from PythonType internal bool TryBaseGetAttr(ICallerContext context, ISuperDynamicObject self, SymbolId name, out object ret) { if (name == SymbolTable.Dict) { ret = GetInitializedDict(self); return(true); } IAttributesDictionary d = self.GetDict(); if (d != null) { if (d.TryGetValue(name, out ret)) { return(true); } } if (TryLookupSlot(context, name, out ret)) { ret = Ops.GetDescriptor(ret, self, this); return(true); } if (name == SymbolTable.Class) { ret = this; return(true); } if (name == SymbolTable.WeakRef) { ret = null; return(true); } if (!__getattr__F.IsObjectMethod()) { ret = __getattr__F.Invoke(self, SymbolTable.IdToString(name)); return(true); } ret = null; return(false); }
public override List GetAttrNames(ICallerContext context, object self) { List baseNames = base.GetAttrNames(context, self); ISuperDynamicObject sdo = self as ISuperDynamicObject; if (sdo != null) { IAttributesDictionary dict = sdo.GetDict(); if (dict != null) { foreach (object o in dict.Keys) { if (!baseNames.Contains(o)) { baseNames.Add(o); } } } } return(baseNames); }
private static IAttributesDictionary GetInitializedDict(ISuperDynamicObject self) { IAttributesDictionary d = self.GetDict(); if (d == null) { d = new FieldIdDict(); if (!self.SetDict(d)) return null; } return d; }