From ba2cba36102062282dac6a32de085ded69357393 Mon Sep 17 00:00:00 2001 From: Mukul Sabharwal Date: Sat, 9 Jul 2016 19:31:12 -0700 Subject: [PATCH] Add compilation database functions --- ClangSharp.sln | 4 +-- Generated.cs | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ build.bat | 2 +- 3 files changed, 81 insertions(+), 3 deletions(-) diff --git a/ClangSharp.sln b/ClangSharp.sln index dc0e0044..8ffd31d3 100644 --- a/ClangSharp.sln +++ b/ClangSharp.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 +# Visual Studio 2015 +VisualStudioVersion = 14.0.20420.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClangSharp", "ClangSharp.csproj", "{6091B9F6-D75E-4457-BF5B-89076FCB262B}" EndProject diff --git a/Generated.cs b/Generated.cs index f0de2a65..cbed6444 100644 --- a/Generated.cs +++ b/Generated.cs @@ -465,6 +465,36 @@ public CXIndexAction(IntPtr pointer) [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate CXVisitorResult CXFieldVisitor(CXCursor @C, IntPtr @client_data); + public partial struct CXCompilationDatabase + { + public CXCompilationDatabase(IntPtr pointer) + { + this.Pointer = pointer; + } + + public IntPtr Pointer; + } + + public partial struct CXCompileCommands + { + public CXCompileCommands(IntPtr pointer) + { + this.Pointer = pointer; + } + + public IntPtr Pointer; + } + + public partial struct CXCompileCommand + { + public CXCompileCommand(IntPtr pointer) + { + this.Pointer = pointer; + } + + public IntPtr Pointer; + } + public enum CXErrorCode : int { @CXError_Success = 0, @@ -1171,6 +1201,12 @@ public enum CXCommentParamPassDirection : int @CXCommentParamPassDirection_InOut = 2, } + public enum CXCompilationDatabase_Error : int + { + @CXCompilationDatabase_NoError = 0, + @CXCompilationDatabase_CanNotLoadDatabase = 1, + } + public static partial class clang { private const string libraryPath = "libclang"; @@ -2093,5 +2129,47 @@ public static partial class clang [DllImport(libraryPath, EntryPoint = "clang_FullComment_getAsXML", CallingConvention = CallingConvention.Cdecl)] public static extern CXString FullComment_getAsXML(CXComment @Comment); + [DllImport(libraryPath, EntryPoint = "clang_CompilationDatabase_fromDirectory", CallingConvention = CallingConvention.Cdecl)] + public static extern CXCompilationDatabase CompilationDatabase_fromDirectory([MarshalAs(UnmanagedType.LPStr)] string @BuildDir, out CXCompilationDatabase_Error @ErrorCode); + + [DllImport(libraryPath, EntryPoint = "clang_CompilationDatabase_dispose", CallingConvention = CallingConvention.Cdecl)] + public static extern void CompilationDatabase_dispose(CXCompilationDatabase @param0); + + [DllImport(libraryPath, EntryPoint = "clang_CompilationDatabase_getCompileCommands", CallingConvention = CallingConvention.Cdecl)] + public static extern CXCompileCommands CompilationDatabase_getCompileCommands(CXCompilationDatabase @param0, [MarshalAs(UnmanagedType.LPStr)] string @CompleteFileName); + + [DllImport(libraryPath, EntryPoint = "clang_CompilationDatabase_getAllCompileCommands", CallingConvention = CallingConvention.Cdecl)] + public static extern CXCompileCommands CompilationDatabase_getAllCompileCommands(CXCompilationDatabase @param0); + + [DllImport(libraryPath, EntryPoint = "clang_CompileCommands_dispose", CallingConvention = CallingConvention.Cdecl)] + public static extern void CompileCommands_dispose(CXCompileCommands @param0); + + [DllImport(libraryPath, EntryPoint = "clang_CompileCommands_getSize", CallingConvention = CallingConvention.Cdecl)] + public static extern uint CompileCommands_getSize(CXCompileCommands @param0); + + [DllImport(libraryPath, EntryPoint = "clang_CompileCommands_getCommand", CallingConvention = CallingConvention.Cdecl)] + public static extern CXCompileCommand CompileCommands_getCommand(CXCompileCommands @param0, uint @I); + + [DllImport(libraryPath, EntryPoint = "clang_CompileCommand_getDirectory", CallingConvention = CallingConvention.Cdecl)] + public static extern CXString CompileCommand_getDirectory(CXCompileCommand @param0); + + [DllImport(libraryPath, EntryPoint = "clang_CompileCommand_getFilename", CallingConvention = CallingConvention.Cdecl)] + public static extern CXString CompileCommand_getFilename(CXCompileCommand @param0); + + [DllImport(libraryPath, EntryPoint = "clang_CompileCommand_getNumArgs", CallingConvention = CallingConvention.Cdecl)] + public static extern uint CompileCommand_getNumArgs(CXCompileCommand @param0); + + [DllImport(libraryPath, EntryPoint = "clang_CompileCommand_getArg", CallingConvention = CallingConvention.Cdecl)] + public static extern CXString CompileCommand_getArg(CXCompileCommand @param0, uint @I); + + [DllImport(libraryPath, EntryPoint = "clang_CompileCommand_getNumMappedSources", CallingConvention = CallingConvention.Cdecl)] + public static extern uint CompileCommand_getNumMappedSources(CXCompileCommand @param0); + + [DllImport(libraryPath, EntryPoint = "clang_CompileCommand_getMappedSourcePath", CallingConvention = CallingConvention.Cdecl)] + public static extern CXString CompileCommand_getMappedSourcePath(CXCompileCommand @param0, uint @I); + + [DllImport(libraryPath, EntryPoint = "clang_CompileCommand_getMappedSourceContent", CallingConvention = CallingConvention.Cdecl)] + public static extern CXString CompileCommand_getMappedSourceContent(CXCompileCommand @param0, uint @I); + } } diff --git a/build.bat b/build.bat index 7d420aba..0b598b95 100644 --- a/build.bat +++ b/build.bat @@ -9,5 +9,5 @@ if [%2]==[] ( ) csc /out:ClangSharpPInvokeGenerator.exe ClangSharpPInvokeGenerator\*.cs -ClangSharpPInvokeGenerator.exe --m clang --p clang_ --namespace ClangSharp --output Generated.cs --libraryPath %1 --include %2 --file %2/clang-c/Index.h --file %2/clang-c/CXString.h --file %2/clang-c/Documentation.h --file %2/clang-c/CXErrorCode.h +ClangSharpPInvokeGenerator.exe --m clang --p clang_ --namespace ClangSharp --output Generated.cs --libraryPath %1 --include %2 --file %2/clang-c/Index.h --file %2/clang-c/CXString.h --file %2/clang-c/Documentation.h --file %2/clang-c/CXErrorCode.h --file %2/clang-c/BuildSystem.h --file %2/clang-c/CXCompilationDatabase.h csc /target:library /out:ClangSharp.dll Generated.cs Extensions.cs \ No newline at end of file