using System;
using System.Runtime.InteropServices;
namespace Wasmtime.Imports
{
///
/// The base class for import types.
///
public abstract class Import
{
internal Import(IntPtr importType)
{
unsafe
{
Handle = importType;
var moduleName = Interop.wasm_importtype_module(Handle);
ModuleName = Marshal.PtrToStringUTF8((IntPtr)moduleName->data, (int)moduleName->size);
var name = Interop.wasm_importtype_name(Handle);
Name = Marshal.PtrToStringUTF8((IntPtr)name->data, (int)name->size);
}
}
///
/// The module name of the import.
///
public string ModuleName { get; private set; }
///
/// The name of the import.
///
public string Name { get; private set; }
internal IntPtr Handle { get; private set; }
///
public override string ToString()
{
return $"{ModuleName}{(string.IsNullOrEmpty(ModuleName) ? "" : ".")}{Name}";
}
}
}