feat: v1.10.9, add se supprot

This commit is contained in:
2024-12-15 00:56:51 +08:00
parent 0fec0c25e7
commit bf9f228967
31 changed files with 3276 additions and 355 deletions

View File

@@ -0,0 +1,55 @@
use crate::{swift::SwiftObject, *};
use std::ffi::c_void;
/// Identifies a type as being a valid return type from a Swift function.
/// For types that are objects which need extra retains,
/// the [`retain`](SwiftRet::retain) function will be re-implemented.
pub trait SwiftRet {
/// Adds a retain to the value if possible
///
/// # Safety
/// Just don't use this.
/// Let [`swift!`] handle it.
unsafe fn retain(&self) {}
}
macro_rules! primitive_impl {
($($t:ty),+) => {
$(impl SwiftRet for $t {
})+
};
}
primitive_impl!(
Bool,
Int,
Int8,
Int16,
Int32,
Int64,
UInt,
UInt8,
UInt16,
UInt32,
UInt64,
Float32,
Float64,
*const c_void,
*mut c_void,
*const u8,
()
);
impl<T: SwiftObject> SwiftRet for Option<T> {
unsafe fn retain(&self) {
if let Some(v) = self {
v.retain()
}
}
}
impl<T: SwiftObject> SwiftRet for T {
unsafe fn retain(&self) {
(*self).retain()
}
}