expose new command to uniffi API

This commit is contained in:
Vinzenz Schroeter 2025-01-12 13:12:02 +01:00
parent 2f2160f246
commit 2a6005fff9
3 changed files with 49 additions and 0 deletions

View file

@ -681,6 +681,10 @@ static class _UniFFILib {
public static extern CommandSafeHandle uniffi_servicepoint_binding_uniffi_fn_constructor_command_hard_reset(ref RustCallStatus _uniffi_out_err
);
[DllImport("servicepoint_binding_uniffi")]
public static extern CommandSafeHandle uniffi_servicepoint_binding_uniffi_fn_constructor_command_utf8_data(ulong @offsetX,ulong @offsetY,CharGridSafeHandle @grid,ref RustCallStatus _uniffi_out_err
);
[DllImport("servicepoint_binding_uniffi")]
public static extern sbyte uniffi_servicepoint_binding_uniffi_fn_method_command_equals(CommandSafeHandle @ptr,CommandSafeHandle @other,ref RustCallStatus _uniffi_out_err
);
@ -1255,6 +1259,10 @@ static class _UniFFILib {
public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_command_hard_reset(
);
[DllImport("servicepoint_binding_uniffi")]
public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_command_utf8_data(
);
[DllImport("servicepoint_binding_uniffi")]
public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_connection_new(
);
@ -1697,6 +1705,12 @@ static class _UniFFILib {
throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_constructor_command_hard_reset` checksum `62130`, library returned `{checksum}`");
}
}
{
var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_constructor_command_utf8_data();
if (checksum != 2263) {
throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_constructor_command_utf8_data` checksum `2263`, library returned `{checksum}`");
}
}
{
var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_constructor_connection_new();
if (checksum != 30445) {
@ -2671,6 +2685,13 @@ public class Command: FFIObject<CommandSafeHandle>, ICommand {
));
}
public static Command Utf8Data(ulong @offsetX, ulong @offsetY, CharGrid @grid) {
return new Command(
_UniffiHelpers.RustCall( (ref RustCallStatus _status) =>
_UniFFILib.uniffi_servicepoint_binding_uniffi_fn_constructor_command_utf8_data(FfiConverterUInt64.INSTANCE.Lower(@offsetX), FfiConverterUInt64.INSTANCE.Lower(@offsetY), FfiConverterTypeCharGrid.INSTANCE.Lower(@grid), ref _status)
));
}
}

View file

@ -918,6 +918,9 @@ module UniFFILib
attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_command_hard_reset,
[RustCallStatus.by_ref],
:pointer
attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_command_utf8_data,
[:uint64, :uint64, :pointer, RustCallStatus.by_ref],
:pointer
attach_function :uniffi_servicepoint_binding_uniffi_fn_method_command_equals,
[:pointer, :pointer, RustCallStatus.by_ref],
:int8
@ -1188,6 +1191,9 @@ module UniFFILib
attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_command_hard_reset,
[RustCallStatus.by_ref],
:uint16
attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_command_utf8_data,
[RustCallStatus.by_ref],
:uint16
attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_connection_new,
[RustCallStatus.by_ref],
:uint16
@ -1817,6 +1823,15 @@ end
# and just create a new instance with the required pointer.
return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_command_hard_reset,))
end
def self.utf8_data(offset_x, offset_y, grid)
offset_x = ServicepointBindingUniffi::uniffi_in_range(offset_x, "u64", 0, 2**64)
offset_y = ServicepointBindingUniffi::uniffi_in_range(offset_y, "u64", 0, 2**64)
grid = grid
# Call the (fallible) function before creating any half-baked object instances.
# Lightly yucky way to bypass the usual "initialize" logic
# and just create a new instance with the required pointer.
return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_command_utf8_data,offset_x,offset_y,(CharGrid._uniffi_lower grid)))
end
def equals(other)

View file

@ -1,6 +1,7 @@
use crate::bitmap::Bitmap;
use crate::bitvec::BitVec;
use crate::brightness_grid::BrightnessGrid;
use crate::char_grid::CharGrid;
use crate::compression_code::CompressionCode;
use crate::cp437_grid::Cp437Grid;
use crate::errors::ServicePointError;
@ -151,6 +152,18 @@ impl Command {
Self::internal_new(actual)
}
#[uniffi::constructor]
pub fn utf8_data(
offset_x: u64,
offset_y: u64,
grid: &Arc<CharGrid>,
) -> Arc<Self> {
let origin = Origin::new(offset_x as usize, offset_y as usize);
let grid = grid.actual.read().unwrap().clone();
let actual = servicepoint::Command::Utf8Data(origin, grid);
Self::internal_new(actual)
}
#[uniffi::constructor]
pub fn clone(other: &Arc<Self>) -> Arc<Self> {
Self::internal_new(other.actual.clone())