Skip to content

Conversation

@MarijnS95
Copy link
Contributor

No description provided.

@MarijnS95 MarijnS95 requested a review from mikebattista as a code owner March 10, 2025 08:26
Comment on lines 2026 to 2027
IDxDiagContainer::EnumChildContainerNames::pwszContainer=[Out][NativeArrayInfo(CountFieldName = "cchContainer")]
IDxDiagContainer::EnumPropNames::pwszPropName=[Out][NativeArrayInfo(CountFieldName = "cchPropName")]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noting to self that this needs to use CountParamIndex so that this special piece of code in windows-rs translates the function argument to &mut [u16] (unfortunately loosing the PWSTR type) to pass the "capacity" of the output string into cch* without users having to do so manually:

https://github.com/microsoft/windows-rs/blob/4523c9d2c12b2227f369b3ed86ceb0ba9db409d2/crates/libs/bindgen/src/types/cpp_method.rs#L632-L640

Since there are a few more functions with CountFieldName attributes, maybe those should be renamed or windows-rs needs to lookup by name as well?

(Bonus: PWSTR can't be used as function argument because it defines the length based on strlen() that searches for a NUL-terminator, which isn't defined for an arbitrary "output only" buffer. The transparent PWSTR pointer wrapper "newtype" doesn't behave like an "owned" Rust Vec which carries a length and capacity field)

riverar
riverar previously approved these changes Sep 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants