-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
112 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[package] | ||
name = "test_reference_float" | ||
version = "0.0.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
doc = false | ||
doctest = false | ||
|
||
[build-dependencies.windows-bindgen] | ||
workspace = true | ||
|
||
[dependencies.windows-core] | ||
workspace = true | ||
|
||
[dependencies.windows] | ||
workspace = true | ||
features = [ | ||
"implement", | ||
"Foundation", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
fn main() { | ||
let mut command = std::process::Command::new("midlrt.exe"); | ||
command.args([ | ||
"/winrt", | ||
"/nomidl", | ||
"/h", | ||
"nul", | ||
"/metadata_dir", | ||
"../../../libs/bindgen/default", | ||
"/reference", | ||
"../../../libs/bindgen/default/Windows.winmd", | ||
"/winmd", | ||
"metadata.winmd", | ||
"src/metadata.idl", | ||
]); | ||
|
||
if !command.status().unwrap().success() { | ||
panic!("Failed to run midlrt"); | ||
} | ||
|
||
windows_bindgen::bindgen([ | ||
"--in", | ||
"metadata.winmd", | ||
"--out", | ||
"src/bindings.rs", | ||
"--filter", | ||
"test_reference_float", | ||
"--config", | ||
"implement", | ||
"no-bindgen-comment", | ||
]) | ||
.unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#![allow( | ||
non_snake_case, | ||
non_upper_case_globals, | ||
non_camel_case_types, | ||
dead_code, | ||
clippy::all | ||
)] | ||
#[repr(C)] | ||
#[derive(Clone, Debug, PartialEq)] | ||
pub struct RefWithFloat { | ||
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))" ) ; | ||
} | ||
impl Default for RefWithFloat { | ||
fn default() -> Self { | ||
unsafe { core::mem::zeroed() } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#![cfg(test)] | ||
|
||
mod bindings; | ||
use bindings::*; | ||
use windows::{core::*, Foundation::*}; | ||
|
||
#[test] | ||
fn test() -> Result<()> { | ||
let mut container = RefWithFloat::default(); | ||
container.Value = Some(PropertyValue::CreateSingle(1.23)?.cast()?); | ||
assert_eq!(container.Value.unwrap().Value()?, 1.23); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// This tests that windows-bindgen avoids deriving `Eq` for types with floating point fields. | ||
// https://github.com/microsoft/windows-rs/issues/3220 | ||
|
||
namespace test_reference_float | ||
{ | ||
struct RefWithFloat | ||
{ | ||
Windows.Foundation.IReference<Single> Value; | ||
}; | ||
} |