diff --git a/chore/_xtool/llcppsigfetch/parse/cvt.go b/chore/_xtool/llcppsigfetch/parse/cvt.go index b91a5a32..64ed372f 100644 --- a/chore/_xtool/llcppsigfetch/parse/cvt.go +++ b/chore/_xtool/llcppsigfetch/parse/cvt.go @@ -194,6 +194,8 @@ func visit(cursor, parent clang.Cursor, clientData unsafe.Pointer) clang.ChildVi ct.PopScope() case clang.CursorStructDecl: ct.ProcessStruct(cursor) + case clang.CursorUnionDecl: + ct.ProcessUnion(cursor) case clang.CursorFunctionDecl: ct.curFile.Decls = append(ct.curFile.Decls, ct.ProcessFunc(cursor)) case clang.CursorNamespace: @@ -435,6 +437,11 @@ func (ct *Converter) ProcessStruct(cursor clang.Cursor) { 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) { classDecl := ct.ProcessStructOrClass(cursor, ast.Class) // other logic for class diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/decl.go b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/decl.go index 27cd2253..ec00ba19 100644 --- a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/decl.go +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/decl.go @@ -10,6 +10,7 @@ func main() { TestComment() TestStructDecl() TestClassDecl() + TestUnionDecl() TestEnumDecl() } @@ -100,6 +101,16 @@ func TestStructDecl() { test.RunTest("TestStructDecl", testCases) } +func TestUnionDecl() { + testCases := []string{ + `union A { + int a; + int b; + };`, + } + test.RunTest("TestUnionDecl", testCases) +} + func TestClassDecl() { testCases := []string{ `class A { diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/llgo.expect b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/llgo.expect index 893bc838..5a37e43c 100644 --- a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/llgo.expect +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/llgo.expect @@ -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: { "temp.h": {