-
Notifications
You must be signed in to change notification settings - Fork 149
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
Support multi file generation in the Binding generator #43
Conversation
This allows a single pass per translation unit. This has a side effect of always emitting two files, even if I did this in a couple stages to validate that nothing regressed in the overall generation story. Notably, the first commit adds support for multi-file generation but just regenerates the code into two files. The second commit then regenerates things split up. |
Overall, having things split into one file per type allows easier review of changes and makes the output deterministic, rather than dependent on various parse orderings (such as passing in |
|
||
namespace ClangSharpPInvokeGenerator | ||
{ | ||
internal sealed class OutputBuilder : IDisposable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could also allow some other interesting configuration options. Such as sorting types or methods before writing them out to the file (which would allow determinism for single-file generation and for the method class file).
@@ -2533,6 +1088,5 @@ public static partial class clang | |||
|
|||
[DllImport(libraryPath, EntryPoint = "clang_CompileCommand_getMappedSourceContent", CallingConvention = CallingConvention.Cdecl)] | |||
public static extern CXString CompileCommand_getMappedSourceContent(CXCompileCommand param0, uint I); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The OutputBuilder
also makes it easier to handle these trailing newlines 🎉
This resolves #30
This updates the ClangSharpPInvokeGenerator to support emitting one file per type (and one file for all methods).
It also updates the generator to only emit required usings and to not emit a class to hold methods if the header file contains no methods.