bottlenoselabs / c2cs

Generate C# bindings from a C header.
MIT License
245 stars 18 forks source link

Use most derived element size for ElementSize #69

Closed waldnercharles closed 2 years ago

waldnercharles commented 2 years ago

I've made it so that the element type is based on the most derived element type. I've also added support for pointers.

Originally when machineBitWidth was set to 64, int would translate to long in C# because it would default to the pointer's size since no ElementSize was specified before.

Without the loop, this would continue to happen with int translating to long.

lithiumtoast commented 2 years ago

The name element is for the type inside the array type, complex type, or vector type. Here it's being used for also the type attached to a pointer. It's kind of bending the naming convention of Clang to use element for the type attached to a pointer, but I think it makes sense. I would probably want to add some commits on top of this PR to start documenting the CType properties so it's clear that ElementSize also applies to pointers.

lithiumtoast commented 2 years ago

Deleted because I figure the real problem was unrelated to what was proposed in this PR.