Skip to content

Commit

Permalink
simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr committed Sep 5, 2024
1 parent 8587e77 commit ed973c9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 31 deletions.
22 changes: 2 additions & 20 deletions crates/tests/winrt/reference_float/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,16 @@
#[repr(C)]
#[derive(Clone, Debug, PartialEq)]
pub struct RefWithFloat {
pub ReferenceFloat: Option<windows::Foundation::IReference<f32>>,
pub ReferenceWithFloat: Option<windows::Foundation::IReference<WithFloat>>,
pub Value: Option<windows::Foundation::IReference<f32>>,
}
impl windows_core::TypeKind for RefWithFloat {
type TypeKind = windows_core::CloneType;
}
impl windows_core::RuntimeType for RefWithFloat {
const SIGNATURE :windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::from_slice ( b"struct(test_reference_float.RefWithFloat;pinterface({61c17706-2d65-11e0-9ae8-d48564015472};f4);pinterface({61c17706-2d65-11e0-9ae8-d48564015472};struct(test_reference_float.WithFloat;f4)))" ) ;
const SIGNATURE :windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::from_slice ( b"struct(test_reference_float.RefWithFloat;pinterface({61c17706-2d65-11e0-9ae8-d48564015472};f4))" ) ;
}
impl Default for RefWithFloat {
fn default() -> Self {
unsafe { core::mem::zeroed() }
}
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct WithFloat {
pub Value: f32,
}
impl windows_core::TypeKind for WithFloat {
type TypeKind = windows_core::CopyType;
}
impl windows_core::RuntimeType for WithFloat {
const SIGNATURE: windows_core::imp::ConstBuffer =
windows_core::imp::ConstBuffer::from_slice(b"struct(test_reference_float.WithFloat;f4)");
}
impl Default for WithFloat {
fn default() -> Self {
unsafe { core::mem::zeroed() }
}
}
5 changes: 1 addition & 4 deletions crates/tests/winrt/reference_float/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ use windows::{core::*, Foundation::*};
#[test]
fn test() -> Result<()> {
let mut container = RefWithFloat::default();
container.ReferenceFloat = Some(PropertyValue::CreateSingle(1.23)?.cast()?);

// TODO: https://github.com/microsoft/windows-rs/issues/292 is needed to provide a stock implementation
// of `IReference` for arbitrary types in order to test `container.ReferenceWithFloat`.
container.Value = Some(PropertyValue::CreateSingle(1.23)?.cast()?);

Ok(())
}
8 changes: 1 addition & 7 deletions crates/tests/winrt/reference_float/src/metadata.idl
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@

namespace test_reference_float
{
struct WithFloat
{
Single Value;
};

struct RefWithFloat
{
Windows.Foundation.IReference<Single> ReferenceFloat;
Windows.Foundation.IReference<WithFloat> ReferenceWithFloat;
Windows.Foundation.IReference<Single> Value;
};
}

0 comments on commit ed973c9

Please sign in to comment.