windows-drivers-rs icon indicating copy to clipboard operation
windows-drivers-rs copied to clipboard

Refactor `call_unsafe_wdf_function_binding` so invocations look like function calls

Open DrChat opened this issue 1 year ago • 2 comments

This PR just changes the syntax for call_unsafe_wdf_function_binding so that the contents actually look like a function call.

This is important both for ergonomics (e.g. rust-analyzer will highlight the function like a function), as well as because I assume eventually you want to get rid of this macro altogether and this will make it easier for users to refactor their code when the time comes.

DrChat avatar Dec 16 '23 22:12 DrChat

This is important both for ergonomics (e.g. rust-analyzer will highlight the function like a function

Could you elaborate on what ergonomics you're referring to here? Does allow rust-analyzer to provide any additional feature beyond just highlighting as a function?

, as well as because I assume eventually you want to get rid of this macro altogether and this will make it easier for users to refactor their code when the time comes.

Our rough plan right now does not include the removal of the macro. Our thinking is that as we work to write idiomatic rust wrappers for the individual apis, those wrappers would use the call_unsafe_wdf_function_binding. Those who want to use the raw bindings in wdk-sys can continue to use them via the macro, but those who want to use the idiomatic api in wdk will need some refactor work anyways. these idiomatic apis are still something we are experimenting with so it will take some time before we get to the point of merging those in.

wmmc88 avatar Dec 19 '23 01:12 wmmc88

Ah sorry - I forgot to follow up on this!

Could you elaborate on what ergonomics you're referring to here? Does allow rust-analyzer to provide any additional feature beyond just highlighting as a function?

Really the only benefits would be that this makes the function call look like a function call both to developers and rust-analyzer. It's important IMO for allowing developers to quickly understand any code that makes these calls, whether internal or external.

Our rough plan right now does not include the removal of the macro. Our thinking is that as we work to write idiomatic rust wrappers for the individual apis, those wrappers would use the call_unsafe_wdf_function_binding.

Hopefully I can change this plan with my other PR :) I do think that PR is more valuable than this one because it has the above benefits plus it allows rust-analyzer to display rich information about both input parameters as well as the return value for each Wdf function. Even if the plan is to wrap these APIs so that most or all end-users won't have to use them, this would still be beneficial for developers contributing to this SDK.

DrChat avatar Jan 03 '24 16:01 DrChat