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

Remove PointerSize and use nint/nuint #209

Open
amerkoleci opened this issue Sep 15, 2021 · 4 comments
Open

Remove PointerSize and use nint/nuint #209

amerkoleci opened this issue Sep 15, 2021 · 4 comments

Comments

@amerkoleci
Copy link
Contributor

Hi @andrew-boyarshin ,
Recent .NET language added nint and nuint support, I would suggest to remove PointerSize and map to those directly, same applies to SharpGen.Runtime.COM.

It is supported in ClangSharp as well:
intptr_t -> nint
ptrdiff_t -> nint
size_t -> nuint
uintptr_t -> nuint
SIZE_T -> nuint
SSIZE_T -> nint

@andrew-boyarshin
Copy link
Contributor

Having PointerSize might theoretically enable us to provide APIs not available on pre-.NET5 runtimes (like IComparable). But yeah, using these is simpler.

@amerkoleci
Copy link
Contributor Author

Not sure what you mean, nuint maps to UIntPtr and nint maps to IntrPtr, so there is no special magin under the hood.

@amerkoleci
Copy link
Contributor Author

If you plan to keep PointerSize then we need UPointerSize with ulong and map SIZE_T to that instance.
Otherwise we'll end in marshalling issues (amerkoleci/Vortice.Windows#185)

@andrew-boyarshin
Copy link
Contributor

Yeah, I know that nint is a syntax sugar for System.IntPtr and native int. But until .NET 5 (dotnet/runtime#307) IntPtr had a much more narrow API surface, and so does the nint on these older runtimes.

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

2 participants