add clone to macro

This commit is contained in:
Vinzenz Schroeter 2025-06-13 01:13:51 +02:00
parent 88f7696dbd
commit fda2b9419d
7 changed files with 8 additions and 30 deletions

View file

@ -28,11 +28,6 @@ impl Bitmap {
).unwrap())
}
#[uniffi::constructor]
pub fn clone(other: &Arc<Self>) -> Arc<Self> {
Self::internal_new(other.actual.read().unwrap().clone())
}
pub fn set(&self, x: u64, y: u64, value: bool) {
self.actual
.write()

View file

@ -14,11 +14,6 @@ impl BitVec {
Self::internal_new(servicepoint::DisplayBitVec::from_slice(&data))
}
#[uniffi::constructor]
pub fn clone(other: &Arc<Self>) -> Arc<Self> {
Self::internal_new(other.actual.read().unwrap().clone())
}
pub fn set(&self, index: u64, value: bool) {
self.actual.write().unwrap().set(index as usize, value)
}

View file

@ -23,11 +23,6 @@ impl BrightnessGrid {
).unwrap())
}
#[uniffi::constructor]
pub fn clone(other: &Arc<Self>) -> Arc<Self> {
Self::internal_new(other.actual.read().unwrap().clone())
}
pub fn set(&self, x: u64, y: u64, value: u8) {
self.actual.write().unwrap().set(
x as usize,

View file

@ -31,11 +31,6 @@ impl CharGrid {
Self::internal_new(servicepoint::CharGrid::from(&*data))
}
#[uniffi::constructor]
pub fn clone(other: &Arc<Self>) -> Arc<Self> {
Self::internal_new(other.actual.read().unwrap().clone())
}
pub fn set(
&self,
x: u64,

View file

@ -116,11 +116,6 @@ impl Command {
Self::internal_new(actual.into())
}
#[uniffi::constructor]
pub fn clone(other: &Arc<Self>) -> Arc<Self> {
Self::internal_new(other.actual.read().unwrap().clone())
}
pub fn equals(&self, other: &Command) -> bool {
*self.actual.read().unwrap() == *other.actual.read().unwrap()
}

View file

@ -24,11 +24,6 @@ impl Cp437Grid {
).unwrap())
}
#[uniffi::constructor]
pub fn clone(other: &Arc<Self>) -> Arc<Self> {
Self::internal_new(other.actual.read().unwrap().clone())
}
pub fn set(&self, x: u64, y: u64, value: u8) {
self.actual
.write()

View file

@ -13,6 +13,14 @@ macro_rules! wrap_uniffi_object {
})
}
}
#[uniffi::export]
impl $new_t {
#[uniffi::constructor]
pub fn clone(other: &Arc<Self>) -> Arc<Self> {
Self::internal_new(other.actual.read().unwrap().clone())
}
}
};
($t:ident) => {
wrap_uniffi_object!($t, $t);