pub struct BoundAssembly {
pub assembly_name: &'static str,
pub assembly_path: &'static str,
pub thunks_name: &'static str,
pub coreclr_thunks: &'static [u8],
pub mono_thunks: &'static [u8],
pub function_count: usize,
/* private fields */
}Expand description
A .NET assembly bound with hao_runtime_macros::bind!.
Fields§
§assembly_name: &'static strThe bound assembly’s name, e.g. MyLib.
assembly_path: &'static strWhere the bound assembly is loaded from; empty when the runtime already has it (a framework assembly).
thunks_name: &'static strThe generated thunk assembly’s name.
coreclr_thunks: &'static [u8]The thunk assembly for CoreCLR, whose thunks are [UnmanagedCallersOnly].
mono_thunks: &'static [u8]The thunk assembly for Mono.
function_count: usizeHow many thunks there are, the helpers included.
Implementations§
Source§impl BoundAssembly
impl BoundAssembly
Sourcepub const fn new(
assembly_name: &'static str,
assembly_path: &'static str,
thunks_name: &'static str,
coreclr_thunks: &'static [u8],
mono_thunks: &'static [u8],
function_count: usize,
) -> Self
pub const fn new( assembly_name: &'static str, assembly_path: &'static str, thunks_name: &'static str, coreclr_thunks: &'static [u8], mono_thunks: &'static [u8], function_count: usize, ) -> Self
Describes a bound assembly; bind! generates this call, so there is
usually no need to write it.
Sourcepub fn load(&self, runtime: &Runtime) -> Result<()>
pub fn load(&self, runtime: &Runtime) -> Result<()>
Loads the bound assembly and its thunks into runtime. Called on first use.
Sourcepub fn function(&self, runtime: &Runtime, index: usize) -> Result<*const c_void>
pub fn function(&self, runtime: &Runtime, index: usize) -> Result<*const c_void>
A native pointer to thunk f{index}, loading the assembly and
attaching the calling thread first. Call it with Runtime::backend’s
calling convention.
Sourcepub fn free(&self, runtime: &Runtime, handle: isize) -> Result<()>
pub fn free(&self, runtime: &Runtime, handle: isize) -> Result<()>
Frees a GCHandle a thunk returned, letting the object be collected.
Sourcepub fn take_string(
&self,
runtime: &Runtime,
handle: isize,
) -> Result<Option<String>>
pub fn take_string( &self, runtime: &Runtime, handle: isize, ) -> Result<Option<String>>
Reads and frees a handle to a System.String. 0 is null.
Sourcepub fn object_to_string(
&self,
runtime: &Runtime,
handle: isize,
) -> Result<String>
pub fn object_to_string( &self, runtime: &Runtime, handle: isize, ) -> Result<String>
ToString() of the object behind handle, without freeing it.
Sourcepub fn take_exception(&self, runtime: &Runtime, handle: isize) -> Error
pub fn take_exception(&self, runtime: &Runtime, handle: isize) -> Error
Turns a handle to a thrown exception into an Error::Managed, freeing it.