-
Notifications
You must be signed in to change notification settings - Fork 160
Expand file tree
/
Copy pathITypedArray.cs
More file actions
133 lines (124 loc) · 7.09 KB
/
ITypedArray.cs
File metadata and controls
133 lines (124 loc) · 7.09 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
129
130
131
132
133
// 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 JavaScript
/// <see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays">typed arrays</see>.
/// </summary>
public interface ITypedArray : IArrayBufferView
{
/// <summary>
/// Gets the typed array's length.
/// </summary>
ulong Length { get; }
}
// ReSharper disable GrammarMistakeInComment
/// <summary>
/// Represents a JavaScript <see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays">typed array</see>.
/// </summary>
/// <typeparam name="T">The typed array's element type.</typeparam>
/// <remarks>
/// <para>
/// The following table lists the specific interfaces implemented by JavaScript typed arrays:
/// </para>
/// <para>
/// <list type="table">
/// <listheader>
/// <term>Typed Array</term>
/// <term>Interface(s) (C#)</term>
/// </listheader>
/// <item>
/// <term><c><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</see></c></term>
/// <term><c>ITypedArray<byte></c></term>
/// </item>
/// <item>
/// <term><c><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray">Uint8ClampedArray</see></c></term>
/// <term><c>ITypedArray<byte></c></term>
/// </item>
/// <item>
/// <term><c><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array">Int8Array</see></c></term>
/// <term><c>ITypedArray<sbyte></c></term>
/// </item>
/// <item>
/// <term><c><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array">Uint16Array</see></c></term>
/// <term><c>ITypedArray<ushort></c> and <c>ITypedArray<char></c></term>
/// </item>
/// <item>
/// <term><c><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array">Int16Array</see></c></term>
/// <term><c>ITypedArray<short></c></term>
/// </item>
/// <item>
/// <term><c><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array">Uint32Array</see></c></term>
/// <term><c>ITypedArray<uint></c></term>
/// </item>
/// <item>
/// <term><c><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array">Int32Array</see></c></term>
/// <term><c>ITypedArray<int></c></term>
/// </item>
/// <item>
/// <term><c><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array">BigUint64Array</see></c></term>
/// <term><c>ITypedArray<ulong></c></term>
/// </item>
/// <item>
/// <term><c><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array">BigInt64Array</see></c></term>
/// <term><c>ITypedArray<long></c></term>
/// </item>
/// <item>
/// <term><c><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array">Float32Array</see></c></term>
/// <term><c>ITypedArray<float></c></term>
/// </item>
/// <item>
/// <term><c><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array">Float64Array</see></c></term>
/// <term><c>ITypedArray<double></c></term>
/// </item>
/// </list>
/// </para>
/// </remarks>
public interface ITypedArray<T> : ITypedArray where T : unmanaged
{
/// <summary>
/// Creates an array containing a copy of the typed array's contents.
/// </summary>
/// <returns>A new array containing a copy of the typed array's contents.</returns>
T[] ToArray();
/// <summary>
/// Copies elements from the typed array into the specified array.
/// </summary>
/// <param name="index">The index within the typed array of the first element to copy.</param>
/// <param name="length">The maximum number of elements to copy.</param>
/// <param name="destination">The array into which to copy the elements.</param>
/// <param name="destinationIndex">The index within <paramref name="destination"/> at which to store the first copied element.</param>
/// <returns>The number of elements copied.</returns>
ulong Read(ulong index, ulong length, T[] destination, ulong destinationIndex);
/// <summary>
/// Copies elements from the typed array into the specified span.
/// </summary>
/// <param name="index">The index within the typed array of the first element to copy.</param>
/// <param name="length">The maximum number of elements to copy.</param>
/// <param name="destination">The span into which to copy the elements.</param>
/// <param name="destinationIndex">The index within <paramref name="destination"/> at which to store the first copied element.</param>
/// <returns>The number of elements copied.</returns>
ulong Read(ulong index, ulong length, Span<T> destination, ulong destinationIndex);
/// <summary>
/// Copies elements from the specified array into the typed array.
/// </summary>
/// <param name="source">The array from which to copy the elements.</param>
/// <param name="sourceIndex">The index within <paramref name="source"/> of the first element to copy.</param>
/// <param name="length">The maximum number of elements to copy.</param>
/// <param name="index">The index within the typed array at which to store the first copied element.</param>
/// <returns>The number of elements copied.</returns>
ulong Write(T[] source, ulong sourceIndex, ulong length, ulong index);
/// <summary>
/// Copies elements from the specified span into the typed array.
/// </summary>
/// <param name="source">The span from which to copy the elements.</param>
/// <param name="sourceIndex">The index within <paramref name="source"/> of the first element to copy.</param>
/// <param name="length">The maximum number of elements to copy.</param>
/// <param name="index">The index within the typed array at which to store the first copied element.</param>
/// <returns>The number of elements copied.</returns>
ulong Write(ReadOnlySpan<T> source, ulong sourceIndex, ulong length, ulong index);
}
// ReSharper restore GrammarMistakeInComment
}