Skip to content

Commit 3234344

Browse files
committed
Implement ToGodot/FromGodot for const void*
1 parent 3b3fedb commit 3234344

File tree

1 file changed

+22
-1
lines changed
  • godot-core/src/builtin/meta/godot_convert

1 file changed

+22
-1
lines changed

godot-core/src/builtin/meta/godot_convert/impls.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ impl_godot_scalar!(
208208
u8 as i64,
209209
sys::GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT8
210210
);
211-
212211
impl_godot_scalar!(
213212
u64 as i64,
214213
sys::GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT64;
@@ -219,3 +218,25 @@ impl_godot_scalar!(
219218
sys::GDEXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_FLOAT;
220219
lossy
221220
);
221+
222+
// ----------------------------------------------------------------------------------------------------------------------------------------------
223+
// Raw pointers
224+
225+
// const void* is used in some APIs like OpenXrApiExtension::transform_from_pose().
226+
// Other impls for raw pointers are generated for native structures.
227+
228+
impl GodotConvert for *const std::ffi::c_void {
229+
type Via = i64;
230+
}
231+
232+
impl ToGodot for *const std::ffi::c_void {
233+
fn to_godot(&self) -> Self::Via {
234+
*self as i64
235+
}
236+
}
237+
238+
impl FromGodot for *const std::ffi::c_void {
239+
fn try_from_godot(via: Self::Via) -> Option<Self> {
240+
Some(via as Self)
241+
}
242+
}

0 commit comments

Comments
 (0)