Permalink
Browse files

Final change to make it PInvokeCompiler compatible

  • Loading branch information...
mjsabby committed Jul 22, 2016
1 parent 3820a64 commit b14e6b36edd4c073f8edaba97a8e3f41455a2ffb
Showing with 37 additions and 5 deletions.
  1. +37 −5 Generated.Custom.cs
View
@@ -117,30 +117,38 @@ public static IntPtr codeCompleteAt(CXTranslationUnit @TU, string @complete_file
public static int indexSourceFile(CXIndexAction @param0, CXClientData @client_data, IndexerCallbacks[] @index_callbacks, uint @index_callbacks_size, uint @index_options, string @source_filename, string[] @command_line_args, int @num_command_line_args, CXUnsavedFile[] @unsaved_files, uint @num_unsaved_files, out CXTranslationUnit @out_TU, uint @TU_options)
{
var arr = new _CXUnsavedFile[unsaved_files.Length];
IntPtr result = IntPtr.Zero;
try
{
BeginCXUnsavedFileMarshal(ref arr, ref unsaved_files);
return indexSourceFile(param0, client_data, index_callbacks, index_callbacks_size, index_options, source_filename, command_line_args, num_command_line_args, arr, num_unsaved_files, out out_TU, TU_options);
BeginIndexerCallbacksMarshal(out result, ref index_callbacks);
return indexSourceFile(param0, client_data, result, index_callbacks_size, index_options, source_filename, command_line_args, num_command_line_args, arr, num_unsaved_files, out out_TU, TU_options);
}
finally
{
EndCXUnsavedFileMarshal(ref arr);
EndIndexerCallbacksMarshal(result);
}
}
public static int indexSourceFileFullArgv(CXIndexAction @param0, CXClientData @client_data, IndexerCallbacks[] @index_callbacks, uint @index_callbacks_size, uint @index_options, string @source_filename, string[] @command_line_args, int @num_command_line_args, CXUnsavedFile[] @unsaved_files, uint @num_unsaved_files, out CXTranslationUnit @out_TU, uint @TU_options)
{
var arr = new _CXUnsavedFile[unsaved_files.Length];
IntPtr result = IntPtr.Zero;
try
{
BeginCXUnsavedFileMarshal(ref arr, ref unsaved_files);
return indexSourceFileFullArgv(param0, client_data, index_callbacks, index_callbacks_size, index_options, source_filename, command_line_args, num_command_line_args, arr, num_unsaved_files, out out_TU, TU_options);
BeginIndexerCallbacksMarshal(out result, ref index_callbacks);
return indexSourceFileFullArgv(param0, client_data, result, index_callbacks_size, index_options, source_filename, command_line_args, num_command_line_args, arr, num_unsaved_files, out out_TU, TU_options);
}
finally
{
EndCXUnsavedFileMarshal(ref arr);
EndIndexerCallbacksMarshal(result);
}
}
@@ -227,17 +235,41 @@ public static void index_setClientEntity(ref CXIdxEntityInfo @param0, CXIdxClien
private static extern IntPtr codeCompleteAt(CXTranslationUnit @TU, [MarshalAs(UnmanagedType.LPStr)] string @complete_filename, uint @complete_line, uint @complete_column, [MarshalAs(UnmanagedType.LPArray)] _CXUnsavedFile[] @unsaved_files, uint @num_unsaved_files, uint @options);
[DllImport(libraryPath, EntryPoint = "clang_indexSourceFile", CallingConvention = CallingConvention.Cdecl)]
private static extern int indexSourceFile(CXIndexAction @param0, CXClientData @client_data, IndexerCallbacks[] @index_callbacks, uint @index_callbacks_size, uint @index_options, [MarshalAs(UnmanagedType.LPStr)] string @source_filename, string[] @command_line_args, int @num_command_line_args, [MarshalAs(UnmanagedType.LPArray)] _CXUnsavedFile[] @unsaved_files, uint @num_unsaved_files, out CXTranslationUnit @out_TU, uint @TU_options);
private static extern int indexSourceFile(CXIndexAction @param0, CXClientData @client_data, IntPtr @index_callbacks, uint @index_callbacks_size, uint @index_options, [MarshalAs(UnmanagedType.LPStr)] string @source_filename, string[] @command_line_args, int @num_command_line_args, [MarshalAs(UnmanagedType.LPArray)] _CXUnsavedFile[] @unsaved_files, uint @num_unsaved_files, out CXTranslationUnit @out_TU, uint @TU_options);
[DllImport(libraryPath, EntryPoint = "clang_indexSourceFileFullArgv", CallingConvention = CallingConvention.Cdecl)]
private static extern int indexSourceFileFullArgv(CXIndexAction @param0, CXClientData @client_data, IndexerCallbacks[] @index_callbacks, uint @index_callbacks_size, uint @index_options, [MarshalAs(UnmanagedType.LPStr)] string @source_filename, string[] @command_line_args, int @num_command_line_args, [MarshalAs(UnmanagedType.LPArray)] _CXUnsavedFile[] @unsaved_files, uint @num_unsaved_files, out CXTranslationUnit @out_TU, uint @TU_options);
private static extern int indexSourceFileFullArgv(CXIndexAction @param0, CXClientData @client_data, IntPtr @index_callbacks, uint @index_callbacks_size, uint @index_options, [MarshalAs(UnmanagedType.LPStr)] string @source_filename, string[] @command_line_args, int @num_command_line_args, [MarshalAs(UnmanagedType.LPArray)] _CXUnsavedFile[] @unsaved_files, uint @num_unsaved_files, out CXTranslationUnit @out_TU, uint @TU_options);
[DllImport(libraryPath, EntryPoint = "clang_index_getClientEntity", CallingConvention = CallingConvention.Cdecl)]
private static extern CXIdxClientEntity index_getClientEntity(ref _CXIdxEntityInfo @param0);
[DllImport(libraryPath, EntryPoint = "clang_index_setClientEntity", CallingConvention = CallingConvention.Cdecl)]
private static extern void index_setClientEntity(ref _CXIdxEntityInfo @param0, CXIdxClientEntity @param1);
private static void BeginIndexerCallbacksMarshal(out IntPtr result, ref IndexerCallbacks[] index_callbacks)
{
int length = index_callbacks.Length;
int size = Marshal.SizeOf(typeof(IndexerCallbacks));
result = Marshal.AllocHGlobal(size * length);
var ptr = result.ToInt64();
for (int i = 0; i < length; ++i)
{
var cursor = new IntPtr(ptr);
Marshal.StructureToPtr(index_callbacks[i], cursor, false);
ptr += Marshal.SizeOf(size);
}
}
private static void EndIndexerCallbacksMarshal(IntPtr result)
{
if (result != IntPtr.Zero)
{
Marshal.FreeHGlobal(result);
}
}
private static void BeginCXUnsavedFileMarshal(ref _CXUnsavedFile[] arr, ref CXUnsavedFile[] @unsaved_files)
{
int size = arr.Length;

0 comments on commit b14e6b3

Please sign in to comment.