public List GetAttrNames(ICallerContext context) { List ret = new List(); ret.AddRange(GetNamesInScope()); ret.AddNoLock(SymbolTable.Name.ToString()); ret.AddNoLock(SymbolTable.File.ToString()); return(ret); }
internal List GetAttrNames(ICallerContext context) { Initialize(context); List list = List.Make(); if (HaveInterfaces) { foreach (DynamicType type in interfaces) { List names = type.GetAttrNames(context, obj); foreach (object o in names) { if (!list.Contains(o)) { list.AddNoLock(o); } } } } else { //return GetDynamicType().GetAttrNames(context, this); } return(list); }
public static List Items(IDictionary <object, object> self) { List ret = List.MakeEmptyList(self.Count); foreach (KeyValuePair <object, object> kv in self) { ret.AddNoLock(Tuple.MakeTuple(kv.Key, kv.Value)); } return(ret); }
private static List ToList(IDictionary <object, object> self) { List ret = PythonOps.MakeEmptyList(self.Count); foreach (KeyValuePair <object, object> kv in self) { ret.AddNoLock(PythonTuple.MakeTuple(kv.Key, kv.Value)); } return(ret); }
private void SliceNoStep(int start, int stop, object value) { IEnumerator enumerator = Ops.GetEnumerator(value); // save a ref to myData incase other calls cause us // to re-size. List newList = new List(data.Length); // race is tolerable... lock (this) { for (int i = 0; i < start; i++) { newList.AddNoLock(data[i]); } } // calling user code, get rid of the lock... while (enumerator.MoveNext()) { newList.AddNoLock(enumerator.Current); } lock (this) { for (int i = stop; i < size; i++) { newList.AddNoLock(data[i]); } if (newList.data.Length < data.Length) { // shrinking our array may result in IndexOutOfRange in // this[...] where we read w/o a lock. Array.Copy(newList.data, data, newList.data.Length); } else { this.data = newList.data; } this.size = newList.size; } }
public List GetAttrNames(ICallerContext context) { List ret = TypeCache.Method.GetAttrNames(context, this); ret = List.Make(ret); if (!ret.Contains(SymbolTable.Module.ToString())) { ret.AddNoLock(SymbolTable.Module.ToString()); } // Check the func foreach (KeyValuePair <object, object> kvp in ((PythonFunction)func).dict) { if (!ret.Contains(kvp.Key)) { ret.AddNoLock(kvp.Key); } } return(ret); }
public override List GetAttrNames(ICallerContext context, object self) { List names = base.GetAttrNames(context, self); for (int i = 0; i < noneAttrs.Length; i++) { if (!names.Contains(SymbolTable.IdToString(noneAttrs[i]))) { names.AddNoLock(SymbolTable.IdToString(noneAttrs[i])); } } return(names); }
private static void OtherSliceAssign(SliceAssign assign, int start, int stop, int step, object value) { // get enumerable data into a list, and then // do the slice. IEnumerator enumerator = Ops.GetEnumerator(value); List sliceData = new List(); while (enumerator.MoveNext()) { sliceData.AddNoLock(enumerator.Current); } DoSliceAssign(assign, start, stop, step, sliceData); }
private static object TryConvertToArray(object value, Type to, out Conversion conversion) { int rank = to.GetArrayRank(); if (rank == 1) { Tuple tupleVal = value as Tuple; List listVal; IEnumerator ie; if (tupleVal != null) { Array res = Activator.CreateInstance(to, tupleVal.Count) as Array; try { tupleVal.CopyTo(res, 0); conversion = Conversion.NonStandard; return(res); } catch (InvalidCastException) { // invalid conversion } } else if ((listVal = value as List) != null) { Array res = Activator.CreateInstance(to, listVal.Count) as Array; try { listVal.CopyTo(res, 0); conversion = Conversion.NonStandard; return(res); } catch (InvalidCastException) { // invalid conversion } } else if (Ops.TryGetEnumerator(value, out ie)) { List vals = new List(); while (ie.MoveNext()) { vals.AddNoLock(ie.Current); } // recurse back to the List version. return(TryConvertToArray(vals, to, out conversion)); } } conversion = Conversion.None; return((object[])null); }
public List ReadLines() { List ret = new List(); string line; for (; ;) { line = ReadLine(); if (line == "") { break; } ret.AddNoLock(line); } return(ret); }
public List __subclasses__() { List l = new List(); int i = 0; lock (subclasses) { while (i < subclasses.Count) { if (subclasses[i].IsAlive && subclasses[i].Target != null) { l.AddNoLock(subclasses[i].Target); i++; } else { // class has been collected subclasses.RemoveAt(i); } } } return(l); }
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); }
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); }