forked from ClearFoundry/ClearScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathV8FastArgs.cs
More file actions
449 lines (400 loc) · 27.3 KB
/
Copy pathV8FastArgs.cs
File metadata and controls
449 lines (400 loc) · 27.3 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System;
using System.Numerics;
using Microsoft.ClearScript.Util;
using Microsoft.ClearScript.V8.SplitProxy;
namespace Microsoft.ClearScript.V8.FastProxy
{
/// <summary>
/// Represents a list of arguments passed to a fast host object from script code.
/// </summary>
public readonly ref struct V8FastArgs
{
private readonly ReadOnlySpan<V8Value.FastArg> args;
private readonly V8FastArgKind argKind;
private readonly object[] objects;
internal V8FastArgs(V8ScriptEngine engine, in ReadOnlySpan<V8Value.FastArg> args, V8FastArgKind argKind)
{
this.args = args;
this.argKind = argKind;
objects = null;
for (var index = 0; index < args.Length; index++)
{
var tempObject = V8FastArgImpl.InitializeObject(engine, args[index]);
if (tempObject is not Nonexistent)
{
EnsureObjects(ref objects, args.Length);
objects[index] = tempObject;
}
}
}
/// <summary>
/// Gets the number of arguments in the list.
/// </summary>
public int Count => args.Length;
/// <summary>
/// Determines whether the argument at the specified index is <see href="https://developer.mozilla.org/en-US/docs/Glossary/Falsy">falsy</see>.
/// </summary>
/// <param name="index">The argument index.</param>
/// <returns><c>True</c> if the argument at the specified index is <see href="https://developer.mozilla.org/en-US/docs/Glossary/Falsy">falsy</see>, <c>false</c> otherwise.</returns>
public bool IsFalsy(int index) => V8FastArgImpl.IsFalsy(args[index], GetObject(index));
/// <summary>
/// Determines whether the argument at the specified index is <see href="https://developer.mozilla.org/en-US/docs/Glossary/Truthy">truthy</see>.
/// </summary>
/// <param name="index">The argument index.</param>
/// <returns><c>True</c> if the argument at the specified index is <see href="https://developer.mozilla.org/en-US/docs/Glossary/Truthy">truthy</see>, <c>false</c> otherwise.</returns>
public bool IsTruthy(int index) => V8FastArgImpl.IsTruthy(args[index], GetObject(index));
/// <summary>
/// Determines whether the argument at the specified index is <c><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined">undefined</see></c>.
/// </summary>
/// <param name="index">The argument index.</param>
/// <returns><c>True</c> if the argument at the specified index is <c><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined">undefined</see></c>, <c>false</c> otherwise.</returns>
public bool IsUndefined(int index) => V8FastArgImpl.IsUndefined(args[index], GetObject(index));
/// <summary>
/// Determines whether the argument at the specified index is <c><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/null">null</see></c>.
/// </summary>
/// <param name="index">The argument index.</param>
/// <returns><c>True</c> if the argument at the specified index is <c><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined">undefined</see></c>, <c>false</c> otherwise.</returns>
public bool IsNull(int index) => V8FastArgImpl.IsNull(args[index], GetObject(index));
/// <summary>
/// Gets the <c><see cref="bool"/></c> value of the argument at the specified index if possible.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="value">On return, the <c><see cref="bool"/></c> value of the argument at the specified index if the operation succeeded.</param>
/// <returns><c>True</c> if the operation succeeded, <c>false</c> otherwise.</returns>
public bool TryGet(int index, out bool value) => V8FastArgImpl.TryGet(args[index], GetObject(index), out value);
/// <summary>
/// Gets the <c><see cref="char"/></c> value of the argument at the specified index if possible.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="value">On return, the <c><see cref="char"/></c> value of the argument at the specified index if the operation succeeded.</param>
/// <returns><c>True</c> if the operation succeeded, <c>false</c> otherwise.</returns>
public bool TryGet(int index, out char value) => V8FastArgImpl.TryGet(args[index], GetObject(index), out value);
/// <summary>
/// Gets the <c><see cref="sbyte"/></c> value of the argument at the specified index if possible.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="value">On return, the <c><see cref="sbyte"/></c> value of the argument at the specified index if the operation succeeded.</param>
/// <returns><c>True</c> if the operation succeeded, <c>false</c> otherwise.</returns>
public bool TryGet(int index, out sbyte value) => V8FastArgImpl.TryGet(args[index], GetObject(index), out value);
/// <summary>
/// Gets the <c><see cref="byte"/></c> value of the argument at the specified index if possible.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="value">On return, the <c><see cref="byte"/></c> value of the argument at the specified index if the operation succeeded.</param>
/// <returns><c>True</c> if the operation succeeded, <c>false</c> otherwise.</returns>
public bool TryGet(int index, out byte value) => V8FastArgImpl.TryGet(args[index], GetObject(index), out value);
/// <summary>
/// Gets the <c><see cref="short"/></c> value of the argument at the specified index if possible.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="value">On return, the <c><see cref="short"/></c> value of the argument at the specified index if the operation succeeded.</param>
/// <returns><c>True</c> if the operation succeeded, <c>false</c> otherwise.</returns>
public bool TryGet(int index, out short value) => V8FastArgImpl.TryGet(args[index], GetObject(index), out value);
/// <summary>
/// Gets the <c><see cref="ushort"/></c> value of the argument at the specified index if possible.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="value">On return, the <c><see cref="ushort"/></c> value of the argument at the specified index if the operation succeeded.</param>
/// <returns><c>True</c> if the operation succeeded, <c>false</c> otherwise.</returns>
public bool TryGet(int index, out ushort value) => V8FastArgImpl.TryGet(args[index], GetObject(index), out value);
/// <summary>
/// Gets the <c><see cref="int"/></c> value of the argument at the specified index if possible.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="value">On return, the <c><see cref="int"/></c> value of the argument at the specified index if the operation succeeded.</param>
/// <returns><c>True</c> if the operation succeeded, <c>false</c> otherwise.</returns>
public bool TryGet(int index, out int value) => V8FastArgImpl.TryGet(args[index], GetObject(index), out value);
/// <summary>
/// Gets the <c><see cref="uint"/></c> value of the argument at the specified index if possible.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="value">On return, the <c><see cref="uint"/></c> value of the argument at the specified index if the operation succeeded.</param>
/// <returns><c>True</c> if the operation succeeded, <c>false</c> otherwise.</returns>
public bool TryGet(int index, out uint value) => V8FastArgImpl.TryGet(args[index], GetObject(index), out value);
/// <summary>
/// Gets the <c><see cref="long"/></c> value of the argument at the specified index if possible.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="value">On return, the <c><see cref="long"/></c> value of the argument at the specified index if the operation succeeded.</param>
/// <returns><c>True</c> if the operation succeeded, <c>false</c> otherwise.</returns>
public bool TryGet(int index, out long value) => V8FastArgImpl.TryGet(args[index], GetObject(index), out value);
/// <summary>
/// Gets the <c><see cref="ulong"/></c> value of the argument at the specified index if possible.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="value">On return, the <c><see cref="ulong"/></c> value of the argument at the specified index if the operation succeeded.</param>
/// <returns><c>True</c> if the operation succeeded, <c>false</c> otherwise.</returns>
public bool TryGet(int index, out ulong value) => V8FastArgImpl.TryGet(args[index], GetObject(index), out value);
/// <summary>
/// Gets the <c><see cref="float"/></c> value of the argument at the specified index if possible.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="value">On return, the <c><see cref="float"/></c> value of the argument at the specified index if the operation succeeded.</param>
/// <returns><c>True</c> if the operation succeeded, <c>false</c> otherwise.</returns>
public bool TryGet(int index, out float value) => V8FastArgImpl.TryGet(args[index], GetObject(index), out value);
/// <summary>
/// Gets the <c><see cref="double"/></c> value of the argument at the specified index if possible.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="value">On return, the <c><see cref="double"/></c> value of the argument at the specified index if the operation succeeded.</param>
/// <returns><c>True</c> if the operation succeeded, <c>false</c> otherwise.</returns>
public bool TryGet(int index, out double value) => V8FastArgImpl.TryGet(args[index], GetObject(index), out value);
/// <summary>
/// Gets the <c><see cref="decimal"/></c> value of the argument at the specified index if possible.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="value">On return, the <c><see cref="decimal"/></c> value of the argument at the specified index if the operation succeeded.</param>
/// <returns><c>True</c> if the operation succeeded, <c>false</c> otherwise.</returns>
public bool TryGet(int index, out decimal value) => V8FastArgImpl.TryGet(args[index], GetObject(index), out value);
/// <summary>
/// Gets the string value of the argument at the specified index if possible.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="value">On return, the string value of the argument at the specified index if the operation succeeded.</param>
/// <returns><c>True</c> if the operation succeeded, <c>false</c> otherwise.</returns>
public bool TryGet(int index, out string value) => V8FastArgImpl.TryGet(args[index], GetObject(index), out value);
/// <summary>
/// Gets the string value of the argument at the specified index as a <c><see href="https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1">ReadOnlySpan<char></see></c> if possible.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="value">On return, the string value of the argument at the specified index as a <c><see href="https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1">ReadOnlySpan<char></see></c> if the operation succeeded.</param>
/// <returns><c>True</c> if the operation succeeded, <c>false</c> otherwise.</returns>
public bool TryGet(int index, out ReadOnlySpan<char> value) => V8FastArgImpl.TryGet(args[index], GetObject(index), out value);
/// <summary>
/// Gets the <c><see cref="DateTime"/></c> value of the argument at the specified index if possible.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="value">On return, the <c><see cref="DateTime"/></c> value of the argument at the specified index if the operation succeeded.</param>
/// <returns><c>True</c> if the operation succeeded, <c>false</c> otherwise.</returns>
public bool TryGet(int index, out DateTime value) => V8FastArgImpl.TryGet(args[index], GetObject(index), out value);
/// <summary>
/// Gets the <c><see cref="BigInteger"/></c> value of the argument at the specified index if possible.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="value">On return, the <c><see cref="BigInteger"/></c> value of the argument at the specified index if the operation succeeded.</param>
/// <returns><c>True</c> if the operation succeeded, <c>false</c> otherwise.</returns>
public bool TryGet(int index, out BigInteger value) => V8FastArgImpl.TryGet(args[index], GetObject(index), out value);
/// <summary>
/// Gets a nullable value of the given underlying type from the argument at the specified index if possible.
/// </summary>
/// <typeparam name="T">The underlying type of the nullable value to get.</typeparam>
/// <param name="index">The argument index.</param>
/// <param name="value">On return, a nullable value of underlying type <typeparamref name="T"/> if the operation succeeded.</param>
/// <returns><c>True</c> if the operation succeeded, <c>false</c> otherwise.</returns>
public bool TryGet<T>(int index, out T? value) where T : struct => V8FastArgImpl.TryGet(args[index], GetObject(index), out value);
/// <summary>
/// Gets a value of the given type from the argument at the specified index if possible.
/// </summary>
/// <typeparam name="T">The type of value to get.</typeparam>
/// <param name="index">The argument index.</param>
/// <param name="value">On return, a value of type <typeparamref name="T"/> if the operation succeeded.</param>
/// <returns><c>True</c> if the operation succeeded, <c>false</c> otherwise.</returns>
public bool TryGet<T>(int index, out T value) => V8FastArgImpl.TryGet(args[index], GetObject(index), out value);
/// <summary>
/// Gets the <c><see cref="bool"/></c> value of the argument at the specified index.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="name">An optional argument or property name.</param>
/// <returns>The <c><see cref="bool"/></c> value of the argument at the specified index.</returns>
/// <remarks>
/// This method throws an exception if the operation fails.
/// </remarks>
public bool GetBoolean(int index, string name = null) => V8FastArgImpl.GetBoolean(args[index], GetObject(index), argKind, name);
/// <summary>
/// Gets the <c><see cref="char"/></c> value of the argument at the specified index.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="name">An optional argument or property name.</param>
/// <returns>The <c><see cref="char"/></c> value of the argument at the specified index.</returns>
/// <remarks>
/// This method throws an exception if the operation fails.
/// </remarks>
public char GetChar(int index, string name = null) => V8FastArgImpl.GetChar(args[index], GetObject(index), argKind, name);
/// <summary>
/// Gets the <c><see cref="sbyte"/></c> value of the argument at the specified index.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="name">An optional argument or property name.</param>
/// <returns>The <c><see cref="sbyte"/></c> value of the argument at the specified index.</returns>
/// <remarks>
/// This method throws an exception if the operation fails.
/// </remarks>
public sbyte GetSByte(int index, string name = null) => V8FastArgImpl.GetSByte(args[index], GetObject(index), argKind, name);
/// <summary>
/// Gets the <c><see cref="byte"/></c> value of the argument at the specified index.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="name">An optional argument or property name.</param>
/// <returns>The <c><see cref="byte"/></c> value of the argument at the specified index.</returns>
/// <remarks>
/// This method throws an exception if the operation fails.
/// </remarks>
public byte GetByte(int index, string name = null) => V8FastArgImpl.GetByte(args[index], GetObject(index), argKind, name);
/// <summary>
/// Gets the <c><see cref="short"/></c> value of the argument at the specified index.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="name">An optional argument or property name.</param>
/// <returns>The <c><see cref="short"/></c> value of the argument at the specified index.</returns>
/// <remarks>
/// This method throws an exception if the operation fails.
/// </remarks>
public short GetInt16(int index, string name = null) => V8FastArgImpl.GetInt16(args[index], GetObject(index), argKind, name);
/// <summary>
/// Gets the <c><see cref="ushort"/></c> value of the argument at the specified index.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="name">An optional argument or property name.</param>
/// <returns>The <c><see cref="ushort"/></c> value of the argument at the specified index.</returns>
/// <remarks>
/// This method throws an exception if the operation fails.
/// </remarks>
public ushort GetUInt16(int index, string name = null) => V8FastArgImpl.GetUInt16(args[index], GetObject(index), argKind, name);
/// <summary>
/// Gets the <c><see cref="int"/></c> value of the argument at the specified index.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="name">An optional argument or property name.</param>
/// <returns>The <c><see cref="int"/></c> value of the argument at the specified index.</returns>
/// <remarks>
/// This method throws an exception if the operation fails.
/// </remarks>
public int GetInt32(int index, string name = null) => V8FastArgImpl.GetInt32(args[index], GetObject(index), argKind, name);
/// <summary>
/// Gets the <c><see cref="uint"/></c> value of the argument at the specified index.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="name">An optional argument or property name.</param>
/// <returns>The <c><see cref="uint"/></c> value of the argument at the specified index.</returns>
/// <remarks>
/// This method throws an exception if the operation fails.
/// </remarks>
public uint GetUInt32(int index, string name = null) => V8FastArgImpl.GetUInt32(args[index], GetObject(index), argKind, name);
/// <summary>
/// Gets the <c><see cref="long"/></c> value of the argument at the specified index.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="name">An optional argument or property name.</param>
/// <returns>The <c><see cref="long"/></c> value of the argument at the specified index.</returns>
/// <remarks>
/// This method throws an exception if the operation fails.
/// </remarks>
public long GetInt64(int index, string name = null) => V8FastArgImpl.GetInt64(args[index], GetObject(index), argKind, name);
/// <summary>
/// Gets the <c><see cref="ulong"/></c> value of the argument at the specified index.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="name">An optional argument or property name.</param>
/// <returns>The <c><see cref="ulong"/></c> value of the argument at the specified index.</returns>
/// <remarks>
/// This method throws an exception if the operation fails.
/// </remarks>
public ulong GetUInt64(int index, string name = null) => V8FastArgImpl.GetUInt64(args[index], GetObject(index), argKind, name);
/// <summary>
/// Gets the <c><see cref="float"/></c> value of the argument at the specified index.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="name">An optional argument or property name.</param>
/// <returns>The <c><see cref="float"/></c> value of the argument at the specified index.</returns>
/// <remarks>
/// This method throws an exception if the operation fails.
/// </remarks>
public float GetSingle(int index, string name = null) => V8FastArgImpl.GetSingle(args[index], GetObject(index), argKind, name);
/// <summary>
/// Gets the <c><see cref="double"/></c> value of the argument at the specified index.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="name">An optional argument or property name.</param>
/// <returns>The <c><see cref="double"/></c> value of the argument at the specified index.</returns>
/// <remarks>
/// This method throws an exception if the operation fails.
/// </remarks>
public double GetDouble(int index, string name = null) => V8FastArgImpl.GetDouble(args[index], GetObject(index), argKind, name);
/// <summary>
/// Gets the <c><see cref="decimal"/></c> value of the argument at the specified index.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="name">An optional argument or property name.</param>
/// <returns>The <c><see cref="decimal"/></c> value of the argument at the specified index.</returns>
/// <remarks>
/// This method throws an exception if the operation fails.
/// </remarks>
public decimal GetDecimal(int index, string name = null) => V8FastArgImpl.GetDecimal(args[index], GetObject(index), argKind, name);
/// <summary>
/// Gets the string value of the argument at the specified index.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="name">An optional argument or property name.</param>
/// <returns>The string value of the argument at the specified index.</returns>
/// <remarks>
/// This method throws an exception if the operation fails.
/// </remarks>
public string GetString(int index, string name = null) => V8FastArgImpl.GetString(args[index], GetObject(index), argKind, name);
/// <summary>
/// Gets the string value of the argument at the specified index as a <c><see href="https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1">ReadOnlySpan<char></see></c>.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="name">An optional argument or property name.</param>
/// <returns>The string value of the argument at the specified index as a <c><see href="https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1">ReadOnlySpan<char></see></c>.</returns>
/// <remarks>
/// This method throws an exception if the operation fails.
/// </remarks>
public ReadOnlySpan<char> GetCharSpan(int index, string name = null) => V8FastArgImpl.GetCharSpan(args[index], GetObject(index), argKind, name);
/// <summary>
/// Gets the <c><see cref="DateTime"/></c> value of the argument at the specified index.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="name">An optional argument or property name.</param>
/// <returns>The <c><see cref="DateTime"/></c> value of the argument at the specified index.</returns>
/// <remarks>
/// This method throws an exception if the operation fails.
/// </remarks>
public DateTime GetDateTime(int index, string name = null) => V8FastArgImpl.GetDateTime(args[index], GetObject(index), argKind, name);
/// <summary>
/// Gets the <c><see cref="BigInteger"/></c> value of the argument at the specified index.
/// </summary>
/// <param name="index">The argument index.</param>
/// <param name="name">An optional argument or property name.</param>
/// <returns>The <c><see cref="BigInteger"/></c> value of the argument at the specified index.</returns>
/// <remarks>
/// This method throws an exception if the operation fails.
/// </remarks>
public BigInteger GetBigInteger(int index, string name = null) => V8FastArgImpl.GetBigInteger(args[index], GetObject(index), argKind, name);
/// <summary>
/// Gets a nullable value of the given underlying type from the argument at the specified index.
/// </summary>
/// <typeparam name="T">The underlying type of the nullable value to get.</typeparam>
/// <param name="index">The argument index.</param>
/// <param name="name">An optional argument or property name.</param>
/// <returns>A nullable value of underlying type <typeparamref name="T"/>.</returns>
/// <remarks>
/// This method throws an exception if the operation fails.
/// </remarks>
public T? GetNullable<T>(int index, string name = null) where T : struct => V8FastArgImpl.GetNullable<T>(args[index], GetObject(index), argKind, name);
/// <summary>
/// Gets a value of the given type from the argument at the specified index.
/// </summary>
/// <typeparam name="T">The type of value to get.</typeparam>
/// <param name="index">The argument index.</param>
/// <param name="name">An optional argument or property name.</param>
/// <returns>A value of type <typeparamref name="T"/>.</returns>
/// <remarks>
/// This method throws an exception if the operation fails.
/// </remarks>
public T Get<T>(int index, string name = null) => V8FastArgImpl.Get<T>(args[index], GetObject(index), argKind, name);
private static void EnsureObjects(ref object[] objects, int count)
{
if (objects is null)
{
objects = new object[count];
for (var index = 0; index < count; index++)
{
objects[index] = Nonexistent.Value;
}
}
}
private object GetObject(int index) => (objects is not null) ? objects[index] : Nonexistent.Value;
}
}