-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmyThread.cpp
47 lines (33 loc) · 1.16 KB
/
myThread.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "myThread.h"
#include <wx/thread.h>
#include <cbplugin.h>
DEFINE_EVENT_TYPE(wxEVT_MY_EVENT)
void freeCommandLine(const char** args, int numOfTokens)
{
for (int i = 0; i < numOfTokens; i++)
{
free((char*)args[i]);
}
free(args);
}
CXTranslationUnit myThread::threadFunc()
{
CXTranslationUnit unit = clang_parseTranslationUnit(index, buffer.data(),args,numOfTokens, NULL,0, CXTranslationUnit_PrecompiledPreamble | CXTranslationUnit_CacheCompletionResults | CXTranslationUnit_CXXPrecompiledPreamble);
int status = clang_reparseTranslationUnit(unit,0, NULL, clang_defaultReparseOptions(unit));
CXCodeCompleteResults* results= clang_codeCompleteAt(unit,buffer.data(),1,1, NULL, 0, clang_defaultCodeCompleteOptions());
clang_disposeCodeCompleteResults(results);
freeCommandLine(args,numOfTokens);
return unit;
}
void* myThread::Entry()
{
transferData* data = new transferData;
data->unit = threadFunc();
data->filename = buffer;
data->id = id;
data->project = project;
wxCommandEvent event(wxEVT_MY_EVENT, threadDoneId);
event.SetClientData(data);
wxPostEvent(handle,event);
return 0;
}