wip fix documentation
This commit is contained in:
parent
597614bc95
commit
e0d82b2b87
13 changed files with 405 additions and 380 deletions
|
|
@ -1,4 +1,4 @@
|
|||
//! C functions for interacting with [SPCharGrid]s
|
||||
//! C functions for interacting with [CharGrid]s
|
||||
//!
|
||||
//! prefix `sp_char_grid_`
|
||||
//!
|
||||
|
|
@ -22,9 +22,9 @@ use crate::SPByteSlice;
|
|||
use servicepoint::{CharGrid, Grid};
|
||||
use std::ptr::NonNull;
|
||||
|
||||
/// Creates a new [SPCharGrid] with the specified dimensions.
|
||||
/// Creates a new [CharGrid] with the specified dimensions.
|
||||
///
|
||||
/// returns: [SPCharGrid] initialized to 0. Will never return NULL.
|
||||
/// returns: [CharGrid] initialized to 0. Will never return NULL.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
|
|
@ -41,7 +41,7 @@ pub unsafe extern "C" fn sp_char_grid_new(
|
|||
NonNull::from(Box::leak(result))
|
||||
}
|
||||
|
||||
/// Loads a [SPCharGrid] with the specified dimensions from the provided data.
|
||||
/// Loads a [CharGrid] with the specified dimensions from the provided data.
|
||||
///
|
||||
/// Will never return NULL.
|
||||
///
|
||||
|
|
@ -72,7 +72,7 @@ pub unsafe extern "C" fn sp_char_grid_load(
|
|||
NonNull::from(Box::leak(result))
|
||||
}
|
||||
|
||||
/// Clones a [SPCharGrid].
|
||||
/// Clones a [CharGrid].
|
||||
///
|
||||
/// Will never return NULL.
|
||||
///
|
||||
|
|
@ -84,7 +84,7 @@ pub unsafe extern "C" fn sp_char_grid_load(
|
|||
///
|
||||
/// The caller has to make sure that:
|
||||
///
|
||||
/// - `char_grid` points to a valid [SPCharGrid]
|
||||
/// - `char_grid` points to a valid [CharGrid]
|
||||
/// - `char_grid` is not written to concurrently
|
||||
/// - the returned instance is freed in some way, either by using a consuming function or
|
||||
/// by explicitly calling `sp_char_grid_free`.
|
||||
|
|
@ -96,7 +96,7 @@ pub unsafe extern "C" fn sp_char_grid_clone(
|
|||
NonNull::from(Box::leak(result))
|
||||
}
|
||||
|
||||
/// Deallocates a [SPCharGrid].
|
||||
/// Deallocates a [CharGrid].
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
|
|
@ -106,11 +106,11 @@ pub unsafe extern "C" fn sp_char_grid_clone(
|
|||
///
|
||||
/// The caller has to make sure that:
|
||||
///
|
||||
/// - `char_grid` points to a valid [SPCharGrid]
|
||||
/// - `char_grid` points to a valid [CharGrid]
|
||||
/// - `char_grid` is not used concurrently or after char_grid call
|
||||
/// - `char_grid` was not passed to another consuming function, e.g. to create a [SPCommand]
|
||||
/// - `char_grid` was not passed to another consuming function, e.g. to create a [TypedCommand]
|
||||
///
|
||||
/// [SPCommand]: [crate::SPCommand]
|
||||
/// [TypedCommand]: [crate::TypedCommand]
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn sp_char_grid_free(char_grid: NonNull<CharGrid>) {
|
||||
_ = unsafe { Box::from_raw(char_grid.as_ptr()) };
|
||||
|
|
@ -132,7 +132,7 @@ pub unsafe extern "C" fn sp_char_grid_free(char_grid: NonNull<CharGrid>) {
|
|||
///
|
||||
/// The caller has to make sure that:
|
||||
///
|
||||
/// - `char_grid` points to a valid [SPCharGrid]
|
||||
/// - `char_grid` points to a valid [CharGrid]
|
||||
/// - `char_grid` is not written to concurrently
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn sp_char_grid_get(
|
||||
|
|
@ -143,7 +143,7 @@ pub unsafe extern "C" fn sp_char_grid_get(
|
|||
unsafe { char_grid.as_ref().get(x, y) as u32 }
|
||||
}
|
||||
|
||||
/// Sets the value of the specified position in the [SPCharGrid].
|
||||
/// Sets the value of the specified position in the [CharGrid].
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
|
|
@ -176,7 +176,7 @@ pub unsafe extern "C" fn sp_char_grid_set(
|
|||
unsafe { (*char_grid.as_ptr()).set(x, y, char::from_u32(value).unwrap()) };
|
||||
}
|
||||
|
||||
/// Sets the value of all cells in the [SPCharGrid].
|
||||
/// Sets the value of all cells in the [CharGrid].
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
|
|
@ -191,7 +191,7 @@ pub unsafe extern "C" fn sp_char_grid_set(
|
|||
///
|
||||
/// The caller has to make sure that:
|
||||
///
|
||||
/// - `char_grid` points to a valid [SPCharGrid]
|
||||
/// - `char_grid` points to a valid [CharGrid]
|
||||
/// - `char_grid` is not written to or read from concurrently
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn sp_char_grid_fill(
|
||||
|
|
@ -201,7 +201,7 @@ pub unsafe extern "C" fn sp_char_grid_fill(
|
|||
unsafe { (*char_grid.as_ptr()).fill(char::from_u32(value).unwrap()) };
|
||||
}
|
||||
|
||||
/// Gets the width of the [SPCharGrid] instance.
|
||||
/// Gets the width of the [CharGrid] instance.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
|
|
@ -215,7 +215,7 @@ pub unsafe extern "C" fn sp_char_grid_fill(
|
|||
///
|
||||
/// The caller has to make sure that:
|
||||
///
|
||||
/// - `char_grid` points to a valid [SPCharGrid]
|
||||
/// - `char_grid` points to a valid [CharGrid]
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn sp_char_grid_width(
|
||||
char_grid: NonNull<CharGrid>,
|
||||
|
|
@ -223,7 +223,7 @@ pub unsafe extern "C" fn sp_char_grid_width(
|
|||
unsafe { char_grid.as_ref().width() }
|
||||
}
|
||||
|
||||
/// Gets the height of the [SPCharGrid] instance.
|
||||
/// Gets the height of the [CharGrid] instance.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
|
|
@ -237,7 +237,7 @@ pub unsafe extern "C" fn sp_char_grid_width(
|
|||
///
|
||||
/// The caller has to make sure that:
|
||||
///
|
||||
/// - `char_grid` points to a valid [SPCharGrid]
|
||||
/// - `char_grid` points to a valid [CharGrid]
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn sp_char_grid_height(
|
||||
char_grid: NonNull<CharGrid>,
|
||||
|
|
|
|||
Loading…
Reference in a new issue