public IEnumerator <PyObject> GetEnumerator() { if (IsInvalid) { yield break; } var iter = PyObject_GetIter(Pointer); if (iter == IntPtr.Zero) { yield break; } if (Python.ErrorSet) { Python.ClearError(); yield break; } IntPtr p = PyIter_Next(iter); while (p != IntPtr.Zero) { yield return(GetSpecialized(p)); p = PyIter_Next(iter); } }
public bool Insert(int index, IntPtr item) { if (IsInvalid || item == IntPtr.Zero || index < 0) { return(false); } var r = PyList_Insert(Pointer, index, item); if (r == -1) { Python.ClearError(); return(false); } return(true); }
public bool Append(IntPtr item) { if (IsInvalid || item == IntPtr.Zero) { return(false); } var r = PyList_Append(Pointer, item); if (r == -1) { Python.ClearError(); return(false); } return(true); }
public override PyObject this[int key] { get { if (IsInvalid || key < 0) { return(null); } return(new PyObject(PyList_GetItem(Pointer, key), ReferenceType.Borrowed)); } set { if (IsInvalid || key < 0 || value.IsInvalid) { return; } if (PyList_SetItem(Pointer, key, value.Pointer) != 0) { Python.ClearError(); } } }
private int RunCodeInternal(IntPtr unused) { try { Result = Python.RunPure(Code); if (Python.ErrorSet) { _exception = Python.GetError(); Python.ClearError(); } return(0); } catch (Exception ex) { _exception = ex; return(0); } finally { _executed.Set(); } }