-
Couldn't load subscription status.
- Fork 166
Closed
Labels
Description
When generating an interop structure for the following type:
struct PackedVertex
{
union
{
int i;
struct
{
int x : 11;
int y : 11;
int z : 10;
};
};
};ClangSharpPInvokeGenerator produces accessors like the following:
[NativeTypeName("int : 11")]
public int x
{
get
{
return _bitfield & 0x7FF;
}
set
{
_bitfield = (_bitfield & ~0x7FF) | (value & 0x7FF);
}
}Which does not appear to handle the sign of each component properly.
Setting i to 0xFB3E7064 should produce 100, -50, -20 for x, y, z, but with the currently generated code, it produces 100, 1998, 1004. If the code for the getters are tweaked to match the assembly generated by Clang and MSVC, then the results are correct.