Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 106 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ members = [
"pomme-block",
"pomme-protocol",
"tools/blockgen",
"tools/protogen"
"tools/protogen",

"plugin-api",
"plugin-loader",
"plugin-macros",
"plugin-example",
]

[workspace.dependencies]
Expand All @@ -28,7 +33,14 @@ glam = "0.33"
# client
pyronyx = "=0.3.2"
tracing = "0.1"
tracing-subscriber = "0.3"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
tracing-shared = "0.1"

plugin-api = { path = "./plugin-api" }
plugin-loader = { path = "./plugin-loader" }
plugin-macros = { path = "./plugin-macros" }

stabby = "=72.1.16"

# azalea lags crates.io releases; track the 26.2 branch from git.
# azalea-block is replaced by the pomme-block shim (pomme owns block data);
Expand Down
1 change: 1 addition & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ launcher-pre-pr:
@pnpm --filter pomme-launcher pre-pr

client-dev *args:
@cargo build -p plugin-example
@cargo run -p pomme-client {{ args }}

# Optimized release client for accurate benchmarking (supplies the launch token the guard needs).
Expand Down
9 changes: 9 additions & 0 deletions plugin-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "plugin-api"
version = "0.1.0"
edition = "2024"

[dependencies]
stabby.workspace = true
tracing-shared.workspace = true
plugin-macros.workspace = true
52 changes: 52 additions & 0 deletions plugin-api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
use stabby::boxed::Box;
use stabby::dynptr;
use stabby::str::Str;

pub mod meta;

pub use plugin_macros::plugin;
pub use stabby;

use crate::meta::Version;

pub trait Plugin {
fn new() -> Self;

fn on_client_started(&mut self) {}
fn on_client_stopping(&mut self) {}

fn on_client_tick_start(&mut self) {}
fn on_client_tick_end(&mut self) {}
}

#[stabby::stabby]
pub trait SPlugin {
extern "C" fn on_client_started(&mut self);
extern "C" fn on_client_stopping(&mut self);

extern "C" fn on_client_tick_start(&mut self);
extern "C" fn on_client_tick_end(&mut self);
}

impl<T: Plugin> SPlugin for T {
extern "C" fn on_client_started(&mut self) {
<Self as Plugin>::on_client_started(self);
}
extern "C" fn on_client_stopping(&mut self) {
<Self as Plugin>::on_client_stopping(self);
}

extern "C" fn on_client_tick_start(&mut self) {
<Self as Plugin>::on_client_tick_start(self);
}
extern "C" fn on_client_tick_end(&mut self) {
<Self as Plugin>::on_client_tick_end(self);
}
}

#[stabby::stabby]
pub struct PluginModule {
pub name: Str<'static>,
pub version: Version,
pub plugin: dynptr!(Box<dyn SPlugin>),
}
Loading
Loading