create separate types per command

This commit is contained in:
Vinzenz Schroeter 2025-06-16 11:32:12 +02:00
parent c29482ac56
commit bffc905261
19 changed files with 306 additions and 200 deletions

View file

@ -2,7 +2,7 @@ use crate::macros::*;
use servicepoint::Grid;
use std::{ops::Deref, sync::Arc};
wrap_uniffi_object!(Bitmap);
wrap_object!(Bitmap);
wrap_width_height!(Bitmap);
wrap_get_set_fill_2d!(Bitmap, bool);
@ -29,12 +29,12 @@ impl Bitmap {
}
pub fn equals(&self, other: &Bitmap) -> bool {
let a = self.actual.read().unwrap();
let b = other.actual.read().unwrap();
let a = self.read();
let b = other.read();
*a == *b
}
pub fn copy_raw(&self) -> Vec<u8> {
self.actual.read().unwrap().deref().into()
self.read().deref().into()
}
}

View file

@ -1,7 +1,7 @@
use crate::macros::wrap_uniffi_object;
use crate::macros::wrap_object;
use std::sync::Arc;
wrap_uniffi_object!(DisplayBitVec, BitVec);
wrap_object!(DisplayBitVec, BitVec);
#[uniffi::export]
impl BitVec {
@ -34,16 +34,16 @@ impl BitVec {
}
pub fn len(&self) -> u64 {
self.actual.read().unwrap().len() as u64
self.read().len() as u64
}
pub fn equals(&self, other: &BitVec) -> bool {
let a = self.actual.read().unwrap();
let b = other.actual.read().unwrap();
let a = self.read();
let b = other.read();
*a == *b
}
pub fn copy_raw(&self) -> Vec<u8> {
self.actual.read().unwrap().clone().into_vec()
self.read().clone().into_vec()
}
}

View file

@ -2,7 +2,7 @@ use crate::macros::*;
use servicepoint::{Brightness, Grid};
use std::{ops::Deref, sync::Arc};
wrap_uniffi_object!(BrightnessGrid);
wrap_object!(BrightnessGrid);
wrap_width_height!(BrightnessGrid);
wrap_get_set_fill_2d!(BrightnessGrid, Brightness);
@ -29,12 +29,12 @@ impl BrightnessGrid {
}
pub fn equals(&self, other: &BrightnessGrid) -> bool {
let a = self.actual.read().unwrap();
let b = other.actual.read().unwrap();
let a = self.read();
let b = other.read();
*a == *b
}
pub fn copy_raw(&self) -> Vec<u8> {
self.actual.read().unwrap().deref().into()
self.read().deref().into()
}
}

View file

@ -2,7 +2,7 @@ use crate::{containers::cp437_grid::Cp437Grid, macros::*};
use servicepoint::{Grid, SetValueSeriesError};
use std::{convert::Into, sync::Arc};
wrap_uniffi_object!(CharGrid);
wrap_object!(CharGrid);
wrap_width_height!(CharGrid);
#[derive(uniffi::Error, thiserror::Error, Debug)]
@ -59,13 +59,13 @@ impl CharGrid {
}
pub fn equals(&self, other: &CharGrid) -> bool {
let a = self.actual.read().unwrap();
let b = other.actual.read().unwrap();
let a = self.read();
let b = other.read();
*a == *b
}
pub fn as_string(&self) -> String {
let grid = self.actual.read().unwrap();
let grid = self.read();
String::from(&*grid)
}
@ -110,9 +110,7 @@ impl CharGrid {
}
pub fn to_cp437(&self) -> Arc<Cp437Grid> {
Cp437Grid::internal_new(servicepoint::Cp437Grid::from(
&*self.actual.read().unwrap(),
))
Cp437Grid::internal_new(servicepoint::Cp437Grid::from(&*self.read()))
}
}

View file

@ -2,7 +2,7 @@ use crate::{containers::char_grid::CharGrid, macros::*};
use servicepoint::Grid;
use std::{ops::Deref, sync::Arc};
wrap_uniffi_object!(Cp437Grid);
wrap_object!(Cp437Grid);
wrap_width_height!(Cp437Grid);
wrap_get_set_fill_2d!(Cp437Grid, u8);
@ -29,18 +29,16 @@ impl Cp437Grid {
}
pub fn equals(&self, other: &Cp437Grid) -> bool {
let a = self.actual.read().unwrap();
let b = other.actual.read().unwrap();
let a = self.read();
let b = other.read();
*a == *b
}
pub fn copy_raw(&self) -> Vec<u8> {
self.actual.read().unwrap().deref().into()
self.read().deref().into()
}
pub fn to_utf8(&self) -> Arc<CharGrid> {
CharGrid::internal_new(servicepoint::CharGrid::from(
&*self.actual.read().unwrap(),
))
CharGrid::internal_new(servicepoint::CharGrid::from(&*self.read()))
}
}