mirror of
https://github.com/cccb/servicepoint.git
synced 2025-01-18 18:10:14 +01:00
annotate which parameters are consumed, move constants
This commit is contained in:
parent
57c66d9d31
commit
f836220259
|
@ -121,6 +121,8 @@ pub unsafe extern "C" fn sp_bitmap_clone(
|
||||||
/// - `bitmap` points to a valid [SPBitmap]
|
/// - `bitmap` points to a valid [SPBitmap]
|
||||||
/// - `bitmap` is not used concurrently or after bitmap call
|
/// - `bitmap` is not used concurrently or after bitmap call
|
||||||
/// - `bitmap` was not passed to another consuming function, e.g. to create a [SPCommand]
|
/// - `bitmap` was not passed to another consuming function, e.g. to create a [SPCommand]
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: bitmap
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_bitmap_free(bitmap: *mut SPBitmap) {
|
pub unsafe extern "C" fn sp_bitmap_free(bitmap: *mut SPBitmap) {
|
||||||
assert!(!bitmap.is_null());
|
assert!(!bitmap.is_null());
|
||||||
|
|
|
@ -8,13 +8,6 @@ use std::convert::Into;
|
||||||
use std::intrinsics::transmute;
|
use std::intrinsics::transmute;
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
/// see [Brightness::MIN]
|
|
||||||
pub const SP_BRIGHTNESS_MIN: u8 = 0;
|
|
||||||
/// see [Brightness::MAX]
|
|
||||||
pub const SP_BRIGHTNESS_MAX: u8 = 11;
|
|
||||||
/// Count of possible brightness values
|
|
||||||
pub const SP_BRIGHTNESS_LEVELS: u8 = 12;
|
|
||||||
|
|
||||||
/// A grid containing brightness values.
|
/// A grid containing brightness values.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
|
@ -133,6 +126,8 @@ pub unsafe extern "C" fn sp_brightness_grid_clone(
|
||||||
/// - `brightness_grid` points to a valid [SPBrightnessGrid]
|
/// - `brightness_grid` points to a valid [SPBrightnessGrid]
|
||||||
/// - `brightness_grid` is not used concurrently or after this call
|
/// - `brightness_grid` is not used concurrently or after this call
|
||||||
/// - `brightness_grid` was not passed to another consuming function, e.g. to create a [SPCommand]
|
/// - `brightness_grid` was not passed to another consuming function, e.g. to create a [SPCommand]
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: brightness_grid
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_brightness_grid_free(
|
pub unsafe extern "C" fn sp_brightness_grid_free(
|
||||||
brightness_grid: *mut SPBrightnessGrid,
|
brightness_grid: *mut SPBrightnessGrid,
|
||||||
|
|
|
@ -50,6 +50,8 @@ impl Clone for SPCommand {
|
||||||
/// - the result is checked for NULL
|
/// - the result is checked for NULL
|
||||||
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
||||||
/// by explicitly calling `sp_command_free`.
|
/// by explicitly calling `sp_command_free`.
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: packet
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_command_try_from_packet(
|
pub unsafe extern "C" fn sp_command_try_from_packet(
|
||||||
packet: *mut SPPacket,
|
packet: *mut SPPacket,
|
||||||
|
@ -187,6 +189,8 @@ pub unsafe extern "C" fn sp_command_brightness(
|
||||||
/// - `grid` is not used concurrently or after this call
|
/// - `grid` is not used concurrently or after this call
|
||||||
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
||||||
/// by explicitly calling `sp_command_free`.
|
/// by explicitly calling `sp_command_free`.
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: grid
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_command_char_brightness(
|
pub unsafe extern "C" fn sp_command_char_brightness(
|
||||||
x: usize,
|
x: usize,
|
||||||
|
@ -227,6 +231,8 @@ pub unsafe extern "C" fn sp_command_char_brightness(
|
||||||
/// - `compression` matches one of the allowed enum values
|
/// - `compression` matches one of the allowed enum values
|
||||||
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
||||||
/// by explicitly calling `sp_command_free`.
|
/// by explicitly calling `sp_command_free`.
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: bit_vec
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_command_bitmap_linear(
|
pub unsafe extern "C" fn sp_command_bitmap_linear(
|
||||||
offset: usize,
|
offset: usize,
|
||||||
|
@ -268,6 +274,8 @@ pub unsafe extern "C" fn sp_command_bitmap_linear(
|
||||||
/// - `compression` matches one of the allowed enum values
|
/// - `compression` matches one of the allowed enum values
|
||||||
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
||||||
/// by explicitly calling `sp_command_free`.
|
/// by explicitly calling `sp_command_free`.
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: bit_vec
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_command_bitmap_linear_and(
|
pub unsafe extern "C" fn sp_command_bitmap_linear_and(
|
||||||
offset: usize,
|
offset: usize,
|
||||||
|
@ -309,6 +317,8 @@ pub unsafe extern "C" fn sp_command_bitmap_linear_and(
|
||||||
/// - `compression` matches one of the allowed enum values
|
/// - `compression` matches one of the allowed enum values
|
||||||
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
||||||
/// by explicitly calling `sp_command_free`.
|
/// by explicitly calling `sp_command_free`.
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: bit_vec
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_command_bitmap_linear_or(
|
pub unsafe extern "C" fn sp_command_bitmap_linear_or(
|
||||||
offset: usize,
|
offset: usize,
|
||||||
|
@ -350,6 +360,8 @@ pub unsafe extern "C" fn sp_command_bitmap_linear_or(
|
||||||
/// - `compression` matches one of the allowed enum values
|
/// - `compression` matches one of the allowed enum values
|
||||||
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
||||||
/// by explicitly calling `sp_command_free`.
|
/// by explicitly calling `sp_command_free`.
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: bit_vec
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_command_bitmap_linear_xor(
|
pub unsafe extern "C" fn sp_command_bitmap_linear_xor(
|
||||||
offset: usize,
|
offset: usize,
|
||||||
|
@ -384,6 +396,8 @@ pub unsafe extern "C" fn sp_command_bitmap_linear_xor(
|
||||||
/// - `grid` is not used concurrently or after this call
|
/// - `grid` is not used concurrently or after this call
|
||||||
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
||||||
/// by explicitly calling `sp_command_free`.
|
/// by explicitly calling `sp_command_free`.
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: grid
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_command_cp437_data(
|
pub unsafe extern "C" fn sp_command_cp437_data(
|
||||||
x: usize,
|
x: usize,
|
||||||
|
@ -419,6 +433,8 @@ pub unsafe extern "C" fn sp_command_cp437_data(
|
||||||
/// - `compression` matches one of the allowed enum values
|
/// - `compression` matches one of the allowed enum values
|
||||||
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
||||||
/// by explicitly calling `sp_command_free`.
|
/// by explicitly calling `sp_command_free`.
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: bitmap
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_command_bitmap_linear_win(
|
pub unsafe extern "C" fn sp_command_bitmap_linear_win(
|
||||||
x: usize,
|
x: usize,
|
||||||
|
@ -458,6 +474,8 @@ pub unsafe extern "C" fn sp_command_bitmap_linear_win(
|
||||||
/// - `command` points to a valid [SPCommand]
|
/// - `command` points to a valid [SPCommand]
|
||||||
/// - `command` is not used concurrently or after this call
|
/// - `command` is not used concurrently or after this call
|
||||||
/// - `command` was not passed to another consuming function, e.g. to create a [SPPacket]
|
/// - `command` was not passed to another consuming function, e.g. to create a [SPPacket]
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: command
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_command_free(command: *mut SPCommand) {
|
pub unsafe extern "C" fn sp_command_free(command: *mut SPCommand) {
|
||||||
assert!(!command.is_null());
|
assert!(!command.is_null());
|
||||||
|
|
|
@ -64,6 +64,8 @@ pub unsafe extern "C" fn sp_connection_open(
|
||||||
/// - `connection` points to a valid instance of [SPConnection]
|
/// - `connection` points to a valid instance of [SPConnection]
|
||||||
/// - `packet` points to a valid instance of [SPPacket]
|
/// - `packet` points to a valid instance of [SPPacket]
|
||||||
/// - `packet` is not used concurrently or after this call
|
/// - `packet` is not used concurrently or after this call
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: packet
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_connection_send_packet(
|
pub unsafe extern "C" fn sp_connection_send_packet(
|
||||||
connection: *const SPConnection,
|
connection: *const SPConnection,
|
||||||
|
@ -93,6 +95,8 @@ pub unsafe extern "C" fn sp_connection_send_packet(
|
||||||
/// - `connection` points to a valid instance of [SPConnection]
|
/// - `connection` points to a valid instance of [SPConnection]
|
||||||
/// - `command` points to a valid instance of [SPPacket]
|
/// - `command` points to a valid instance of [SPPacket]
|
||||||
/// - `command` is not used concurrently or after this call
|
/// - `command` is not used concurrently or after this call
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: packet
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_connection_send_command(
|
pub unsafe extern "C" fn sp_connection_send_command(
|
||||||
connection: *const SPConnection,
|
connection: *const SPConnection,
|
||||||
|
@ -116,6 +120,8 @@ pub unsafe extern "C" fn sp_connection_send_command(
|
||||||
///
|
///
|
||||||
/// - `connection` points to a valid [SPConnection]
|
/// - `connection` points to a valid [SPConnection]
|
||||||
/// - `connection` is not used concurrently or after this call
|
/// - `connection` is not used concurrently or after this call
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: connection
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_connection_free(connection: *mut SPConnection) {
|
pub unsafe extern "C" fn sp_connection_free(connection: *mut SPConnection) {
|
||||||
assert!(!connection.is_null());
|
assert!(!connection.is_null());
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//! re-exported constants for use in C
|
//! re-exported constants for use in C
|
||||||
|
|
||||||
use servicepoint::CompressionCode;
|
use servicepoint::{CompressionCode};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
/// size of a single tile in one dimension
|
/// size of a single tile in one dimension
|
||||||
|
@ -24,6 +24,13 @@ pub const SP_PIXEL_COUNT: usize = SP_PIXEL_WIDTH * SP_PIXEL_HEIGHT;
|
||||||
/// Actual hardware limit is around 28-29ms/frame. Rounded up for less dropped packets.
|
/// Actual hardware limit is around 28-29ms/frame. Rounded up for less dropped packets.
|
||||||
pub const SP_FRAME_PACING_MS: u128 = Duration::from_millis(30).as_millis();
|
pub const SP_FRAME_PACING_MS: u128 = Duration::from_millis(30).as_millis();
|
||||||
|
|
||||||
|
/// see [Brightness::MIN]
|
||||||
|
pub const SP_BRIGHTNESS_MIN: u8 = 0;
|
||||||
|
/// see [Brightness::MAX]
|
||||||
|
pub const SP_BRIGHTNESS_MAX: u8 = 11;
|
||||||
|
/// Count of possible brightness values
|
||||||
|
pub const SP_BRIGHTNESS_LEVELS: u8 = 12;
|
||||||
|
|
||||||
/// Specifies the kind of compression to use.
|
/// Specifies the kind of compression to use.
|
||||||
#[repr(u16)]
|
#[repr(u16)]
|
||||||
pub enum SPCompressionCode {
|
pub enum SPCompressionCode {
|
||||||
|
|
|
@ -116,6 +116,8 @@ pub unsafe extern "C" fn sp_cp437_grid_clone(
|
||||||
/// - `cp437_grid` points to a valid [SPCp437Grid]
|
/// - `cp437_grid` points to a valid [SPCp437Grid]
|
||||||
/// - `cp437_grid` is not used concurrently or after cp437_grid call
|
/// - `cp437_grid` is not used concurrently or after cp437_grid call
|
||||||
/// - `cp437_grid` was not passed to another consuming function, e.g. to create a [SPCommand]
|
/// - `cp437_grid` was not passed to another consuming function, e.g. to create a [SPCommand]
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: cp437_grid
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cp437_grid_free(cp437_grid: *mut SPCp437Grid) {
|
pub unsafe extern "C" fn sp_cp437_grid_free(cp437_grid: *mut SPCp437Grid) {
|
||||||
assert!(!cp437_grid.is_null());
|
assert!(!cp437_grid.is_null());
|
||||||
|
|
|
@ -26,6 +26,8 @@ pub struct SPPacket(pub(crate) servicepoint::packet::Packet);
|
||||||
/// - [SPCommand] is not used concurrently or after this call
|
/// - [SPCommand] is not used concurrently or after this call
|
||||||
/// - the returned [SPPacket] instance is freed in some way, either by using a consuming function or
|
/// - the returned [SPPacket] instance is freed in some way, either by using a consuming function or
|
||||||
/// by explicitly calling `sp_packet_free`.
|
/// by explicitly calling `sp_packet_free`.
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: command
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_packet_from_command(
|
pub unsafe extern "C" fn sp_packet_from_command(
|
||||||
command: *mut SPCommand,
|
command: *mut SPCommand,
|
||||||
|
@ -94,7 +96,7 @@ pub unsafe extern "C" fn sp_packet_clone(
|
||||||
///
|
///
|
||||||
/// # Panics
|
/// # Panics
|
||||||
///
|
///
|
||||||
/// - when `sp_packet_free` is NULL
|
/// - when `packet` is NULL
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
|
@ -102,6 +104,8 @@ pub unsafe extern "C" fn sp_packet_clone(
|
||||||
///
|
///
|
||||||
/// - `packet` points to a valid [SPPacket]
|
/// - `packet` points to a valid [SPPacket]
|
||||||
/// - `packet` is not used concurrently or after this call
|
/// - `packet` is not used concurrently or after this call
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: packet
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_packet_free(packet: *mut SPPacket) {
|
pub unsafe extern "C" fn sp_packet_free(packet: *mut SPPacket) {
|
||||||
assert!(!packet.is_null());
|
assert!(!packet.is_null());
|
||||||
|
|
|
@ -79,7 +79,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BitVec Clone()
|
public BitVec Clone()
|
||||||
{
|
{
|
||||||
return new BitVec(BitVec.sp_bitvec_clone(Instance));
|
return new BitVec(BitVec.sp_bitvec_clone(this.Instance));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -106,7 +106,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Get(nuint index)
|
public bool Get(nuint index)
|
||||||
{
|
{
|
||||||
return BitVec.sp_bitvec_get(Instance, index);
|
return BitVec.sp_bitvec_get(this.Instance, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -132,7 +132,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Set(nuint index, bool value)
|
public void Set(nuint index, bool value)
|
||||||
{
|
{
|
||||||
BitVec.sp_bitvec_set(Instance, index, value);
|
BitVec.sp_bitvec_set(this.Instance, index, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -156,7 +156,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Fill(bool value)
|
public void Fill(bool value)
|
||||||
{
|
{
|
||||||
BitVec.sp_bitvec_fill(Instance, value);
|
BitVec.sp_bitvec_fill(this.Instance, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -178,7 +178,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public nuint Len()
|
public nuint Len()
|
||||||
{
|
{
|
||||||
return BitVec.sp_bitvec_len(Instance);
|
return BitVec.sp_bitvec_len(this.Instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -200,7 +200,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsEmpty()
|
public bool IsEmpty()
|
||||||
{
|
{
|
||||||
return BitVec.sp_bitvec_is_empty(Instance);
|
return BitVec.sp_bitvec_is_empty(this.Instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -224,10 +224,11 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SPByteSlice UnsafeDataRef()
|
public SPByteSlice UnsafeDataRef()
|
||||||
{
|
{
|
||||||
return BitVec.sp_bitvec_unsafe_data_ref(Instance);
|
return BitVec.sp_bitvec_unsafe_data_ref(this.Instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region internal machinery
|
||||||
private SPBitVec* _instance;
|
private SPBitVec* _instance;
|
||||||
internal SPBitVec* Instance
|
internal SPBitVec* Instance
|
||||||
{
|
{
|
||||||
|
@ -266,8 +267,11 @@ namespace ServicePoint
|
||||||
|
|
||||||
~BitVec() => Free();
|
~BitVec() => Free();
|
||||||
|
|
||||||
const string __DllName = "servicepoint_binding_c";
|
#endregion
|
||||||
|
|
||||||
#nullable restore
|
#nullable restore
|
||||||
|
#region native methods
|
||||||
|
const string __DllName = "servicepoint_binding_c";
|
||||||
[DllImport(__DllName, EntryPoint = "sp_bitvec_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
[DllImport(__DllName, EntryPoint = "sp_bitvec_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||||
private static extern SPBitVec* sp_bitvec_new(nuint size);
|
private static extern SPBitVec* sp_bitvec_new(nuint size);
|
||||||
|
|
||||||
|
@ -301,6 +305,7 @@ namespace ServicePoint
|
||||||
private static extern SPByteSlice sp_bitvec_unsafe_data_ref(SPBitVec* bit_vec);
|
private static extern SPByteSlice sp_bitvec_unsafe_data_ref(SPBitVec* bit_vec);
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
|
|
@ -86,7 +86,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Bitmap Clone()
|
public Bitmap Clone()
|
||||||
{
|
{
|
||||||
return new Bitmap(Bitmap.sp_bitmap_clone(Instance));
|
return new Bitmap(Bitmap.sp_bitmap_clone(this.Instance));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -111,7 +111,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Get(nuint x, nuint y)
|
public bool Get(nuint x, nuint y)
|
||||||
{
|
{
|
||||||
return Bitmap.sp_bitmap_get(Instance, x, y);
|
return Bitmap.sp_bitmap_get(this.Instance, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -139,7 +139,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Set(nuint x, nuint y, bool value)
|
public void Set(nuint x, nuint y, bool value)
|
||||||
{
|
{
|
||||||
Bitmap.sp_bitmap_set(Instance, x, y, value);
|
Bitmap.sp_bitmap_set(this.Instance, x, y, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -163,7 +163,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Fill(bool value)
|
public void Fill(bool value)
|
||||||
{
|
{
|
||||||
Bitmap.sp_bitmap_fill(Instance, value);
|
Bitmap.sp_bitmap_fill(this.Instance, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -185,7 +185,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public nuint Width()
|
public nuint Width()
|
||||||
{
|
{
|
||||||
return Bitmap.sp_bitmap_width(Instance);
|
return Bitmap.sp_bitmap_width(this.Instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -207,7 +207,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public nuint Height()
|
public nuint Height()
|
||||||
{
|
{
|
||||||
return Bitmap.sp_bitmap_height(Instance);
|
return Bitmap.sp_bitmap_height(this.Instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -227,10 +227,11 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SPByteSlice UnsafeDataRef()
|
public SPByteSlice UnsafeDataRef()
|
||||||
{
|
{
|
||||||
return Bitmap.sp_bitmap_unsafe_data_ref(Instance);
|
return Bitmap.sp_bitmap_unsafe_data_ref(this.Instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region internal machinery
|
||||||
private SPBitmap* _instance;
|
private SPBitmap* _instance;
|
||||||
internal SPBitmap* Instance
|
internal SPBitmap* Instance
|
||||||
{
|
{
|
||||||
|
@ -269,8 +270,11 @@ namespace ServicePoint
|
||||||
|
|
||||||
~Bitmap() => Free();
|
~Bitmap() => Free();
|
||||||
|
|
||||||
const string __DllName = "servicepoint_binding_c";
|
#endregion
|
||||||
|
|
||||||
#nullable restore
|
#nullable restore
|
||||||
|
#region native methods
|
||||||
|
const string __DllName = "servicepoint_binding_c";
|
||||||
[DllImport(__DllName, EntryPoint = "sp_bitmap_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
[DllImport(__DllName, EntryPoint = "sp_bitmap_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||||
private static extern SPBitmap* sp_bitmap_new(nuint width, nuint height);
|
private static extern SPBitmap* sp_bitmap_new(nuint width, nuint height);
|
||||||
|
|
||||||
|
@ -303,6 +307,7 @@ namespace ServicePoint
|
||||||
private static extern SPByteSlice sp_bitmap_unsafe_data_ref(SPBitmap* bitmap);
|
private static extern SPByteSlice sp_bitmap_unsafe_data_ref(SPBitmap* bitmap);
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
|
|
@ -10,17 +10,6 @@ using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace ServicePoint
|
namespace ServicePoint
|
||||||
{
|
{
|
||||||
public static unsafe partial class BrightnessGridNative
|
|
||||||
{
|
|
||||||
const string __DllName = "servicepoint_binding_c";
|
|
||||||
|
|
||||||
public const byte SP_BRIGHTNESS_MIN = 0;
|
|
||||||
public const byte SP_BRIGHTNESS_MAX = 11;
|
|
||||||
public const byte SP_BRIGHTNESS_LEVELS = 12;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public unsafe sealed partial class BrightnessGrid: IDisposable
|
public unsafe sealed partial class BrightnessGrid: IDisposable
|
||||||
{
|
{
|
||||||
|
@ -87,7 +76,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BrightnessGrid Clone()
|
public BrightnessGrid Clone()
|
||||||
{
|
{
|
||||||
return new BrightnessGrid(BrightnessGrid.sp_brightness_grid_clone(Instance));
|
return new BrightnessGrid(BrightnessGrid.sp_brightness_grid_clone(this.Instance));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -114,7 +103,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public byte Get(nuint x, nuint y)
|
public byte Get(nuint x, nuint y)
|
||||||
{
|
{
|
||||||
return BrightnessGrid.sp_brightness_grid_get(Instance, x, y);
|
return BrightnessGrid.sp_brightness_grid_get(this.Instance, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -143,7 +132,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Set(nuint x, nuint y, byte value)
|
public void Set(nuint x, nuint y, byte value)
|
||||||
{
|
{
|
||||||
BrightnessGrid.sp_brightness_grid_set(Instance, x, y, value);
|
BrightnessGrid.sp_brightness_grid_set(this.Instance, x, y, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -168,7 +157,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Fill(byte value)
|
public void Fill(byte value)
|
||||||
{
|
{
|
||||||
BrightnessGrid.sp_brightness_grid_fill(Instance, value);
|
BrightnessGrid.sp_brightness_grid_fill(this.Instance, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -192,7 +181,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public nuint Width()
|
public nuint Width()
|
||||||
{
|
{
|
||||||
return BrightnessGrid.sp_brightness_grid_width(Instance);
|
return BrightnessGrid.sp_brightness_grid_width(this.Instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -216,7 +205,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public nuint Height()
|
public nuint Height()
|
||||||
{
|
{
|
||||||
return BrightnessGrid.sp_brightness_grid_height(Instance);
|
return BrightnessGrid.sp_brightness_grid_height(this.Instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -242,10 +231,11 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SPByteSlice UnsafeDataRef()
|
public SPByteSlice UnsafeDataRef()
|
||||||
{
|
{
|
||||||
return BrightnessGrid.sp_brightness_grid_unsafe_data_ref(Instance);
|
return BrightnessGrid.sp_brightness_grid_unsafe_data_ref(this.Instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region internal machinery
|
||||||
private SPBrightnessGrid* _instance;
|
private SPBrightnessGrid* _instance;
|
||||||
internal SPBrightnessGrid* Instance
|
internal SPBrightnessGrid* Instance
|
||||||
{
|
{
|
||||||
|
@ -284,8 +274,11 @@ namespace ServicePoint
|
||||||
|
|
||||||
~BrightnessGrid() => Free();
|
~BrightnessGrid() => Free();
|
||||||
|
|
||||||
const string __DllName = "servicepoint_binding_c";
|
#endregion
|
||||||
|
|
||||||
#nullable restore
|
#nullable restore
|
||||||
|
#region native methods
|
||||||
|
const string __DllName = "servicepoint_binding_c";
|
||||||
[DllImport(__DllName, EntryPoint = "sp_brightness_grid_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
[DllImport(__DllName, EntryPoint = "sp_brightness_grid_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||||
private static extern SPBrightnessGrid* sp_brightness_grid_new(nuint width, nuint height);
|
private static extern SPBrightnessGrid* sp_brightness_grid_new(nuint width, nuint height);
|
||||||
|
|
||||||
|
@ -317,6 +310,7 @@ namespace ServicePoint
|
||||||
private static extern SPByteSlice sp_brightness_grid_unsafe_data_ref(SPBrightnessGrid* brightness_grid);
|
private static extern SPByteSlice sp_brightness_grid_unsafe_data_ref(SPBrightnessGrid* brightness_grid);
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
|
|
@ -34,10 +34,12 @@ namespace ServicePoint
|
||||||
/// - the result is checked for NULL
|
/// - the result is checked for NULL
|
||||||
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
||||||
/// by explicitly calling `sp_command_free`.
|
/// by explicitly calling `sp_command_free`.
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: packet
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static Command? TryFromPacket(Packet packet)
|
public static Command? TryFromPacket(Packet packet)
|
||||||
{
|
{
|
||||||
var native = Command.sp_command_try_from_packet(packet.Instance);
|
var native = Command.sp_command_try_from_packet(packet.Into());
|
||||||
return native == null ? null : new Command(native);
|
return native == null ? null : new Command(native);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +63,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Command Clone()
|
public Command Clone()
|
||||||
{
|
{
|
||||||
return new Command(Command.sp_command_clone(Instance));
|
return new Command(Command.sp_command_clone(this.Instance));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -165,10 +167,12 @@ namespace ServicePoint
|
||||||
/// - `grid` is not used concurrently or after this call
|
/// - `grid` is not used concurrently or after this call
|
||||||
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
||||||
/// by explicitly calling `sp_command_free`.
|
/// by explicitly calling `sp_command_free`.
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: grid
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static Command CharBrightness(nuint x, nuint y, BrightnessGrid grid)
|
public static Command CharBrightness(nuint x, nuint y, BrightnessGrid grid)
|
||||||
{
|
{
|
||||||
return new Command(Command.sp_command_char_brightness(x, y, grid.Instance));
|
return new Command(Command.sp_command_char_brightness(x, y, grid.Into()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -197,10 +201,12 @@ namespace ServicePoint
|
||||||
/// - `compression` matches one of the allowed enum values
|
/// - `compression` matches one of the allowed enum values
|
||||||
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
||||||
/// by explicitly calling `sp_command_free`.
|
/// by explicitly calling `sp_command_free`.
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: bit_vec
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static Command BitmapLinear(nuint offset, BitVec bit_vec, CompressionCode compression)
|
public static Command BitmapLinear(nuint offset, BitVec bit_vec, CompressionCode compression)
|
||||||
{
|
{
|
||||||
return new Command(Command.sp_command_bitmap_linear(offset, bit_vec.Instance, compression));
|
return new Command(Command.sp_command_bitmap_linear(offset, bit_vec.Into(), compression));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -229,10 +235,12 @@ namespace ServicePoint
|
||||||
/// - `compression` matches one of the allowed enum values
|
/// - `compression` matches one of the allowed enum values
|
||||||
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
||||||
/// by explicitly calling `sp_command_free`.
|
/// by explicitly calling `sp_command_free`.
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: bit_vec
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static Command BitmapLinearAnd(nuint offset, BitVec bit_vec, CompressionCode compression)
|
public static Command BitmapLinearAnd(nuint offset, BitVec bit_vec, CompressionCode compression)
|
||||||
{
|
{
|
||||||
return new Command(Command.sp_command_bitmap_linear_and(offset, bit_vec.Instance, compression));
|
return new Command(Command.sp_command_bitmap_linear_and(offset, bit_vec.Into(), compression));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -261,10 +269,12 @@ namespace ServicePoint
|
||||||
/// - `compression` matches one of the allowed enum values
|
/// - `compression` matches one of the allowed enum values
|
||||||
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
||||||
/// by explicitly calling `sp_command_free`.
|
/// by explicitly calling `sp_command_free`.
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: bit_vec
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static Command BitmapLinearOr(nuint offset, BitVec bit_vec, CompressionCode compression)
|
public static Command BitmapLinearOr(nuint offset, BitVec bit_vec, CompressionCode compression)
|
||||||
{
|
{
|
||||||
return new Command(Command.sp_command_bitmap_linear_or(offset, bit_vec.Instance, compression));
|
return new Command(Command.sp_command_bitmap_linear_or(offset, bit_vec.Into(), compression));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -293,10 +303,12 @@ namespace ServicePoint
|
||||||
/// - `compression` matches one of the allowed enum values
|
/// - `compression` matches one of the allowed enum values
|
||||||
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
||||||
/// by explicitly calling `sp_command_free`.
|
/// by explicitly calling `sp_command_free`.
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: bit_vec
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static Command BitmapLinearXor(nuint offset, BitVec bit_vec, CompressionCode compression)
|
public static Command BitmapLinearXor(nuint offset, BitVec bit_vec, CompressionCode compression)
|
||||||
{
|
{
|
||||||
return new Command(Command.sp_command_bitmap_linear_xor(offset, bit_vec.Instance, compression));
|
return new Command(Command.sp_command_bitmap_linear_xor(offset, bit_vec.Into(), compression));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -318,10 +330,12 @@ namespace ServicePoint
|
||||||
/// - `grid` is not used concurrently or after this call
|
/// - `grid` is not used concurrently or after this call
|
||||||
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
||||||
/// by explicitly calling `sp_command_free`.
|
/// by explicitly calling `sp_command_free`.
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: grid
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static Command Cp437Data(nuint x, nuint y, Cp437Grid grid)
|
public static Command Cp437Data(nuint x, nuint y, Cp437Grid grid)
|
||||||
{
|
{
|
||||||
return new Command(Command.sp_command_cp437_data(x, y, grid.Instance));
|
return new Command(Command.sp_command_cp437_data(x, y, grid.Into()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -345,13 +359,16 @@ namespace ServicePoint
|
||||||
/// - `compression` matches one of the allowed enum values
|
/// - `compression` matches one of the allowed enum values
|
||||||
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
/// - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
|
||||||
/// by explicitly calling `sp_command_free`.
|
/// by explicitly calling `sp_command_free`.
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: bitmap
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static Command BitmapLinearWin(nuint x, nuint y, Bitmap bitmap, CompressionCode compression_code)
|
public static Command BitmapLinearWin(nuint x, nuint y, Bitmap bitmap, CompressionCode compression_code)
|
||||||
{
|
{
|
||||||
return new Command(Command.sp_command_bitmap_linear_win(x, y, bitmap.Instance, compression_code));
|
return new Command(Command.sp_command_bitmap_linear_win(x, y, bitmap.Into(), compression_code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region internal machinery
|
||||||
private SPCommand* _instance;
|
private SPCommand* _instance;
|
||||||
internal SPCommand* Instance
|
internal SPCommand* Instance
|
||||||
{
|
{
|
||||||
|
@ -390,8 +407,11 @@ namespace ServicePoint
|
||||||
|
|
||||||
~Command() => Free();
|
~Command() => Free();
|
||||||
|
|
||||||
const string __DllName = "servicepoint_binding_c";
|
#endregion
|
||||||
|
|
||||||
#nullable restore
|
#nullable restore
|
||||||
|
#region native methods
|
||||||
|
const string __DllName = "servicepoint_binding_c";
|
||||||
[DllImport(__DllName, EntryPoint = "sp_command_try_from_packet", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
[DllImport(__DllName, EntryPoint = "sp_command_try_from_packet", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||||
private static extern SPCommand* sp_command_try_from_packet(SPPacket* packet);
|
private static extern SPCommand* sp_command_try_from_packet(SPPacket* packet);
|
||||||
|
|
||||||
|
@ -435,6 +455,7 @@ namespace ServicePoint
|
||||||
private static extern void sp_command_free(SPCommand* command);
|
private static extern void sp_command_free(SPCommand* command);
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
|
|
@ -55,10 +55,12 @@ namespace ServicePoint
|
||||||
/// - `connection` points to a valid instance of [SPConnection]
|
/// - `connection` points to a valid instance of [SPConnection]
|
||||||
/// - `packet` points to a valid instance of [SPPacket]
|
/// - `packet` points to a valid instance of [SPPacket]
|
||||||
/// - `packet` is not used concurrently or after this call
|
/// - `packet` is not used concurrently or after this call
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: packet
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool SendPacket(Packet packet)
|
public bool SendPacket(Packet packet)
|
||||||
{
|
{
|
||||||
return Connection.sp_connection_send_packet(Instance, packet.Instance);
|
return Connection.sp_connection_send_packet(this.Instance, packet.Into());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -80,13 +82,16 @@ namespace ServicePoint
|
||||||
/// - `connection` points to a valid instance of [SPConnection]
|
/// - `connection` points to a valid instance of [SPConnection]
|
||||||
/// - `command` points to a valid instance of [SPPacket]
|
/// - `command` points to a valid instance of [SPPacket]
|
||||||
/// - `command` is not used concurrently or after this call
|
/// - `command` is not used concurrently or after this call
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: packet
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool SendCommand(Command command)
|
public bool SendCommand(Command command)
|
||||||
{
|
{
|
||||||
return Connection.sp_connection_send_command(Instance, command.Instance);
|
return Connection.sp_connection_send_command(this.Instance, command.Instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region internal machinery
|
||||||
private SPConnection* _instance;
|
private SPConnection* _instance;
|
||||||
internal SPConnection* Instance
|
internal SPConnection* Instance
|
||||||
{
|
{
|
||||||
|
@ -125,8 +130,11 @@ namespace ServicePoint
|
||||||
|
|
||||||
~Connection() => Free();
|
~Connection() => Free();
|
||||||
|
|
||||||
const string __DllName = "servicepoint_binding_c";
|
#endregion
|
||||||
|
|
||||||
#nullable restore
|
#nullable restore
|
||||||
|
#region native methods
|
||||||
|
const string __DllName = "servicepoint_binding_c";
|
||||||
[DllImport(__DllName, EntryPoint = "sp_connection_open", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
[DllImport(__DllName, EntryPoint = "sp_connection_open", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||||
private static extern SPConnection* sp_connection_open(byte* host);
|
private static extern SPConnection* sp_connection_open(byte* host);
|
||||||
|
|
||||||
|
@ -142,6 +150,7 @@ namespace ServicePoint
|
||||||
private static extern void sp_connection_free(SPConnection* connection);
|
private static extern void sp_connection_free(SPConnection* connection);
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
|
|
@ -19,4 +19,8 @@ public static class Constants
|
||||||
|
|
||||||
/// pixel count on whole screen
|
/// pixel count on whole screen
|
||||||
public const nuint PixelCount = PixelWidth * PixelHeight;
|
public const nuint PixelCount = PixelWidth * PixelHeight;
|
||||||
|
|
||||||
|
public const byte MinBrightness = ConstantsNative.SP_BRIGHTNESS_MIN;
|
||||||
|
public const byte MaxBrightness = ConstantsNative.SP_BRIGHTNESS_MAX;
|
||||||
|
public const byte BrightnessLevels = ConstantsNative.SP_BRIGHTNESS_LEVELS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,9 @@ namespace ServicePoint
|
||||||
public const nuint SP_TILE_SIZE = 8;
|
public const nuint SP_TILE_SIZE = 8;
|
||||||
public const nuint SP_TILE_WIDTH = 56;
|
public const nuint SP_TILE_WIDTH = 56;
|
||||||
public const nuint SP_TILE_HEIGHT = 20;
|
public const nuint SP_TILE_HEIGHT = 20;
|
||||||
|
public const byte SP_BRIGHTNESS_MIN = 0;
|
||||||
|
public const byte SP_BRIGHTNESS_MAX = 11;
|
||||||
|
public const byte SP_BRIGHTNESS_LEVELS = 12;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Cp437Grid Clone()
|
public Cp437Grid Clone()
|
||||||
{
|
{
|
||||||
return new Cp437Grid(Cp437Grid.sp_cp437_grid_clone(Instance));
|
return new Cp437Grid(Cp437Grid.sp_cp437_grid_clone(this.Instance));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -97,7 +97,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public byte Get(nuint x, nuint y)
|
public byte Get(nuint x, nuint y)
|
||||||
{
|
{
|
||||||
return Cp437Grid.sp_cp437_grid_get(Instance, x, y);
|
return Cp437Grid.sp_cp437_grid_get(this.Instance, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -125,7 +125,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Set(nuint x, nuint y, byte value)
|
public void Set(nuint x, nuint y, byte value)
|
||||||
{
|
{
|
||||||
Cp437Grid.sp_cp437_grid_set(Instance, x, y, value);
|
Cp437Grid.sp_cp437_grid_set(this.Instance, x, y, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -149,7 +149,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Fill(byte value)
|
public void Fill(byte value)
|
||||||
{
|
{
|
||||||
Cp437Grid.sp_cp437_grid_fill(Instance, value);
|
Cp437Grid.sp_cp437_grid_fill(this.Instance, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -171,7 +171,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public nuint Width()
|
public nuint Width()
|
||||||
{
|
{
|
||||||
return Cp437Grid.sp_cp437_grid_width(Instance);
|
return Cp437Grid.sp_cp437_grid_width(this.Instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -193,7 +193,7 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public nuint Height()
|
public nuint Height()
|
||||||
{
|
{
|
||||||
return Cp437Grid.sp_cp437_grid_height(Instance);
|
return Cp437Grid.sp_cp437_grid_height(this.Instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -215,10 +215,11 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SPByteSlice UnsafeDataRef()
|
public SPByteSlice UnsafeDataRef()
|
||||||
{
|
{
|
||||||
return Cp437Grid.sp_cp437_grid_unsafe_data_ref(Instance);
|
return Cp437Grid.sp_cp437_grid_unsafe_data_ref(this.Instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region internal machinery
|
||||||
private SPCp437Grid* _instance;
|
private SPCp437Grid* _instance;
|
||||||
internal SPCp437Grid* Instance
|
internal SPCp437Grid* Instance
|
||||||
{
|
{
|
||||||
|
@ -257,8 +258,11 @@ namespace ServicePoint
|
||||||
|
|
||||||
~Cp437Grid() => Free();
|
~Cp437Grid() => Free();
|
||||||
|
|
||||||
const string __DllName = "servicepoint_binding_c";
|
#endregion
|
||||||
|
|
||||||
#nullable restore
|
#nullable restore
|
||||||
|
#region native methods
|
||||||
|
const string __DllName = "servicepoint_binding_c";
|
||||||
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||||
private static extern SPCp437Grid* sp_cp437_grid_new(nuint width, nuint height);
|
private static extern SPCp437Grid* sp_cp437_grid_new(nuint width, nuint height);
|
||||||
|
|
||||||
|
@ -290,6 +294,7 @@ namespace ServicePoint
|
||||||
private static extern SPByteSlice sp_cp437_grid_unsafe_data_ref(SPCp437Grid* cp437_grid);
|
private static extern SPByteSlice sp_cp437_grid_unsafe_data_ref(SPCp437Grid* cp437_grid);
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
|
|
@ -32,10 +32,12 @@ namespace ServicePoint
|
||||||
/// - [SPCommand] is not used concurrently or after this call
|
/// - [SPCommand] is not used concurrently or after this call
|
||||||
/// - the returned [SPPacket] instance is freed in some way, either by using a consuming function or
|
/// - the returned [SPPacket] instance is freed in some way, either by using a consuming function or
|
||||||
/// by explicitly calling `sp_packet_free`.
|
/// by explicitly calling `sp_packet_free`.
|
||||||
|
///
|
||||||
|
/// servicepoint_csbindgen_consumes: command
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static Packet FromCommand(Command command)
|
public static Packet FromCommand(Command command)
|
||||||
{
|
{
|
||||||
return new Packet(Packet.sp_packet_from_command(command.Instance));
|
return new Packet(Packet.sp_packet_from_command(command.Into()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -82,10 +84,11 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Packet Clone()
|
public Packet Clone()
|
||||||
{
|
{
|
||||||
return new Packet(Packet.sp_packet_clone(Instance));
|
return new Packet(Packet.sp_packet_clone(this.Instance));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region internal machinery
|
||||||
private SPPacket* _instance;
|
private SPPacket* _instance;
|
||||||
internal SPPacket* Instance
|
internal SPPacket* Instance
|
||||||
{
|
{
|
||||||
|
@ -124,8 +127,11 @@ namespace ServicePoint
|
||||||
|
|
||||||
~Packet() => Free();
|
~Packet() => Free();
|
||||||
|
|
||||||
const string __DllName = "servicepoint_binding_c";
|
#endregion
|
||||||
|
|
||||||
#nullable restore
|
#nullable restore
|
||||||
|
#region native methods
|
||||||
|
const string __DllName = "servicepoint_binding_c";
|
||||||
[DllImport(__DllName, EntryPoint = "sp_packet_from_command", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
[DllImport(__DllName, EntryPoint = "sp_packet_from_command", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||||
private static extern SPPacket* sp_packet_from_command(SPCommand* command);
|
private static extern SPPacket* sp_packet_from_command(SPCommand* command);
|
||||||
|
|
||||||
|
@ -139,6 +145,7 @@ namespace ServicePoint
|
||||||
private static extern void sp_packet_free(SPPacket* packet);
|
private static extern void sp_packet_free(SPPacket* packet);
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
|
|
||||||
namespace ServicePoint;
|
|
||||||
|
|
||||||
public static class ServicePointExtensions
|
|
||||||
{
|
|
||||||
public static Packet IntoPacket(this Command command)
|
|
||||||
{
|
|
||||||
return Packet.FromCommand(command);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool TryIntoCommand(this Packet packet, [MaybeNullWhen(false)] out Command command)
|
|
||||||
{
|
|
||||||
return Command.TryFromPacket(packet, out command);
|
|
||||||
}
|
|
||||||
|
|
||||||
public unsafe static Span<byte> AsSpan(this SPByteSlice slice)
|
|
||||||
{
|
|
||||||
return new Span<byte>(slice.start, (int)slice.length);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,8 +7,8 @@ if (connection == null)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
connection.Send(Command.Clear().IntoPacket());
|
connection.Send(Command.Clear());
|
||||||
connection.Send(Command.Brightness(128).IntoPacket());
|
connection.Send(Command.Brightness(Constants.MaxBrightness));
|
||||||
|
|
||||||
using var pixels = new Bitmap(Constants.PixelWidth, Constants.PixelHeight);
|
using var pixels = new Bitmap(Constants.PixelWidth, Constants.PixelHeight);
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 2dcf44a5c398925249cf96e9bbf724dd551e5b76
|
Subproject commit de49df92fa878f0c6685d05ee42f36e3b7d9b042
|
Loading…
Reference in a new issue