public ByteArray InPlaceAdd(MemoryView other) { lock (this) { _bytes.AddRange(other.tobytes()); return(this); } }
public bool __eq__(CodeContext /*!*/ context, [NotNull] MemoryView value) { if (_buffer == null) { return(value._buffer == null); } // TODO: comparing flat bytes is oversimplification; besides, no data copyimg return(tobytes().Equals(value.tobytes())); }
public bool __eq__(CodeContext /*!*/ context, [NotNull] MemoryView value) => tobytes().Equals(value.tobytes());
public PythonTuple recvfrom_into(MemoryView buffer, [DefaultParameterValue(0)]int nbytes, [DefaultParameterValue(0)]int flags){ int bytesRead; byte[] byteBuffer = buffer.tobytes().ToByteArray(); IPEndPoint remoteIPEP = new IPEndPoint(IPAddress.Any, 0); EndPoint remoteEP = remoteIPEP; try { bytesRead = _socket.ReceiveFrom(byteBuffer, (SocketFlags)flags, ref remoteEP); } catch (Exception e) { throw MakeRecvException(e, SocketError.InvalidArgument); } buffer[new Slice(0, bytesRead)] = byteBuffer.Slice(new Slice(0, bytesRead)); PythonTuple remoteAddress = EndPointToTuple((IPEndPoint)remoteEP); return PythonTuple.MakeTuple(bytesRead, remoteAddress); }
public int recv_into(MemoryView buffer, [DefaultParameterValue(0)]int nbytes, [DefaultParameterValue(0)]int flags) { int bytesRead; byte[] byteBuffer = buffer.tobytes().ToByteArray(); try { bytesRead = _socket.Receive(byteBuffer, (SocketFlags)flags); } catch (Exception e) { if (_socket.SendTimeout == 0) { var s = new SocketException((int)SocketError.NotConnected); throw PythonExceptions.CreateThrowable(error(_context), (int)SocketError.NotConnected, s.Message); } else throw MakeException(_context, e); } buffer[new Slice(0, bytesRead)] = byteBuffer.Slice(new Slice(0, bytesRead)); return bytesRead; }
public static Bytes hexlify(MemoryView data) { return hexlify(data.tobytes()); }