fix!: generated types from DECLARE_HANDLE
macro are marked as opaque, non-copy, and non-default
#280
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request fixes default
bindgen
behavior that resulted in types from the WDK macroDECLARE_HANDLE
not being marked as opaque. My PR introduces a new function in the traitBuilderExt
,opaque_windows_handle_types
, which searches through the currentConfig
'sinclude_paths
, and finds each instance of theDECLARE_HANDLE
macro in order to mark these types asopaque_type
,no_copy
, andno_default
.Validation
The effect of this change can be found in opaque_handles.zip. There are three directories: one for the original versions of the file
types.rs
generated bybindgen
, one for the new versions oftypes.rs
, and one containing the diffs between the two.The
DECLARE_HANDLE
macro is defined as follows:In each diffed file, you can see each struct defined by this macro, marked by
pub unused: ::core::ffi::c_int
, is now replaced by an opaque type, marked bypub _bindgen_opaque_blob: u32
. We can be sure of this approach as there are no generated structs in the newtypes.rs
files that contain theunused
member.Breaking Changes
Types generated by
bindgen
for the WDK have been edited. These are public facing, so therefore this PR contains a breaking change.