llcppsigfetch:anonymous record name
This commit is contained in:
@@ -427,10 +427,15 @@ func (ct *Converter) ProcessMethods(cursor clang.Cursor) []*ast.FuncDecl {
|
|||||||
return methods
|
return methods
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ct *Converter) ProcessStructOrClass(cursor clang.Cursor, tag ast.Tag) *ast.TypeDecl {
|
func (ct *Converter) ProcessRecord(cursor clang.Cursor, tag ast.Tag) *ast.TypeDecl {
|
||||||
|
anony := cursor.IsAnonymousRecordDecl()
|
||||||
|
|
||||||
name := cursor.String()
|
var name *ast.Ident
|
||||||
defer name.Dispose()
|
if anony == 0 {
|
||||||
|
cursorName := cursor.String()
|
||||||
|
defer cursorName.Dispose()
|
||||||
|
name = &ast.Ident{Name: c.GoString(cursorName.CStr())}
|
||||||
|
}
|
||||||
|
|
||||||
fields := ct.ProcessFieldList(cursor)
|
fields := ct.ProcessFieldList(cursor)
|
||||||
methods := ct.ProcessMethods(cursor)
|
methods := ct.ProcessMethods(cursor)
|
||||||
@@ -438,7 +443,7 @@ func (ct *Converter) ProcessStructOrClass(cursor clang.Cursor, tag ast.Tag) *ast
|
|||||||
decl := &ast.TypeDecl{
|
decl := &ast.TypeDecl{
|
||||||
DeclBase: ct.CreateDeclBase(cursor),
|
DeclBase: ct.CreateDeclBase(cursor),
|
||||||
Tag: tag,
|
Tag: tag,
|
||||||
Name: &ast.Ident{Name: c.GoString(name.CStr())},
|
Name: name,
|
||||||
Fields: fields,
|
Fields: fields,
|
||||||
Methods: methods,
|
Methods: methods,
|
||||||
}
|
}
|
||||||
@@ -447,15 +452,15 @@ func (ct *Converter) ProcessStructOrClass(cursor clang.Cursor, tag ast.Tag) *ast
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ct *Converter) ProcessStruct(cursor clang.Cursor) *ast.TypeDecl {
|
func (ct *Converter) ProcessStruct(cursor clang.Cursor) *ast.TypeDecl {
|
||||||
return ct.ProcessStructOrClass(cursor, ast.Struct)
|
return ct.ProcessRecord(cursor, ast.Struct)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ct *Converter) ProcessUnion(cursor clang.Cursor) *ast.TypeDecl {
|
func (ct *Converter) ProcessUnion(cursor clang.Cursor) *ast.TypeDecl {
|
||||||
return ct.ProcessStructOrClass(cursor, ast.Union)
|
return ct.ProcessRecord(cursor, ast.Union)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ct *Converter) ProcessClass(cursor clang.Cursor) *ast.TypeDecl {
|
func (ct *Converter) ProcessClass(cursor clang.Cursor) *ast.TypeDecl {
|
||||||
return ct.ProcessStructOrClass(cursor, ast.Class)
|
return ct.ProcessRecord(cursor, ast.Class)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ct *Converter) ProcessBuiltinType(t clang.Type) *ast.BuiltinType {
|
func (ct *Converter) ProcessBuiltinType(t clang.Type) *ast.BuiltinType {
|
||||||
|
|||||||
@@ -85,6 +85,9 @@ void foo();`,
|
|||||||
|
|
||||||
func TestStructDecl() {
|
func TestStructDecl() {
|
||||||
testCases := []string{
|
testCases := []string{
|
||||||
|
`struct {
|
||||||
|
int a;
|
||||||
|
};`,
|
||||||
`struct A {
|
`struct A {
|
||||||
int a;
|
int a;
|
||||||
int b;
|
int b;
|
||||||
@@ -103,6 +106,10 @@ func TestStructDecl() {
|
|||||||
|
|
||||||
func TestUnionDecl() {
|
func TestUnionDecl() {
|
||||||
testCases := []string{
|
testCases := []string{
|
||||||
|
`union {
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
};`,
|
||||||
`union A {
|
`union A {
|
||||||
int a;
|
int a;
|
||||||
int b;
|
int b;
|
||||||
|
|||||||
@@ -958,9 +958,7 @@ TestStructDecl Case 1:
|
|||||||
},
|
},
|
||||||
"Parent": null,
|
"Parent": null,
|
||||||
"Tag": 0,
|
"Tag": 0,
|
||||||
"Name": {
|
"Name": null,
|
||||||
"Name": "A"
|
|
||||||
},
|
|
||||||
"Fields": {
|
"Fields": {
|
||||||
"List": [{
|
"List": [{
|
||||||
"Type": {
|
"Type": {
|
||||||
@@ -976,20 +974,6 @@ TestStructDecl Case 1:
|
|||||||
"Names": [{
|
"Names": [{
|
||||||
"Name": "a"
|
"Name": "a"
|
||||||
}]
|
}]
|
||||||
}, {
|
|
||||||
"Type": {
|
|
||||||
"Kind": 6,
|
|
||||||
"Flags": 0
|
|
||||||
},
|
|
||||||
"Doc": {
|
|
||||||
"List": []
|
|
||||||
},
|
|
||||||
"Comment": {
|
|
||||||
"List": []
|
|
||||||
},
|
|
||||||
"Names": [{
|
|
||||||
"Name": "b"
|
|
||||||
}]
|
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
"Methods": []
|
"Methods": []
|
||||||
@@ -1054,6 +1038,60 @@ TestStructDecl Case 2:
|
|||||||
}
|
}
|
||||||
|
|
||||||
TestStructDecl Case 3:
|
TestStructDecl Case 3:
|
||||||
|
{
|
||||||
|
"temp.h": {
|
||||||
|
"path": "temp.h",
|
||||||
|
"decls": [{
|
||||||
|
"Loc": {
|
||||||
|
"File": "temp.h"
|
||||||
|
},
|
||||||
|
"Doc": {
|
||||||
|
"List": []
|
||||||
|
},
|
||||||
|
"Parent": null,
|
||||||
|
"Tag": 0,
|
||||||
|
"Name": {
|
||||||
|
"Name": "A"
|
||||||
|
},
|
||||||
|
"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": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TestStructDecl Case 4:
|
||||||
{
|
{
|
||||||
"temp.h": {
|
"temp.h": {
|
||||||
"path": "temp.h",
|
"path": "temp.h",
|
||||||
@@ -1318,6 +1356,58 @@ TestClassDecl Case 2:
|
|||||||
}
|
}
|
||||||
|
|
||||||
TestUnionDecl Case 1:
|
TestUnionDecl Case 1:
|
||||||
|
{
|
||||||
|
"temp.h": {
|
||||||
|
"path": "temp.h",
|
||||||
|
"decls": [{
|
||||||
|
"Loc": {
|
||||||
|
"File": "temp.h"
|
||||||
|
},
|
||||||
|
"Doc": {
|
||||||
|
"List": []
|
||||||
|
},
|
||||||
|
"Parent": null,
|
||||||
|
"Tag": 1,
|
||||||
|
"Name": null,
|
||||||
|
"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": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TestUnionDecl Case 2:
|
||||||
{
|
{
|
||||||
"temp.h": {
|
"temp.h": {
|
||||||
"path": "temp.h",
|
"path": "temp.h",
|
||||||
|
|||||||
@@ -131,6 +131,9 @@ func MarshalASTExpr(t ast.Expr) *cjson.JSON {
|
|||||||
}
|
}
|
||||||
root.SetItem(c.Str("Names"), names)
|
root.SetItem(c.Str("Names"), names)
|
||||||
case *ast.Ident:
|
case *ast.Ident:
|
||||||
|
if d == nil {
|
||||||
|
return cjson.Null()
|
||||||
|
}
|
||||||
root.SetItem(c.Str("Name"), cjson.String(c.AllocaCStr(d.Name)))
|
root.SetItem(c.Str("Name"), cjson.String(c.AllocaCStr(d.Name)))
|
||||||
case *ast.EnumItem:
|
case *ast.EnumItem:
|
||||||
root.SetItem(c.Str("Name"), MarshalASTExpr(d.Name))
|
root.SetItem(c.Str("Name"), MarshalASTExpr(d.Name))
|
||||||
@@ -147,6 +150,9 @@ func MarshalASTExpr(t ast.Expr) *cjson.JSON {
|
|||||||
root.SetItem(c.Str("Kind"), cjson.Number(float64(d.Kind)))
|
root.SetItem(c.Str("Kind"), cjson.Number(float64(d.Kind)))
|
||||||
root.SetItem(c.Str("Flags"), cjson.Number(float64(d.Flags)))
|
root.SetItem(c.Str("Flags"), cjson.Number(float64(d.Flags)))
|
||||||
case *ast.Comment:
|
case *ast.Comment:
|
||||||
|
if d == nil {
|
||||||
|
return cjson.Null()
|
||||||
|
}
|
||||||
root.SetItem(c.Str("Text"), cjson.String(c.AllocaCStr(d.Text)))
|
root.SetItem(c.Str("Text"), cjson.String(c.AllocaCStr(d.Text)))
|
||||||
case *ast.CommentGroup:
|
case *ast.CommentGroup:
|
||||||
if d == nil {
|
if d == nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user