nanocom

Crates.ionanocom
lib.rsnanocom
version0.2.1
sourcesrc
created_at2022-09-05 00:30:12.458585
updated_at2022-10-31 08:09:36.652149
descriptionNano-COM, extremly small subset of cross-platform COM
homepagehttps://github.com/functionalscript/functionalscript/tree/main/com/rust/nanocom
repositoryhttps://github.com/functionalscript/functionalscript
max_upload_size
id658500
size19,006
Sergey Shandar (sergey-shandar)

documentation

README

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
        }
    }
    
Commit count: 535

cargo fmt