mhgu-forge-sys 1.1.3

Raw FFI bindings to the forge plugin API
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use core::ffi::c_void;

/// Declares a type as having a C++ virtual function table.
/// Structs that implement this trait should only ever exist as pointers/references
/// from the game itself. They should never be instantiated directly.
///
/// This trait can be implemented with a `derive`
/// ```ignore
/// #[derive(forge::HasVtable)]
/// pub struct MyStruct;
/// ```
pub trait HasVtable {
    fn vtable_ptr(&self) -> *const *const c_void;

    fn get_virtual_function(&self, index: usize) -> *const c_void {
        unsafe { *self.vtable_ptr().add(index) }
    }
}