pub mod callback; pub mod handle; pub mod new_stack; pub mod vtable; #[macro_use] extern crate tracing; use std::{any::Any, fmt::Debug, mem::transmute, ptr::null_mut, sync::Arc}; use callback::{OperationHandlerCallback, SettingGetterCallback, ValueGetterCallback}; use dlopen2::wrapper::WrapperApi; use giterated_models::{ object::GiteratedObject, operation::GiteratedOperation, settings::Setting, value::GiteratedObjectValue, }; 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() -> 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 ()) } } impl AsRef for FFIBox { fn as_ref(&self) -> &T { todo!() } } impl std::ops::Deref for FFIBox { type Target = T; fn deref(&self) -> &Self::Target { unsafe { self.0.as_ref() }.unwrap() } }