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

Generating numerical constants instead of enum variants #8

Closed
kvark opened this issue Jan 13, 2018 · 3 comments
Closed

Generating numerical constants instead of enum variants #8

kvark opened this issue Jan 13, 2018 · 3 comments

Comments

@kvark
Copy link
Contributor

kvark commented Jan 13, 2018

How easy would this option be to implement? I need:

pub const SYSTEM_ALLOCATION_SCOPE_COMMAND: u32 = 0;
pub const SYSTEM_ALLOCATION_SCOPE_OBJECT:u32 = 1;
pub const SYSTEM_ALLOCATION_SCOPE_CACHE:u32 = 2;
pub const SYSTEM_ALLOCATION_SCOPE_DEVICE:u32 = 3;
pub const SYSTEM_ALLOCATION_SCOPE_INSTANCE:u32 = 4;
}

instead of

pub enum SystemAllocationScope {
    VK_SYSTEM_ALLOCATION_SCOPE_COMMAND = 0,
    VK_SYSTEM_ALLOCATION_SCOPE_OBJECT = 1,
    VK_SYSTEM_ALLOCATION_SCOPE_CACHE = 2,
    VK_SYSTEM_ALLOCATION_SCOPE_DEVICE = 3,
    VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE = 4,
}

One thing is moving from enum variants to constants. Another is - stripping "VK_" prefix only, leaving the other padding (SYSTEM_ALLOCATION_SCOPE_). Finally, I suppose the enum type would then turn into pub type SystemAllocationScope = u32;

@kvark
Copy link
Contributor Author

kvark commented Jan 14, 2018

Hacked this in master...kvark:enum-const
Please let me know if you'd like this upstreamed, and in what shape.

@Osspial
Copy link
Owner

Osspial commented Jan 21, 2018

Having this upstreamed would be great - I'm actually kinda surprised this wasn't implemented already. Most of the code in the hack looks good, but it would need a config flag to switch between the enum and numerical constants version. It might also make sense to make the enum type a wrapper struct to keep type-checking, which in this case would be pub struct SystemAllocationScope(u32);

@Osspial
Copy link
Owner

Osspial commented Jan 21, 2018

Getting enum stripping to only strip VK_ should be easy enough, but I'll look into doing that after I get some sleep and can actually think about code.

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

No branches or pull requests

2 participants