llcppsigfetch:enum type
This commit is contained in:
@@ -334,7 +334,9 @@ func (ct *Converter) ProcessEnumDecl(cursor clang.Cursor) *ast.EnumTypeDecl {
|
|||||||
return &ast.EnumTypeDecl{
|
return &ast.EnumTypeDecl{
|
||||||
DeclBase: ct.CreateDeclBase(cursor),
|
DeclBase: ct.CreateDeclBase(cursor),
|
||||||
Name: &ast.Ident{Name: c.GoString(name.CStr())},
|
Name: &ast.Ident{Name: c.GoString(name.CStr())},
|
||||||
Items: items,
|
Type: &ast.EnumType{
|
||||||
|
Items: items,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,31 +13,33 @@ TestEnumDecl Case 1:
|
|||||||
"Name": {
|
"Name": {
|
||||||
"Name": "Foo"
|
"Name": "Foo"
|
||||||
},
|
},
|
||||||
"Items": [{
|
"Type": {
|
||||||
"Name": {
|
"Items": [{
|
||||||
"Name": "a"
|
"Name": {
|
||||||
},
|
"Name": "a"
|
||||||
"Value": {
|
},
|
||||||
"Kind": 0,
|
"Value": {
|
||||||
"Value": "0"
|
"Kind": 0,
|
||||||
}
|
"Value": "0"
|
||||||
}, {
|
}
|
||||||
"Name": {
|
}, {
|
||||||
"Name": "b"
|
"Name": {
|
||||||
},
|
"Name": "b"
|
||||||
"Value": {
|
},
|
||||||
"Kind": 0,
|
"Value": {
|
||||||
"Value": "1"
|
"Kind": 0,
|
||||||
}
|
"Value": "1"
|
||||||
}, {
|
}
|
||||||
"Name": {
|
}, {
|
||||||
"Name": "c"
|
"Name": {
|
||||||
},
|
"Name": "c"
|
||||||
"Value": {
|
},
|
||||||
"Kind": 0,
|
"Value": {
|
||||||
"Value": "2"
|
"Kind": 0,
|
||||||
}
|
"Value": "2"
|
||||||
}]
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
}],
|
}],
|
||||||
"includes": [],
|
"includes": [],
|
||||||
"macros": []
|
"macros": []
|
||||||
@@ -58,31 +60,33 @@ TestEnumDecl Case 2:
|
|||||||
"Name": {
|
"Name": {
|
||||||
"Name": "Foo"
|
"Name": "Foo"
|
||||||
},
|
},
|
||||||
"Items": [{
|
"Type": {
|
||||||
"Name": {
|
"Items": [{
|
||||||
"Name": "a"
|
"Name": {
|
||||||
},
|
"Name": "a"
|
||||||
"Value": {
|
},
|
||||||
"Kind": 0,
|
"Value": {
|
||||||
"Value": "1"
|
"Kind": 0,
|
||||||
}
|
"Value": "1"
|
||||||
}, {
|
}
|
||||||
"Name": {
|
}, {
|
||||||
"Name": "b"
|
"Name": {
|
||||||
},
|
"Name": "b"
|
||||||
"Value": {
|
},
|
||||||
"Kind": 0,
|
"Value": {
|
||||||
"Value": "2"
|
"Kind": 0,
|
||||||
}
|
"Value": "2"
|
||||||
}, {
|
}
|
||||||
"Name": {
|
}, {
|
||||||
"Name": "c"
|
"Name": {
|
||||||
},
|
"Name": "c"
|
||||||
"Value": {
|
},
|
||||||
"Kind": 0,
|
"Value": {
|
||||||
"Value": "4"
|
"Kind": 0,
|
||||||
}
|
"Value": "4"
|
||||||
}]
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
}],
|
}],
|
||||||
"includes": [],
|
"includes": [],
|
||||||
"macros": []
|
"macros": []
|
||||||
@@ -103,31 +107,33 @@ TestEnumDecl Case 3:
|
|||||||
"Name": {
|
"Name": {
|
||||||
"Name": "Foo"
|
"Name": "Foo"
|
||||||
},
|
},
|
||||||
"Items": [{
|
"Type": {
|
||||||
"Name": {
|
"Items": [{
|
||||||
"Name": "a"
|
"Name": {
|
||||||
},
|
"Name": "a"
|
||||||
"Value": {
|
},
|
||||||
"Kind": 0,
|
"Value": {
|
||||||
"Value": "1"
|
"Kind": 0,
|
||||||
}
|
"Value": "1"
|
||||||
}, {
|
}
|
||||||
"Name": {
|
}, {
|
||||||
"Name": "b"
|
"Name": {
|
||||||
},
|
"Name": "b"
|
||||||
"Value": {
|
},
|
||||||
"Kind": 0,
|
"Value": {
|
||||||
"Value": "2"
|
"Kind": 0,
|
||||||
}
|
"Value": "2"
|
||||||
}, {
|
}
|
||||||
"Name": {
|
}, {
|
||||||
"Name": "c"
|
"Name": {
|
||||||
},
|
"Name": "c"
|
||||||
"Value": {
|
},
|
||||||
"Kind": 0,
|
"Value": {
|
||||||
"Value": "3"
|
"Kind": 0,
|
||||||
}
|
"Value": "3"
|
||||||
}]
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
}],
|
}],
|
||||||
"includes": [],
|
"includes": [],
|
||||||
"macros": []
|
"macros": []
|
||||||
|
|||||||
@@ -68,11 +68,7 @@ func MarshalASTDecl(decl ast.Decl) *cjson.JSON {
|
|||||||
case *ast.EnumTypeDecl:
|
case *ast.EnumTypeDecl:
|
||||||
MarshalASTDeclBase(d.DeclBase, root)
|
MarshalASTDeclBase(d.DeclBase, root)
|
||||||
root.SetItem(c.Str("Name"), MarshalASTExpr(d.Name))
|
root.SetItem(c.Str("Name"), MarshalASTExpr(d.Name))
|
||||||
items := cjson.Array()
|
root.SetItem(c.Str("Type"), MarshalASTExpr(d.Type))
|
||||||
for _, i := range d.Items {
|
|
||||||
items.AddItem(MarshalASTExpr(i))
|
|
||||||
}
|
|
||||||
root.SetItem(c.Str("Items"), items)
|
|
||||||
case *ast.TypedefDecl:
|
case *ast.TypedefDecl:
|
||||||
MarshalASTDeclBase(d.DeclBase, root)
|
MarshalASTDeclBase(d.DeclBase, root)
|
||||||
root.SetItem(c.Str("Name"), MarshalASTExpr(d.Name))
|
root.SetItem(c.Str("Name"), MarshalASTExpr(d.Name))
|
||||||
@@ -106,6 +102,15 @@ func MarshalASTExpr(t ast.Expr) *cjson.JSON {
|
|||||||
root := cjson.Object()
|
root := cjson.Object()
|
||||||
|
|
||||||
switch d := t.(type) {
|
switch d := t.(type) {
|
||||||
|
case *ast.EnumType:
|
||||||
|
items := cjson.Array()
|
||||||
|
for _, e := range d.Items {
|
||||||
|
items.AddItem(MarshalASTExpr(e))
|
||||||
|
}
|
||||||
|
root.SetItem(c.Str("Items"), items)
|
||||||
|
case *ast.EnumItem:
|
||||||
|
root.SetItem(c.Str("Name"), MarshalASTExpr(d.Name))
|
||||||
|
root.SetItem(c.Str("Value"), MarshalASTExpr(d.Value))
|
||||||
case *ast.RecordType:
|
case *ast.RecordType:
|
||||||
root.SetItem(c.Str("Tag"), cjson.Number(float64(d.Tag)))
|
root.SetItem(c.Str("Tag"), cjson.Number(float64(d.Tag)))
|
||||||
root.SetItem(c.Str("Fields"), MarshalASTExpr(d.Fields))
|
root.SetItem(c.Str("Fields"), MarshalASTExpr(d.Fields))
|
||||||
@@ -143,9 +148,6 @@ func MarshalASTExpr(t ast.Expr) *cjson.JSON {
|
|||||||
case *ast.TagExpr:
|
case *ast.TagExpr:
|
||||||
root.SetItem(c.Str("Name"), MarshalASTExpr(d.Name))
|
root.SetItem(c.Str("Name"), MarshalASTExpr(d.Name))
|
||||||
root.SetItem(c.Str("Tag"), cjson.Number(float64(d.Tag)))
|
root.SetItem(c.Str("Tag"), cjson.Number(float64(d.Tag)))
|
||||||
case *ast.EnumItem:
|
|
||||||
root.SetItem(c.Str("Name"), MarshalASTExpr(d.Name))
|
|
||||||
root.SetItem(c.Str("Value"), MarshalASTExpr(d.Value))
|
|
||||||
case *ast.BasicLit:
|
case *ast.BasicLit:
|
||||||
root.SetItem(c.Str("Kind"), cjson.Number(float64(d.Kind)))
|
root.SetItem(c.Str("Kind"), cjson.Number(float64(d.Kind)))
|
||||||
root.SetItem(c.Str("Value"), cjson.String(c.AllocaCStr(d.Value)))
|
root.SetItem(c.Str("Value"), cjson.String(c.AllocaCStr(d.Value)))
|
||||||
|
|||||||
Reference in New Issue
Block a user