Skip to content

Add support for Win32 array parameters - #1562

Merged
Kenny Kerr (kennykerr) merged 34 commits into
masterfrom
win32_array
Feb 24, 2022
Merged

Kenny Kerr (kennykerr) merged 34 commits into
masterfrom
win32_array

Conversation

@kennykerr

@kennykerr Kenny Kerr (kennykerr) commented Feb 23, 2022 •

Copy link
Copy Markdown
Collaborator

Adds support for both relative and fixed size Win32 array parameters.

Here's an example of an API with a fixed-size array parameter:

let mut buffer = [0; 260];
let a = GetTempFileNameA(".", "test", 0x7b, &mut buffer);
assert_eq!(a, 0x7b);
assert_eq!(&buffer[..12], b".\\tes7B.tmp\0");

Previously, the last parameter was merely a pointer and could not check whether the buffer was large enough. Now the size is checked at compile time.

And here is an example of an API with a relative array parameter:

let input = b"hello";
let mut output = [0; 5];
let len = MultiByteToWideChar(CP_UTF8, Default::default(), input, &mut output);
assert_eq!(len, 5);

Previously, both input and output buffers consisted of a pair of parameters for each pointer and length. Now, a pair of slices is expected and the underlying argument pairs are derived from those.

Fixes #1339
Fixes #972
Fixes #790
Fixes #479

@kennykerr Kenny Kerr (kennykerr) changed the title Test build Add support for Win32 array parameters Feb 23, 2022
@kennykerr

Kenny Kerr (kennykerr) commented Feb 23, 2022 •

Copy link
Copy Markdown
Collaborator Author

Damyan Pepper (@damyanp) could you look over the DirectX APIs - many changes there - they look good to me, but I'd appreciate another pair of eyes. It's a lot easier with CodeFlow. 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants