Skip to content

Commit 6c91651

Browse files
committed
naming
1 parent 824843e commit 6c91651

File tree

6 files changed

+40
-40
lines changed

6 files changed

+40
-40
lines changed

crates/libs/core/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ mod guid;
1919
mod handles;
2020
mod inspectable;
2121
mod interface;
22+
mod out_param;
23+
mod out_ref;
2224
mod param;
23-
mod param_mut;
2425
mod param_value;
2526
mod r#ref;
26-
mod ref_mut;
2727
mod runtime_name;
2828
mod runtime_type;
2929
mod scoped_interface;
@@ -41,12 +41,12 @@ pub use guid::*;
4141
pub use handles::*;
4242
pub use inspectable::*;
4343
pub use interface::*;
44+
pub use out_param::*;
45+
pub use out_ref::*;
4446
pub use param::*;
45-
pub use param_mut::*;
4647
pub use param_value::*;
4748
pub use r#ref::*;
4849
pub use r#type::*;
49-
pub use ref_mut::*;
5050
pub use runtime_name::*;
5151
pub use runtime_type::*;
5252
pub use scoped_interface::*;

crates/libs/core/src/param_mut.rs renamed to crates/libs/core/src/out_param.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,50 @@ use super::*;
44
///
55
/// This is a mutable version of [Param] meant to support out parameters.
66
/// There is no need to implement this trait. Blanket implementations are provided for all applicable Windows types.
7-
pub trait ParamMut<T: TypeKind, C = <T as TypeKind>::TypeKind>: Sized
7+
pub trait OutParam<T: TypeKind, C = <T as TypeKind>::TypeKind>: Sized
88
where
99
T: Type<T>,
1010
{
1111
#[doc(hidden)]
12-
unsafe fn borrow_mut(&self) -> RefMut<'_, T>;
12+
unsafe fn borrow_mut(&self) -> OutRef<'_, T>;
1313
}
1414

15-
impl<T> ParamMut<T, CloneType> for &mut T
15+
impl<T> OutParam<T, CloneType> for &mut T
1616
where
1717
T: TypeKind<TypeKind = CloneType> + Clone + Default,
1818
{
19-
unsafe fn borrow_mut(&self) -> RefMut<'_, T> {
19+
unsafe fn borrow_mut(&self) -> OutRef<'_, T> {
2020
let this: &mut T = std::mem::transmute_copy(self);
2121
std::mem::take(this);
2222
std::mem::transmute_copy(self)
2323
}
2424
}
2525

26-
impl<T> ParamMut<T, CopyType> for &mut T
26+
impl<T> OutParam<T, CopyType> for &mut T
2727
where
2828
T: TypeKind<TypeKind = CopyType> + Clone + Default,
2929
{
30-
unsafe fn borrow_mut(&self) -> RefMut<'_, T> {
30+
unsafe fn borrow_mut(&self) -> OutRef<'_, T> {
3131
std::mem::transmute_copy(self)
3232
}
3333
}
3434

35-
impl<T> ParamMut<T, InterfaceType> for &mut Option<T>
35+
impl<T> OutParam<T, InterfaceType> for &mut Option<T>
3636
where
3737
T: TypeKind<TypeKind = InterfaceType> + Clone,
3838
{
39-
unsafe fn borrow_mut(&self) -> RefMut<'_, T> {
39+
unsafe fn borrow_mut(&self) -> OutRef<'_, T> {
4040
let this: &mut Option<T> = std::mem::transmute_copy(self);
4141
std::mem::take(this);
4242
std::mem::transmute_copy(self)
4343
}
4444
}
4545

46-
impl<T> ParamMut<T> for Option<&mut T>
46+
impl<T> OutParam<T> for Option<&mut T>
4747
where
4848
T: Type<T>,
4949
{
50-
unsafe fn borrow_mut(&self) -> RefMut<'_, T> {
50+
unsafe fn borrow_mut(&self) -> OutRef<'_, T> {
5151
match self {
5252
Some(this) => std::mem::transmute_copy(this),
5353
None => std::mem::zeroed(),

crates/libs/core/src/ref_mut.rs renamed to crates/libs/core/src/out_ref.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use super::*;
44
///
55
/// This is a mutable version of [Ref] meant to support out parameters.
66
#[repr(transparent)]
7-
pub struct RefMut<'a, T: Type<T>>(*mut T::Abi, std::marker::PhantomData<&'a T>);
7+
pub struct OutRef<'a, T: Type<T>>(*mut T::Abi, std::marker::PhantomData<&'a T>);
88

9-
impl<'a, T: Type<T>> RefMut<'a, T> {
9+
impl<'a, T: Type<T>> OutRef<'a, T> {
1010
/// Returns `true` if the argument is null.
1111
pub fn is_null(&self) -> bool {
1212
self.0.is_null()

crates/libs/interface/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ impl InterfaceMethod {
563563
if ident == "Ref" {
564564
Some(quote! { #generic_ident: ::windows_core::Param<#ty> })
565565
} else {
566-
Some(quote! { #generic_ident: ::windows_core::ParamMut<#ty> })
566+
Some(quote! { #generic_ident: ::windows_core::OutParam<#ty> })
567567
}
568568
} else {
569569
None
@@ -652,7 +652,7 @@ impl InterfaceMethodArg {
652652
if let syn::Type::Path(path) = &*self.ty {
653653
if let Some(segment) = path.path.segments.last() {
654654
let ident = segment.ident.to_string();
655-
if matches!(ident.as_str(), "Ref" | "RefMut") {
655+
if matches!(ident.as_str(), "Ref" | "OutRef") {
656656
if let syn::PathArguments::AngleBracketed(args) = &segment.arguments {
657657
if args.args.len() == 1 {
658658
if let Some(syn::GenericArgument::Type(ty)) = args.args.first() {

crates/tests/component/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl IActivationFactory_Impl for ClassFactory {
7272
#[no_mangle]
7373
unsafe extern "system" fn DllGetActivationFactory(
7474
name: Ref<HSTRING>,
75-
factory: RefMut<IActivationFactory>,
75+
factory: OutRef<IActivationFactory>,
7676
) -> HRESULT {
7777
if *name == "test_component.Class" {
7878
factory.write(Some(ClassFactory.into())).into()

crates/tests/interface_core/tests/ref.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,59 +9,59 @@ pub const E_POINTER: HRESULT = HRESULT(0x80004003_u32 as _);
99

1010
#[interface("09428a59-5b40-4e4c-9175-e7a78514316d")]
1111
unsafe trait ITest: IUnknown {
12-
// TODO: compile error if param type is not Ref/RefMut and is not Copy
13-
14-
unsafe fn usize(&self, input: usize, output: RefMut<usize>) -> HRESULT;
15-
unsafe fn hstring(&self, input: Ref<HSTRING>, output: RefMut<HSTRING>) -> HRESULT;
16-
unsafe fn interface(&self, input: Ref<ITest>, output: RefMut<ITest>) -> HRESULT;
17-
unsafe fn required_input(&self, input: Ref<ITest>, output: RefMut<ITest>) -> HRESULT;
18-
unsafe fn optional_output(&self, input: Ref<ITest>, output: RefMut<ITest>) -> HRESULT;
19-
20-
unsafe fn result_usize(&self, input: usize, output: RefMut<usize>) -> Result<()>;
21-
unsafe fn result_hstring(&self, input: Ref<HSTRING>, output: RefMut<HSTRING>) -> Result<()>;
22-
unsafe fn result_interface(&self, input: Ref<ITest>, output: RefMut<ITest>) -> Result<()>;
23-
unsafe fn result_required_input(&self, input: Ref<ITest>, output: RefMut<ITest>) -> Result<()>;
12+
// TODO: compile error if param type is not Ref/OutRef and is not Copy
13+
14+
unsafe fn usize(&self, input: usize, output: OutRef<usize>) -> HRESULT;
15+
unsafe fn hstring(&self, input: Ref<HSTRING>, output: OutRef<HSTRING>) -> HRESULT;
16+
unsafe fn interface(&self, input: Ref<ITest>, output: OutRef<ITest>) -> HRESULT;
17+
unsafe fn required_input(&self, input: Ref<ITest>, output: OutRef<ITest>) -> HRESULT;
18+
unsafe fn optional_output(&self, input: Ref<ITest>, output: OutRef<ITest>) -> HRESULT;
19+
20+
unsafe fn result_usize(&self, input: usize, output: OutRef<usize>) -> Result<()>;
21+
unsafe fn result_hstring(&self, input: Ref<HSTRING>, output: OutRef<HSTRING>) -> Result<()>;
22+
unsafe fn result_interface(&self, input: Ref<ITest>, output: OutRef<ITest>) -> Result<()>;
23+
unsafe fn result_required_input(&self, input: Ref<ITest>, output: OutRef<ITest>) -> Result<()>;
2424
}
2525

2626
#[implement(ITest)]
2727
struct Test;
2828

2929
impl ITest_Impl for Test {
30-
unsafe fn usize(&self, input: usize, output: RefMut<usize>) -> HRESULT {
30+
unsafe fn usize(&self, input: usize, output: OutRef<usize>) -> HRESULT {
3131
output.write(input).into()
3232
}
33-
unsafe fn hstring(&self, input: Ref<HSTRING>, output: RefMut<HSTRING>) -> HRESULT {
33+
unsafe fn hstring(&self, input: Ref<HSTRING>, output: OutRef<HSTRING>) -> HRESULT {
3434
output.write(input.clone()).into()
3535
}
36-
unsafe fn interface(&self, input: Ref<ITest>, output: RefMut<ITest>) -> HRESULT {
36+
unsafe fn interface(&self, input: Ref<ITest>, output: OutRef<ITest>) -> HRESULT {
3737
output.write(input.clone()).into()
3838
}
39-
unsafe fn required_input(&self, input: Ref<ITest>, output: RefMut<ITest>) -> HRESULT {
39+
unsafe fn required_input(&self, input: Ref<ITest>, output: OutRef<ITest>) -> HRESULT {
4040
if input.is_none() {
4141
E_INVALIDARG
4242
} else {
4343
self.interface(input, output)
4444
}
4545
}
4646

47-
unsafe fn optional_output(&self, input: Ref<ITest>, output: RefMut<ITest>) -> HRESULT {
47+
unsafe fn optional_output(&self, input: Ref<ITest>, output: OutRef<ITest>) -> HRESULT {
4848
if output.is_null() {
4949
S_FALSE
5050
} else {
5151
self.interface(input, output)
5252
}
5353
}
5454

55-
unsafe fn result_usize(&self, input: usize, output: RefMut<usize>) -> Result<()> {
55+
unsafe fn result_usize(&self, input: usize, output: OutRef<usize>) -> Result<()> {
5656
output.write(input)
5757
}
58-
unsafe fn result_hstring(&self, input: Ref<HSTRING>, output: RefMut<HSTRING>) -> Result<()> {
58+
unsafe fn result_hstring(&self, input: Ref<HSTRING>, output: OutRef<HSTRING>) -> Result<()> {
5959
output.write(input.clone())
6060
}
61-
unsafe fn result_interface(&self, input: Ref<ITest>, output: RefMut<ITest>) -> Result<()> {
61+
unsafe fn result_interface(&self, input: Ref<ITest>, output: OutRef<ITest>) -> Result<()> {
6262
output.write(input.clone())
6363
}
64-
unsafe fn result_required_input(&self, input: Ref<ITest>, output: RefMut<ITest>) -> Result<()> {
64+
unsafe fn result_required_input(&self, input: Ref<ITest>, output: OutRef<ITest>) -> Result<()> {
6565
if input.is_none() {
6666
E_INVALIDARG.ok()
6767
} else {

0 commit comments

Comments
 (0)