Use array instead of enumerating values in SMCParamStruct
beltex opened this issue · 3 comments
beltex commented
- The original
SMCParamStruct
defines an array of 32 UInt8 values (for the actual data returned from the SMC) - When we do this, can't read the array once passed back from C (I/O Kit call), thus we enumerate 32 UInt8 values instead
- The array works fine on the C side, checked via bridging header to a small C wrapper function
- We know the data is there (as enumerating values works)
- There's some trickery to be had here with UnsafePointers, but have yet to get it to work
beltex commented
The Advanced Swift Debugging in LLDB talk from WWDC might help with this.
beltex commented
This just hit me now, but the various C structs in the Darwin module that contain arrays are bridged as tuples! Probably because C arrays are fixed size while Swift ones are not (at least for now no other option). So I just tried out using a tuple of 32 UInt8
s and it works. The problem is tuples are really inflexible to work with, so it doesn’t make things much better, basically the same as what we have now.
beltex commented
Closing. Until Swift has fixed sized arrays, I don't think there is a solution to this. WWDC 15 could address that :)