contextfree / winrt-rust

Use and (eventually) make Windows Runtime APIs with Rust
Apache License 2.0
142 stars 10 forks source link

Support for array types #9

Closed Boddlnagg closed 6 years ago

Boddlnagg commented 7 years ago

Array types in method parameters are currently (hopefully) correct in the raw VTable definitions, but not yet idiomatically represented in the wrapper methods. (Array parameters are taken as raw pointers and just forwarded directly.)

https://msdn.microsoft.com/en-us/library/hh700131.aspx shows how arrays are handled in C++/CX. Also have a look at vccorlib.h (part of Visual Studio installation) for the definitions of Platform::Array, etc.

Boddlnagg commented 7 years ago

See also the ComArray type that I have added in comptr.rs

Boddlnagg commented 7 years ago

This is mostly done in #24. The only case left is dealing with arrays as output parameters, where a safe API would require a mutable, write-only, empty slice, e.g. in ISpiDevice.read(...).

Boddlnagg commented 6 years ago

Maybe it's helpful that the arrays in those remaining cases are always (at least until now) arrays of value types (primitives or structs) ... which means that those arrays are easily constructible (because the elements are Copy) and the elements don't have destructors. So maybe taking &mut [T] is not too bad after all.