add init/cleanup functions, now the plugin actually loads!

This commit is contained in:
Adrian Malacoda
2019-02-11 02:46:23 -06:00
parent c48d967e3a
commit 81a9db0b8d
3 changed files with 31 additions and 6 deletions

View File

@@ -1,18 +1,35 @@
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![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"));
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]
pub extern "C" fn geany_load_module (plugin: *mut GeanyPlugin) {
pub extern "C" fn geany_load_module(plugin: *mut GeanyPlugin) {
println!("loading shenlong module");
unsafe {
(*(*plugin).info).name = CString::new("Project Shenlong").unwrap().into_raw();
(*(*plugin).info).description = CString::new("Experimental Geany plugin project").unwrap().into_raw();
(*(*plugin).info).version = CString::new("0.0.1").unwrap().into_raw();
(*(*plugin).info).author = CString::new("Adrian Malacoda <malacoda@monarch-pass.net>").unwrap().into_raw();
let mut plugin_info = &mut *(*plugin).info;
plugin_info.name = c_str!("Project Shenlong").to_owned().into_raw();
plugin_info.description = c_str!("Experimental Geany plugin project").to_owned().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);
}
}