2019-08-23 11:56:54 -07:00
|
|
|
#if false
|
|
|
|
|
|
|
|
using System;
|
2020-04-29 06:40:03 -07:00
|
|
|
using System.Collections;
|
2019-08-23 11:56:54 -07:00
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Beefy.widgets;
|
|
|
|
using IDE.Compiler;
|
|
|
|
|
|
|
|
namespace IDE.Clang
|
|
|
|
{
|
|
|
|
public class ClangHelper : CompilerBase
|
|
|
|
{
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern IntPtr ClangHelper_Create();
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern void ClangHelper_Delete(IntPtr clangHelper);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern IntPtr ClangHelper_Classify(IntPtr clangHelper, char* fileName, void* elementTypeArray, int charLen, int cursorIdx);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern IntPtr ClangHelper_FindDefinition(IntPtr clangHelper, char* fileName, int line, int column, out int outDefLine, out int outDefColumn);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern IntPtr ClangHelper_Autocomplete(IntPtr clangHelper, char* fileName, int cursorIdx);
|
|
|
|
|
|
|
|
IntPtr mNativeClangHelper;
|
|
|
|
|
|
|
|
public this()
|
|
|
|
{
|
|
|
|
mNativeClangHelper = ClangHelper_Create();
|
|
|
|
}
|
|
|
|
|
|
|
|
public ~this()
|
|
|
|
{
|
|
|
|
ClangHelper_Delete(mNativeClangHelper);
|
|
|
|
mNativeClangHelper = IntPtr.Zero;
|
|
|
|
}
|
|
|
|
|
|
|
|
public string Classify(string fileName, EditWidgetContent.CharData[] charData, int cursorIdx)
|
|
|
|
{
|
|
|
|
fixed (EditWidgetContent.CharData* charDataPtr = charData)
|
|
|
|
{
|
|
|
|
IntPtr returnStringPtr = ClangHelper_Classify(mNativeClangHelper, fileName, charDataPtr, charData.Length, cursorIdx);
|
|
|
|
if (returnStringPtr == IntPtr.Zero)
|
|
|
|
return null;
|
|
|
|
return Marshal.PtrToStringAnsi(returnStringPtr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void FindDefinition(string fileName, int line, int column, out string defFileName, out int defLine, out int defColumn)
|
|
|
|
{
|
|
|
|
IntPtr fileNamePtr = ClangHelper_FindDefinition(mNativeClangHelper, fileName, line, column, out defLine, out defColumn);
|
|
|
|
if (fileNamePtr == null)
|
|
|
|
{
|
|
|
|
defFileName = null;
|
|
|
|
defLine = 0;
|
|
|
|
defColumn = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
defFileName = Marshal.PtrToStringAnsi(fileNamePtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
public string Autocomplete(string fileName, int cursorIdx)
|
|
|
|
{
|
|
|
|
IntPtr fileNamePtr = ClangHelper_Autocomplete(mNativeClangHelper, fileName, cursorIdx);
|
|
|
|
if (fileNamePtr == IntPtr.Zero)
|
|
|
|
return null;
|
|
|
|
return Marshal.PtrToStringAnsi(fileNamePtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void ProcessQueue()
|
|
|
|
{
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
Command command = null;
|
|
|
|
using (mMonitor.Enter())
|
|
|
|
{
|
|
|
|
if (mCommandQueue.Count == 0)
|
|
|
|
break;
|
|
|
|
command = mCommandQueue[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|