This commit is contained in:
Ryan Levick 2019-09-19 17:45:31 +02:00
Родитель e5cc9efad7
Коммит 60a17b4b04
6 изменённых файлов: 11 добавлений и 16 удалений

Просмотреть файл

@ -216,7 +216,7 @@ pub fn gen_aggregate_match_arms(aggr_map: &HashMap<Ident, Vec<Ident>>) -> Helper
let mut aggr_interface_ptr: com::ComPtr<dyn com::interfaces::iunknown::IUnknown> = com::ComPtr::new(self.#aggr_field_ident as *mut winapi::ctypes::c_void);
let hr = aggr_interface_ptr.query_interface(riid, ppv);
if com::failed(hr) {
if com::_winapi::shared::winerror::FAILED(hr) {
*ppv = std::ptr::null_mut::<winapi::ctypes::c_void>();
return winapi::shared::winerror::E_NOINTERFACE;
}

Просмотреть файл

@ -1,10 +1,10 @@
use crate::{failed, interfaces::iunknown::IUnknown, ComInterface, IID};
use crate::{interfaces::iunknown::IUnknown, ComInterface, IID};
use std::ptr::NonNull;
use std::marker::PhantomData;
use winapi::ctypes::c_void;
use winapi::shared::winerror::{E_NOINTERFACE, E_POINTER};
use winapi::shared::winerror::{E_NOINTERFACE, E_POINTER, FAILED};
pub struct ComPtr<T: ?Sized + ComInterface> {
ptr: NonNull<c_void>,
@ -39,7 +39,7 @@ impl<T: ?Sized + ComInterface> ComPtr<T> {
pub fn get_interface<S: ComInterface + ?Sized>(&self) -> Option<ComPtr<S>> {
let mut ppv = std::ptr::null_mut::<c_void>();
let hr = unsafe { self.query_interface(&S::IID as *const IID, &mut ppv) };
if failed(hr) {
if FAILED(hr) {
assert!(
hr == E_NOINTERFACE || hr == E_POINTER,
"QueryInterface returned non-standard error"

Просмотреть файл

@ -202,7 +202,7 @@ macro_rules! inproc_dll_module {
#[no_mangle]
extern "stdcall" fn DllRegisterServer() -> $crate::_winapi::shared::winerror::HRESULT {
let hr = com::register_keys(get_relevant_registry_keys());
if com::failed(hr) {
if com::_winapi::shared::winerror::FAILED(hr) {
DllUnregisterServer();
}

Просмотреть файл

@ -5,11 +5,11 @@ use winapi::{
guiddef::{IID, REFIID},
minwindef::BOOL,
ntdef::HRESULT,
winerror::FAILED,
},
};
use crate::{
failed,
interfaces::iunknown::{IUnknown, IUnknownVPtr},
ComInterface, ComPtr,
};
@ -30,7 +30,7 @@ impl ComPtr<dyn IClassFactory> {
let mut ppv = std::ptr::null_mut::<c_void>();
let aggr = std::ptr::null_mut();
let hr = unsafe { self.create_instance(aggr, &T::IID as *const IID, &mut ppv) };
if failed(hr) {
if FAILED(hr) {
// TODO: decide what failures are possible
return None;
}

Просмотреть файл

@ -9,11 +9,7 @@ pub use inproc::*;
pub use runtime::ApartmentThreadedRuntime;
use interfaces::iunknown::IUnknown;
use winapi::shared::{guiddef::IID, winerror::HRESULT};
pub fn failed(result: HRESULT) -> bool {
result < 0
}
use winapi::shared::guiddef::IID;
/// A COM compliant interface
///

Просмотреть файл

@ -3,7 +3,7 @@ use winapi::{
shared::{
guiddef::{IID, REFCLSID, REFIID},
minwindef::LPVOID,
winerror::{HRESULT, S_FALSE, S_OK},
winerror::{FAILED, HRESULT, S_FALSE, S_OK},
wtypesbase::CLSCTX_INPROC_SERVER,
},
um::{
@ -14,7 +14,6 @@ use winapi::{
};
use crate::{
failed,
interfaces::iclass_factory::{IClassFactory, IID_ICLASS_FACTORY},
CoClass, ComInterface, ComPtr,
};
@ -52,7 +51,7 @@ impl ApartmentThreadedRuntime {
&mut class_factory as *mut LPVOID,
)
};
if failed(hr) {
if FAILED(hr) {
return Err(hr);
}
@ -91,7 +90,7 @@ impl ApartmentThreadedRuntime {
&T::IID as REFIID,
&mut instance as *mut LPVOID,
);
if failed(hr) {
if FAILED(hr) {
return Err(hr);
}