public virtual List GetAttrNames(ICallerContext context) { Initialize(); Dictionary <object, object> names = new Dictionary <object, object>(); if ((context.ContextFlags & CallerContextFlags.ShowCls) == 0) { foreach (KeyValuePair <object, object> kvp in dict) { IContextAwareMember icaa = kvp.Value as IContextAwareMember; if (icaa == null || icaa.IsVisible(context)) { string strKey = kvp.Key as string; if (strKey == null) { continue; } names[strKey] = strKey; } } } else { foreach (object key in dict.Keys) { names[key] = null; } } foreach (DynamicType dt in BaseClasses) { if (dt != TypeCache.Object) { foreach (string name in Ops.GetAttrNames(context, dt)) { if (name[0] == '_' && name[1] != '_') { continue; } names[name] = name; } } } names["__class__"] = "__class__"; return(List.Make(names.Keys)); }
internal bool TryGetSlot(ICallerContext context, SymbolId name, out object ret) { Initialize(); switch (name.Id) { case SymbolTable.DictId: ret = dict; return(true); case SymbolTable.GetAttributeId: ret = __getattribute__F; return(true); case SymbolTable.GetAttrId: ret = __getattr__F; return(true); case SymbolTable.SetAttrId: ret = __setattr__F; return(true); case SymbolTable.DelAttrId: ret = __delattr__F; return(true); case SymbolTable.ReprId: ret = __repr__F; return(true); case SymbolTable.StringId: ret = __str__F; return(true); case SymbolTable.CmpId: if (!__cmp__F.IsSuperTypeMethod()) { ret = __cmp__F; return(true); } break; case SymbolTable.MethodResolutionOrderId: if (methodResolutionOrder == null) { methodResolutionOrder = CalculateMro(BaseClasses); } ret = methodResolutionOrder; return(true); } if (dict.TryGetValue(name, out ret)) { IContextAwareMember icam = ret as IContextAwareMember; if (icam != null && !icam.IsVisible(context)) { ret = null; return(false); } return(true); } return(false); }
public bool TryGetAttr(ICallerContext context, SymbolId name, out object value) { if (__dict__.TryGetValue(name, out value)) { IContextAwareMember icaa = value as IContextAwareMember; if (icaa == null || icaa.IsVisible(context)) { return(true); } value = null; } if (name == SymbolTable.Dict) { value = __dict__; return(true); } if (packageImported) { return(innerMod.TryGetAttr(context, name, out value)); } return(false); }
public List GetAttrNames(ICallerContext context) { List ret; if ((context.ContextFlags & CallerContextFlags.ShowCls) == 0) { ret = new List(); foreach (KeyValuePair <object, object> kvp in __dict__) { IContextAwareMember icaa = kvp.Value as IContextAwareMember; if (icaa == null || icaa.IsVisible(context)) { ret.AddNoLock(kvp.Key); } } } else { ret = List.Make(__dict__.Keys); } ret.AddNoLock("__dict__"); if (packageImported) { foreach (object o in innerMod.GetAttrNames(context)) { if (o is string && (string)o == "__dict__") { continue; } if (!((IDictionary <object, object>)__dict__).ContainsKey(o)) { ret.AddNoLock(o); } } } return(ret); }