Merge pull request #116 from luoliwoshang/llcppsigfetch/enum_anony
llcppsigfetch:anonymous enumdecl
This commit is contained in:
@@ -611,13 +611,22 @@ func (ct *Converter) ProcessEnumType(cursor clang.Cursor) *ast.EnumType {
|
||||
}
|
||||
|
||||
func (ct *Converter) ProcessEnumDecl(cursor clang.Cursor) *ast.EnumTypeDecl {
|
||||
name := toStr(cursor.String())
|
||||
cursorName, cursorKind := getCursorDesc(cursor)
|
||||
ct.logln("ProcessEnumDecl: CursorName:", cursorName, "CursorKind:", cursorKind)
|
||||
|
||||
decl := &ast.EnumTypeDecl{
|
||||
DeclBase: ct.CreateDeclBase(cursor),
|
||||
Name: &ast.Ident{Name: name},
|
||||
Type: ct.ProcessEnumType(cursor),
|
||||
}
|
||||
|
||||
anony := cursor.IsAnonymous()
|
||||
if anony == 0 {
|
||||
decl.Name = &ast.Ident{Name: cursorName}
|
||||
ct.logln("ProcessEnumDecl: has name", cursorName)
|
||||
} else {
|
||||
ct.logln("ProcessRecordDecl: is anonymous")
|
||||
}
|
||||
|
||||
ct.SetTypeDecl(cursor, decl)
|
||||
return decl
|
||||
}
|
||||
@@ -738,22 +747,20 @@ func (ct *Converter) ProcessRecordDecl(cursor clang.Cursor) *ast.TypeDecl {
|
||||
cursorName, cursorKind := getCursorDesc(cursor)
|
||||
ct.logln("ProcessRecordDecl: CursorName:", cursorName, "CursorKind:", cursorKind)
|
||||
|
||||
decl := &ast.TypeDecl{
|
||||
DeclBase: ct.CreateDeclBase(cursor),
|
||||
Type: ct.ProcessRecordType(cursor),
|
||||
}
|
||||
|
||||
anony := cursor.IsAnonymousRecordDecl()
|
||||
var name *ast.Ident
|
||||
if anony == 0 {
|
||||
name = &ast.Ident{Name: cursorName}
|
||||
decl.Name = &ast.Ident{Name: cursorName}
|
||||
ct.logln("ProcessRecordDecl: has name", cursorName)
|
||||
} else {
|
||||
ct.logln("ProcessRecordDecl: is anonymous")
|
||||
}
|
||||
|
||||
decl := &ast.TypeDecl{
|
||||
DeclBase: ct.CreateDeclBase(cursor),
|
||||
Name: name,
|
||||
Type: ct.ProcessRecordType(cursor),
|
||||
}
|
||||
ct.SetTypeDecl(cursor, decl)
|
||||
|
||||
return decl
|
||||
}
|
||||
|
||||
@@ -775,7 +782,7 @@ func (ct *Converter) ProcessClassDecl(cursor clang.Cursor) *ast.TypeDecl {
|
||||
|
||||
decl := &ast.TypeDecl{
|
||||
DeclBase: base,
|
||||
Name: &ast.Ident{Name: c.GoString(cursor.String().CStr())},
|
||||
Name: &ast.Ident{Name: cursorName},
|
||||
Type: typ,
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,11 @@ func main() {
|
||||
|
||||
func TestEnumDecl() {
|
||||
testCases := []string{
|
||||
`enum {
|
||||
a,
|
||||
b,
|
||||
c,
|
||||
};`,
|
||||
`enum Foo {
|
||||
a,
|
||||
b,
|
||||
|
||||
@@ -11,10 +11,7 @@ TestEnumDecl Case 1:
|
||||
},
|
||||
"Doc": null,
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"_Type": "Ident",
|
||||
"Name": "Foo"
|
||||
},
|
||||
"Name": null,
|
||||
"Type": {
|
||||
"_Type": "EnumType",
|
||||
"Items": [{
|
||||
@@ -59,6 +56,65 @@ TestEnumDecl Case 1:
|
||||
}
|
||||
|
||||
TestEnumDecl Case 2:
|
||||
{
|
||||
"temp.h": {
|
||||
"_Type": "File",
|
||||
"decls": [{
|
||||
"_Type": "EnumTypeDecl",
|
||||
"Loc": {
|
||||
"_Type": "Location",
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": null,
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"_Type": "Ident",
|
||||
"Name": "Foo"
|
||||
},
|
||||
"Type": {
|
||||
"_Type": "EnumType",
|
||||
"Items": [{
|
||||
"_Type": "EnumItem",
|
||||
"Name": {
|
||||
"_Type": "Ident",
|
||||
"Name": "a"
|
||||
},
|
||||
"Value": {
|
||||
"_Type": "BasicLit",
|
||||
"Kind": 0,
|
||||
"Value": "0"
|
||||
}
|
||||
}, {
|
||||
"_Type": "EnumItem",
|
||||
"Name": {
|
||||
"_Type": "Ident",
|
||||
"Name": "b"
|
||||
},
|
||||
"Value": {
|
||||
"_Type": "BasicLit",
|
||||
"Kind": 0,
|
||||
"Value": "1"
|
||||
}
|
||||
}, {
|
||||
"_Type": "EnumItem",
|
||||
"Name": {
|
||||
"_Type": "Ident",
|
||||
"Name": "c"
|
||||
},
|
||||
"Value": {
|
||||
"_Type": "BasicLit",
|
||||
"Kind": 0,
|
||||
"Value": "2"
|
||||
}
|
||||
}]
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestEnumDecl Case 3:
|
||||
{
|
||||
"temp.h": {
|
||||
"_Type": "File",
|
||||
@@ -117,7 +173,7 @@ TestEnumDecl Case 2:
|
||||
}
|
||||
}
|
||||
|
||||
TestEnumDecl Case 3:
|
||||
TestEnumDecl Case 4:
|
||||
{
|
||||
"temp.h": {
|
||||
"_Type": "File",
|
||||
|
||||
Reference in New Issue
Block a user