rust-lang / rust-lang/rust-bindgen

Improve codegen for C style enums

Open
#1,096 7 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement I-unclear
Dominant language
Rust
Stars
5.3k
Forks
829
Avg merge
1d 1h
Merged PRs (30d)
15

Description

Because C style enums are loosely typed and aren't typed they tend to be expressed in C more loosely than they are actually used.

For example, one might have an enum like:
https://github.com/zyantific/zydis/blob/4dd632463c122ee85ba9c5f0c1e56ac748bf246e/include/Zydis/DecoderTypes.h#L478

but that enum is stored in a ZydisCPUFlagAction/uint8_t (https://github.com/zyantific/zydis/blob/4dd632463c122ee85ba9c5f0c1e56ac748bf246e/include/Zydis/DecoderTypes.h#L473, https://github.com/zyantific/zydis/blob/4dd632463c122ee85ba9c5f0c1e56ac748bf246e/include/Zydis/DecoderTypes.h#L816).

It would be nice to be able map the ZydisCPUFlagAction type to the ZydisCPUFlagActions enum somehow.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the linked enum and storage declarations in include/Zydis/DecoderTypes.h at lines 473, 478, and 816, then trace how bindgen currently represents these C enums in generated Rust. Define how a storage type such as ZydisCPUFlagAction should map to its related ZydisCPUFlagActions enum, and verify the generated bindings for this example.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.