1use std::ffi::c_void;
2
3macro_rules! define_ptr_handle {
8 ($(#[$meta:meta])* $name:ident) => {
9 $(#[$meta])*
10 #[repr(transparent)]
11 #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
12 pub struct $name(pub *mut c_void);
13
14 impl $name {
15 pub fn is_null(&self) -> bool {
16 self.0.is_null()
17 }
18
19 pub fn null() -> Self {
20 Self(std::ptr::null_mut())
21 }
22
23 pub fn from_addr(addr: u64) -> Self {
25 Self(addr as usize as *mut c_void)
26 }
27
28 pub fn to_addr(&self) -> u64 {
30 self.0 as usize as u64
31 }
32 }
33 };
34}
35
36define_ptr_handle! {
37 UObjectHandle
39}
40
41define_ptr_handle! {
42 UClassHandle
44}
45
46define_ptr_handle! {
47 FPropertyHandle
49}
50
51define_ptr_handle! {
52 UFunctionHandle
55}
56
57define_ptr_handle! {
58 UStructHandle
60}
61
62#[repr(transparent)]
64#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Default)]
65pub struct FNameHandle(pub u64);
66
67#[repr(C)]
69#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
70pub struct FWeakObjectHandle {
71 pub object_index: i32,
72 pub object_serial_number: i32,
73}
74
75impl Default for FWeakObjectHandle {
76 fn default() -> Self {
77 FWeakObjectHandle {
78 object_index: -1,
79 object_serial_number: 0,
80 }
81 }
82}
83
84unsafe impl Send for UObjectHandle {}
88unsafe impl Sync for UObjectHandle {}
89unsafe impl Send for UClassHandle {}
90unsafe impl Sync for UClassHandle {}
91unsafe impl Send for FPropertyHandle {}
92unsafe impl Sync for FPropertyHandle {}
93unsafe impl Send for UFunctionHandle {}
94unsafe impl Sync for UFunctionHandle {}
95unsafe impl Send for UStructHandle {}
96unsafe impl Sync for UStructHandle {}
97unsafe impl Send for FWeakObjectHandle {}
98unsafe impl Sync for FWeakObjectHandle {}