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

Cleanup how the PInvokeGenerator handles CXType and resolves names #61

Merged
merged 6 commits into from
Jun 6, 2019

Conversation

tannergooding
Copy link
Member

This does some minor cleanup that namely extends the CXType wrapper to more closely match the Clang C++ bindings.

This also improves how cursor and type names are resolved to better match how the wrapper types/etc are generated.

@tannergooding
Copy link
Member Author

This also sets things up so that support for generating "safe code" can be removed. This support, while nice, is very error prone and can have various hidden overhead that isn't going to be easy to maintain long term.

Namely, things like out vs ref and marshaling behavior (especially around things like arrays) is almost impossible to determine without some kind of additional input. Wrapper types are also not always compatible with the underlying calling convention (namely for thiscall) and can prevent an API from working as expected.

The best case scenario is to just generate bindings which have 1-to-1 mapping with the underlying signatures and with no marshaling. This gives a zero-cost (modulo the overhead of the P/Invoke stub) abstraction over the native APIs which allows usage in performance oriented scenarios and allows better use with new library functionality such as Span<T>. Safe managed wrapper APIs can then be created over those unsafe native bindings (as we're already doing in ClangSharp/LLVMSharp) which expose the friendly API.

}
return name;
}
case "size_t":
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

size_t is spec'd to be unsigned, so this is a change in how the bindings are generated.

{
switch (decl.Kind)
case "int64_t":
case "time_t":
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time_t is generally 64-bit on modern hardware (even 32-bit machines), but not always. Should probably provide a way to override this....

@tannergooding tannergooding merged commit 696cb97 into dotnet:master Jun 6, 2019
@tannergooding tannergooding deleted the type-cleanup branch June 8, 2019 02:55
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

Successfully merging this pull request may close these issues.

2 participants