macro_rules! object_common {
() => {
pub fn handle(&self) -> &Handle {
&self.0
}
pub fn into_handle(self) -> Handle {
self.0
}
pub fn get_type(&self) -> Result<ObjectType> {
self.0.get_type()
}
pub fn cast_to<T: CastTarget>(&self) -> Result<Option<T>> {
T::cast_from(self.handle_ref())
}
pub fn get_userdata(&self) -> Result<Option<Arc<dyn Any + Send + Sync>>> {
self.0.get_userdata()
}
pub fn set_userdata(&self, userdata: Option<impl Any + Send + Sync>) -> Result<()> {
self.0.set_userdata(userdata)
}
pub fn config_delete_behavior(&self, config: &DeleteBehaviorConfig) -> Result<()> {
self.0.config_delete_behavior(config)
}
#[allow(dead_code)]
pub(crate) fn from_handle_internal(h: Handle) -> Self {
Self(h)
}
double_p!(SYZ_P_CURRENT_TIME, current_time);
double_p!(SYZ_P_SUGGESTED_AUTOMATION_TIME, suggested_automation_time);
};
}
macro_rules! pausable_common {
() => {
pub fn pause(&self) -> Result<()> {
check_error(unsafe { syz_pause(self.to_syz_handle()) })
}
pub fn play(&self) -> Result<()> {
check_error(unsafe { syz_play(self.to_syz_handle()) })
}
};
}
macro_rules! source_common {
() => {
pub fn add_generator<T: IsGenerator>(&self, generator: &T) -> Result<()> {
check_error(unsafe {
syz_sourceAddGenerator(self.to_syz_handle(), generator.to_syz_handle())
})
}
pub fn remove_generator<T: IsGenerator>(&self, generator: &T) -> Result<()> {
check_error(unsafe {
syz_sourceRemoveGenerator(self.to_syz_handle(), generator.to_syz_handle())
})
}
};
}
macro_rules! effect_common {
() => {
pub fn reset(&self) -> Result<()> {
check_error(unsafe { syz_effectReset(self.to_syz_handle()) })
}
};
}