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

Improve the handling of various declaration types and add support for generating macro bindings #160

Merged
merged 14 commits into from
Jul 10, 2020

Conversation

tannergooding
Copy link
Member

This improves the handling of various declaration types, particularly anonymous unions. This also adds basic support for generating bindings for variable like macros. Function like macros are still unsupported.

Due to the recent changes in how various members are exposed (via direct calls to helper methods in libClangSharp, rather than trying a "best guess" attempt at picking the right CursorChildren), the creation of a given Cursor's child cursors was no longer lazy, this was causing memory usage and parse time to skyrocket. As such, the mechanism for tracking "parent cursor" had to be modified. In particular, the Cursor no longer tracks the parent itself and instead we track our current traversal hierarchy in the P/Invoke generator. This also fixed a scenario where a given cursor was a child of two independent cursors which was causing certain checks to not line up.

The anonymous union handling now exposes ref properties so you no longer need to go through the .Anonymous member to access the value and instead you can access it more directly. In .NET Core, the codegen for this is "perfect" (that is the MemoryMarshal calls are fully elided). However, as with the fixed-sized buffer helpers that created ref is "unsafe". That is it bypasses the normal C# lifetime rules and should not be manually cached.

For the macro support, it currently handles the basic scenarios of the various .NET primitives and specially handles any type remapped to Guid. This also fixed up the handling of VarDecl in global scopes and proper bindings should now be generated for those as well.

@tannergooding tannergooding merged commit 6355b74 into dotnet:master Jul 10, 2020
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.

1 participant