#![feature(prelude_import)]
#![no_std]
#[prelude_import]
use std::prelude::rust_2015::*;
#[macro_use]
extern crate std;
extern crate intercom;
use intercom::*;
use std::mem::MaybeUninit;
pub mod some {
pub mod path {
use std::mem::MaybeUninit;
pub struct Type;
pub const CLSID_Type: i8 = 0i8;
pub(crate) fn get_intercom_coclass_info_for_Type() -> intercom::typelib::TypeInfo {
unsafe { MaybeUninit::uninit().assume_init() }
}
}
}
pub struct SimpleType;
pub const CLSID_SimpleType: i8 = 0i8;
pub(crate) fn get_intercom_coclass_info_for_SimpleType() -> intercom::typelib::TypeInfo {
unsafe { MaybeUninit::uninit().assume_init() }
}
#[allow(dead_code)]
#[doc(hidden)]
pub unsafe fn __get_module_class_factory(
rclsid: intercom::REFCLSID,
riid: intercom::REFIID,
pout: *mut intercom::raw::RawComPtr,
) -> Option<intercom::raw::HRESULT> {
match *rclsid {
some::path::CLSID_Type => {
return Some(intercom::ClassFactory::<some::path::Type>::create(
riid, pout,
))
}
CLSID_SimpleType => return Some(intercom::ClassFactory::<SimpleType>::create(riid, pout)),
_ => {}
};
None
}
#[no_mangle]
#[allow(non_snake_case)]
#[allow(dead_code)]
#[doc(hidden)]
pub unsafe extern "system" fn DllGetClassObject(
rclsid: intercom::REFCLSID,
riid: intercom::REFIID,
pout: *mut intercom::raw::RawComPtr,
) -> intercom::raw::HRESULT {
if let Some(hr) = __get_module_class_factory(rclsid, riid, pout) {
return hr;
}
if let Some(hr) = intercom::__get_module_class_factory(rclsid, riid, pout) {
return hr;
}
intercom::raw::E_CLASSNOTAVAILABLE
}
#[doc(hidden)]
static mut __INTERCOM_DLL_INSTANCE: *mut std::os::raw::c_void = 0 as _;
#[no_mangle]
#[allow(non_camel_case_types)]
#[deprecated]
#[doc(hidden)]
pub extern "system" fn DllMain(
dll_instance: *mut std::os::raw::c_void,
reason: u32,
_reserved: *mut std::os::raw::c_void,
) -> bool {
match reason {
1 => unsafe {
__INTERCOM_DLL_INSTANCE = dll_instance;
},
_ => {}
}
true
}
pub fn __gather_module_types() -> Vec<intercom::typelib::TypeInfo> {
<[_]>::into_vec(
#[rustc_box]
::alloc::boxed::Box::new([
<some::path::Type as intercom::attributes::ComClassTypeInfo>::gather_type_info(),
<SimpleType as intercom::attributes::ComClassTypeInfo>::gather_type_info(),
]),
)
.into_iter()
.flatten()
.collect()
}
#[no_mangle]
pub unsafe extern "system" fn IntercomTypeLib(
type_system: intercom::type_system::TypeSystemName,
out: *mut intercom::raw::RawComPtr,
) -> intercom::raw::HRESULT {
let mut tlib = intercom::ComBox::new(intercom::typelib::TypeLib::__new(
"TestLib".into(),
intercom::GUID {
data1: 0u32,
data2: 0u16,
data3: 0u16,
data4: [0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8],
},
"0.1".into(),
intercom::__gather_module_types()
.into_iter()
.chain(__gather_module_types())
.collect(),
));
let rc = intercom::ComRc::<intercom::typelib::IIntercomTypeLib>::from(&tlib);
let itf = intercom::ComRc::detach(rc);
*out = type_system.get_ptr(&itf);
intercom::raw::S_OK
}
#[no_mangle]
#[allow(non_snake_case)]
#[allow(dead_code)]
#[doc(hidden)]
pub unsafe extern "system" fn IntercomListClassObjects(
pcount: *mut usize,
pclsids: *mut *const intercom::CLSID,
) -> intercom::raw::HRESULT {
if pcount.is_null() {
return intercom::raw::E_POINTER;
}
if pclsids.is_null() {
return intercom::raw::E_POINTER;
}
static mut AVAILABLE_CLASSES: Option<Vec<intercom::CLSID>> = None;
static INIT_AVAILABLE_CLASSES: std::sync::Once = std::sync::Once::new();
INIT_AVAILABLE_CLASSES.call_once(|| unsafe {
AVAILABLE_CLASSES = Some(
__gather_module_types()
.into_iter()
.chain(intercom::__gather_module_types())
.filter_map(|ty| match ty {
intercom::typelib::TypeInfo::Class(cls) => Some(cls.clsid.clone()),
_ => None,
})
.collect(),
);
});
let available_classes = AVAILABLE_CLASSES
.as_ref()
.expect("AVAILABLE_CLASSES was not initialized");
*pcount = available_classes.len();
*pclsids = available_classes.as_ptr();
intercom::raw::S_OK
}
#[no_mangle]
#[allow(non_snake_case)]
#[allow(dead_code)]
#[doc(hidden)]
pub unsafe extern "system" fn DllRegisterServer() -> intercom::raw::HRESULT {
let mut tlib = intercom::typelib::TypeLib::__new(
"TestLib".into(),
intercom::GUID {
data1: 0u32,
data2: 0u16,
data3: 0u16,
data4: [0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8],
},
"0.1".into(),
intercom::__gather_module_types()
.into_iter()
.chain(__gather_module_types())
.collect(),
);
if let Err(hr) = intercom::registry::register(__INTERCOM_DLL_INSTANCE, tlib) {
return hr;
}
intercom::raw::S_OK
}
#[no_mangle]
#[allow(non_snake_case)]
#[allow(dead_code)]
#[doc(hidden)]
pub unsafe extern "system" fn DllUnregisterServer() -> intercom::raw::HRESULT {
let mut tlib = intercom::typelib::TypeLib::__new(
"TestLib".into(),
intercom::GUID {
data1: 0u32,
data2: 0u16,
data3: 0u16,
data4: [0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8],
},
"0.1".into(),
intercom::__gather_module_types()
.into_iter()
.chain(__gather_module_types())
.collect(),
);
if let Err(hr) = intercom::registry::unregister(__INTERCOM_DLL_INSTANCE, tlib) {
return hr;
}
intercom::raw::S_OK
}