#[macro_use]
extern crate cr;
use std::thread;
use std::time::Duration;
mod basic_state;
use basic_state::*;
use cr::cr_op::*;
cr_main!(plugin_main);
pub fn plugin_main(ctx: &mut BasicPlugin, cr_op: cr::cr_op) -> i32 {
#[cfg(not(feature = "guest"))]
{
println!("Guest compiled with host-side code.");
let plugin = BasicPlugin::new(BasicState { counter: 0 }, "test");
println!("- plugin = {:?}", plugin);
}
println!("test recompile. test1");
match cr_op {
CR_LOAD => {
println!("Plugin load. version = {}", ctx.get_version());
}
CR_STEP => {
let version = ctx.get_version();
let state = ctx.state_mut();
state.counter += 1;
println!(
"Plugin step. count = {}. version = {}",
state.counter, version
);
thread::sleep(Duration::from_millis(200));
}
CR_UNLOAD => {
println!("Plugin unload. version = {}", ctx.get_version());
}
CR_CLOSE => {
println!("Plugin close. version = {}", ctx.get_version());
}
}
return 0;
}