Introduced dylib extension format, cleared up shutdown sequence

This commit is contained in:
2026-01-17 00:23:35 +01:00
parent 1a7230ce9b
commit 6a3c1d5917
18 changed files with 214 additions and 113 deletions

View File

@@ -9,7 +9,7 @@ use crate::ext_port::ExtPort;
pub type ExtCx = api::binary::ExtensionContext;
struct Spawner(api::binary::Spawner);
struct Spawner(api::binary::SpawnerBin);
impl Drop for Spawner {
fn drop(&mut self) { (self.0.drop)(self.0.data) }
}
@@ -28,3 +28,22 @@ pub fn orchid_extension_main_body(cx: ExtCx, builder: ExtensionBuilder) {
spawn: Rc::new(move |fut| spawner.spawn(fut)),
});
}
/// Generate entrypoint for the dylib extension loader
///
/// # Usage
///
/// ```
/// dylib_main! {
/// ExtensionBuilder::new("orchid-std::main")
/// }
/// ```
#[macro_export]
macro_rules! dylib_main {
($builder:expr) => {
#[unsafe(no_mangle)]
pub extern "C" fn orchid_extension_main(cx: ::orchid_api::binary::ExtensionContext) {
$crate::binary::orchid_extension_main_body(cx, $builder);
}
};
}