use crate::combox::ComBoxData;
use crate::raw::RawComPtr;
use crate::type_system;
use crate::RawComResult;
use crate::REFIID;
use crate::{type_system::TypeSystem, IID};
pub trait ComClass
{
type VTableList: Copy;
const VTABLE: Self::VTableList;
fn query_interface(vtables: &Self::VTableList, riid: REFIID) -> RawComResult<RawComPtr>;
fn interface_supports_error_info(riid: REFIID) -> bool;
}
pub trait HasInterface<T: ComInterface + ?Sized>: ComClass {}
pub trait ComClassInterface<TInterface: ?Sized, TS: TypeSystem>: ComClass + Sized
{
fn offset() -> usize;
unsafe fn get_box<'a>(vtable: RawComPtr) -> &'a mut ComBoxData<Self>
{
let offset = Self::offset();
let self_ptr = (vtable as usize - offset) as *mut _;
&mut *self_ptr
}
}
pub trait ComInterfaceVTableFor<I: ?Sized, S, TS: TypeSystem>: ComInterfaceVariant<TS>
{
const VTABLE: Self::VTable;
}
pub trait ComInterface
{
type TSelf: ?Sized;
fn iid(ts: type_system::TypeSystemName) -> Option<&'static IID>;
fn iid_ts<TS: intercom::type_system::TypeSystem>() -> &'static intercom::IID
where
Self: intercom::attributes::ComInterfaceVariant<TS>;
fn deref(com_itf: &crate::ComItf<Self>) -> &Self;
}
pub trait ComInterfaceVariant<TS: TypeSystem>
{
type VTable: Copy + 'static;
fn iid() -> &'static IID;
}
pub trait ComClassTypeInfo
{
fn gather_type_info() -> Vec<crate::typelib::TypeInfo>;
}
pub trait ComInterfaceTypeInfo
{
fn gather_type_info() -> Vec<crate::typelib::TypeInfo>;
}