Esempio n. 1
0
            char[] ITypedArray <char> .ToArray()
            {
                return(engine.ScriptInvoke(() =>
                {
                    var result = new char[Length];
                    target.InvokeWithArrayBufferOrViewData(pData =>
                    {
                        UnmanagedMemoryHelpers.Copy(pData, Length, result, 0);
                    });

                    return result;
                }));
            }
Esempio n. 2
0
            protected byte[] GetBytes()
            {
                return(engine.ScriptInvoke(() =>
                {
                    var result = new byte[Size];
                    target.InvokeWithArrayBufferOrViewData(pData =>
                    {
                        UnmanagedMemoryHelpers.Copy(pData, Size, result, 0);
                    });

                    return result;
                }));
            }
Esempio n. 3
0
            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;
                }));
            }
Esempio n. 4
0
            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;
                }));
            }
Esempio n. 5
0
            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;
                }));
            }
Esempio n. 6
0
            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;
                }));
            }