#![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; // We need the IID and Vtbl to ensure this compiles. // // Normally these are provided by the [com_interface]. #[allow(non_camel_case_types)] struct __Foo_AutomationVtbl; const IID_Foo_Automation: intercom::IID = intercom::GUID { data1: 0, data2: 0, data3: 0, data4: [0, 0, 0, 0, 0, 0, 0, 0], }; #[allow(non_camel_case_types)] struct __Foo_RawVtbl; const IID_Foo_Raw: intercom::IID = intercom::GUID { data1: 0, data2: 0, data3: 0, data4: [0, 0, 0, 0, 0, 0, 0, 0], }; fn get_intercom_interface_info_for_Foo() -> Vec { unsafe { MaybeUninit::uninit().assume_init() } } pub struct Foo; impl intercom::IUnknown for Foo {} impl intercom::attributes::HasInterface for Foo {} #[allow(non_snake_case)] impl intercom::attributes::ComClassInterface for Foo { #[inline(always)] fn offset() -> usize { unsafe { &intercom::ComBoxData::::null_vtable().Foo_Automation as *const _ as usize } } } #[allow(non_snake_case)] impl intercom::attributes::ComClassInterface for Foo { #[inline(always)] fn offset() -> usize { unsafe { &intercom::ComBoxData::::null_vtable().Foo_Raw as *const _ as usize } } } #[allow(non_snake_case)] impl intercom::attributes::ComClassInterface< dyn intercom::ISupportErrorInfo, intercom::type_system::AutomationTypeSystem, > for Foo { #[inline(always)] fn offset() -> usize { 0 } } impl intercom::attributes::HasInterface for Foo {} #[allow(non_snake_case)] #[doc(hidden)] pub struct __intercom_vtable_for_Foo { _ISupportErrorInfo: &'static >::VTable, Foo_Automation: &'static <::TSelf as intercom::attributes::ComInterfaceVariant>::VTable, Foo_Raw: &'static <::TSelf as intercom::attributes::ComInterfaceVariant>::VTable, } #[automatically_derived] #[allow(unused_qualifications)] #[allow(non_snake_case)] impl ::core::clone::Clone for __intercom_vtable_for_Foo { #[inline] fn clone(&self) -> __intercom_vtable_for_Foo { { let _: ::core::clone::AssertParamIsClone<&'static >::VTable>; let _: ::core::clone::AssertParamIsClone<&'static <::TSelf as intercom::attributes::ComInterfaceVariant>::VTable>; let _: ::core::clone::AssertParamIsClone<&'static <::TSelf as intercom::attributes::ComInterfaceVariant>::VTable>; *self } } } #[automatically_derived] #[allow(unused_qualifications)] #[allow(non_snake_case)] impl ::core::marker::Copy for __intercom_vtable_for_Foo {} #[allow(non_snake_case)] pub struct Static__intercom_vtable_for_Foo { Foo_Automation: <::TSelf as intercom::attributes::ComInterfaceVariant>::VTable, Foo_Raw: <::TSelf as intercom::attributes::ComInterfaceVariant>::VTable, } #[allow(clippy::all)] impl intercom::attributes::ComClass for Foo { type VTableList = __intercom_vtable_for_Foo; const VTABLE: Self::VTableList = __intercom_vtable_for_Foo { _ISupportErrorInfo: &>::VTABLE, Foo_Automation: &>::VTABLE, Foo_Raw: &>::VTABLE, }; fn query_interface( vtables: &Self::VTableList, riid: intercom::REFIID, ) -> intercom::RawComResult { if riid.is_null() { intercom::logging::error(|l| { l( "testcrate", ::core::fmt::Arguments::new_v1( &["[", "] ", "::query_interface(NULL)"], &[ ::core::fmt::ArgumentV1::new_pointer(&vtables), ::core::fmt::ArgumentV1::new_display(&"Foo"), ], ), ) }); return Err(intercom::raw::E_NOINTERFACE); } unsafe { let riid = &*riid; intercom::logging::trace(|l| { l( "testcrate", ::core::fmt::Arguments::new_v1_formatted( &["[", "] ", "::query_interface(", ")"], &[ ::core::fmt::ArgumentV1::new_pointer(&vtables), ::core::fmt::ArgumentV1::new_display(&"Foo"), ::core::fmt::ArgumentV1::new_upper_hex(&riid), ], &[ ::core::fmt::rt::v1::Argument { position: 0usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 0u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }, ::core::fmt::rt::v1::Argument { position: 1usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 0u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }, ::core::fmt::rt::v1::Argument { position: 2usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 2u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }, ], unsafe { ::core::fmt::UnsafeArg::new() }, ), ) }); Ok(if riid == >::iid() { let ptr = (&vtables._ISupportErrorInfo) as *const &>::VTable as *mut &>::VTable as intercom::raw::RawComPtr; intercom::logging::trace(|l| l("testcrate", ::core::fmt::Arguments::new_v1_formatted(&["[", "] ", "::query_interface(", ") -> IUnknown [", "]"], &[::core::fmt::ArgumentV1::new_pointer(&vtables), ::core::fmt::ArgumentV1::new_display(&"Foo"), ::core::fmt::ArgumentV1::new_upper_hex(&riid), ::core::fmt::ArgumentV1::new_pointer(&ptr)], &[::core::fmt::rt::v1::Argument { position: 0usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 0u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }, ::core::fmt::rt::v1::Argument { position: 1usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 0u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }, ::core::fmt::rt::v1::Argument { position: 2usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 2u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }, ::core::fmt::rt::v1::Argument { position: 3usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 0u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }], unsafe { ::core::fmt::UnsafeArg::new() }))); ptr } else if riid == >::iid() { let ptr = (&vtables._ISupportErrorInfo) as *const &>::VTable as *mut &>::VTable as intercom::raw::RawComPtr; intercom::logging::trace(|l| l("testcrate", ::core::fmt::Arguments::new_v1_formatted(&["[", "] ", "::query_interface(", ") -> ISupportErrorInfo [", "]"], &[::core::fmt::ArgumentV1::new_pointer(&vtables), ::core::fmt::ArgumentV1::new_display(&"Foo"), ::core::fmt::ArgumentV1::new_upper_hex(&riid), ::core::fmt::ArgumentV1::new_pointer(&ptr)], &[::core::fmt::rt::v1::Argument { position: 0usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 0u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }, ::core::fmt::rt::v1::Argument { position: 1usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 0u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }, ::core::fmt::rt::v1::Argument { position: 2usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 2u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }, ::core::fmt::rt::v1::Argument { position: 3usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 0u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }], unsafe { ::core::fmt::UnsafeArg::new() }))); ptr } else if riid == <::TSelf as intercom::attributes::ComInterfaceVariant>::iid() { let ptr = &vtables.Foo_Automation as *const &<::TSelf as intercom::attributes::ComInterfaceVariant>::VTable as *mut &<::TSelf as intercom::attributes::ComInterfaceVariant>::VTable as intercom::raw::RawComPtr; intercom::logging::trace(|l| l("testcrate", ::core::fmt::Arguments::new_v1_formatted(&["[", "] ", "::query_interface(", ") -> ", " (", ") [", "]"], &[::core::fmt::ArgumentV1::new_pointer(&vtables), ::core::fmt::ArgumentV1::new_display(&"Foo"), ::core::fmt::ArgumentV1::new_upper_hex(&riid), ::core::fmt::ArgumentV1::new_display(&"Foo"), ::core::fmt::ArgumentV1::new_display(&"Automation"), ::core::fmt::ArgumentV1::new_pointer(&ptr)], &[::core::fmt::rt::v1::Argument { position: 0usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 0u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }, ::core::fmt::rt::v1::Argument { position: 1usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 0u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }, ::core::fmt::rt::v1::Argument { position: 2usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 2u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }, ::core::fmt::rt::v1::Argument { position: 3usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 0u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }, ::core::fmt::rt::v1::Argument { position: 4usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 0u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }, ::core::fmt::rt::v1::Argument { position: 5usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 0u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }], unsafe { ::core::fmt::UnsafeArg::new() }))); ptr } else if riid == <::TSelf as intercom::attributes::ComInterfaceVariant>::iid() { let ptr = &vtables.Foo_Raw as *const &<::TSelf as intercom::attributes::ComInterfaceVariant>::VTable as *mut &<::TSelf as intercom::attributes::ComInterfaceVariant>::VTable as intercom::raw::RawComPtr; intercom::logging::trace(|l| l("testcrate", ::core::fmt::Arguments::new_v1_formatted(&["[", "] ", "::query_interface(", ") -> ", " (", ") [", "]"], &[::core::fmt::ArgumentV1::new_pointer(&vtables), ::core::fmt::ArgumentV1::new_display(&"Foo"), ::core::fmt::ArgumentV1::new_upper_hex(&riid), ::core::fmt::ArgumentV1::new_display(&"Foo"), ::core::fmt::ArgumentV1::new_display(&"Raw"), ::core::fmt::ArgumentV1::new_pointer(&ptr)], &[::core::fmt::rt::v1::Argument { position: 0usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 0u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }, ::core::fmt::rt::v1::Argument { position: 1usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 0u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }, ::core::fmt::rt::v1::Argument { position: 2usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 2u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }, ::core::fmt::rt::v1::Argument { position: 3usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 0u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }, ::core::fmt::rt::v1::Argument { position: 4usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 0u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }, ::core::fmt::rt::v1::Argument { position: 5usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 0u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }], unsafe { ::core::fmt::UnsafeArg::new() }))); ptr } else { intercom::logging::trace(|l| l("testcrate", ::core::fmt::Arguments::new_v1_formatted(&["[", "] ", "::query_interface(", ") -> E_NOINTERFACE"], &[::core::fmt::ArgumentV1::new_pointer(&vtables), ::core::fmt::ArgumentV1::new_display(&"Foo"), ::core::fmt::ArgumentV1::new_upper_hex(&riid)], &[::core::fmt::rt::v1::Argument { position: 0usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 0u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }, ::core::fmt::rt::v1::Argument { position: 1usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 0u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }, ::core::fmt::rt::v1::Argument { position: 2usize, format: ::core::fmt::rt::v1::FormatSpec { fill: ' ', align: ::core::fmt::rt::v1::Alignment::Unknown, flags: 2u32, precision: ::core::fmt::rt::v1::Count::Implied, width: ::core::fmt::rt::v1::Count::Implied, }, }], unsafe { ::core::fmt::UnsafeArg::new() }))); return Err(intercom::raw::E_NOINTERFACE) }) } } fn interface_supports_error_info(riid: intercom::REFIID) -> bool { if riid.is_null() { return false; } unsafe { let riid = &*riid; if riid == <::TSelf as intercom::attributes::ComInterfaceVariant>::iid() { true } else if riid == <::TSelf as intercom::attributes::ComInterfaceVariant>::iid() { true } else { false } } } } #[allow(non_upper_case_globals)] #[doc = "`Foo` class ID."] pub const CLSID_Foo: intercom::CLSID = intercom::GUID { data1: 0u32, data2: 0u16, data3: 0u16, data4: [0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8], }; impl intercom::attributes::ComClassTypeInfo for Foo { fn gather_type_info() -> Vec { let mut r = // Should be VARIANT_BOOL in Automation interface. <[_]>::into_vec(#[rustc_box] ::alloc::boxed::Box::new([intercom::typelib::TypeInfo::Class(intercom::ComBox::new(intercom::typelib::CoClass::__new("Foo".into(), intercom::GUID { data1: 0u32, data2: 0u16, data3: 0u16, data4: [0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8], }, <[_]>::into_vec(#[rustc_box] ::alloc::boxed::Box::new([intercom::typelib::InterfaceRef { name: "Foo".into(), iid_automation: <::TSelf as intercom::attributes::ComInterfaceVariant>::iid().clone(), iid_raw: <::TSelf as intercom::attributes::ComInterfaceVariant>::iid().clone(), }])))))])); r.extend(::gather_type_info()); r } } impl Foo { fn static_method(a: u16, b: i16) {} fn simple_method(&self) {} fn arg_method(&self, a: u16) {} fn simple_result_method(&self) -> u16 { 0 } fn com_result_method(&self) -> ComResult { Ok(0) } fn rust_result_method(&self) -> Result { Ok(0) } fn tuple_result_method(&self) -> Result<(u8, u16, u32), i32> { Ok(0) } fn string_method(&self, input: String) -> String { input } fn string_result_method(&self, input: String) -> ComResult { Ok(input) } fn complete_method(&mut self, a: u16, b: i16) -> ComResult { Ok(true) } fn bool_method(&self, input: bool) -> ComResult { Ok(input) } fn variant_method(&self, input: Variant) -> ComResult { Ok(input) } }