add init/cleanup functions, now the plugin actually loads!
This commit is contained in:
parent
c48d967e3a
commit
81a9db0b8d
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -82,6 +82,11 @@ name = "byteorder"
|
|||||||
version = "1.3.1"
|
version = "1.3.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "c_str_macro"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.0.28"
|
version = "1.0.28"
|
||||||
@ -290,6 +295,7 @@ name = "shenlong"
|
|||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bindgen 0.47.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bindgen 0.47.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"c_str_macro 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -420,6 +426,7 @@ dependencies = [
|
|||||||
"checksum bindgen 0.47.1 (registry+https://github.com/rust-lang/crates.io-index)" = "91f5aa1a54c5997396b59cfac31af9c1cbcaa988958c4ce84364257b2cadfad0"
|
"checksum bindgen 0.47.1 (registry+https://github.com/rust-lang/crates.io-index)" = "91f5aa1a54c5997396b59cfac31af9c1cbcaa988958c4ce84364257b2cadfad0"
|
||||||
"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
|
"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
|
||||||
"checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb"
|
"checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb"
|
||||||
|
"checksum c_str_macro 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2e08268d37bbcbf98f70312c449a35763d3f85beafbedbb4e28b4c438e2b5bd"
|
||||||
"checksum cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749"
|
"checksum cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749"
|
||||||
"checksum cexpr 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "644d693ecfa91955ed32dcc7eda4914e1be97a641fb6f0645a37348e20b230da"
|
"checksum cexpr 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "644d693ecfa91955ed32dcc7eda4914e1be97a641fb6f0645a37348e20b230da"
|
||||||
"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4"
|
"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4"
|
||||||
|
@ -8,6 +8,7 @@ edition = "2018"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
log = "0.4.6"
|
log = "0.4.6"
|
||||||
env_logger = "0.6.0"
|
env_logger = "0.6.0"
|
||||||
|
c_str_macro = "1.0.2"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
cc = "1.0.28"
|
cc = "1.0.28"
|
||||||
|
27
src/lib.rs
27
src/lib.rs
@ -1,18 +1,35 @@
|
|||||||
#![allow(non_upper_case_globals)]
|
#![allow(non_upper_case_globals)]
|
||||||
#![allow(non_camel_case_types)]
|
#![allow(non_camel_case_types)]
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
extern crate c_str_macro;
|
||||||
|
|
||||||
|
use c_str_macro::c_str;
|
||||||
|
|
||||||
use std::ffi::CString;
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||||
|
|
||||||
|
extern "C" fn shenlong_init(plugin: *mut GeanyPlugin, pdata: gpointer) -> gboolean {
|
||||||
|
println!("shenlong init");
|
||||||
|
1
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" fn shenlong_cleanup(plugin: *mut GeanyPlugin, pdata: gpointer) {
|
||||||
|
println!("shenlong cleanup");
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn geany_load_module(plugin: *mut GeanyPlugin) {
|
pub extern "C" fn geany_load_module(plugin: *mut GeanyPlugin) {
|
||||||
println!("loading shenlong module");
|
println!("loading shenlong module");
|
||||||
unsafe {
|
unsafe {
|
||||||
(*(*plugin).info).name = CString::new("Project Shenlong").unwrap().into_raw();
|
let mut plugin_info = &mut *(*plugin).info;
|
||||||
(*(*plugin).info).description = CString::new("Experimental Geany plugin project").unwrap().into_raw();
|
plugin_info.name = c_str!("Project Shenlong").to_owned().into_raw();
|
||||||
(*(*plugin).info).version = CString::new("0.0.1").unwrap().into_raw();
|
plugin_info.description = c_str!("Experimental Geany plugin project").to_owned().into_raw();
|
||||||
(*(*plugin).info).author = CString::new("Adrian Malacoda <malacoda@monarch-pass.net>").unwrap().into_raw();
|
plugin_info.version = c_str!("0.0.1").to_owned().into_raw();
|
||||||
|
plugin_info.author = c_str!("Adrian Malacoda <malacoda@monarch-pass.net>").to_owned().into_raw();
|
||||||
|
|
||||||
|
let mut plugin_funcs = &mut *(*plugin).funcs;
|
||||||
|
plugin_funcs.init = Some(shenlong_init);
|
||||||
|
plugin_funcs.cleanup = Some(shenlong_cleanup);
|
||||||
|
|
||||||
geany_plugin_register(plugin, 235, GEANY_API_VERSION as i32, GEANY_ABI_VERSION as i32);
|
geany_plugin_register(plugin, 235, GEANY_API_VERSION as i32, GEANY_ABI_VERSION as i32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user