#![allow(improper_ctypes_definitions)] pub mod callback; pub mod future; pub mod handle; pub mod new_stack; pub mod vtable; #[macro_use] extern crate tracing; use callback::RuntimeState; use dlopen2::wrapper::WrapperApi; use handle::PluginInitializationState; use new_stack::{FFIPluginMeta, PluginState}; pub use vtable::{AnyFailure, AnyObject, AnyOperation, AnySuccess, NewAnySetting, NewAnyValue}; use vtable::{HostVTable, InitializationVTable}; #[derive(WrapperApi)] pub struct GiteratedPluginApi { plugin_meta: unsafe extern "C" fn() -> FFIPluginMeta, load_host_vtable: unsafe extern "C" fn(vtable: &HostVTable), load_initialization_vtable: unsafe extern "C" fn(vtable: &InitializationVTable), initialize: unsafe extern "C" fn(runtime_state: *const RuntimeState) -> PluginState, initialize_registration: unsafe extern "C" fn( init_state: *mut PluginInitializationState, ) -> *mut PluginInitializationState, } #[repr(C)] pub struct FFIBox(*mut T); impl FFIBox { pub fn from_box(src: Box) -> Self { Self(Box::into_raw(src)) } pub fn untyped(self) -> FFIBox<()> { FFIBox(self.0 as *mut ()) } pub unsafe fn retype(self) -> FFIBox { FFIBox(self.0 as *mut N) } pub unsafe fn into_box(self) -> Box { Box::from_raw(self.0) } pub unsafe fn transmute_ref(&self) -> &N { unsafe { (self.0 as *const N).as_ref() }.unwrap() } } impl ToString for FFIBox { fn to_string(&self) -> String { todo!() } } impl AsRef for FFIBox { fn as_ref(&self) -> &T { unsafe { self.0.as_ref() }.unwrap() } } impl std::ops::Deref for FFIBox { type Target = T; fn deref(&self) -> &Self::Target { unsafe { self.0.as_ref() }.unwrap() } }