```rust= // wasm-plugin crate extern "C" { fn get_u8(id: Id); // <snipped> } pub trait Plugin { fn game_time(&self) -> f64; // <snipped> } macro_rules! plugin_glue { ($ty:ty = $block:block) => { static PLUGIN: $ty = { extern "C" { fn game_time() { unsafe { PLUGIN }.game_time() } // <snipped> } $block }; }; } ``` ```rust= // actual plugin crate that depends on `wasm-plugin` crate struct MyPlugin { hey: f64 } impl wasm_plugin::Plugin for MyPlugin { fn game_time(&self) { self.hey + wasm_plugin::get_u8(Id::new(0)) as f64 } } register_plugin! { MyPlugin = MyPlugin { hey: 0.0 } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up