1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
macro_rules! impl_object {
    ($name: ident) => {
        impl Object for $name {
            fn new(addr: usize) -> Self { 
                Self(addr)
            }

            fn try_new(addr: usize) -> Option<Self> { 
                match addr {
                    0 => None,
                    _ => Some(Self(addr))
                }
            }

            fn addr(&self) -> usize { 
                self.0
            }
        }

        impl UnrealPointer for $name {
            fn from_ptr(addr: usize) -> Self { Self(addr) }
        }
    }
}

macro_rules! impl_unreal_pointer_struct {
    ($name: ident) => {
        impl UnrealPointer for $name {
            fn from_ptr(addr: usize) -> Self {
                unsafe { *(addr as *const Self) }
            }
        }
    }
}

macro_rules! struct_default_new {
    ($name: ident) => {
        impl $name {
            pub fn new() -> Self { Self(0) }
        }
    }
}