-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from KristofferStrube/feature/add-more-typed-a…
…rrays Feature/add more typed arrays
- Loading branch information
Showing
48 changed files
with
3,363 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
78 changes: 78 additions & 0 deletions
78
src/KristofferStrube.Blazor.WebIDL/TypedArrays/Float64Array.InProcess.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using Microsoft.JSInterop; | ||
|
||
namespace KristofferStrube.Blazor.WebIDL; | ||
|
||
/// <summary> | ||
/// A view on to a buffer type instance that exposes it as an array of IEEE 754 floating point numbers of 8 bytes. | ||
/// </summary> | ||
/// <remarks><see href="https://webidl.spec.whatwg.org/#idl-Float64Array">See the API definition here</see>.</remarks> | ||
[IJSWrapperConverter] | ||
public class Float64ArrayInProcess : Float64Array, ITypedArrayInProcess<double, Float64ArrayInProcess, Float64Array> | ||
{ | ||
/// <summary> | ||
/// A lazily loaded task that evaluates to a helper module instance from the Blazor.WebIDL library. | ||
/// </summary> | ||
public IJSInProcessObjectReference InProcessHelper { get; } | ||
|
||
/// <inheritdoc/> | ||
public new IJSInProcessObjectReference JSReference { get; } | ||
|
||
/// <inheritdoc/> | ||
public static async Task<Float64ArrayInProcess> CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference) | ||
{ | ||
return await CreateAsync(jSRuntime, jSReference, new()); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static async Task<Float64ArrayInProcess> CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference, CreationOptions options) | ||
{ | ||
IJSInProcessObjectReference inProcessHelper = await jSRuntime.GetInProcessHelperAsync(); | ||
return new(jSRuntime, inProcessHelper, jSReference, options); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static new async Task<Float64ArrayInProcess> CreateAsync(IJSRuntime jSRuntime) | ||
{ | ||
return await ITypedArrayInProcess<double, Float64ArrayInProcess, Float64Array>.CreateInternalAsync(jSRuntime); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static new async Task<Float64ArrayInProcess> CreateAsync<TFromElement, TFromTypedArray>(IJSRuntime jSRuntime, TypedArray<TFromElement, TFromTypedArray> typedArray) where TFromTypedArray : IJSCreatable<TFromTypedArray> | ||
{ | ||
return await ITypedArrayInProcess<double, Float64ArrayInProcess, Float64Array>.CreateInternalAsync(jSRuntime, typedArray); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static new async Task<Float64ArrayInProcess> CreateAsync(IJSRuntime jSRuntime, IArrayBuffer buffer, long? byteOffset, long? length) | ||
{ | ||
return await ITypedArrayInProcess<double, Float64ArrayInProcess, Float64Array>.CreateInternalAsync(jSRuntime, buffer, byteOffset, length); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static new async Task<Float64ArrayInProcess> CreateAsync(IJSRuntime jSRuntime, long length) | ||
{ | ||
return await ITypedArrayInProcess<double, Float64ArrayInProcess, Float64Array>.CreateInternalAsync(jSRuntime, length); | ||
} | ||
|
||
/// <inheritdoc cref="IJSInProcessCreatable{TInProcess, T}.CreateAsync(IJSRuntime, IJSInProcessObjectReference, CreationOptions)"/> | ||
protected Float64ArrayInProcess(IJSRuntime jSRuntime, IJSInProcessObjectReference inProcessHelper, IJSInProcessObjectReference jSReference, CreationOptions options) : base(jSRuntime, jSReference, options) | ||
{ | ||
this.InProcessHelper = inProcessHelper; | ||
JSReference = jSReference; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public new async Task<IArrayBufferInProcess> GetBufferAsync() | ||
{ | ||
return await ITypedArrayInProcess<double, Float64ArrayInProcess, Float64Array>.GetBufferAsync(this); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public double At(long index) | ||
{ | ||
return ITypedArrayInProcess<double, Float64ArrayInProcess, Float64Array>.At(this, index); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public long Length => ITypedArrayInProcess<double, Float64ArrayInProcess, Float64Array>.GetLength(this); | ||
} |
26 changes: 26 additions & 0 deletions
26
src/KristofferStrube.Blazor.WebIDL/TypedArrays/Float64Array.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Microsoft.JSInterop; | ||
|
||
namespace KristofferStrube.Blazor.WebIDL; | ||
|
||
/// <summary> | ||
/// A view on to a buffer type instance that exposes it as an array of IEEE 754 floating point numbers of 8 bytes. | ||
/// </summary> | ||
/// <remarks><see href="https://webidl.spec.whatwg.org/#idl-Float64Array">See the API definition here</see>.</remarks> | ||
[IJSWrapperConverter] | ||
public class Float64Array : TypedArray<double, Float64Array>, IJSCreatable<Float64Array> | ||
{ | ||
/// <inheritdoc/> | ||
public static Task<Float64Array> CreateAsync(IJSRuntime jSRuntime, IJSObjectReference jSReference) | ||
{ | ||
return Task.FromResult(new Float64Array(jSRuntime, jSReference, new())); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static Task<Float64Array> CreateAsync(IJSRuntime jSRuntime, IJSObjectReference jSReference, CreationOptions options) | ||
{ | ||
return Task.FromResult(new Float64Array(jSRuntime, jSReference, options)); | ||
} | ||
|
||
/// <inheritdoc cref="CreateAsync(IJSRuntime, IJSObjectReference, CreationOptions)"/> | ||
protected Float64Array(IJSRuntime jSRuntime, IJSObjectReference jSReference, CreationOptions options) : base(jSRuntime, jSReference, options) { } | ||
} |
File renamed without changes.
87 changes: 87 additions & 0 deletions
87
src/KristofferStrube.Blazor.WebIDL/TypedArrays/Int16Array.InProcess.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using Microsoft.JSInterop; | ||
|
||
namespace KristofferStrube.Blazor.WebIDL; | ||
|
||
/// <summary> | ||
/// A view on to a buffer type instance that exposes it as an array of shorts. | ||
/// </summary> | ||
/// <remarks><see href="https://webidl.spec.whatwg.org/#idl-Int16Array">See the API definition here</see>.</remarks> | ||
[IJSWrapperConverter] | ||
public class Int16ArrayInProcess : Int16Array, ITypedArrayInProcess<short, Int16ArrayInProcess, Int16Array> | ||
{ | ||
/// <summary> | ||
/// A lazily loaded task that evaluates to a helper module instance from the Blazor.WebIDL library. | ||
/// </summary> | ||
public IJSInProcessObjectReference InProcessHelper { get; } | ||
|
||
/// <inheritdoc/> | ||
public new IJSInProcessObjectReference JSReference { get; } | ||
|
||
/// <inheritdoc/> | ||
public static async Task<Int16ArrayInProcess> CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference) | ||
{ | ||
return await CreateAsync(jSRuntime, jSReference, new()); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static async Task<Int16ArrayInProcess> CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference, CreationOptions options) | ||
{ | ||
IJSInProcessObjectReference inProcessHelper = await jSRuntime.GetInProcessHelperAsync(); | ||
return new(jSRuntime, inProcessHelper, jSReference, options); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static new async Task<Int16ArrayInProcess> CreateAsync(IJSRuntime jSRuntime) | ||
{ | ||
return await ITypedArrayInProcess<short, Int16ArrayInProcess, Int16Array>.CreateInternalAsync(jSRuntime); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static new async Task<Int16ArrayInProcess> CreateAsync<TFromElement, TFromTypedArray>(IJSRuntime jSRuntime, TypedArray<TFromElement, TFromTypedArray> typedArray) where TFromTypedArray : IJSCreatable<TFromTypedArray> | ||
{ | ||
return await ITypedArrayInProcess<short, Int16ArrayInProcess, Int16Array>.CreateInternalAsync(jSRuntime, typedArray); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static new async Task<Int16ArrayInProcess> CreateAsync(IJSRuntime jSRuntime, IArrayBuffer buffer, long? byteOffset, long? length) | ||
{ | ||
return await ITypedArrayInProcess<short, Int16ArrayInProcess, Int16Array>.CreateInternalAsync(jSRuntime, buffer, byteOffset, length); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static new async Task<Int16ArrayInProcess> CreateAsync(IJSRuntime jSRuntime, long length) | ||
{ | ||
return await ITypedArrayInProcess<short, Int16ArrayInProcess, Int16Array>.CreateInternalAsync(jSRuntime, length); | ||
} | ||
|
||
/// <inheritdoc cref="IJSInProcessCreatable{TInProcess, T}.CreateAsync(IJSRuntime, IJSInProcessObjectReference, CreationOptions)"/> | ||
protected Int16ArrayInProcess(IJSRuntime jSRuntime, IJSInProcessObjectReference inProcessHelper, IJSInProcessObjectReference jSReference, CreationOptions options) : base(jSRuntime, jSReference, options) | ||
{ | ||
this.InProcessHelper = inProcessHelper; | ||
JSReference = jSReference; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public new async Task<IArrayBufferInProcess> GetBufferAsync() | ||
{ | ||
return await ITypedArrayInProcess<short, Int16ArrayInProcess, Int16Array>.GetBufferAsync(this); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public short At(long index) | ||
{ | ||
return ITypedArrayInProcess<short, Int16ArrayInProcess, Int16Array>.At(this, index); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public long Length => ITypedArrayInProcess<short, Int16ArrayInProcess, Int16Array>.GetLength(this); | ||
|
||
/// <inheritdoc/> | ||
public new async ValueTask DisposeAsync() | ||
{ | ||
await InProcessHelper.DisposeAsync(); | ||
await IJSWrapper.DisposeJSReference(this); | ||
await base.DisposeAsync(); | ||
GC.SuppressFinalize(this); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/KristofferStrube.Blazor.WebIDL/TypedArrays/Int16Array.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Microsoft.JSInterop; | ||
|
||
namespace KristofferStrube.Blazor.WebIDL; | ||
|
||
/// <summary> | ||
/// A view on to a buffer type instance that exposes it as an array of shorts. | ||
/// </summary> | ||
/// <remarks><see href="https://webidl.spec.whatwg.org/#idl-Int16Array">See the API definition here</see>.</remarks> | ||
[IJSWrapperConverter] | ||
public class Int16Array : TypedArray<short, Int16Array>, IJSCreatable<Int16Array> | ||
{ | ||
/// <inheritdoc/> | ||
public static Task<Int16Array> CreateAsync(IJSRuntime jSRuntime, IJSObjectReference jSReference) | ||
{ | ||
return Task.FromResult(new Int16Array(jSRuntime, jSReference, new())); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static Task<Int16Array> CreateAsync(IJSRuntime jSRuntime, IJSObjectReference jSReference, CreationOptions options) | ||
{ | ||
return Task.FromResult(new Int16Array(jSRuntime, jSReference, options)); | ||
} | ||
|
||
/// <inheritdoc cref="CreateAsync(IJSRuntime, IJSObjectReference, CreationOptions)"/> | ||
protected Int16Array(IJSRuntime jSRuntime, IJSObjectReference jSReference, CreationOptions options) : base(jSRuntime, jSReference, options) { } | ||
} |
87 changes: 87 additions & 0 deletions
87
src/KristofferStrube.Blazor.WebIDL/TypedArrays/Int32Array.InProcess.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using Microsoft.JSInterop; | ||
|
||
namespace KristofferStrube.Blazor.WebIDL; | ||
|
||
/// <summary> | ||
/// A view on to a buffer type instance that exposes it as an array of ints. | ||
/// </summary> | ||
/// <remarks><see href="https://webidl.spec.whatwg.org/#idl-Int32Array">See the API definition here</see>.</remarks> | ||
[IJSWrapperConverter] | ||
public class Int32ArrayInProcess : Int32Array, ITypedArrayInProcess<int, Int32ArrayInProcess, Int32Array> | ||
{ | ||
/// <summary> | ||
/// A lazily loaded task that evaluates to a helper module instance from the Blazor.WebIDL library. | ||
/// </summary> | ||
public IJSInProcessObjectReference InProcessHelper { get; } | ||
|
||
/// <inheritdoc/> | ||
public new IJSInProcessObjectReference JSReference { get; } | ||
|
||
/// <inheritdoc/> | ||
public static async Task<Int32ArrayInProcess> CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference) | ||
{ | ||
return await CreateAsync(jSRuntime, jSReference, new()); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static async Task<Int32ArrayInProcess> CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference, CreationOptions options) | ||
{ | ||
IJSInProcessObjectReference inProcessHelper = await jSRuntime.GetInProcessHelperAsync(); | ||
return new(jSRuntime, inProcessHelper, jSReference, options); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static new async Task<Int32ArrayInProcess> CreateAsync(IJSRuntime jSRuntime) | ||
{ | ||
return await ITypedArrayInProcess<int, Int32ArrayInProcess, Int32Array>.CreateInternalAsync(jSRuntime); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static new async Task<Int32ArrayInProcess> CreateAsync<TFromElement, TFromTypedArray>(IJSRuntime jSRuntime, TypedArray<TFromElement, TFromTypedArray> typedArray) where TFromTypedArray : IJSCreatable<TFromTypedArray> | ||
{ | ||
return await ITypedArrayInProcess<int, Int32ArrayInProcess, Int32Array>.CreateInternalAsync(jSRuntime, typedArray); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static new async Task<Int32ArrayInProcess> CreateAsync(IJSRuntime jSRuntime, IArrayBuffer buffer, long? byteOffset, long? length) | ||
{ | ||
return await ITypedArrayInProcess<int, Int32ArrayInProcess, Int32Array>.CreateInternalAsync(jSRuntime, buffer, byteOffset, length); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static new async Task<Int32ArrayInProcess> CreateAsync(IJSRuntime jSRuntime, long length) | ||
{ | ||
return await ITypedArrayInProcess<int, Int32ArrayInProcess, Int32Array>.CreateInternalAsync(jSRuntime, length); | ||
} | ||
|
||
/// <inheritdoc cref="IJSInProcessCreatable{TInProcess, T}.CreateAsync(IJSRuntime, IJSInProcessObjectReference, CreationOptions)"/> | ||
protected Int32ArrayInProcess(IJSRuntime jSRuntime, IJSInProcessObjectReference inProcessHelper, IJSInProcessObjectReference jSReference, CreationOptions options) : base(jSRuntime, jSReference, options) | ||
{ | ||
this.InProcessHelper = inProcessHelper; | ||
JSReference = jSReference; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public new async Task<IArrayBufferInProcess> GetBufferAsync() | ||
{ | ||
return await ITypedArrayInProcess<int, Int32ArrayInProcess, Int32Array>.GetBufferAsync(this); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public int At(long index) | ||
{ | ||
return ITypedArrayInProcess<int, Int32ArrayInProcess, Int32Array>.At(this, index); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public long Length => ITypedArrayInProcess<int, Int32ArrayInProcess, Int32Array>.GetLength(this); | ||
|
||
/// <inheritdoc/> | ||
public new async ValueTask DisposeAsync() | ||
{ | ||
await InProcessHelper.DisposeAsync(); | ||
await IJSWrapper.DisposeJSReference(this); | ||
await base.DisposeAsync(); | ||
GC.SuppressFinalize(this); | ||
} | ||
} |
Oops, something went wrong.