forked from ClearFoundry/ClearScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathITypedArray.cs
More file actions
99 lines (95 loc) · 5.04 KB
/
ITypedArray.cs
File metadata and controls
99 lines (95 loc) · 5.04 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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
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; }
}
/// <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><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</see></term>
/// <term><c>ITypedArray<byte></c></term>
/// </item>
/// <item>
/// <term><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray">Uint8ClampedArray</see></term>
/// <term><c>ITypedArray<byte></c></term>
/// </item>
/// <item>
/// <term><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array">Int8Array</see></term>
/// <term><c>ITypedArray<sbyte></c></term>
/// </item>
/// <item>
/// <term><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array">Uint16Array</see></term>
/// <term><c>ITypedArray<ushort></c> and <c>ITypedArray<char></c></term>
/// </item>
/// <item>
/// <term><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array">Int16Array</see></term>
/// <term><c>ITypedArray<short></c></term>
/// </item>
/// <item>
/// <term><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array">Uint32Array</see></term>
/// <term><c>ITypedArray<uint></c></term>
/// </item>
/// <item>
/// <term><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array">Int32Array</see></term>
/// <term><c>ITypedArray<int></c></term>
/// </item>
/// <item>
/// <term><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array">Float32Array</see></term>
/// <term><c>ITypedArray<float></c></term>
/// </item>
/// <item>
/// <term><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array">Float64Array</see></term>
/// <term><c>ITypedArray<double></c></term>
/// </item>
/// </list>
/// </para>
/// </remarks>
public interface ITypedArray<T> : ITypedArray
{
/// <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 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);
}
}