declare wrapper types with macro

This commit is contained in:
Vinzenz Schroeter 2025-06-13 01:09:31 +02:00
parent f7cb5546b3
commit 14970c0ac4
9 changed files with 44 additions and 77 deletions

View file

@ -1,4 +1,3 @@
use crate::bitmap::Bitmap;
use crate::bitvec::BitVec;
use crate::brightness_grid::BrightnessGrid;
use crate::char_grid::CharGrid;
@ -7,17 +6,10 @@ use crate::cp437_grid::Cp437Grid;
use crate::errors::ServicePointError;
use servicepoint::{BitVecCommand, BrightnessGridCommand, CharGridCommand, ClearCommand, Cp437GridCommand, FadeOutCommand, GlobalBrightnessCommand, HardResetCommand, Origin};
use std::sync::Arc;
use crate::bitmap::Bitmap;
use crate::macros::wrap_uniffi_object;
#[derive(uniffi::Object)]
pub struct Command {
pub(crate) actual: servicepoint::TypedCommand,
}
impl Command {
fn internal_new(actual: servicepoint::TypedCommand) -> Arc<Command> {
Arc::new(Command { actual })
}
}
wrap_uniffi_object!(TypedCommand, Command);
#[uniffi::export]
impl Command {
@ -126,11 +118,11 @@ impl Command {
#[uniffi::constructor]
pub fn clone(other: &Arc<Self>) -> Arc<Self> {
Self::internal_new(other.actual.clone())
Self::internal_new(other.actual.read().unwrap().clone())
}
pub fn equals(&self, other: &Command) -> bool {
self.actual == other.actual
*self.actual.read().unwrap() == *other.actual.read().unwrap()
}
}