Improve the handling of various declaration types and add support for generating macro bindings #160
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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, theCursor
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 createdref
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 ofVarDecl
in global scopes and proper bindings should now be generated for those as well.