public override BigInteger write(CodeContext /*!*/ context, object b) { byte[] bArray = b as byte[]; if (bArray != null) { return(write(bArray)); } Bytes bBytes = b as Bytes; if (bBytes != null) { return(write(bBytes)); } ArrayModule.array bPythonArray = b as ArrayModule.array; if (bPythonArray != null) { return(write(bPythonArray.ToByteArray())); } ICollection <byte> bCollection = b as ICollection <byte>; if (bCollection != null) { return(write(bCollection)); } EnsureWritable(); throw PythonOps.TypeError("expected a readable buffer object"); }
public _Array from_buffer_copy(ArrayModule.array array, int offset = 0) { ValidateArraySizes(array, offset, ((INativeType)this).Size); _Array res = (_Array)CreateInstance(Context.SharedContext); res._memHolder = new MemoryHolder(((INativeType)this).Size); res._memHolder.CopyFrom(array.GetArrayAddress().Add(offset), new IntPtr(((INativeType)this).Size)); GC.KeepAlive(array); return(res); }
public _Array from_buffer(ArrayModule.array array, int offset = 0) { ValidateArraySizes(array, offset, ((INativeType)this).Size); _Array res = (_Array)CreateInstance(Context.SharedContext); IntPtr addr = array.GetArrayAddress(); res._memHolder = new MemoryHolder(addr.Add(offset), ((INativeType)this).Size); res._memHolder.AddObject("ffffffff", array); return(res); }
public _Structure from_buffer(ArrayModule.array array, [DefaultParameterValue(0)] int offset) { ValidateArraySizes(array, offset, ((INativeType)this).Size); _Structure res = (_Structure)CreateInstance(Context.SharedContext); IntPtr addr = array.GetArrayAddress(); res._memHolder = new MemoryHolder(addr.Add(offset), ((INativeType)this).Size); res._memHolder.AddObject("ffffffff", array); return(res); }
public object from_buffer(CodeContext /*!*/ context, ArrayModule.array array, int offset = 0) { ValidateArraySizes(array, offset, ((INativeType)this).Size); _Union res = (_Union)CreateInstance(context); IntPtr addr = array.GetArrayAddress(); res._memHolder = new MemoryHolder(addr.Add(offset), ((INativeType)this).Size); res._memHolder.AddObject("ffffffff", array); return(res); }
public _Structure from_buffer_copy(ArrayModule.array array, [DefaultParameterValue(0)] int offset) { ValidateArraySizes(array, offset, ((INativeType)this).Size); _Structure res = (_Structure)CreateInstance(Context.SharedContext); res._memHolder = new MemoryHolder(((INativeType)this).Size); res._memHolder.CopyFrom(array.GetArrayAddress().Add(offset), new IntPtr(((INativeType)this).Size)); GC.KeepAlive(array); return(res); }
public void update(object newData) { ArrayModule.array a = newData as ArrayModule.array; if (a != null) { update(a.ToByteArray()); } else { update(Converter.ConvertToString(newData).MakeByteArray()); } }
public override BigInteger readinto(CodeContext /*!*/ context, object buf) { ByteArray bytes = buf as ByteArray; if (bytes != null) { return(readinto(bytes)); } ArrayModule.array array = buf as ArrayModule.array; if (array != null) { return(readinto(array)); } _checkClosed(); throw PythonOps.TypeError("must be read-write buffer, not {0}", PythonTypeOps.GetName(buf)); }
public override BigInteger readinto(CodeContext /*!*/ context, object buf) { ByteArray bytes = buf as ByteArray; if (bytes != null) { return(readinto(bytes)); } ArrayModule.array arr = buf as ArrayModule.array; if (arr != null) { return(readinto(bytes)); } ; EnsureReadable(); throw PythonOps.TypeError( "argument 1 must be read/write buffer, not {0}", DynamicHelpers.GetPythonType(buf).Name ); }
public BigInteger readinto([NotNull] ArrayModule.array buffer) { _checkClosed(); int len = Math.Min(_length - _pos, buffer.__len__() * buffer.itemsize); int tailLen = len % buffer.itemsize; buffer.FromStream(new MemoryStream(_data, _pos, len - tailLen, false, false), 0); _pos += len - tailLen; if (tailLen != 0) { byte[] tail = buffer.RawGetItem(len / buffer.itemsize); for (int i = 0; i < tailLen; i++) { tail[i] = _data[_pos++]; } buffer.FromStream(new MemoryStream(tail), len / buffer.itemsize); } return(len); }
public static sha sha1(ArrayModule.array data) { return(new sha(data.ToByteArray())); }
public static MD5Object md5(ArrayModule.array data) { return(new MD5Object(data)); }
public BigInteger readinto([NotNull] ArrayModule.array buffer) { EnsureReadable(); return((int)buffer.FromStream(_readStream, 0, buffer.__len__() * buffer.itemsize)); }
private static void ValidateArraySizes(ArrayModule.array array, int offset, int size) { ValidateArraySizes(array.__len__() * array.itemsize, offset, size); }
public static sha sha1(ArrayModule.array data) { return(new sha(data)); }
public static Sha384Object sha384(ArrayModule.array data) { return(new Sha384Object(data.ToByteArray())); }
public static Sha256Object sha256(ArrayModule.array data) { return(new Sha256Object(data)); }