Crates.io | vtables |
lib.rs | vtables |
version | 0.1.0 |
source | src |
created_at | 2021-07-22 21:40:05.508646 |
updated_at | 2021-07-22 21:40:05.508646 |
description | Interact with C++ virtual method tables from Rust |
homepage | https://github.com/not-wlan/vtables |
repository | https://github.com/not-wlan/vtables |
max_upload_size | |
id | 426051 |
size | 37,826 |
Interact with C++ virtual method tables from Rust
Clone both this and vtables_derive and add the following to your Cargo.toml:
[dependencies]
vtables = "0.1"
vtables_derive = "0.1"
You can then use methods from the virtual method table like this:
use vtables::VTable;
use vtables_derive::VTable;
use vtables_derive::has_vtable;
use vtables_derive::virtual_index;
#[has_vtable]
#[derive(VTable, Debug)]
pub struct EngineClient {
}
#[allow(non_snake_case)]
impl EngineClient {
#[virtual_index(5)]
pub fn GetScreenSize(&self, width: *mut i32, height: *mut i32) {}
#[virtual_index(26)]
pub fn IsInGame(&self) -> bool {}
#[virtual_index(108)]
pub fn ExecuteClientCmd(&self, command: *const c_char) {}
#[virtual_index(113)]
pub fn ClientCmd_Unrestricted(&self, command: *const c_char) {}
}
A field containing the virtual method table pointer will automatically be added to your structure. Support for multiple inheritance is untested.