-
Notifications
You must be signed in to change notification settings - Fork 524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a way to convert from an Interface
to Option<Interface>
#1339
Comments
Doing |
This API is difficult to use because it really expects an array but the Rust bindings aren't yet adapted to accept a slice. This is a duplicate of #479 that I hope to get to soon. |
Sorry for the delay, #1562 adds support for Win32 array parameters. |
Unfortunately #1562 does not solve the core issue. Even for functions that take slices, they expect slices of |
Reopening to address this. |
This function is generated as follows: pub unsafe fn VSSetConstantBuffers(&self, startslot: u32, ppconstantbuffers: &[::core::option::Option<ID3D11Buffer>]) {
(::windows::core::Interface::vtable(self).VSSetConstantBuffers)(::core::mem::transmute_copy(self), ::core::mem::transmute(startslot), ppconstantbuffers.len() as _, ::core::mem::transmute(::windows::core::as_ptr_or_null(ppconstantbuffers)))
} This is in line with the metadata: unsafe void VSSetConstantBuffers([In] uint StartSlot, [In] uint NumBuffers, [Optional][In][NativeArrayInfo(CountParamIndex = 1)] ID3D11Buffer* ppConstantBuffers); Unfortunately, there's nothing in the metadata that says that the interface pointers in the array may not be null, hence the |
What if an This wouldn't work for |
Ah that's a good point, thanks for the reminder! Yes, I'll experiment with using |
I know this issue is very old. I can open a new issue if that is preferred. But this was closed with a change (#2233) that had to be reverted and never re-opened. Going back to the original use case: User has Can we get an AsRef to take us from Right now the options seem to be:
See also: #2930 (comment) |
If VSSetConstantBuffers took Option<Ref<ID3D11Buffer>> instead, neither clone nor transmute would be necessary. That would be ideal IMO. |
Yes, I added |
Some APIs like
VSSetConstantBuffers
take an*const Option<ID3D11Buffer>
. Given a&ID3D11Buffer
I'd like to be able to construct a&Option<ID3D11Buffer>
to pass to a function like this.The text was updated successfully, but these errors were encountered: