From fda2b9419d6d454f4f02678698689123cfc112b8 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Fri, 13 Jun 2025 01:13:51 +0200 Subject: [PATCH] add clone to macro --- src/bitmap.rs | 5 ----- src/bitvec.rs | 5 ----- src/brightness_grid.rs | 5 ----- src/char_grid.rs | 5 ----- src/command.rs | 5 ----- src/cp437_grid.rs | 5 ----- src/macros.rs | 8 ++++++++ 7 files changed, 8 insertions(+), 30 deletions(-) diff --git a/src/bitmap.rs b/src/bitmap.rs index c07fa07..aa2309c 100644 --- a/src/bitmap.rs +++ b/src/bitmap.rs @@ -28,11 +28,6 @@ impl Bitmap { ).unwrap()) } - #[uniffi::constructor] - pub fn clone(other: &Arc) -> Arc { - Self::internal_new(other.actual.read().unwrap().clone()) - } - pub fn set(&self, x: u64, y: u64, value: bool) { self.actual .write() diff --git a/src/bitvec.rs b/src/bitvec.rs index e9356fd..ef216f5 100644 --- a/src/bitvec.rs +++ b/src/bitvec.rs @@ -14,11 +14,6 @@ impl BitVec { Self::internal_new(servicepoint::DisplayBitVec::from_slice(&data)) } - #[uniffi::constructor] - pub fn clone(other: &Arc) -> Arc { - 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) } diff --git a/src/brightness_grid.rs b/src/brightness_grid.rs index ca64ebf..956f139 100644 --- a/src/brightness_grid.rs +++ b/src/brightness_grid.rs @@ -23,11 +23,6 @@ impl BrightnessGrid { ).unwrap()) } - #[uniffi::constructor] - pub fn clone(other: &Arc) -> Arc { - 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, diff --git a/src/char_grid.rs b/src/char_grid.rs index 8bf70ac..1f39e1c 100644 --- a/src/char_grid.rs +++ b/src/char_grid.rs @@ -31,11 +31,6 @@ impl CharGrid { Self::internal_new(servicepoint::CharGrid::from(&*data)) } - #[uniffi::constructor] - pub fn clone(other: &Arc) -> Arc { - Self::internal_new(other.actual.read().unwrap().clone()) - } - pub fn set( &self, x: u64, diff --git a/src/command.rs b/src/command.rs index 5939761..aaf508c 100644 --- a/src/command.rs +++ b/src/command.rs @@ -116,11 +116,6 @@ impl Command { Self::internal_new(actual.into()) } - #[uniffi::constructor] - pub fn clone(other: &Arc) -> Arc { - Self::internal_new(other.actual.read().unwrap().clone()) - } - pub fn equals(&self, other: &Command) -> bool { *self.actual.read().unwrap() == *other.actual.read().unwrap() } diff --git a/src/cp437_grid.rs b/src/cp437_grid.rs index 7ca1e62..9db5d8e 100644 --- a/src/cp437_grid.rs +++ b/src/cp437_grid.rs @@ -24,11 +24,6 @@ impl Cp437Grid { ).unwrap()) } - #[uniffi::constructor] - pub fn clone(other: &Arc) -> Arc { - Self::internal_new(other.actual.read().unwrap().clone()) - } - pub fn set(&self, x: u64, y: u64, value: u8) { self.actual .write() diff --git a/src/macros.rs b/src/macros.rs index 8f46c1c..b22b12a 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -13,6 +13,14 @@ macro_rules! wrap_uniffi_object { }) } } + + #[uniffi::export] + impl $new_t { + #[uniffi::constructor] + pub fn clone(other: &Arc) -> Arc { + Self::internal_new(other.actual.read().unwrap().clone()) + } + } }; ($t:ident) => { wrap_uniffi_object!($t, $t);