-
Notifications
You must be signed in to change notification settings - Fork 160
Expand file tree
/
Copy pathIArrayBufferView.cs
More file actions
128 lines (115 loc) · 6.65 KB
/
IArrayBufferView.cs
File metadata and controls
128 lines (115 loc) · 6.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System;
namespace Microsoft.ClearScript.JavaScript
{
/// <summary>
/// Defines properties and methods common to all
/// <c><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer">ArrayBuffer</see></c>
/// views.
/// </summary>
public interface IArrayBufferView : IJavaScriptObject
{
/// <summary>
/// Gets view's underlying <c>ArrayBuffer</c>.
/// </summary>
IArrayBuffer ArrayBuffer { get; }
/// <summary>
/// Gets the view's offset within the underlying <c>ArrayBuffer</c>.
/// </summary>
ulong Offset { get; }
/// <summary>
/// Gets the view's size in bytes.
/// </summary>
ulong Size { get; }
/// <summary>
/// Creates a byte array containing a copy of the view's contents.
/// </summary>
/// <returns>A new byte array containing a copy of the view's contents.</returns>
byte[] GetBytes();
/// <summary>
/// Copies bytes from the view into the specified byte array.
/// </summary>
/// <param name="offset">The offset within the view of the first byte to copy.</param>
/// <param name="count">The maximum number of bytes to copy.</param>
/// <param name="destination">The byte array into which to copy the bytes.</param>
/// <param name="destinationIndex">The index within <paramref name="destination"/> at which to store the first copied byte.</param>
/// <returns>The number of bytes copied.</returns>
ulong ReadBytes(ulong offset, ulong count, byte[] destination, ulong destinationIndex);
/// <summary>
/// Copies bytes from the view into the specified byte span.
/// </summary>
/// <param name="offset">The offset within the view of the first byte to copy.</param>
/// <param name="count">The maximum number of bytes to copy.</param>
/// <param name="destination">The byte span into which to copy the bytes.</param>
/// <param name="destinationIndex">The index within <paramref name="destination"/> at which to store the first copied byte.</param>
/// <returns>The number of bytes copied.</returns>
ulong ReadBytes(ulong offset, ulong count, Span<byte> destination, ulong destinationIndex);
/// <summary>
/// Copies bytes from the specified byte array into the view.
/// </summary>
/// <param name="source">The byte array from which to copy the bytes.</param>
/// <param name="sourceIndex">The index within <paramref name="source"/> of the first byte to copy.</param>
/// <param name="count">The maximum number of bytes to copy.</param>
/// <param name="offset">The offset within the view at which to store the first copied byte.</param>
/// <returns>The number of bytes copied.</returns>
ulong WriteBytes(byte[] source, ulong sourceIndex, ulong count, ulong offset);
/// <summary>
/// Copies bytes from the specified byte span into the view.
/// </summary>
/// <param name="source">The byte span from which to copy the bytes.</param>
/// <param name="sourceIndex">The index within <paramref name="source"/> of the first byte to copy.</param>
/// <param name="count">The maximum number of bytes to copy.</param>
/// <param name="offset">The offset within the view at which to store the first copied byte.</param>
/// <returns>The number of bytes copied.</returns>
ulong WriteBytes(ReadOnlySpan<byte> source, ulong sourceIndex, ulong count, ulong offset);
/// <summary>
/// Invokes a delegate that returns no value, giving it direct access to the view's contents.
/// </summary>
/// <param name="action">The delegate to invoke.</param>
/// <remarks>
/// This method invokes the specified delegate, passing in the memory address of the view's
/// contents. This memory address is valid only while the delegate is executing. The
/// delegate must not access memory outside the view's range.
/// </remarks>
void InvokeWithDirectAccess(Action<IntPtr> action);
/// <summary>
/// Invokes a delegate that returns a value, giving it direct access to the view's contents.
/// </summary>
/// <typeparam name="TResult">The delegate's return type.</typeparam>
/// <param name="func">The delegate to invoke.</param>
/// <returns>The delegate's return value.</returns>
/// <remarks>
/// This method invokes the specified delegate, passing in the memory address of the view's
/// contents. This memory address is valid only while the delegate is executing. The
/// delegate must not access memory outside the view's range.
/// </remarks>
TResult InvokeWithDirectAccess<TResult>(Func<IntPtr, TResult> func);
/// <summary>
/// Invokes a delegate that takes an argument and returns no value, giving it direct access to the view's contents.
/// </summary>
/// <typeparam name="TArg">The delegate's argument type.</typeparam>
/// <param name="action">The delegate to invoke.</param>
/// <param name="arg">The argument to pass to the delegate.</param>
/// <remarks>
/// This method invokes the specified delegate, passing in the memory address of the view's
/// contents. This memory address is valid only while the delegate is executing. The
/// delegate must not access memory outside the view's range.
/// </remarks>
void InvokeWithDirectAccess<TArg>(Action<IntPtr, TArg> action, in TArg arg);
/// <summary>
/// Invokes a delegate that takes an argument and returns a value, giving it direct access to the view's contents.
/// </summary>
/// <typeparam name="TArg">The delegate's argument type.</typeparam>
/// <typeparam name="TResult">The delegate's return type.</typeparam>
/// <param name="func">The delegate to invoke.</param>
/// <param name="arg">The argument to pass to the delegate.</param>
/// <returns>The delegate's return value.</returns>
/// <remarks>
/// This method invokes the specified delegate, passing in the memory address of the view's
/// contents. This memory address is valid only while the delegate is executing. The
/// delegate must not access memory outside the view's range.
/// </remarks>
TResult InvokeWithDirectAccess<TArg, TResult>(Func<IntPtr, TArg, TResult> func, in TArg arg);
}
}