extra stuff
This commit is contained in:
parent
5b3b89ec4c
commit
6dd22fe0c3
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,4 +1,6 @@
|
||||||
/target
|
/target
|
||||||
/plugins
|
/plugins
|
||||||
/.cache
|
/.cache
|
||||||
|
/config/*
|
||||||
|
!/config/main.template.toml
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
|
|
12
Cargo.lock
generated
12
Cargo.lock
generated
|
@ -592,6 +592,18 @@ version = "0.2.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "volume"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"dim_sdk",
|
||||||
|
"lazy_static",
|
||||||
|
"regex",
|
||||||
|
"serde",
|
||||||
|
"toml",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen"
|
name = "wasm-bindgen"
|
||||||
version = "0.2.92"
|
version = "0.2.92"
|
||||||
|
|
|
@ -5,6 +5,7 @@ members = [
|
||||||
"dim_plugins/clock",
|
"dim_plugins/clock",
|
||||||
"dim_plugins/counter",
|
"dim_plugins/counter",
|
||||||
"dim_plugins/battery",
|
"dim_plugins/battery",
|
||||||
|
"dim_plugins/volume",
|
||||||
]
|
]
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
|
|
55
\
Normal file
55
\
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
// Lord have mercy on me
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! plugin_info {
|
||||||
|
($typ:ty, $name:literal, $version:literal, $license:literal) => {
|
||||||
|
|
||||||
|
lazy_static::lazy_static!(
|
||||||
|
static ref PLUGIN_INFO: $crate::PluginInfo = $crate::PluginInfo::new($name, $version, $license);
|
||||||
|
);
|
||||||
|
|
||||||
|
static mut PLUG: *mut $typ = std::ptr::null_mut() as *mut $typ;
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
unsafe extern "C" fn plug_get_info() -> *const std::ffi::c_void {
|
||||||
|
PLUGIN_INFO.get_raw_ptr()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
unsafe extern "C" fn plug_init(ctx: *const $crate::ContextRaw) {
|
||||||
|
PLUG = std::alloc::alloc(std::alloc::Layout::new::<$typ>()) as *mut $typ;
|
||||||
|
*PLUG = <$typ>::new();
|
||||||
|
|
||||||
|
let ctx = $crate::Context::new(ctx);
|
||||||
|
(&mut *PLUG).init(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
unsafe extern "C" fn plug_pre_reload() -> *mut $typ {
|
||||||
|
//TODO: Untested
|
||||||
|
(&mut *PLUG).pre_reload();
|
||||||
|
return PLUG;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
unsafe extern "C" fn plug_post_reload(state: *mut $typ) {
|
||||||
|
//TODO: Untested
|
||||||
|
PLUG = state;
|
||||||
|
(&mut *PLUG).post_reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
unsafe extern "C" fn plug_poll(buf: *mut i8, len: std::ffi::c_uint) {
|
||||||
|
let mut buf = $crate::CBuffer::from_raw_parts_mut(buf, len as usize);
|
||||||
|
if let Err(_e) = (&mut *PLUG).poll(&mut buf) {
|
||||||
|
// TODO: Handle error maybe?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
unsafe extern "C" fn plug_free() {
|
||||||
|
std::alloc::dealloc(PLUG as *mut u8, std::alloc::Layout::new::<$typ>());
|
||||||
|
(&mut *PLUG).free();
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user