cpp-inherit

Crates.iocpp-inherit
lib.rscpp-inherit
version0.1.1
sourcesrc
created_at2020-07-31 00:17:30.084776
updated_at2020-07-31 01:37:27.186551
descriptionMacros for enabling you to subclass a Rust struct from a C++ class
homepage
repositoryhttps://github.com/jam1garner/cpp-inherit
max_upload_size
id271499
size30,961
(jam1garner)

documentation

https://docs.rs/cpp-inherit

README

cpp-inherit

A macro for inheriting Rust structures from C++ classes. Nothing of value lies here.

Example

use cpp_inherit::*;

#[inherit_from(BaseType)]
#[derive(Debug)]
struct RustType {}

#[inherit_from_impl(BaseType, "test.hpp")]
impl RustType {
    fn new() -> Self {
        Self {
            _base: BaseType { vtable_: RustType::VTABLE_ as _, value: 3 }
        }
    }

    #[overridden] fn x(&self) -> i32 {
        99
    }
}

// Now you can pass RustType as a BaseType, access any BaseType fields, call any BaseType methods (virtual or not), from either C++ or Rust

Rest of example usage here

Commit count: 13

cargo fmt