Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 131 additions & 0 deletions src/Function.FromCallback.cs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/Function.FromCallback.tt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Diagnostics.CodeAnalysis;

namespace Wasmtime
{
Expand All @@ -41,6 +42,7 @@ foreach (var (hasCaller, resultCount, parameterCount, methodGenerics, delegateTy
/// </summary>
/// <param name="store">The store to create the function in.</param>
/// <param name="callback">The callback for when the function is invoked.</param>
[ExcludeFromCodeCoverage]
public static Function FromCallback<#= methodGenerics #>(Store store, <#= delegateType #> callback)
{
if (store is null)
Expand Down
35 changes: 35 additions & 0 deletions src/Function.Wrap.cs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/Function.Wrap.tt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#nullable enable

using System;
using System.Diagnostics.CodeAnalysis;

namespace Wasmtime
{
Expand All @@ -39,6 +40,7 @@ foreach (var (_, returnTypeCount, parameterCount, methodGenerics, delegateType,
/// Attempt to wrap this function as <#= returnTypeCount > 0 ? "a <c>Func</c>" : "an <c>Action</c>" #>. Wrapped <c><#= returnTypeCount > 0 ? "Func" : "Action" #></c> is faster than a normal Invoke call.
/// </summary>
/// <returns>A <c><#= returnTypeCount > 0 ? "Func" : "Action" #></c> to invoke this function, or <c>null</c> if the type signature is incompatible.</returns>
[ExcludeFromCodeCoverage]
public <#= delegateType #>? Wrap<#= returnTypeCount > 0 ? "Func" : "Action" #><#= methodGenerics #>()
{
if (store is null || IsNull)
Expand Down
17 changes: 17 additions & 0 deletions src/Instance.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Text;

Expand Down Expand Up @@ -108,6 +109,7 @@ public Instance(Store store, Module module, params object[] imports)
/// <typeparam name="TB">Second parameter type</typeparam>
/// <typeparam name="TC">Third parameter type</typeparam>
/// <returns>Returns the function if a function of that name and type was exported or null if not.</returns>
[ExcludeFromCodeCoverage]
public Action<TA, TB, TC>? GetAction<TA, TB, TC>(string name)
{
return GetFunction(name)
Expand All @@ -123,6 +125,7 @@ public Instance(Store store, Module module, params object[] imports)
/// <typeparam name="TC">Third parameter type</typeparam>
/// <typeparam name="TD">Fourth parameter type</typeparam>
/// <returns>Returns the function if a function of that name and type was exported or null if not.</returns>
[ExcludeFromCodeCoverage]
public Action<TA, TB, TC, TD>? GetAction<TA, TB, TC, TD>(string name)
{
return GetFunction(name)
Expand All @@ -139,6 +142,7 @@ public Instance(Store store, Module module, params object[] imports)
/// <typeparam name="TD">Fourth parameter type</typeparam>
/// <typeparam name="TE">Fifth parameter type</typeparam>
/// <returns>Returns the function if a function of that name and type was exported or null if not.</returns>
[ExcludeFromCodeCoverage]
public Action<TA, TB, TC, TD, TE>? GetAction<TA, TB, TC, TD, TE>(string name)
{
return GetFunction(name)
Expand Down Expand Up @@ -209,6 +213,7 @@ public Instance(Store store, Module module, params object[] imports)
/// <typeparam name="TD">Fourth parameter type</typeparam>
/// <typeparam name="TR">Return type. Use a tuple for multiple return values</typeparam>
/// <returns>Returns the function if a function of that name and type was exported or null if not.</returns>
[ExcludeFromCodeCoverage]
public Func<TA, TB, TC, TD, TR?>? GetFunction<TA, TB, TC, TD, TR>(string name)
{
return GetFunction(name)
Expand All @@ -226,6 +231,7 @@ public Instance(Store store, Module module, params object[] imports)
/// <typeparam name="TE">Fifth parameter type</typeparam>
/// <typeparam name="TR">Return type. Use a tuple for multiple return values</typeparam>
/// <returns>Returns the function if a function of that name and type was exported or null if not.</returns>
[ExcludeFromCodeCoverage]
public Func<TA, TB, TC, TD, TE, TR?>? GetFunction<TA, TB, TC, TD, TE, TR>(string name)
{
return GetFunction(name)
Expand All @@ -244,6 +250,7 @@ public Instance(Store store, Module module, params object[] imports)
/// <typeparam name="TF">Sixth parameter type</typeparam>
/// <typeparam name="TR">Return type. Use a tuple for multiple return values</typeparam>
/// <returns>Returns the function if a function of that name and type was exported or null if not.</returns>
[ExcludeFromCodeCoverage]
public Func<TA, TB, TC, TD, TE, TF, TR?>? GetFunction<TA, TB, TC, TD, TE, TF, TR>(string name)
{
return GetFunction(name)
Expand All @@ -263,6 +270,7 @@ public Instance(Store store, Module module, params object[] imports)
/// <typeparam name="TG">Seventh parameter type</typeparam>
/// <typeparam name="TR">Return type. Use a tuple for multiple return values</typeparam>
/// <returns>Returns the function if a function of that name and type was exported or null if not.</returns>
[ExcludeFromCodeCoverage]
public Func<TA, TB, TC, TD, TE, TF, TG, TR?>? GetFunction<TA, TB, TC, TD, TE, TF, TG, TR>(string name)
{
return GetFunction(name)
Expand All @@ -283,6 +291,7 @@ public Instance(Store store, Module module, params object[] imports)
/// <typeparam name="TH">Eighth parameter type</typeparam>
/// <typeparam name="TR">Return type. Use a tuple for multiple return values</typeparam>
/// <returns>Returns the function if a function of that name and type was exported or null if not.</returns>
[ExcludeFromCodeCoverage]
public Func<TA, TB, TC, TD, TE, TF, TG, TH, TR?>? GetFunction<TA, TB, TC, TD, TE, TF, TG, TH, TR>(string name)
{
return GetFunction(name)
Expand All @@ -304,6 +313,7 @@ public Instance(Store store, Module module, params object[] imports)
/// <typeparam name="TI">Ninth parameter type</typeparam>
/// <typeparam name="TR">Return type. Use a tuple for multiple return values</typeparam>
/// <returns>Returns the function if a function of that name and type was exported or null if not.</returns>
[ExcludeFromCodeCoverage]
public Func<TA, TB, TC, TD, TE, TF, TG, TH, TI, TR?>? GetFunction<TA, TB, TC, TD, TE, TF, TG, TH, TI, TR>(string name)
{
return GetFunction(name)
Expand All @@ -326,6 +336,7 @@ public Instance(Store store, Module module, params object[] imports)
/// <typeparam name="TJ">Tenth parameter type</typeparam>
/// <typeparam name="TR">Return type. Use a tuple for multiple return values</typeparam>
/// <returns>Returns the function if a function of that name and type was exported or null if not.</returns>
[ExcludeFromCodeCoverage]
public Func<TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ, TR?>? GetFunction<TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ, TR>(string name)
{
return GetFunction(name)
Expand All @@ -349,6 +360,7 @@ public Instance(Store store, Module module, params object[] imports)
/// <typeparam name="TK">Eleventh parameter type</typeparam>
/// <typeparam name="TR">Return type. Use a tuple for multiple return values</typeparam>
/// <returns>Returns the function if a function of that name and type was exported or null if not.</returns>
[ExcludeFromCodeCoverage]
public Func<TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ, TK, TR?>? GetFunction<TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ, TK, TR>(string name)
{
return GetFunction(name)
Expand All @@ -373,6 +385,7 @@ public Instance(Store store, Module module, params object[] imports)
/// <typeparam name="TL">Twelfth parameter type</typeparam>
/// <typeparam name="TR">Return type. Use a tuple for multiple return values</typeparam>
/// <returns>Returns the function if a function of that name and type was exported or null if not.</returns>
[ExcludeFromCodeCoverage]
public Func<TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ, TK, TL, TR?>? GetFunction<TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ, TK, TL, TR>(string name)
{
return GetFunction(name)
Expand All @@ -398,6 +411,7 @@ public Instance(Store store, Module module, params object[] imports)
/// <typeparam name="TM">Thirteenth parameter type</typeparam>
/// <typeparam name="TR">Return type. Use a tuple for multiple return values</typeparam>
/// <returns>Returns the function if a function of that name and type was exported or null if not.</returns>
[ExcludeFromCodeCoverage]
public Func<TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ, TK, TL, TM, TR?>? GetFunction<TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ, TK, TL, TM, TR>(string name)
{
return GetFunction(name)
Expand All @@ -424,6 +438,7 @@ public Instance(Store store, Module module, params object[] imports)
/// <typeparam name="TN">Fourteenth parameter type</typeparam>
/// <typeparam name="TR">Return type. Use a tuple for multiple return values</typeparam>
/// <returns>Returns the function if a function of that name and type was exported or null if not.</returns>
[ExcludeFromCodeCoverage]
public Func<TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ, TK, TL, TM, TN, TR?>? GetFunction<TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ, TK, TL, TM, TN, TR>(string name)
{
return GetFunction(name)
Expand Down Expand Up @@ -451,6 +466,7 @@ public Instance(Store store, Module module, params object[] imports)
/// <typeparam name="TO">Fifteenth parameter type</typeparam>
/// <typeparam name="TR">Return type. Use a tuple for multiple return values</typeparam>
/// <returns>Returns the function if a function of that name and type was exported or null if not.</returns>
[ExcludeFromCodeCoverage]
public Func<TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ, TK, TL, TM, TN, TO, TR?>? GetFunction<TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ, TK, TL, TM, TN, TO, TR>(string name)
{
return GetFunction(name)
Expand Down Expand Up @@ -479,6 +495,7 @@ public Instance(Store store, Module module, params object[] imports)
/// <typeparam name="TP">Sixteenth parameter type</typeparam>
/// <typeparam name="TR">Return type. Use a tuple for multiple return values</typeparam>
/// <returns>Returns the function if a function of that name and type was exported or null if not.</returns>
[ExcludeFromCodeCoverage]
public Func<TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ, TK, TL, TM, TN, TO, TP, TR?>? GetFunction<TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ, TK, TL, TM, TN, TO, TP, TR>(string name)
{
return GetFunction(name)
Expand Down
Loading
Loading