Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 4ffbe21

Browse files
committed
Address PRs
1 parent 61d67dd commit 4ffbe21

File tree

9 files changed

+28
-24
lines changed

9 files changed

+28
-24
lines changed

examples/aggregation/server/src/local_file_manager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use interface::ilocal_file_manager::ILocalFileManager;
22

33
use com::co_class;
4-
use com::sys::HRESULT;
4+
use com::sys::{HRESULT, NOERROR};
55

66
/// The implementation class
77
#[co_class(implements(ILocalFileManager), aggregatable)]
@@ -12,7 +12,7 @@ pub struct LocalFileManager {
1212
impl ILocalFileManager for LocalFileManager {
1313
unsafe fn delete_local(&self) -> HRESULT {
1414
println!("Deleting Locally...");
15-
0
15+
NOERROR
1616
}
1717
}
1818

examples/aggregation/server/src/windows_file_manager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use interface::{
66
};
77

88
use com::co_class;
9-
use com::sys::HRESULT;
9+
use com::sys::{HRESULT, NOERROR};
1010

1111
/// The implementation class
1212
#[co_class(implements(IFileManager), aggregates(ILocalFileManager))]
@@ -17,7 +17,7 @@ pub struct WindowsFileManager {
1717
impl IFileManager for WindowsFileManager {
1818
unsafe fn delete_all(&self) -> HRESULT {
1919
println!("Deleting all by delegating to Local and Remote File Managers...");
20-
0
20+
NOERROR
2121
}
2222
}
2323

examples/basic/server/src/british_short_hair_cat.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use interface::{ianimal::IAnimal, icat::ICat, idomesticanimal::IDomesticAnimal};
22

33
use com::co_class;
4-
use com::sys::HRESULT;
4+
use com::sys::{HRESULT, NOERROR};
55

66
/// The implementation class
77
/// https://en.wikipedia.org/wiki/British_Shorthair
@@ -13,21 +13,21 @@ pub struct BritishShortHairCat {
1313
impl IDomesticAnimal for BritishShortHairCat {
1414
unsafe fn train(&self) -> HRESULT {
1515
println!("Training...");
16-
0
16+
NOERROR
1717
}
1818
}
1919

2020
impl ICat for BritishShortHairCat {
2121
unsafe fn ignore_humans(&self) -> HRESULT {
2222
println!("Ignoring Humans...");
23-
0
23+
NOERROR
2424
}
2525
}
2626

2727
impl IAnimal for BritishShortHairCat {
2828
unsafe fn eat(&self) -> HRESULT {
2929
println!("Eating...");
30-
0
30+
NOERROR
3131
}
3232
}
3333

macros/support/src/aggr_co_class/iunknown_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use syn::ItemStruct;
88
pub fn generate(struct_item: &ItemStruct) -> HelperTokenStream {
99
let struct_ident = &struct_item.ident;
1010
let iunknown_to_use_field_ident = crate::utils::iunknown_to_use_field_ident();
11-
let ptr_casting = quote! { as *mut std::ffi::c_void };
11+
let ptr_casting = quote! { as *mut _ };
1212

1313
quote!(
1414
impl com::interfaces::iunknown::IUnknown for #struct_ident {

macros/support/src/co_class/com_struct_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ pub fn gen_set_aggregate_fns(aggr_map: &HashMap<Ident, Vec<Ident>>) -> HelperTok
151151
let set_aggregate_fn_ident = crate::utils::set_aggregate_fn_ident(&base);
152152
fns.push(quote!(
153153
fn #set_aggregate_fn_ident(&mut self, aggr: com::InterfacePtr<dyn com::interfaces::iunknown::IUnknown>) {
154-
// TODO: What happens if we are overwriting an existing aggregate?
154+
// FaTODO: What happens if we are overwriting an existing aggregate?
155155
self.#aggr_field_ident = aggr.as_raw() as *mut *const <dyn com::interfaces::iunknown::IUnknown as com::ComInterface>::VTable;
156156
}
157157
));

macros/support/src/co_class/iunknown_impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn gen_aggregate_drops(aggr_map: &HashMap<Ident, Vec<Ident>>) -> HelperTokenStre
9191
let aggregate_drops = aggr_map.iter().map(|(aggr_field_ident, _)| {
9292
quote!(
9393
if !self.#aggr_field_ident.is_null() {
94-
let mut aggr_interface_ptr = com::InterfacePtr::<dyn com::interfaces::iunknown::IUnknown>::new(self.#aggr_field_ident as *mut std::ffi::c_void);
94+
let mut aggr_interface_ptr = com::InterfacePtr::<dyn com::interfaces::iunknown::IUnknown>::new(self.#aggr_field_ident as *mut _);
9595
aggr_interface_ptr.release();
9696
}
9797
)
@@ -208,7 +208,7 @@ pub fn gen_aggregate_match_arms(aggr_map: &HashMap<Ident, Vec<Ident>>) -> Helper
208208
return com::sys::E_NOINTERFACE;
209209
}
210210

211-
let mut aggr_interface_ptr = com::InterfacePtr::<dyn com::interfaces::iunknown::IUnknown>::new(self.#aggr_field_ident as *mut std::ffi::c_void);
211+
let mut aggr_interface_ptr = com::InterfacePtr::<dyn com::interfaces::iunknown::IUnknown>::new(self.#aggr_field_ident as *mut _);
212212
let hr = aggr_interface_ptr.query_interface(riid, ppv);
213213
if com::sys::FAILED(hr) {
214214
*ppv = std::ptr::null_mut::<std::ffi::c_void>();

src/inproc.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::interfaces::iunknown::IUnknown;
22
use crate::sys::{
33
GetModuleFileNameA, GetModuleHandleA, RegCloseKey, RegCreateKeyExA, RegDeleteKeyA,
4-
RegSetValueExA, ERROR_SUCCESS, HRESULT, IID, SELFREG_E_CLASS, S_OK,
4+
RegSetValueExA, ERROR_SUCCESS, HRESULT, IID, LSTATUS, SELFREG_E_CLASS, S_OK,
55
};
66

77
use std::convert::TryInto;
@@ -50,7 +50,7 @@ pub fn unregister_keys(registry_keys_to_remove: Vec<RegistryKeyInfo>) -> HRESULT
5050
const HKEY_CLASSES_ROOT: *mut c_void = 0x8000_0000 as *mut c_void;
5151
const KEY_ALL_ACCESS: u32 = 0x000F_003F;
5252
const REG_OPTION_NON_VOLATILE: u32 = 0x00000000;
53-
fn create_class_key(key_info: &RegistryKeyInfo) -> Result<*mut c_void, i32> {
53+
fn create_class_key(key_info: &RegistryKeyInfo) -> Result<*mut c_void, LSTATUS> {
5454
let hk_result = std::ptr::null_mut::<c_void>();
5555
let lp_class = std::ptr::null_mut::<u8>();
5656
let lp_security_attributes = std::ptr::null_mut::<c_void>();
@@ -76,7 +76,10 @@ fn create_class_key(key_info: &RegistryKeyInfo) -> Result<*mut c_void, i32> {
7676
}
7777

7878
const REG_SZ: u32 = 1;
79-
fn set_class_key(key_handle: *mut c_void, key_info: &RegistryKeyInfo) -> Result<*mut c_void, i32> {
79+
fn set_class_key(
80+
key_handle: *mut c_void,
81+
key_info: &RegistryKeyInfo,
82+
) -> Result<*mut c_void, LSTATUS> {
8083
let result = unsafe {
8184
RegSetValueExA(
8285
key_handle,
@@ -99,7 +102,7 @@ fn set_class_key(key_handle: *mut c_void, key_info: &RegistryKeyInfo) -> Result<
99102
Ok(key_handle)
100103
}
101104

102-
fn add_class_key(key_info: &RegistryKeyInfo) -> i32 {
105+
fn add_class_key(key_info: &RegistryKeyInfo) -> LSTATUS {
103106
let key_handle = match create_class_key(key_info) {
104107
Ok(key_handle) => key_handle,
105108
Err(e) => {
@@ -117,7 +120,7 @@ fn add_class_key(key_info: &RegistryKeyInfo) -> i32 {
117120
unsafe { RegCloseKey(key_handle) }
118121
}
119122

120-
fn remove_class_key(key_info: &RegistryKeyInfo) -> i32 {
123+
fn remove_class_key(key_info: &RegistryKeyInfo) -> LSTATUS {
121124
unsafe { RegDeleteKeyA(HKEY_CLASSES_ROOT, key_info.key_path.as_ptr()) }
122125
}
123126

src/runtime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ impl ApartmentThreadedRuntime {
6969
clsid: &IID,
7070
outer: &mut U,
7171
) -> Result<InterfacePtr<T>, HRESULT> {
72-
unsafe { self.create_raw_instance::<T>(clsid, outer as *mut U as *mut *const c_void) }
72+
unsafe { self.create_raw_instance::<T>(clsid, outer as *mut U as *mut c_void) }
7373
}
7474

7575
pub unsafe fn create_raw_instance<T: ComInterface + ?Sized>(
7676
&self,
7777
clsid: &IID,
78-
outer: *mut *const c_void,
78+
outer: *mut c_void,
7979
) -> Result<InterfacePtr<T>, HRESULT> {
8080
let mut instance = std::ptr::null_mut::<c_void>();
8181
let hr = CoCreateInstance(

src/sys.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub fn FAILED(result: HRESULT) -> bool {
66
result < 0
77
}
88
pub type BOOL = i32;
9+
pub type LSTATUS = i32;
910

1011
pub const S_OK: HRESULT = 0;
1112
pub const NOERROR: HRESULT = 0;
@@ -41,18 +42,18 @@ extern "system" {
4142
lpSecurityAttributes: *mut c_void,
4243
phkResult: *mut *mut c_void,
4344
lpdwDisposition: *mut u32,
44-
) -> i32;
45+
) -> LSTATUS;
4546
pub fn GetModuleFileNameA(hModule: *mut c_void, lpFilename: *mut i8, nSize: u32) -> u32;
46-
pub fn RegCloseKey(hKey: *mut c_void) -> i32;
47+
pub fn RegCloseKey(hKey: *mut c_void) -> LSTATUS;
4748
pub fn RegSetValueExA(
4849
hKey: *mut c_void,
4950
lpValueName: *const i8,
5051
Reserved: u32,
5152
dwType: u32,
5253
lpData: *const u8,
5354
cbData: u32,
54-
) -> i32;
55-
pub fn RegDeleteKeyA(hKey: *mut c_void, lpSubKey: *const i8) -> i32;
55+
) -> LSTATUS;
56+
pub fn RegDeleteKeyA(hKey: *mut c_void, lpSubKey: *const i8) -> LSTATUS;
5657
pub fn GetModuleHandleA(lpModuleName: *const i8) -> *mut c_void;
5758
pub fn CoInitializeEx(pvReserved: *mut c_void, dwCoInit: u32) -> HRESULT;
5859
pub fn CoGetClassObject(
@@ -64,7 +65,7 @@ extern "system" {
6465
) -> HRESULT;
6566
pub fn CoCreateInstance(
6667
rclsid: *const IID,
67-
pUnkOuter: *mut *const c_void,
68+
pUnkOuter: *mut c_void,
6869
dwClsContext: u32,
6970
riid: *const IID,
7071
ppv: *mut *mut c_void,

0 commit comments

Comments
 (0)