コード例 #1
0
ファイル: V8ScriptItem.cs プロジェクト: jpsaura/ClearScript
            char[] ITypedArray <char> .ToArray()
            {
                return(engine.ScriptInvoke(() =>
                {
                    var result = new char[Length];
                    target.InvokeWithArrayBufferOrViewData(pData =>
                    {
                        UnmanagedMemoryHelpers.Copy(pData, Length, result, 0);
                    });

                    return result;
                }));
            }
コード例 #2
0
ファイル: V8ScriptItem.cs プロジェクト: jpsaura/ClearScript
            protected byte[] GetBytes()
            {
                return(engine.ScriptInvoke(() =>
                {
                    var result = new byte[Size];
                    target.InvokeWithArrayBufferOrViewData(pData =>
                    {
                        UnmanagedMemoryHelpers.Copy(pData, Size, result, 0);
                    });

                    return result;
                }));
            }
コード例 #3
0
ファイル: V8ScriptItem.cs プロジェクト: jpsaura/ClearScript
            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;
                }));
            }
コード例 #4
0
ファイル: V8ScriptItem.cs プロジェクト: jpsaura/ClearScript
            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;
                }));
            }
コード例 #5
0
ファイル: V8ScriptItem.cs プロジェクト: jpsaura/ClearScript
            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;
                }));
            }
コード例 #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;
                }));
            }