41 lines
1.8 KiB
C#
41 lines
1.8 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using JetBrains.Annotations;
|
|
using PkmnLibSharp.Utils;
|
|
|
|
namespace PkmnLibSharp.FFI.DynamicData.Libraries
|
|
{
|
|
internal static class ScriptResolver
|
|
{
|
|
/// <summary>
|
|
/// Instantiates a basic empty script resolver, that always returns None.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern FFIHandleValue empty_script_resolver_new();
|
|
|
|
// WASM is a feature flag in the crate, and can be disabled. If disabled, these entry points do not exist. In
|
|
// this case it's recommended to remove the WASM compile flag from the csproj as well.
|
|
#if WASM
|
|
/// <summary>
|
|
/// Instantiates a new WebAssemblyScriptResolver.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern FFIHandleValue webassembly_script_resolver_new();
|
|
|
|
/// <summary>
|
|
/// Load a compiled WASM module.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
[MustUseReturnValue]
|
|
internal static extern NativeResult webassembly_script_resolver_load_wasm_from_bytes(FFIHandleValue resolver, IntPtr byteArray,
|
|
ulong arrayLength);
|
|
|
|
/// <summary>
|
|
/// Tells the script resolver we're done loading wasm modules, and to finalize the resolver.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
[MustUseReturnValue]
|
|
internal static extern NativeResult webassembly_script_resolver_finalize(FFIHandleValue resolver);
|
|
#endif
|
|
}
|
|
} |