replace usages of 'this' as parameter name
This commit is contained in:
parent
3e3a933ecb
commit
e46391ca5f
9 changed files with 506 additions and 427 deletions
|
|
@ -86,15 +86,15 @@ pub unsafe extern "C" fn sp_cp437_grid_load(
|
|||
///
|
||||
/// The caller has to make sure that:
|
||||
///
|
||||
/// - `this` points to a valid `SPCp437Grid`
|
||||
/// - `this` is not written to concurrently
|
||||
/// - `cp437_grid` points to a valid `SPCp437Grid`
|
||||
/// - `cp437_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_cp437_grid_free`.
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn sp_cp437_grid_clone(
|
||||
this: *const SPCp437Grid,
|
||||
cp437_grid: *const SPCp437Grid,
|
||||
) -> *mut SPCp437Grid {
|
||||
Box::into_raw(Box::new((*this).clone()))
|
||||
Box::into_raw(Box::new((*cp437_grid).clone()))
|
||||
}
|
||||
|
||||
/// Deallocates a `SPCp437Grid`.
|
||||
|
|
@ -103,19 +103,19 @@ pub unsafe extern "C" fn sp_cp437_grid_clone(
|
|||
///
|
||||
/// The caller has to make sure that:
|
||||
///
|
||||
/// - `this` points to a valid `SPCp437Grid`
|
||||
/// - `this` is not used concurrently or after this call
|
||||
/// - `this` was not passed to another consuming function, e.g. to create a `SPCommand`
|
||||
/// - `cp437_grid` points to a valid `SPCp437Grid`
|
||||
/// - `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`
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn sp_cp437_grid_free(this: *mut SPCp437Grid) {
|
||||
_ = Box::from_raw(this);
|
||||
pub unsafe extern "C" fn sp_cp437_grid_free(cp437_grid: *mut SPCp437Grid) {
|
||||
_ = Box::from_raw(cp437_grid);
|
||||
}
|
||||
|
||||
/// Gets the current value at the specified position.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// - `this`: instance to read from
|
||||
/// - `cp437_grid`: instance to read from
|
||||
/// - `x` and `y`: position of the cell to read
|
||||
///
|
||||
/// # Panics
|
||||
|
|
@ -126,22 +126,22 @@ pub unsafe extern "C" fn sp_cp437_grid_free(this: *mut SPCp437Grid) {
|
|||
///
|
||||
/// The caller has to make sure that:
|
||||
///
|
||||
/// - `this` points to a valid `SPCp437Grid`
|
||||
/// - `this` is not written to concurrently
|
||||
/// - `cp437_grid` points to a valid `SPCp437Grid`
|
||||
/// - `cp437_grid` is not written to concurrently
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn sp_cp437_grid_get(
|
||||
this: *const SPCp437Grid,
|
||||
cp437_grid: *const SPCp437Grid,
|
||||
x: usize,
|
||||
y: usize,
|
||||
) -> u8 {
|
||||
(*this).actual.get(x, y)
|
||||
(*cp437_grid).actual.get(x, y)
|
||||
}
|
||||
|
||||
/// Sets the value of the specified position in the `SPCp437Grid`.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// - `this`: instance to write to
|
||||
/// - `cp437_grid`: instance to write to
|
||||
/// - `x` and `y`: position of the cell
|
||||
/// - `value`: the value to write to the cell
|
||||
///
|
||||
|
|
@ -155,70 +155,73 @@ pub unsafe extern "C" fn sp_cp437_grid_get(
|
|||
///
|
||||
/// The caller has to make sure that:
|
||||
///
|
||||
/// - `this` points to a valid `SPBitVec`
|
||||
/// - `this` is not written to or read from concurrently
|
||||
/// - `cp437_grid` points to a valid `SPBitVec`
|
||||
/// - `cp437_grid` is not written to or read from concurrently
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn sp_cp437_grid_set(
|
||||
this: *mut SPCp437Grid,
|
||||
cp437_grid: *mut SPCp437Grid,
|
||||
x: usize,
|
||||
y: usize,
|
||||
value: u8,
|
||||
) {
|
||||
(*this).actual.set(x, y, value);
|
||||
(*cp437_grid).actual.set(x, y, value);
|
||||
}
|
||||
|
||||
/// Sets the value of all cells in the `SPCp437Grid`.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// - `this`: instance to write to
|
||||
/// - `cp437_grid`: instance to write to
|
||||
/// - `value`: the value to set all cells to
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The caller has to make sure that:
|
||||
///
|
||||
/// - `this` points to a valid `SPCp437Grid`
|
||||
/// - `this` is not written to or read from concurrently
|
||||
/// - `cp437_grid` points to a valid `SPCp437Grid`
|
||||
/// - `cp437_grid` is not written to or read from concurrently
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn sp_cp437_grid_fill(this: *mut SPCp437Grid, value: u8) {
|
||||
(*this).actual.fill(value);
|
||||
pub unsafe extern "C" fn sp_cp437_grid_fill(
|
||||
cp437_grid: *mut SPCp437Grid,
|
||||
value: u8,
|
||||
) {
|
||||
(*cp437_grid).actual.fill(value);
|
||||
}
|
||||
|
||||
/// Gets the width of the `SPCp437Grid` instance.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// - `this`: instance to read from
|
||||
/// - `cp437_grid`: instance to read from
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The caller has to make sure that:
|
||||
///
|
||||
/// - `this` points to a valid `SPCp437Grid`
|
||||
/// - `cp437_grid` points to a valid `SPCp437Grid`
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn sp_cp437_grid_width(
|
||||
this: *const SPCp437Grid,
|
||||
cp437_grid: *const SPCp437Grid,
|
||||
) -> usize {
|
||||
(*this).actual.width()
|
||||
(*cp437_grid).actual.width()
|
||||
}
|
||||
|
||||
/// Gets the height of the `SPCp437Grid` instance.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// - `this`: instance to read from
|
||||
/// - `cp437_grid`: instance to read from
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The caller has to make sure that:
|
||||
///
|
||||
/// - `this` points to a valid `SPCp437Grid`
|
||||
/// - `cp437_grid` points to a valid `SPCp437Grid`
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn sp_cp437_grid_height(
|
||||
this: *const SPCp437Grid,
|
||||
cp437_grid: *const SPCp437Grid,
|
||||
) -> usize {
|
||||
(*this).actual.height()
|
||||
(*cp437_grid).actual.height()
|
||||
}
|
||||
|
||||
/// Gets an unsafe reference to the data of the `SPCp437Grid` instance.
|
||||
|
|
@ -229,14 +232,14 @@ pub unsafe extern "C" fn sp_cp437_grid_height(
|
|||
///
|
||||
/// The caller has to make sure that:
|
||||
///
|
||||
/// - `this` points to a valid `SPCp437Grid`
|
||||
/// - `cp437_grid` points to a valid `SPCp437Grid`
|
||||
/// - the returned memory range is never accessed after the passed `SPCp437Grid` has been freed
|
||||
/// - the returned memory range is never accessed concurrently, either via the `SPCp437Grid` or directly
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn sp_cp437_grid_unsafe_data_ref(
|
||||
this: *mut SPCp437Grid,
|
||||
cp437_grid: *mut SPCp437Grid,
|
||||
) -> SPByteSlice {
|
||||
let data = (*this).actual.data_ref_mut();
|
||||
let data = (*cp437_grid).actual.data_ref_mut();
|
||||
SPByteSlice {
|
||||
start: data.as_mut_ptr_range().start,
|
||||
length: data.len(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue