async_load/ds_map/
internals.rs

1use super::*;
2
3/// Macro used for defining logic to register the internal GMS2 calls.
4///
5/// # Args
6/// - `$name`: Name that will be used to create statics and functions (uppercase).
7/// - `$fun_type`: Type of the internal GMS2 function. (src/ds_map/types.rs)
8macro_rules! define_internal_call {
9    ($name:ty, $fun_type:ty) => { paste! {
10        // Holds an address of the internal GMS2 function.
11        static mut [<ADDR_ $name>]: FnAddr = 0;
12        // Holds a pointer to the internal GMS2 function.
13        pub(super) static mut [<FN_ $name>]: *mut $fun_type = std::ptr::null_mut();
14
15        // Used to save the internal GMS2 function.
16        pub(super) unsafe fn [<register_ $name:lower>](addr: FnAddr) {
17            [<ADDR_ $name>] = addr;
18            [<FN_ $name>] = (&[<ADDR_ $name>] as *const FnAddr) as *mut $fun_type;
19        }
20    } }
21}
22
23define_internal_call!(EVENT_PERFORM_ASYNC, EventPerformAsync);
24define_internal_call!(DS_MAP_CREATE, DsMapCreate);
25define_internal_call!(DS_MAP_ADD_DOUBLE, DsMapAddDouble);
26define_internal_call!(DS_MAP_ADD_STRING, DsMapAddString);