-
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 #13 from KristofferStrube/feature/in-process-typed…
…-arrays-and-buffers Added InProcess variants of typed array and buffer types.
- Loading branch information
Showing
17 changed files
with
641 additions
and
47 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
src/KristofferStrube.Blazor.WebIDL/Buffers/ArrayBuffer.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,38 @@ | ||
using Microsoft.JSInterop; | ||
|
||
namespace KristofferStrube.Blazor.WebIDL; | ||
|
||
/// <summary> | ||
/// An object that holds a pointer (which can be null) to a buffer of a fixed number of bytes. | ||
/// </summary> | ||
/// <remarks><see href="https://tc39.es/ecma262/multipage/structured-data.html#sec-arraybuffer-objects">See the API definition here</see>.</remarks> | ||
public class ArrayBufferInProcess : ArrayBuffer, IArrayBufferInProcess, IJSInProcessCreatable<ArrayBufferInProcess, ArrayBuffer> | ||
{ | ||
/// <summary> | ||
/// A lazily loaded task that evaluates to a helper module instance from the Blazor.WebIDL library. | ||
/// </summary> | ||
protected readonly IJSInProcessObjectReference inProcessHelper; | ||
|
||
/// <inheritdoc/> | ||
public new IJSInProcessObjectReference JSReference { get; } | ||
|
||
/// <inheritdoc/> | ||
public static async Task<ArrayBufferInProcess> CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference) | ||
{ | ||
return await CreateAsync(jSRuntime, jSReference, new()); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static async Task<ArrayBufferInProcess> CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference, CreationOptions options) | ||
{ | ||
IJSInProcessObjectReference inProcessHelper = await jSRuntime.GetInProcessHelperAsync(); | ||
return new(jSRuntime, inProcessHelper, jSReference, options); | ||
} | ||
|
||
/// <inheritdoc cref="ArrayBuffer(IJSRuntime, IJSObjectReference, CreationOptions)"/> | ||
protected ArrayBufferInProcess(IJSRuntime jSRuntime, IJSInProcessObjectReference inProcessHelper, IJSInProcessObjectReference jSReference, CreationOptions options) : base(jSRuntime, jSReference, options) | ||
{ | ||
this.inProcessHelper = inProcessHelper; | ||
JSReference = jSReference; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/KristofferStrube.Blazor.WebIDL/Buffers/IArrayBuffer.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,8 @@ | ||
namespace KristofferStrube.Blazor.WebIDL; | ||
|
||
/// <summary> | ||
/// A common interface for <see cref="ArrayBufferInProcess"/> and <see cref="SharedArrayBufferInProcess"/>. | ||
/// </summary> | ||
public interface IArrayBufferInProcess : IArrayBuffer | ||
{ | ||
} |
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
39 changes: 39 additions & 0 deletions
39
src/KristofferStrube.Blazor.WebIDL/Buffers/SharedArrayBuffer.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,39 @@ | ||
using Microsoft.JSInterop; | ||
|
||
namespace KristofferStrube.Blazor.WebIDL; | ||
|
||
/// <summary> | ||
/// An object that holds a pointer (which cannot be null) to a shared buffer of a fixed number of bytes | ||
/// </summary> | ||
/// <remarks><see href="https://tc39.es/ecma262/multipage/structured-data.html#sec-sharedarraybuffer-objects">See the API definition here</see>.</remarks> | ||
[IJSWrapperConverter] | ||
public class SharedArrayBufferInProcess : SharedArrayBuffer, IArrayBufferInProcess, IJSInProcessCreatable<SharedArrayBufferInProcess, SharedArrayBuffer> | ||
{ | ||
/// <summary> | ||
/// A lazily loaded task that evaluates to a helper module instance from the Blazor.WebIDL library. | ||
/// </summary> | ||
protected IJSInProcessObjectReference inProcessHelper; | ||
|
||
/// <inheritdoc/> | ||
public new IJSInProcessObjectReference JSReference { get; } | ||
|
||
/// <inheritdoc/> | ||
public static async Task<SharedArrayBufferInProcess> CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference) | ||
{ | ||
return await CreateAsync(jSRuntime, jSReference, new()); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static async Task<SharedArrayBufferInProcess> CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference, CreationOptions options) | ||
{ | ||
IJSInProcessObjectReference inProcessHelper = await jSRuntime.GetInProcessHelperAsync(); | ||
return new SharedArrayBufferInProcess(jSRuntime, inProcessHelper, jSReference, options); | ||
} | ||
|
||
/// <inheritdoc/> | ||
protected SharedArrayBufferInProcess(IJSRuntime jSRuntime, IJSInProcessObjectReference inProcessHelper, IJSInProcessObjectReference jSReference, CreationOptions options) : base(jSRuntime, jSReference, options) | ||
{ | ||
this.inProcessHelper = inProcessHelper; | ||
JSReference = jSReference; | ||
} | ||
} |
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
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
78 changes: 78 additions & 0 deletions
78
src/KristofferStrube.Blazor.WebIDL/TypedArray/Float32Array.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 4 bytes. | ||
/// </summary> | ||
/// <remarks><see href="https://webidl.spec.whatwg.org/#idl-Float32Array">See the API definition here</see>.</remarks> | ||
[IJSWrapperConverter] | ||
public class Float32ArrayInProcess : Float32Array, ITypedArrayInProcess<float, Float32ArrayInProcess, Float32Array> | ||
{ | ||
/// <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<Float32ArrayInProcess> CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference) | ||
{ | ||
return await CreateAsync(jSRuntime, jSReference, new()); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static async Task<Float32ArrayInProcess> CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference, CreationOptions options) | ||
{ | ||
IJSInProcessObjectReference inProcessHelper = await jSRuntime.GetInProcessHelperAsync(); | ||
return new(jSRuntime, inProcessHelper, jSReference, options); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static new async Task<Float32ArrayInProcess> CreateAsync(IJSRuntime jSRuntime) | ||
{ | ||
return await ITypedArrayInProcess<float, Float32ArrayInProcess, Float32Array>.CreateInternalAsync(jSRuntime); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static new async Task<Float32ArrayInProcess> CreateAsync<TFromElement, TFromTypedArray>(IJSRuntime jSRuntime, TypedArray<TFromElement, TFromTypedArray> typedArray) where TFromTypedArray : IJSCreatable<TFromTypedArray> | ||
{ | ||
return await ITypedArrayInProcess<float, Float32ArrayInProcess, Float32Array>.CreateInternalAsync(jSRuntime, typedArray); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static new async Task<Float32ArrayInProcess> CreateAsync(IJSRuntime jSRuntime, IArrayBuffer buffer, long? byteOffset, long? length) | ||
{ | ||
return await ITypedArrayInProcess<float, Float32ArrayInProcess, Float32Array>.CreateInternalAsync(jSRuntime, buffer, byteOffset, length); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static new async Task<Float32ArrayInProcess> CreateAsync(IJSRuntime jSRuntime, long length) | ||
{ | ||
return await ITypedArrayInProcess<float, Float32ArrayInProcess, Float32Array>.CreateInternalAsync(jSRuntime, length); | ||
} | ||
|
||
/// <inheritdoc cref="IJSInProcessCreatable{TInProcess, T}.CreateAsync(IJSRuntime, IJSInProcessObjectReference, CreationOptions)"/> | ||
protected Float32ArrayInProcess(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<float, Float32ArrayInProcess, Float32Array>.GetBufferAsync(this); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public float At(long index) | ||
{ | ||
return ITypedArrayInProcess<float, Float32ArrayInProcess, Float32Array>.At(this, index); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public long Length => ITypedArrayInProcess<float, Float32ArrayInProcess, Float32Array>.GetLength(this); | ||
} |
Oops, something went wrong.