Skip to content

Commit 7405d51

Browse files
committed
Change isize -> usize, ptr::offset -> ptr::add()
1 parent 7a27be0 commit 7405d51

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

godot-core/src/meta/error/call_error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl CallError {
182182
/// Returns an error for a failed parameter conversion.
183183
pub(crate) fn failed_param_conversion<P>(
184184
call_ctx: &CallContext,
185-
param_index: isize,
185+
param_index: usize,
186186
convert_error: ConvertError,
187187
) -> Self {
188188
let param_ty = std::any::type_name::<P>();

godot-core/src/meta/param_tuple/impls.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ macro_rules! unsafe_impl_param_tuple {
6464
if arg_count == Self::LEN {
6565
let param_tuple = (
6666
$(
67-
unsafe { varcall_arg::<$P>(*args_ptr.offset($n), call_ctx, $n as isize)? },
67+
unsafe { varcall_arg::<$P>(*args_ptr.add($n), call_ctx, $n)? },
6868
)*
6969
);
7070
return Ok(param_tuple);
@@ -75,7 +75,7 @@ macro_rules! unsafe_impl_param_tuple {
7575

7676
// Copy all provided args.
7777
for i in 0..arg_count {
78-
all_args.push(unsafe { *args_ptr.offset(i as isize) });
78+
all_args.push(unsafe { *args_ptr.add(i) });
7979
}
8080

8181
// Fill remaining parameters with default values.
@@ -89,7 +89,7 @@ macro_rules! unsafe_impl_param_tuple {
8989
let param_tuple = (
9090
$(
9191
// SAFETY: Each pointer in `args_ptr` is borrowable as a &Variant for the duration of this call.
92-
unsafe { varcall_arg::<$P>(all_args[$n], call_ctx, $n as isize)? },
92+
unsafe { varcall_arg::<$P>(all_args[$n], call_ctx, $n)? },
9393
)*
9494
);
9595

@@ -211,16 +211,16 @@ unsafe_impl_param_tuple!((p0, 0): P0, (p1, 1): P1, (p2, 2): P2, (p3, 3): P3, (p4
211211
/// Convert the `N`th argument of `args_ptr` into a value of type `P`.
212212
///
213213
/// # Safety
214-
/// - It must be safe to dereference the address at `args_ptr.offset(N)`.
215-
/// - The pointer at `args_ptr.offset(N)` must follow the safety requirements as laid out in
214+
/// - It must be safe to dereference the address at `args_ptr.add(N)`.
215+
/// - The pointer at `args_ptr.add(N)` must follow the safety requirements as laid out in
216216
/// [`GodotFfi::from_arg_ptr`].
217-
pub(super) unsafe fn ptrcall_arg<P: FromGodot, const N: isize>(
217+
pub(super) unsafe fn ptrcall_arg<P: FromGodot, const N: usize>(
218218
args_ptr: *const sys::GDExtensionConstTypePtr,
219219
call_ctx: &CallContext,
220220
call_type: sys::PtrcallType,
221221
) -> CallResult<P> {
222222
// SAFETY: It is safe to dereference `args_ptr` at `N`.
223-
let offset_ptr = unsafe { *args_ptr.offset(N) };
223+
let offset_ptr = unsafe { *args_ptr.add(N) };
224224

225225
// SAFETY: The pointer follows the safety requirements from `GodotFfi::from_arg_ptr`.
226226
let ffi = unsafe {
@@ -240,7 +240,7 @@ pub(super) unsafe fn ptrcall_arg<P: FromGodot, const N: isize>(
240240
pub(super) unsafe fn varcall_arg<P: FromGodot>(
241241
arg: sys::GDExtensionConstVariantPtr,
242242
call_ctx: &CallContext,
243-
param_index: isize,
243+
param_index: usize,
244244
) -> CallResult<P> {
245245
// SAFETY: It is safe to dereference `args_ptr` at `N` as a `Variant`.
246246
let variant_ref = unsafe { Variant::borrow_var_sys(arg) };

0 commit comments

Comments
 (0)