public static void SetWCharArrayRaw(_Array arr, object value) { PythonBuffer buf = value as PythonBuffer; if (buf != null && buf._object is string) { value = buf.ToString(); } arr.NativeType.SetValue(arr._memHolder, 0, value); }
public static object DeleteWCharArrayRaw(_Array arr) { throw PythonOps.TypeError("cannot delete wchar array raw"); }
public static object DeleteWCharArrayValue(_Array arr) { throw PythonOps.TypeError("cannot delete wchar array value"); }
public static object GetWCharArrayRaw(_Array arr) { return ((ArrayType)arr.NativeType).GetRawValue(arr._memHolder, 0); }
public static object GetWCharArrayValue(_Array arr) { return arr.NativeType.GetValue(arr._memHolder, arr, 0, false); }
public static void SetWCharArrayValue(_Array arr, object value) { arr.NativeType.SetValue(arr._memHolder, 0, value); }
public static void SetWCharArrayRaw(_Array arr, object value) { PythonBuffer buf = value as PythonBuffer; if (buf != null && (buf._object is string || buf._object is Bytes)) { value = buf.ToString(); } MemoryView view = value as MemoryView; if ((object)view != null) { string strVal = view.tobytes().ToString(); if (strVal.Length > arr.__len__()) { throw PythonOps.ValueError("string too long"); } value = strVal; } arr.NativeType.SetValue(arr._memHolder, 0, value); }
public static void DeleteCharArrayValue(_Array arr, object value) { throw PythonOps.TypeError("cannot delete char array value"); }
public static object GetWCharArrayValue(_Array arr) { return(arr.NativeType.GetValue(arr._memHolder, arr, 0, false)); }
public static object GetWCharArrayRaw(_Array arr) { return(((ArrayType)arr.NativeType).GetRawValue(arr._memHolder, 0)); }
object INativeType.SetValue(MemoryHolder address, int offset, object value) { string str = value as string; if (str != null) { if (!IsStringType) { throw PythonOps.TypeError("expected {0} instance, got str", Name); } else if (str.Length > _length) { throw PythonOps.ValueError("string too long ({0}, maximum length {1})", str.Length, _length); } WriteString(address, offset, str); return(null); } else if (IsStringType) { IList <object> objList = value as IList <object>; if (objList != null) { StringBuilder res = new StringBuilder(objList.Count); foreach (object o in objList) { res.Append(Converter.ConvertToChar(o)); } WriteString(address, offset, res.ToString()); return(null); } throw PythonOps.TypeError("expected string or Unicode object, {0} found", DynamicHelpers.GetPythonType(value).Name); } object[] arrArgs = value as object[]; if (arrArgs == null) { PythonTuple pt = value as PythonTuple; if (pt != null) { arrArgs = pt._data; } } if (arrArgs != null) { if (arrArgs.Length > _length) { throw PythonOps.RuntimeError("invalid index"); } for (int i = 0; i < arrArgs.Length; i++) { _type.SetValue(address, checked (offset + i * _type.Size), arrArgs[i]); } } else { _Array arr = value as _Array; if (arr != null && arr.NativeType == this) { arr._memHolder.CopyTo(address, offset, ((INativeType)this).Size); return(arr._memHolder.EnsureObjects()); } throw PythonOps.TypeError("unexpected {0} instance, got {1}", Name, DynamicHelpers.GetPythonType(value).Name); } return(null); }