char[] ITypedArray <char> .ToArray() { return(engine.ScriptInvoke(() => { var result = new char[Length]; target.InvokeWithArrayBufferOrViewData(pData => { UnmanagedMemoryHelpers.Copy(pData, Length, result, 0); }); return result; })); }
protected byte[] GetBytes() { return(engine.ScriptInvoke(() => { var result = new byte[Size]; target.InvokeWithArrayBufferOrViewData(pData => { UnmanagedMemoryHelpers.Copy(pData, Size, result, 0); }); return result; })); }
ulong ITypedArray <char> .Write(char[] source, ulong sourceIndex, ulong length, ulong index) { var totalLength = Length; if (index >= totalLength) { throw new ArgumentOutOfRangeException("index"); } length = Math.Min(length, totalLength - index); return(engine.ScriptInvoke(() => { target.InvokeWithArrayBufferOrViewData(pData => { length = UnmanagedMemoryHelpers.Copy(source, sourceIndex, length, GetPtrWithIndex(pData, index)); }); return length; })); }
protected ulong WriteBytes(byte[] source, ulong sourceIndex, ulong count, ulong offset) { var size = Size; if (offset >= size) { throw new ArgumentOutOfRangeException("offset"); } count = Math.Min(count, size - offset); return(engine.ScriptInvoke(() => { target.InvokeWithArrayBufferOrViewData(pData => { count = UnmanagedMemoryHelpers.Copy(source, sourceIndex, count, GetPtrWithOffset(pData, offset)); }); return count; })); }
protected ulong ReadBytes(ulong offset, ulong count, byte[] destination, ulong destinationIndex) { var size = Size; if (offset >= size) { throw new ArgumentOutOfRangeException("offset"); } count = Math.Min(count, size - offset); return(engine.ScriptInvoke(() => { target.InvokeWithArrayBufferOrViewData(pData => { count = UnmanagedMemoryHelpers.Copy(GetPtrWithOffset(pData, offset), count, destination, destinationIndex); }); return count; })); }
ulong ITypedArray <char> .Read(ulong index, ulong length, char[] destination, ulong destinationIndex) { var totalLength = Length; if (index >= totalLength) { throw new ArgumentOutOfRangeException(nameof(index)); } length = Math.Min(length, totalLength - index); return(engine.ScriptInvoke(() => { target.InvokeWithArrayBufferOrViewData(pData => { length = UnmanagedMemoryHelpers.Copy(GetPtrWithIndex(pData, index), length, destination, destinationIndex); }); return length; })); }