5 releases
0.2.1 | Oct 31, 2022 |
---|---|
0.2.0 | Oct 24, 2022 |
0.1.2 | Sep 5, 2022 |
0.1.1 | Sep 5, 2022 |
0.1.0 | Sep 5, 2022 |
#203 in FFI
10KB
226 lines
Nano-COM
See Nano-COM.
Function Stack
- a public function.
let o: Object<IMy> = ...; // calling a public function let i: u32 = o.B();
trait IMyEx { // a definition fn B(&self) -> u32; } impl IMyEx for Object<IMy> { // an implementation of the public function fn B(&self) -> u32 { // calling a virtual function. unsafe { (self.interface().B()(self) } } }
- a virtual function.
#[repr(C)] pub struct IMy { // a definiton of the virtual function pub B: unsafe extern "stdcall" fn(this: &Object<IMy>) -> u32 } trait IMyVmtFn: Class<Interface = IMy> where CObject<Self>: IMyEx { // an implementation of the virtual function extern "stdcall" fn B(this: &Object<IMy>) -> u32 { // calling a function implementation unsafe { Self::to_cobject(this) }.B() } }
- a function implementation.
trait IMyEx { // a definition fn B(&self) -> u32; } impl IMyEx for CObject<X> { // an implementation of the function. fn B(&self) -> u32 { self.value.0 } }