Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::os::raw::c_void;
- type IUnknownVPtr = c_void;
- struct BritishShortHairCat {
- }
- trait ComInterface {
- fn gen_vtable<T, P>();
- }
- trait ICat {
- }
- impl ComInterface for dyn ICat {
- fn gen_vtable<T, P>() {
- macro_rules! icat_gen_vtable {
- ($generic:ty, $offset:ty) => {
- IAnimal::gen_vtable::<$generic, $offset>();
- unsafe extern "stdcall" fn add_ref<T, P: Offset>(this: *mut IUnknownVPtr) {
- println!("Offset value: {}", P::value());
- let this = this.sub(P::value()) as *mut T;
- // (*this).add_ref();
- }
- }
- }
- icat_gen_vtable!(T, P);
- }
- }
- trait IAnimal {
- }
- impl ComInterface for dyn IAnimal {
- fn gen_vtable<T, P>() {
- macro_rules! ianimal_gen_vtable {
- ($generic:ty, $offset:ty) => {
- }
- }
- ianimal_gen_vtable!(T, P);
- }
- }
- fn main() {
- ICat::gen_vtable::<BritishShortHairCat, ONE>();
- }
- trait Offset {
- fn value() -> usize;
- }
- struct ONE {}
- impl Offset for ONE {
- fn value() -> usize {
- 1
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement