-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preliminary cleanup pass #339
Conversation
{let $p = $f; match $q { vk::Result::SUCCESS => Ok($r), _ => Err($z), }} ==>> {$f.result_with_success($r)}
Using the following regex replacement: let err_code =\s*(.*\((\n|[^;])*?\));\s*match err_code \{\s*vk::Result::SUCCESS => Ok\((.*)\),\s*_ => Err\(err_code\),\s*\} $1.result_with_success($3)
let err_code =\s*(.*\((\n|[^;])*?\));\s*if err_code != vk::Result::SUCCESS \{\s*return Err\(err_code\);\s*\} $1.result()?;
ANativeWindow and AHardwareBuffer were [recently changed] to the basetype category, but without an actual basetype, consequently failing the Ident constructor with an empty name. Since these types are already dealt with in platform_types, and there doesn't seem to be anything sensical to define them to right now, just ignore these cases. [recently changed]: KhronosGroup/Vulkan-Headers@0c5351f#diff-0ff049f722e55de41ee15b2c91ef380fL179-R180
Sorry for being a bit unresponsive, I am a bit swamped right now. The result changes look great 💯, I'll have a look at the rest in a few days. |
@MaikKlein No worries, there's no hurry in merging this as the official RT spec is still in the process of being dropped. It's actually convenient so that I could sneak in some extra fixes, but do let me know if this gets too large, which it already is to some extent! Glad you like it though! |
The reference argument was always None; replace it with a direct call to name_to_tokens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I think everything looks good :). Thanks for the cleanup.
Thanks @MaikKlein for reviewing this rather large chunk of changes, glad you like it :) |
Long ago in #339 I added "opaque" types to ensure that pointers to it stay as pointers in FFI rather than get converted to `&mut` borrows which don't carry the load of an arbitrary pointer value to "something unknown" (= opaque). When the QNX types were added in #429 and #760 some time later, they weren't added to this list and turned into borrows making them impossible to be handled safely in user code.
Long ago in #339 I added "opaque" types to ensure that pointers to it stay as pointers in FFI rather than get converted to `&mut` borrows which don't carry the load of an arbitrary pointer value to "something unknown" (= opaque). When the QNX types were added in #429 and #760 some time later, they weren't added to this list and turned into borrows making them impossible to be handled safely in user code.
Hi Maik,
Apologies for this massive PR. It's some upfront cleanup work that came up while working on
ash
, in particular aroundResult
types and error handling.I can only recommend to review the changes per commit to get around the bulk of it easily. While this aims to make the code ever so slightly better it results in lots of noise, let me know if any commit (hash) is not worth taking in and I'll gladly remove it again.
To highlight the changes:
#[must_use]
onvk::Result
;vk::Result
toResult<T, vk::Result>
;TokenStream
and replacing identifiers with their Rust counterpart. This is going to be more relevant in the future;Thanks!