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

Add support for bit fields #2942

Closed
kennykerr opened this issue Mar 19, 2024 · 6 comments
Closed

Add support for bit fields #2942

kennykerr opened this issue Mar 19, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@kennykerr
Copy link
Collaborator

kennykerr commented Mar 19, 2024

Rust lacks support at the moment: rust-lang/rfcs#314

Metadata now provides this information: microsoft/win32metadata#1392

@kennykerr kennykerr added the enhancement New feature or request label Mar 19, 2024
@mominshaikhdevs
Copy link

I don't see the point of this issue. Since, rust the language itself doesn't support that. I believe this can be reopened and worked on once the lang itself supports it.

@kennykerr
Copy link
Collaborator Author

We could add get/set methods.

@workingjubilee
Copy link

We do indeed effectively farm out this responsibility to crates, essentially so that those crates can implement the getters/setters that strike their fancy. I believe rust-bindgen provides some such support.

@kennykerr
Copy link
Collaborator Author

kennykerr commented Jan 22, 2025

I had a look at the metadata but it doesn't appear to include the type of each bitfield. For example, FLICK_DATA is defined as follows:

typedef struct FLICK_DATA
{
    FLICKACTION_COMMANDCODE iFlickActionCommandCode:5;
    FLICKDIRECTION iFlickDirection:3;
    BOOL fControlModifier:1;
    BOOL fMenuModifier:1;
    BOOL fAltGRModifier:1;
    BOOL fWinModifier:1;
    BOOL fShiftModifier:1;
    INT  iReserved:2;
    BOOL fOnInkingSurface:1;
    INT  iActionArgument:16;
}FLICK_DATA;

But the metadata just contains the offsets:

public struct FLICK_DATA
{
    [NativeBitfield("iFlickActionCommandCode", 0L, 5L)]
    [NativeBitfield("iFlickDirection", 5L, 3L)]
    [NativeBitfield("fControlModifier", 8L, 1L)]
    [NativeBitfield("fMenuModifier", 9L, 1L)]
    [NativeBitfield("fAltGRModifier", 10L, 1L)]
    [NativeBitfield("fWinModifier", 11L, 1L)]
    [NativeBitfield("fShiftModifier", 12L, 1L)]
    [NativeBitfield("iReserved", 13L, 2L)]
    [NativeBitfield("fOnInkingSurface", 15L, 1L)]
    [NativeBitfield("iActionArgument", 16L, 16L)]
    public int _bitfield;
}

@riverar do you know if this is intentionally omitting the field types or am I missing something?

@riverar
Copy link
Collaborator

riverar commented Jan 22, 2025

That is... not good. We'll need to fix that upstream.

@kennykerr
Copy link
Collaborator Author

Thanks, I'll close this for now then - nothing actionable to do here unfortunately.

@kennykerr kennykerr closed this as not planned Won't fix, can't repro, duplicate, stale Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants