Skip to content
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ bin/
obj/

BenchmarkDotNet.Artifacts/
/Wasmtime.sln.DotSettings.user
189 changes: 189 additions & 0 deletions src/Components/Component.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
using Microsoft.Win32.SafeHandles;
using System;
using System.Runtime.InteropServices;

namespace Wasmtime.Components;

/// <summary>
/// Representation of a component in the component model.
/// </summary>
public class Component
: IDisposable
{
private readonly Handle handle;

internal Handle NativeHandle
{
get
{
if (handle.IsInvalid || handle.IsClosed)
{
throw new ObjectDisposedException(typeof(Module).FullName);
}

return handle;
}
}

internal Component(IntPtr handle)
{
this.handle = new Handle(handle);
}

/// <inheritdoc/>
public void Dispose()
{
handle.Dispose();
}

/// <summary>
/// Creates a <see cref="Component"/> given bytes.
/// </summary>
/// <param name="engine">The engine to use for the Component.</param>
/// <param name="bytes">The bytes of the Component.</param>
/// <returns>Returns a new <see cref="Component"/>.</returns>
public static Component FromBytes(Engine engine, ReadOnlySpan<byte> bytes)
{
if (engine is null)
{
throw new ArgumentNullException(nameof(engine));
}

unsafe
{
fixed (byte* ptr = bytes)
{
var error = Native.wasmtime_component_new(engine.NativeHandle, ptr, (UIntPtr)bytes.Length, out var handle);
if (error != IntPtr.Zero)
{
throw new WasmtimeException($"WebAssembly component is not valid: {WasmtimeException.FromOwnedError(error).Message}");
}

return new Component(handle);
}
}
}

/// <summary>
/// This function serializes compiled component artifacts as blob data.
/// </summary>
/// <returns>If the conversion is successful, the serialized compiled component.</returns>
public byte[] Serialize()
{
var error = Native.wasmtime_component_serialize(NativeHandle, out var bytes);
if (error != IntPtr.Zero)
{
throw WasmtimeException.FromOwnedError(error);
}

using (bytes)
return bytes.ToArray();
}

/// <summary>
/// Deserializes a previously serialized component from a span of bytes.
/// </summary>
/// <param name="engine">The engine to use to deserialize the component.</param>
/// <param name="bytes">The previously serialized component bytes.</param>
/// <returns>Returns the <see cref="Component" /> that was previously serialized.</returns>
/// <remarks>The passed bytes must come from a previous call to <see cref="Component.Serialize" />.</remarks>
public static Component Deserialize(Engine engine, ReadOnlySpan<byte> bytes)
{
if (engine is null)
{
throw new ArgumentNullException(nameof(engine));
}

unsafe
{
fixed (byte* ptr = bytes)
{
var error = Native.wasmtime_component_deserialize(engine.NativeHandle, ptr, (UIntPtr)bytes.Length, out var handle);
if (error != IntPtr.Zero)
{
throw WasmtimeException.FromOwnedError(error);
}

return new Component(handle);
}
}
}

/// <summary>
/// Deserializes a previously serialized component from a file.
/// </summary>
/// <param name="engine">The engine to deserialize the component with.</param>
/// <param name="path">The path to the previously serialized component.</param>
/// <returns>Returns the <see cref="Component" /> that was previously serialized.</returns>
/// <remarks>The file's contents must come from a previous call to <see cref="Component.Serialize" />.</remarks>
public static Component DeserializeFile(Engine engine, string path)
{
if (engine is null)
{
throw new ArgumentNullException(nameof(engine));
}

var error = Native.wasmtime_component_deserialize_file(engine.NativeHandle, path, out var handle);
if (error != IntPtr.Zero)
{
throw WasmtimeException.FromOwnedError(error);
}

return new Component(handle);
}

public ComponentExport? GetExport(string name)

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'

Check warning on line 135 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string)'
{
var ret = Native.wasmtime_component_get_export_index(NativeHandle, null, name, (nuint)name.Length);
if (ret == IntPtr.Zero)
return null;

return new ComponentExport(ret);
}

public ComponentExport? GetExport(string name, ComponentExport instance_export_index)

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'

Check warning on line 144 in src/Components/Component.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'Component.GetExport(string, ComponentExport)'
{
var ret = Native.wasmtime_component_get_export_index(NativeHandle, instance_export_index.NativeHandle, name, (nuint)name.Length);
if (ret == IntPtr.Zero)
return null;

return new ComponentExport(ret);
}

internal class Handle
: SafeHandleZeroOrMinusOneIsInvalid
{
public Handle(IntPtr handle)
: base(true)
{
SetHandle(handle);
}

protected override bool ReleaseHandle()
{
Native.wasmtime_component_delete(handle);
return true;
}
}

internal static class Native
{
[DllImport(Engine.LibraryName)]
public static extern unsafe IntPtr wasmtime_component_new(Engine.Handle engine, byte* bytes, nuint size, out IntPtr handle);

[DllImport(Engine.LibraryName)]
public static extern void wasmtime_component_delete(IntPtr handle);

[DllImport(Engine.LibraryName)]
public static extern IntPtr wasmtime_component_serialize(Handle component, out ByteArray ret);

[DllImport(Engine.LibraryName)]
public static extern unsafe IntPtr wasmtime_component_deserialize(Engine.Handle engine, byte* bytes, nuint size, out IntPtr handle);

[DllImport(Engine.LibraryName)]
public static extern IntPtr wasmtime_component_deserialize_file(Engine.Handle engine, string path, out IntPtr handle);

[DllImport(Engine.LibraryName)]
public static extern IntPtr wasmtime_component_get_export_index(Handle component, ComponentExport.Handle? instance_export_index, string name, nuint name_len);
}
}
57 changes: 57 additions & 0 deletions src/Components/ComponentExport.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Microsoft.Win32.SafeHandles;
using System;
using System.Runtime.InteropServices;

namespace Wasmtime.Components;

public class ComponentExport

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'ComponentExport'

Check warning on line 7 in src/Components/ComponentExport.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'ComponentExport'
: IDisposable
{
private readonly Handle handle;

internal Handle NativeHandle
{
get
{
if (handle.IsInvalid || handle.IsClosed)
{
throw new ObjectDisposedException(typeof(Module).FullName);
}

return handle;
}
}

internal ComponentExport(IntPtr handle)
{
this.handle = new Handle(handle);
}

/// <inheritdoc/>
public void Dispose()
{
handle.Dispose();
}

internal class Handle
: SafeHandleZeroOrMinusOneIsInvalid
{
public Handle(IntPtr handle)
: base(true)
{
SetHandle(handle);
}

protected override bool ReleaseHandle()
{
Native.wasmtime_component_export_index_delete(handle);
return true;
}
}

internal static class Native
{
[DllImport(Engine.LibraryName)]
public static extern void wasmtime_component_export_index_delete(IntPtr /* wasmtime_component_export_index_t* */ export_index);
}
}
19 changes: 19 additions & 0 deletions src/Components/ComponentFunction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Wasmtime.Components;

/// <summary>
/// Represents a Wasmtime function.
/// </summary>
public class ComponentFunction
{
//todo: everything!


internal static class Native
{
// [DllImport(Engine.LibraryName)]
//todo: wasmtime_error_t * wasmtime_component_func_call (const wasmtime_component_func_t *func, wasmtime_context_t *context, const wasmtime_component_val_t *args, size_t args_size, wasmtime_component_val_t *results, size_t results_size)

// [DllImport(Engine.LibraryName)]
//todo: wasmtime_error_t * wasmtime_component_func_post_return (const wasmtime_component_func_t *func, wasmtime_context_t *context)
}
}
16 changes: 16 additions & 0 deletions src/Components/ComponentInstance.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Wasmtime.Components;

public class ComponentInstance

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'ComponentInstance'

Check warning on line 3 in src/Components/ComponentInstance.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'ComponentInstance'
{
//todo: everything!


internal static class Native
{
//[DllImport(Engine.LibraryName)]
//public static extern IntPtr /* wasmtime_component_export_index_t* */ wasmtime_component_instance_get_export_index (wasmtime_component_instance_t *instance, wasmtime_context_t *context, ComponentExport.Handle instance_export_index, string name, nuint name_len)

// [DllImport(Engine.LibraryName)]
//todo: bool wasmtime_component_instance_get_func (const wasmtime_component_instance_t *instance, wasmtime_context_t *context, const wasmtime_component_export_index_t *export_index, wasmtime_component_func_t *func_out)
}
}
75 changes: 75 additions & 0 deletions src/Components/ComponentLinker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using Microsoft.Win32.SafeHandles;
using System;
using System.Runtime.InteropServices;

namespace Wasmtime.Components;

public class ComponentLinker

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-debug)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-debug)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-release)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (linux-release)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (windows-release)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'ComponentLinker'

Check warning on line 7 in src/Components/ComponentLinker.cs

View workflow job for this annotation

GitHub Actions / Test .NET embedding of Wasmtime (macos-debug)

Missing XML comment for publicly visible type or member 'ComponentLinker'
: IDisposable
{
private readonly Handle handle;

internal Handle NativeHandle
{
get
{
if (handle.IsInvalid || handle.IsClosed)
{
throw new ObjectDisposedException(typeof(Module).FullName);
}

return handle;
}
}

internal ComponentLinker(IntPtr handle)
{
this.handle = new Handle(handle);
}

/// <inheritdoc/>
public void Dispose()
{
handle.Dispose();
}

internal class Handle
: SafeHandleZeroOrMinusOneIsInvalid
{
public Handle(IntPtr handle)
: base(true)
{
SetHandle(handle);
}

protected override bool ReleaseHandle()
{
Native.wasmtime_component_linker_delete(handle);
return true;
}
}

internal static class Native
{
// [DllImport(Engine.LibraryName)]
//todo: wasmtime_component_linker_t * wasmtime_component_linker_new (const wasm_engine_t *engine)

// [DllImport(Engine.LibraryName)]
//todo: wasmtime_component_linker_instance_t * wasmtime_component_linker_root (wasmtime_component_linker_t *linker)

// [DllImport(Engine.LibraryName)]
//todo: wasmtime_error_t * wasmtime_component_linker_instantiate (const wasmtime_component_linker_t *linker, wasmtime_context_t *context, const wasmtime_component_t *component, wasmtime_component_instance_t *instance_out)

[DllImport(Engine.LibraryName)]
public static extern void wasmtime_component_linker_delete(IntPtr /* wasmtime_component_linker_t* */ linker);

//todo: wasmtime_error_t * wasmtime_component_linker_instance_add_instance (wasmtime_component_linker_instance_t *linker_instance, const char *name, size_t name_len, wasmtime_component_linker_instance_t **linker_instance_out)
//todo: wasmtime_error_t* wasmtime_component_linker_instance_add_module(wasmtime_component_linker_instance_t* linker_instance, const char* name, size_t name_len, const wasmtime_module_t* module)
//todo: wasmtime_error_t * wasmtime_component_linker_instance_add_func (wasmtime_component_linker_instance_t *linker_instance, const char *name, size_t name_len, wasmtime_component_func_callback_t callback, void *data, void(*finalizer)(void *))
//todo: wasmtime_error_t * wasmtime_component_linker_add_wasip2 (wasmtime_component_linker_t *linker)

[DllImport(Engine.LibraryName)]
public static extern void wasmtime_component_linker_instance_delete(IntPtr /* wasmtime_component_linker_instance_t* */ linker_instance);

}
}
Loading
Loading