@@ -8,12 +8,19 @@ use crate as sys;
8
8
use std:: fmt:: Debug ;
9
9
10
10
/// Adds methods to convert from and to Godot FFI pointers.
11
- # [ doc ( hidden ) ]
11
+ /// See [crate::ffi_methods] for ergonomic implementation.
12
12
pub trait GodotFfi {
13
13
/// Construct from Godot opaque pointer.
14
+ ///
15
+ /// # Safety
16
+ /// `ptr` must be a valid _type ptr_: it must follow Godot's convention to encode `Self`,
17
+ /// which is different depending on the type.
14
18
unsafe fn from_sys ( ptr : sys:: GDExtensionTypePtr ) -> Self ;
15
19
16
- /// Construct uninitialized opaque data, then initialize it with `init` function.
20
+ /// Construct uninitialized opaque data, then initialize it with `init_fn` function.
21
+ ///
22
+ /// # Safety
23
+ /// `init_fn` must be a function that correctly handles a (possibly-uninitialized) _type ptr_.
17
24
unsafe fn from_sys_init ( init_fn : impl FnOnce ( sys:: GDExtensionTypePtr ) ) -> Self ;
18
25
19
26
/// Return Godot opaque pointer, for an immutable operation.
@@ -38,6 +45,11 @@ pub trait GodotFfi {
38
45
self . sys ( )
39
46
}
40
47
48
+ /// Write the contents of `self` into the pointer `dst`.
49
+ ///
50
+ /// # Safety
51
+ /// `dst` must be a valid _type ptr_: it must follow Godot's convention to encode `Self`,
52
+ /// which is different depending on the type.
41
53
unsafe fn write_sys ( & self , dst : sys:: GDExtensionTypePtr ) ;
42
54
}
43
55
@@ -66,6 +78,7 @@ pub trait GodotFuncMarshal: Sized {
66
78
// See doc comment of `ffi_methods!` for information
67
79
68
80
#[ macro_export]
81
+ #[ doc( hidden) ]
69
82
macro_rules! ffi_methods_one {
70
83
// type $Ptr = *mut Opaque
71
84
( OpaquePtr $Ptr: ty; $( #[ $attr: meta] ) ? $vis: vis $from_sys: ident = from_sys) => {
@@ -159,6 +172,7 @@ macro_rules! ffi_methods_one {
159
172
}
160
173
161
174
#[ macro_export]
175
+ #[ doc( hidden) ]
162
176
macro_rules! ffi_methods_rest {
163
177
( // impl T: each method has a custom name and is annotated with 'pub'
164
178
$Impl: ident $Ptr: ty; $( fn $user_fn: ident = $sys_fn: ident; ) *
0 commit comments