Skip to content
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

Merged
merged 29 commits into from
Dec 12, 2020
Merged

Preliminary cleanup pass #339

merged 29 commits into from
Dec 12, 2020

Conversation

MarijnS95
Copy link
Collaborator

Hi Maik,

Apologies for this massive PR. It's some upfront cleanup work that came up while working on ash, in particular around Result 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:

  • Make sure all results are checked with #[must_use] on vk::Result;
  • Conversion helpers from vk::Result to Result<T, vk::Result>;
  • Clippy fixes;
  • Simplifications in the generator around array code handling;
  • Parsing some C expressions into TokenStream and replacing identifiers with their Rust counterpart. This is going to be more relevant in the future;
  • A breaking API change: 19552b2. I don't think this one is worth taking in now that I look at it again.

Thanks!

generator/src/lib.rs Outdated Show resolved Hide resolved
    {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
@MaikKlein
Copy link
Member

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.

@MarijnS95
Copy link
Collaborator Author

MarijnS95 commented Nov 24, 2020

@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.
Copy link
Member

@MaikKlein MaikKlein left a 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.

@MaikKlein MaikKlein merged commit bfa0309 into ash-rs:master Dec 12, 2020
@MarijnS95 MarijnS95 deleted the cleanup branch December 12, 2020 21:03
@MarijnS95
Copy link
Collaborator Author

Thanks @MaikKlein for reviewing this rather large chunk of changes, glad you like it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants