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

Extending the exclude support and adding basic name remapping support #55

Merged
merged 4 commits into from
May 29, 2019

Conversation

tannergooding
Copy link
Member

This changes the --excludeFunction support to just be --exclude so that you can exclude types from binding generation as well.

This also adds a new --remap name=value feature that allows you to choose a different name to be emitted for types/cursors. This is particularly useful when the "true" name is less friendly than a more commonly used name (e.g. tagRECT vs RECT or _MyStruct vs MyStruct).

@@ -6,7 +6,7 @@
},
"GenerateLLVMSharp": {
"commandName": "Project",
"commandLineArgs": "-m LLVM -p LLVM --namespace LLVMSharp --output \"./LLVMSharp/Generated/\" --config multi-file --libraryPath \"$(LibLLVMName)\" --include \"$(LLVMIncludePath)\" --file \"$(LLVMIncludePath)/llvm-c/Analysis.h\" --file \"$(LLVMIncludePath)/llvm-c/BitReader.h\" --file \"$(LLVMIncludePath)/llvm-c/BitWriter.h\" --file \"$(LLVMIncludePath)/llvm-c/Comdat.h\" --file \"$(LLVMIncludePath)/llvm-c/Core.h\" --file \"$(LLVMIncludePath)/llvm-c/DataTypes.h\" --file \"$(LLVMIncludePath)/llvm-c/DebugInfo.h\" --file \"$(LLVMIncludePath)/llvm-c/Disassembler.h\" --file \"$(LLVMIncludePath)/llvm-c/DisassemblerTypes.h\" --file \"$(LLVMIncludePath)/llvm-c/Error.h\" --file \"$(LLVMIncludePath)/llvm-c/ErrorHandling.h\" --file \"$(LLVMIncludePath)/llvm-c/ExecutionEngine.h\" --file \"$(LLVMIncludePath)/llvm-c/Initialization.h\" --file \"$(LLVMIncludePath)/llvm-c/IRReader.h\" --file \"$(LLVMIncludePath)/llvm-c/Linker.h\" --file \"$(LLVMIncludePath)/llvm-c/LinkTimeOptimizer.h\" --file \"$(LLVMIncludePath)/llvm-c/lto.h\" --file \"$(LLVMIncludePath)/llvm-c/Object.h\" --file \"$(LLVMIncludePath)/llvm-c/OptRemarks.h\" --file \"$(LLVMIncludePath)/llvm-c/OrcBindings.h\" --file \"$(LLVMIncludePath)/llvm-c/Support.h\" --file \"$(LLVMIncludePath)/llvm-c/Target.h\" --file \"$(LLVMIncludePath)/llvm-c/TargetMachine.h\" --file \"$(LLVMIncludePath)/llvm-c/Types.h\" --file \"$(LLVMIncludePath)/llvm-c/Transforms/AggressiveInstCombine.h\" --file \"$(LLVMIncludePath)/llvm-c/Transforms/Coroutines.h\" --file \"$(LLVMIncludePath)/llvm-c/Transforms/InstCombine.h\" --file \"$(LLVMIncludePath)/llvm-c/Transforms/IPO.h\" --file \"$(LLVMIncludePath)/llvm-c/Transforms/PassManagerBuilder.h\" --file \"$(LLVMIncludePath)/llvm-c/Transforms/Scalar.h\" --file \"$(LLVMIncludePath)/llvm-c/Transforms/Utils.h\" --file \"$(LLVMIncludePath)/llvm-c/Transforms/Vectorize.h\" -e LLVMDisasmInstruction -e LLVMGetBufferStart -e LLVMGetDiagInfoDescription -e LLVMGetDefaultTargetTriple -e LLVMCopyStringRepOfTargetData -e LLVMGetTargetMachineTriple -e LLVMGetTargetMachineCPU -e LLVMGetTargetMachineFeatureString -e LLVMPrintTypeToString -e LLVMCreateMessage -e LLVMDisposeMessage -e LLVMPrintModuleToString -e LLVMPrintValueToString -e LLVMOrcDisposeMangledSymbol -e LLVMTargetMachineEmitToFile -e LLVMInitializeCore -e LLVMAddInstructionCombiningPass"
"commandLineArgs": "-m LLVM -p LLVM --namespace LLVMSharp --output \"./LLVMSharp/Generated/\" --config multi-file --libraryPath \"$(LibLLVMName)\" --include \"$(LLVMIncludePath)\" --file \"$(LLVMIncludePath)/llvm-c/Analysis.h\" --file \"$(LLVMIncludePath)/llvm-c/BitReader.h\" --file \"$(LLVMIncludePath)/llvm-c/BitWriter.h\" --file \"$(LLVMIncludePath)/llvm-c/Comdat.h\" --file \"$(LLVMIncludePath)/llvm-c/Core.h\" --file \"$(LLVMIncludePath)/llvm-c/DataTypes.h\" --file \"$(LLVMIncludePath)/llvm-c/DebugInfo.h\" --file \"$(LLVMIncludePath)/llvm-c/Disassembler.h\" --file \"$(LLVMIncludePath)/llvm-c/DisassemblerTypes.h\" --file \"$(LLVMIncludePath)/llvm-c/Error.h\" --file \"$(LLVMIncludePath)/llvm-c/ErrorHandling.h\" --file \"$(LLVMIncludePath)/llvm-c/ExecutionEngine.h\" --file \"$(LLVMIncludePath)/llvm-c/Initialization.h\" --file \"$(LLVMIncludePath)/llvm-c/IRReader.h\" --file \"$(LLVMIncludePath)/llvm-c/Linker.h\" --file \"$(LLVMIncludePath)/llvm-c/LinkTimeOptimizer.h\" --file \"$(LLVMIncludePath)/llvm-c/lto.h\" --file \"$(LLVMIncludePath)/llvm-c/Object.h\" --file \"$(LLVMIncludePath)/llvm-c/OptRemarks.h\" --file \"$(LLVMIncludePath)/llvm-c/OrcBindings.h\" --file \"$(LLVMIncludePath)/llvm-c/Support.h\" --file \"$(LLVMIncludePath)/llvm-c/Target.h\" --file \"$(LLVMIncludePath)/llvm-c/TargetMachine.h\" --file \"$(LLVMIncludePath)/llvm-c/Types.h\" --file \"$(LLVMIncludePath)/llvm-c/Transforms/AggressiveInstCombine.h\" --file \"$(LLVMIncludePath)/llvm-c/Transforms/Coroutines.h\" --file \"$(LLVMIncludePath)/llvm-c/Transforms/InstCombine.h\" --file \"$(LLVMIncludePath)/llvm-c/Transforms/IPO.h\" --file \"$(LLVMIncludePath)/llvm-c/Transforms/PassManagerBuilder.h\" --file \"$(LLVMIncludePath)/llvm-c/Transforms/Scalar.h\" --file \"$(LLVMIncludePath)/llvm-c/Transforms/Utils.h\" --file \"$(LLVMIncludePath)/llvm-c/Transforms/Vectorize.h\" -e LLVMDisasmInstruction -e LLVMGetBufferStart -e LLVMGetDiagInfoDescription -e LLVMGetDefaultTargetTriple -e LLVMCopyStringRepOfTargetData -e LLVMGetTargetMachineTriple -e LLVMGetTargetMachineCPU -e LLVMGetTargetMachineFeatureString -e LLVMPrintTypeToString -e LLVMCreateMessage -e LLVMDisposeMessage -e LLVMPrintModuleToString -e LLVMPrintValueToString -e LLVMOrcDisposeMangledSymbol -e LLVMTargetMachineEmitToFile -e LLVMInitializeCore -e LLVMAddInstructionCombiningPass -e LLVMAttributeIndex -e LLVMMetadataKind -r __AnonymousEnum_Core_16693=LLVMAttributeIndex -r __AnonymousEnum_DebugInfo_4207=LLVMMetadataKind"
Copy link
Member Author

Choose a reason for hiding this comment

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

The change here is -e LLVMAttributeIndex -e LLVMMetadataKind -r __AnonymousEnum_Core_16693=LLVMAttributeIndex -r __AnonymousEnum_DebugInfo_4207=LLVMMetadataKind" and means that anonymous declarations can be handled.

There is still likely some minor fixups if the header file changes significantly, but it is a step in the right direction.

@@ -786,6 +792,30 @@ private string GetParmModifierForPointeeType(Decl decl, Type pointeeType)
}
}

private string GetRemappedCursorName(NamedDecl namedDecl)
Copy link
Member Author

Choose a reason for hiding this comment

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

There are both upsides and downsides to the super trivial approach here.

The upside is you can remap literally any name. The downside is that it impacts anything with that name and you may want a more precise filter (such as based on whether it is a "struct" or a "field").

@tannergooding tannergooding merged commit d25b054 into dotnet:master May 29, 2019
@tannergooding tannergooding deleted the exclude-and-remap branch May 29, 2019 16:45
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