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

Incorrect enum base type #519

Open
nitroxis opened this issue Dec 23, 2023 · 0 comments
Open

Incorrect enum base type #519

nitroxis opened this issue Dec 23, 2023 · 0 comments

Comments

@nitroxis
Copy link

The PInvoke generator seems to use the wrong enum base type (or else, it generates values that are not always signed ints). One example is the FT_Glyph_Format enum from freetype defined here.

The tool generates:

public enum FT_Glyph_Format_
{
    FT_GLYPH_FORMAT_NONE = unchecked(((uint)((byte)(0)) << 24) | ((uint)((byte)(0)) << 16) | ((uint)((byte)(0)) << 8) | (uint)((byte)(0))),
    FT_GLYPH_FORMAT_COMPOSITE = unchecked(((uint)((byte)('c')) << 24) | ((uint)((byte)('o')) << 16) | ((uint)((byte)('m')) << 8) | (uint)((byte)('p'))),
    FT_GLYPH_FORMAT_BITMAP = unchecked(((uint)((byte)('b')) << 24) | ((uint)((byte)('i')) << 16) | ((uint)((byte)('t')) << 8) | (uint)((byte)('s'))),
    FT_GLYPH_FORMAT_OUTLINE = unchecked(((uint)((byte)('o')) << 24) | ((uint)((byte)('u')) << 16) | ((uint)((byte)('t')) << 8) | (uint)((byte)('l'))),
    FT_GLYPH_FORMAT_PLOTTER = unchecked(((uint)((byte)('p')) << 24) | ((uint)((byte)('l')) << 16) | ((uint)((byte)('o')) << 8) | (uint)((byte)('t'))),
    FT_GLYPH_FORMAT_SVG = unchecked(((uint)((byte)('S')) << 24) | ((uint)((byte)('V')) << 16) | ((uint)((byte)('G')) << 8) | (uint)((byte)(' '))),
}

It seems like the macro is expanded/converted correctly, but it produces uint. Either, the enum should use uint as base type, or the individual values need to be cast to int using unchecked((int) expr). I think both would yield correct code/bindings.

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

1 participant