#![crate_type = "dylib"]
#![allow(clippy::match_bool)]
extern crate self as intercom;
#[cfg(not(windows))]
extern crate libc;
extern crate intercom_attributes;
pub use intercom_attributes::*;
#[allow(clippy::useless_attribute)]
#[allow(unused_imports)]
#[macro_use]
extern crate failure;
#[cfg(feature = "log")]
extern crate log;
pub mod prelude;
mod classfactory;
pub use crate::classfactory::*;
mod combox;
pub use crate::combox::*;
mod comrc;
pub use crate::comrc::*;
mod comitf;
pub use crate::comitf::*;
mod strings;
pub use crate::strings::*;
mod guid;
pub use crate::guid::GUID;
pub mod error;
pub use crate::error::{load_error, store_error, ComError, ErrorValue};
pub mod alloc;
pub mod interfaces;
pub mod runtime;
mod variant;
pub use crate::variant::{Variant, VariantError};
pub mod type_system;
pub mod typelib;
pub use type_system::ForeignType;
pub mod attributes;
pub mod logging;
#[cfg(windows)]
pub mod registry;
#[cfg(not(windows))]
pub mod registry
{
use crate::raw::HRESULT;
use crate::typelib::TypeLib;
#[allow(clippy::upper_case_acronyms)]
type HANDLE = *mut std::os::raw::c_void;
pub fn register(_dll: HANDLE, _lib: TypeLib) -> Result<(), HRESULT>
{
Ok(())
}
pub fn unregister(_dll: HANDLE, _lib: TypeLib) -> Result<(), HRESULT>
{
Ok(())
}
}
com_module!(
class intercom::alloc::Allocator,
class intercom::error::ErrorStore,
);
pub type IID = GUID;
pub type REFIID = *const IID;
pub type CLSID = GUID;
pub type REFCLSID = *const IID;
pub mod raw
{
use std::marker::PhantomData;
use std::os::raw::c_void;
use std::ptr::NonNull;
pub use crate::error::raw::*;
pub use crate::type_system::{ForeignType, TypeSystem};
pub use crate::variant::raw::*;
pub type RawComPtr = *mut c_void;
#[derive(
Clone,
Copy,
intercom_attributes::ExternType,
intercom_attributes::ExternInput,
intercom_attributes::ExternOutput,
intercom_attributes::ForeignType,
)]
#[repr(transparent)]
pub struct BSTR(pub *mut u16);
#[repr(transparent)]
#[derive(PartialEq, Eq)]
pub struct InterfacePtr<TS: TypeSystem, I: ?Sized>
{
pub ptr: NonNull<c_void>,
phantom_itf: PhantomData<I>,
phantom_ts: PhantomData<TS>,
}
impl<TS: TypeSystem, I: ?Sized> Clone for InterfacePtr<TS, I>
{
fn clone(&self) -> Self
{
InterfacePtr {
ptr: self.ptr,
phantom_itf: PhantomData,
phantom_ts: PhantomData,
}
}
}
impl<TS: TypeSystem, I: ?Sized> Copy for InterfacePtr<TS, I> {}
impl<TS: TypeSystem, I: ?Sized> std::fmt::Debug for InterfacePtr<TS, I>
{
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result
{
write!(f, "InterfacePtr({:?})", self.ptr)
}
}
impl<TS: TypeSystem, I: ?Sized> InterfacePtr<TS, I>
{
pub unsafe fn new(ptr: RawComPtr) -> Option<InterfacePtr<TS, I>>
{
let ptr = NonNull::new(ptr);
ptr.map(|ptr| InterfacePtr {
ptr,
phantom_itf: PhantomData,
phantom_ts: PhantomData,
})
}
}
impl<TS: TypeSystem, I: crate::attributes::ComInterface + ?Sized> InterfacePtr<TS, I>
{
pub fn as_unknown(self) -> InterfacePtr<TS, dyn crate::IUnknown>
{
InterfacePtr {
ptr: self.ptr,
phantom_itf: PhantomData,
phantom_ts: PhantomData,
}
}
}
impl<TS: TypeSystem, I: crate::attributes::ComInterface + ?Sized> ForeignType
for Option<InterfacePtr<TS, I>>
where
I: ForeignType,
{
fn type_name() -> &'static str
{
<I as ForeignType>::type_name()
}
fn indirection_level() -> u32
{
<I as ForeignType>::indirection_level() + 1
}
}
}
#[allow(non_upper_case_globals)]
pub const IID_IClassFactory: GUID = GUID {
data1: 0x0000_0001,
data2: 0x0000,
data3: 0x0000,
data4: [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46],
};
#[allow(non_upper_case_globals)]
pub const IID_IErrorInfo: GUID = GUID {
data1: 0x1CF2_B120,
data2: 0x547D,
data3: 0x101B,
data4: [0x8E, 0x65, 0x08, 0x00, 0x2B, 0x2B, 0xD1, 0x19],
};
pub use crate::interfaces::IUnknown;
pub use crate::interfaces::ISupportErrorInfo;
pub type ComResult<A> = Result<A, ComError>;
pub type RawComResult<A> = Result<A, raw::HRESULT>;