llcppsigfetch:union
This commit is contained in:
@@ -194,6 +194,8 @@ func visit(cursor, parent clang.Cursor, clientData unsafe.Pointer) clang.ChildVi
|
|||||||
ct.PopScope()
|
ct.PopScope()
|
||||||
case clang.CursorStructDecl:
|
case clang.CursorStructDecl:
|
||||||
ct.ProcessStruct(cursor)
|
ct.ProcessStruct(cursor)
|
||||||
|
case clang.CursorUnionDecl:
|
||||||
|
ct.ProcessUnion(cursor)
|
||||||
case clang.CursorFunctionDecl:
|
case clang.CursorFunctionDecl:
|
||||||
ct.curFile.Decls = append(ct.curFile.Decls, ct.ProcessFunc(cursor))
|
ct.curFile.Decls = append(ct.curFile.Decls, ct.ProcessFunc(cursor))
|
||||||
case clang.CursorNamespace:
|
case clang.CursorNamespace:
|
||||||
@@ -435,6 +437,11 @@ func (ct *Converter) ProcessStruct(cursor clang.Cursor) {
|
|||||||
ct.curFile.Decls = append(ct.curFile.Decls, structDecl)
|
ct.curFile.Decls = append(ct.curFile.Decls, structDecl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ct *Converter) ProcessUnion(cursor clang.Cursor) {
|
||||||
|
structDecl := ct.ProcessStructOrClass(cursor, ast.Union)
|
||||||
|
ct.curFile.Decls = append(ct.curFile.Decls, structDecl)
|
||||||
|
}
|
||||||
|
|
||||||
func (ct *Converter) ProcessClass(cursor clang.Cursor) {
|
func (ct *Converter) ProcessClass(cursor clang.Cursor) {
|
||||||
classDecl := ct.ProcessStructOrClass(cursor, ast.Class)
|
classDecl := ct.ProcessStructOrClass(cursor, ast.Class)
|
||||||
// other logic for class
|
// other logic for class
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ func main() {
|
|||||||
TestComment()
|
TestComment()
|
||||||
TestStructDecl()
|
TestStructDecl()
|
||||||
TestClassDecl()
|
TestClassDecl()
|
||||||
|
TestUnionDecl()
|
||||||
TestEnumDecl()
|
TestEnumDecl()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +101,16 @@ func TestStructDecl() {
|
|||||||
test.RunTest("TestStructDecl", testCases)
|
test.RunTest("TestStructDecl", testCases)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUnionDecl() {
|
||||||
|
testCases := []string{
|
||||||
|
`union A {
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
};`,
|
||||||
|
}
|
||||||
|
test.RunTest("TestUnionDecl", testCases)
|
||||||
|
}
|
||||||
|
|
||||||
func TestClassDecl() {
|
func TestClassDecl() {
|
||||||
testCases := []string{
|
testCases := []string{
|
||||||
`class A {
|
`class A {
|
||||||
|
|||||||
@@ -1296,6 +1296,57 @@ TestClassDecl Case 2:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TestUnionDecl Case 1:
|
||||||
|
{
|
||||||
|
"temp.h": {
|
||||||
|
"path": "temp.h",
|
||||||
|
"decls": [{
|
||||||
|
"Loc": {
|
||||||
|
"File": "temp.h"
|
||||||
|
},
|
||||||
|
"Doc": {
|
||||||
|
"List": []
|
||||||
|
},
|
||||||
|
"Parent": null,
|
||||||
|
"Tag": 1,
|
||||||
|
"Fields": {
|
||||||
|
"List": [{
|
||||||
|
"Type": {
|
||||||
|
"Kind": 6,
|
||||||
|
"Flags": 0
|
||||||
|
},
|
||||||
|
"Doc": {
|
||||||
|
"List": []
|
||||||
|
},
|
||||||
|
"Comment": {
|
||||||
|
"List": []
|
||||||
|
},
|
||||||
|
"Names": [{
|
||||||
|
"Name": "a"
|
||||||
|
}]
|
||||||
|
}, {
|
||||||
|
"Type": {
|
||||||
|
"Kind": 6,
|
||||||
|
"Flags": 0
|
||||||
|
},
|
||||||
|
"Doc": {
|
||||||
|
"List": []
|
||||||
|
},
|
||||||
|
"Comment": {
|
||||||
|
"List": []
|
||||||
|
},
|
||||||
|
"Names": [{
|
||||||
|
"Name": "b"
|
||||||
|
}]
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
"Methods": []
|
||||||
|
}],
|
||||||
|
"includes": [],
|
||||||
|
"macros": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TestEnumDecl Case 1:
|
TestEnumDecl Case 1:
|
||||||
{
|
{
|
||||||
"temp.h": {
|
"temp.h": {
|
||||||
|
|||||||
Reference in New Issue
Block a user