bool IAttributesDictionary.TryGetValue(SymbolId key, out object value) { return(TryGetValue(SymbolTable.IdToString(key), out value)); }
bool IAttributesDictionary.ContainsKey(SymbolId key) { return(ContainsKey(SymbolTable.IdToString(key))); }
bool IAttributesDictionary.Remove(SymbolId key) { return(Remove(SymbolTable.IdToString(key))); }
bool IAttributesCollection.Remove(SymbolId name) { return(((IDictionary <object, object>) this).Remove(SymbolTable.IdToString(name))); }
/* IAttributesDictionary is implemented on our built-in * dictionaries to allow users to assign dictionaries into * classes. These dictionaries will resolve their key via * the field table, but only get used when the user does * explicit dictionary assignment. * */ #region IAttributesDictionary Members void IAttributesDictionary.Add(SymbolId key, object value) { Add(SymbolTable.IdToString(key), value); }
/* IAttributesDictionary is implemented on our built-in * dictionaries to allow users to assign dictionaries into * classes. These dictionaries will resolve their key via * the field table, but only get used when the user does * explicit dictionary assignment. * */ #region IAttributesCollection Members void IAttributesCollection.Add(SymbolId name, object value) { this[SymbolTable.IdToString(name)] = value; }
bool IAttributesCollection.ContainsKey(SymbolId name) { return(__contains__(SymbolTable.IdToString(name))); }
public void DeleteAttr(ICallerContext context, SymbolId name) { object dummy; if (TypeCache.SystemState.TryGetAttr(context, this, name, out dummy)) { try { TypeCache.SystemState.SetAttr(context, this, name, new Uninitialized((string)SymbolTable.IdToString(name))); } catch { throw new NotImplementedException("deleting from sys"); } } else { __dict__.Remove(name); } }
public override ICollection <MemberDoc> GetMembers(object value) { List <MemberDoc> res = new List <MemberDoc>(); PythonModule mod = value as PythonModule; if (mod != null) { foreach (var kvp in mod.__dict__) { AddMember(res, kvp, false); } return(res); } NamespaceTracker ns = value as NamespaceTracker; if (ns != null) { foreach (var v in ns.SymbolAttributes) { AddMember( res, new KeyValuePair <object, object>( SymbolTable.IdToString(v.Key), Importer.MemberTrackerToPython(_context.SharedClsContext, v.Value) ), false ); } } else { OldInstance oi = value as OldInstance; if (oi != null) { foreach (var member in oi.Dictionary) { AddMember(res, member, false); } AddOldClassMembers(res, oi._class); } else { PythonType pt = value as PythonType; if (pt != null) { foreach (PythonType type in pt.ResolutionOrder) { foreach (var member in type.GetMemberDictionary(_context.SharedContext)) { AddMember(res, member, true); } } } else { OldClass oc = value as OldClass; if (oc != null) { AddOldClassMembers(res, oc); } else { pt = DynamicHelpers.GetPythonType(value); foreach (var member in pt.GetMemberDictionary(_context.SharedContext)) { AddMember(res, member, true); } } } IPythonObject ipo = value as IPythonObject; if (ipo != null && ipo.Dict != null) { foreach (var member in ipo.Dict) { AddMember(res, member, false); } } } } return(res.ToArray()); }
/// <summary> /// You can't actually set anything on NoneType, we just override this to get the correct error. /// </summary> public override void SetAttr(ICallerContext context, object self, SymbolId name, object value) { for (int i = 0; i < noneAttrs.Length; i++) { if (noneAttrs[i] == name) { throw Ops.AttributeError("'NoneType' object attribute '{0}' is read-only", SymbolTable.IdToString(name)); } } throw Ops.AttributeError("'NoneType' object has no attribute '{0}'", SymbolTable.IdToString(name)); }
public virtual void SetAttr(ICallerContext context, object self, SymbolId name, object value) { throw Ops.AttributeError("'{0}' object has no attribute '{1}'", this.__name__, SymbolTable.IdToString(name)); }
public virtual object GetAttr(ICallerContext context, object self, SymbolId name) { object ret; if (TryGetAttr(context, self, name, out ret)) { return(ret); } throw Ops.AttributeError("'{0}' object has no attribute '{1}'", this.__name__, SymbolTable.IdToString(name)); }