mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-25 02:58:02 +02:00
Initial checkin
This commit is contained in:
parent
c74712dad9
commit
078564ac9e
3242 changed files with 1616395 additions and 0 deletions
92
IDE/src/Clang/ClangHelper.bf
Normal file
92
IDE/src/Clang/ClangHelper.bf
Normal file
|
@ -0,0 +1,92 @@
|
|||
#if false
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
using Beefy.widgets;
|
||||
using IDE.Compiler;
|
||||
|
||||
namespace IDE.Clang
|
||||
{
|
||||
public class ClangHelper : CompilerBase
|
||||
{
|
||||
[StdCall, CLink]
|
||||
static extern IntPtr ClangHelper_Create();
|
||||
|
||||
[StdCall, CLink]
|
||||
static extern void ClangHelper_Delete(IntPtr clangHelper);
|
||||
|
||||
[StdCall, CLink]
|
||||
static extern IntPtr ClangHelper_Classify(IntPtr clangHelper, char* fileName, void* elementTypeArray, int charLen, int cursorIdx);
|
||||
|
||||
[StdCall, CLink]
|
||||
static extern IntPtr ClangHelper_FindDefinition(IntPtr clangHelper, char* fileName, int line, int column, out int outDefLine, out int outDefColumn);
|
||||
|
||||
[StdCall, CLink]
|
||||
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
|
Loading…
Add table
Add a link
Reference in a new issue