#![no_std]
use pros_core::error::Result;
pub trait SyncRobot {
fn opcontrol(&mut self) -> Result {
Ok(())
}
fn auto(&mut self) -> Result {
Ok(())
}
fn disabled(&mut self) -> Result {
Ok(())
}
fn comp_init(&mut self) -> Result {
Ok(())
}
}
#[doc(hidden)]
#[macro_export]
macro_rules! __gen_sync_exports {
($rbt:ty) => {
pub static mut ROBOT: Option<$rbt> = None;
#[doc(hidden)]
#[no_mangle]
extern "C" fn opcontrol() {
<$rbt as $crate::SyncRobot>::opcontrol(unsafe {
ROBOT
.as_mut()
.expect("Expected initialize to run before opcontrol")
})
.unwrap();
}
#[doc(hidden)]
#[no_mangle]
extern "C" fn autonomous() {
<$rbt as $crate::SyncRobot>::auto(unsafe {
ROBOT
.as_mut()
.expect("Expected initialize to run before opcontrol")
})
.unwrap();
}
#[doc(hidden)]
#[no_mangle]
extern "C" fn disabled() {
<$rbt as $crate::SyncRobot>::disabled(unsafe {
ROBOT
.as_mut()
.expect("Expected initialize to run before opcontrol")
})
.unwrap();
}
#[doc(hidden)]
#[no_mangle]
extern "C" fn competition_initialize() {
<$rbt as $crate::SyncRobot>::comp_init(unsafe {
ROBOT
.as_mut()
.expect("Expected initialize to run before opcontrol")
})
.unwrap();
}
};
}
#[macro_export]
macro_rules! sync_robot {
($rbt:ty) => {
$crate::__gen_sync_exports!($rbt);
#[no_mangle]
extern "C" fn initialize() {
let robot = Default::default();
unsafe {
ROBOT = Some(robot);
}
}
};
($rbt:ty, $init:expr) => {
$crate::__gen_sync_exports!($rbt);
#[no_mangle]
extern "C" fn initialize() {
let robot = $init;
unsafe {
ROBOT = Some(robot);
}
}
};
}