llcppsigfetch:variadic param
This commit is contained in:
@@ -255,6 +255,12 @@ func (ct *Converter) ProcessFunctionType(t clang.Type) *ast.FuncType {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if t.IsFunctionTypeVariadic() != 0 {
|
||||||
|
params.List = append(params.List, &ast.Field{
|
||||||
|
Type: &ast.Variadic{},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return &ast.FuncType{
|
return &ast.FuncType{
|
||||||
Ret: ret,
|
Ret: ret,
|
||||||
Params: params,
|
Params: params,
|
||||||
@@ -296,38 +302,7 @@ func (ct *Converter) ProcessFuncDecl(cursor clang.Cursor) *ast.FuncDecl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if isMethod(cursor) {
|
if isMethod(cursor) {
|
||||||
|
ct.ProcessMethodAttributes(cursor, fn)
|
||||||
if parent := cursor.SemanticParent(); parent.Equal(cursor.LexicalParent()) != 1 {
|
|
||||||
fn.DeclBase.Parent = buildScopingExpr(cursor.SemanticParent())
|
|
||||||
}
|
|
||||||
|
|
||||||
if cursor.Kind == clang.CursorDestructor {
|
|
||||||
fn.IsDestructor = true
|
|
||||||
}
|
|
||||||
if cursor.Kind == clang.CursorConstructor {
|
|
||||||
fn.IsConstructor = true
|
|
||||||
if cursor.IsExplicit() != 0 {
|
|
||||||
fn.IsExplicit = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if cursor.IsStatic() != 0 {
|
|
||||||
fn.IsStatic = true
|
|
||||||
}
|
|
||||||
// virtual & pure virtual
|
|
||||||
if cursor.IsVirtual() != 0 || cursor.IsPureVirtual() != 0 {
|
|
||||||
fn.IsVirtual = true
|
|
||||||
}
|
|
||||||
if cursor.IsConst() != 0 {
|
|
||||||
fn.IsConst = true
|
|
||||||
}
|
|
||||||
|
|
||||||
var numOverridden c.Uint
|
|
||||||
var overridden *clang.Cursor
|
|
||||||
cursor.OverriddenCursors(&overridden, &numOverridden)
|
|
||||||
if numOverridden > 0 {
|
|
||||||
fn.IsOverride = true
|
|
||||||
}
|
|
||||||
overridden.DisposeOverriddenCursors()
|
|
||||||
} else {
|
} else {
|
||||||
if cursor.StorageClass() == clang.SCStatic {
|
if cursor.StorageClass() == clang.SCStatic {
|
||||||
fn.IsStatic = true
|
fn.IsStatic = true
|
||||||
@@ -337,6 +312,41 @@ func (ct *Converter) ProcessFuncDecl(cursor clang.Cursor) *ast.FuncDecl {
|
|||||||
return fn
|
return fn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get Methods Attributes
|
||||||
|
func (ct *Converter) ProcessMethodAttributes(cursor clang.Cursor, fn *ast.FuncDecl) {
|
||||||
|
if parent := cursor.SemanticParent(); parent.Equal(cursor.LexicalParent()) != 1 {
|
||||||
|
fn.DeclBase.Parent = buildScopingExpr(cursor.SemanticParent())
|
||||||
|
}
|
||||||
|
|
||||||
|
switch cursor.Kind {
|
||||||
|
case clang.CursorDestructor:
|
||||||
|
fn.IsDestructor = true
|
||||||
|
case clang.CursorConstructor:
|
||||||
|
fn.IsConstructor = true
|
||||||
|
if cursor.IsExplicit() != 0 {
|
||||||
|
fn.IsExplicit = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if cursor.IsStatic() != 0 {
|
||||||
|
fn.IsStatic = true
|
||||||
|
}
|
||||||
|
if cursor.IsVirtual() != 0 || cursor.IsPureVirtual() != 0 {
|
||||||
|
fn.IsVirtual = true
|
||||||
|
}
|
||||||
|
if cursor.IsConst() != 0 {
|
||||||
|
fn.IsConst = true
|
||||||
|
}
|
||||||
|
|
||||||
|
var numOverridden c.Uint
|
||||||
|
var overridden *clang.Cursor
|
||||||
|
cursor.OverriddenCursors(&overridden, &numOverridden)
|
||||||
|
if numOverridden > 0 {
|
||||||
|
fn.IsOverride = true
|
||||||
|
}
|
||||||
|
overridden.DisposeOverriddenCursors()
|
||||||
|
}
|
||||||
|
|
||||||
type visitEnumContext struct {
|
type visitEnumContext struct {
|
||||||
enum *[]*ast.EnumItem
|
enum *[]*ast.EnumItem
|
||||||
converter *Converter
|
converter *Converter
|
||||||
@@ -449,12 +459,18 @@ func visitFieldList(cursor, parent clang.Cursor, clientData unsafe.Pointer) clan
|
|||||||
return clang.ChildVisit_Continue
|
return clang.ChildVisit_Continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For Record Type(struct,union ...) & Func 's FieldList
|
||||||
func (ct *Converter) ProcessFieldList(cursor clang.Cursor) *ast.FieldList {
|
func (ct *Converter) ProcessFieldList(cursor clang.Cursor) *ast.FieldList {
|
||||||
params := &ast.FieldList{List: []*ast.Field{}}
|
params := &ast.FieldList{List: []*ast.Field{}}
|
||||||
ctx := &visitFieldContext{
|
ctx := &visitFieldContext{
|
||||||
params: params,
|
params: params,
|
||||||
converter: ct,
|
converter: ct,
|
||||||
}
|
}
|
||||||
|
if (cursor.Kind == clang.CursorFunctionDecl || isMethod(cursor)) && cursor.IsVariadic() != 0 {
|
||||||
|
params.List = append(params.List, &ast.Field{
|
||||||
|
Type: &ast.Variadic{},
|
||||||
|
})
|
||||||
|
}
|
||||||
clang.VisitChildren(cursor, visitFieldList, c.Pointer(ctx))
|
clang.VisitChildren(cursor, visitFieldList, c.Pointer(ctx))
|
||||||
return params
|
return params
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ func TestFuncDecl() {
|
|||||||
testCases := []string{
|
testCases := []string{
|
||||||
`void foo();`,
|
`void foo();`,
|
||||||
`void foo(int a);`,
|
`void foo(int a);`,
|
||||||
|
`void foo(int a,...);`,
|
||||||
`float* foo(int a,double b);`,
|
`float* foo(int a,double b);`,
|
||||||
`static inline int add(int a, int b);`,
|
`static inline int add(int a, int b);`,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,6 +88,63 @@ TestFuncDecl Case 2:
|
|||||||
}
|
}
|
||||||
|
|
||||||
TestFuncDecl Case 3:
|
TestFuncDecl Case 3:
|
||||||
|
{
|
||||||
|
"temp.h": {
|
||||||
|
"decls": [{
|
||||||
|
"Loc": {
|
||||||
|
"File": "temp.h"
|
||||||
|
},
|
||||||
|
"Doc": {
|
||||||
|
"List": []
|
||||||
|
},
|
||||||
|
"Parent": null,
|
||||||
|
"Name": {
|
||||||
|
"Name": "foo"
|
||||||
|
},
|
||||||
|
"Type": {
|
||||||
|
"Params": {
|
||||||
|
"List": [{
|
||||||
|
"Type": {
|
||||||
|
},
|
||||||
|
"Doc": null,
|
||||||
|
"Comment": null,
|
||||||
|
"Names": []
|
||||||
|
}, {
|
||||||
|
"Type": {
|
||||||
|
"Kind": 6,
|
||||||
|
"Flags": 0
|
||||||
|
},
|
||||||
|
"Doc": {
|
||||||
|
"List": []
|
||||||
|
},
|
||||||
|
"Comment": {
|
||||||
|
"List": []
|
||||||
|
},
|
||||||
|
"Names": [{
|
||||||
|
"Name": "a"
|
||||||
|
}]
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
"Ret": {
|
||||||
|
"Kind": 0,
|
||||||
|
"Flags": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"IsInline": false,
|
||||||
|
"IsStatic": false,
|
||||||
|
"IsConst": false,
|
||||||
|
"IsExplicit": false,
|
||||||
|
"IsConstructor": false,
|
||||||
|
"IsDestructor": false,
|
||||||
|
"IsVirtual": false,
|
||||||
|
"IsOverride": false
|
||||||
|
}],
|
||||||
|
"includes": [],
|
||||||
|
"macros": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TestFuncDecl Case 4:
|
||||||
{
|
{
|
||||||
"temp.h": {
|
"temp.h": {
|
||||||
"decls": [{
|
"decls": [{
|
||||||
@@ -154,7 +211,7 @@ TestFuncDecl Case 3:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TestFuncDecl Case 4:
|
TestFuncDecl Case 5:
|
||||||
{
|
{
|
||||||
"temp.h": {
|
"temp.h": {
|
||||||
"decls": [{
|
"decls": [{
|
||||||
|
|||||||
@@ -94,6 +94,12 @@ TestTypeDefDecl Case 3:
|
|||||||
"Doc": null,
|
"Doc": null,
|
||||||
"Comment": null,
|
"Comment": null,
|
||||||
"Names": []
|
"Names": []
|
||||||
|
}, {
|
||||||
|
"Type": {
|
||||||
|
},
|
||||||
|
"Doc": null,
|
||||||
|
"Comment": null,
|
||||||
|
"Names": []
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
"Ret": {
|
"Ret": {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ func TestTypeDefDecl() {
|
|||||||
`typedef int INT;
|
`typedef int INT;
|
||||||
typedef INT STANDARD_INT;`,
|
typedef INT STANDARD_INT;`,
|
||||||
|
|
||||||
`typedef int (*Foo)(int, int);`,
|
`typedef int (*Foo)(int, int, ...);`,
|
||||||
}
|
}
|
||||||
test.RunTest("TestTypeDefDecl", testCases)
|
test.RunTest("TestTypeDefDecl", testCases)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ func MarshalASTExpr(t ast.Expr) *cjson.JSON {
|
|||||||
names.AddItem(MarshalASTExpr(n))
|
names.AddItem(MarshalASTExpr(n))
|
||||||
}
|
}
|
||||||
root.SetItem(c.Str("Names"), names)
|
root.SetItem(c.Str("Names"), names)
|
||||||
|
case *ast.Variadic:
|
||||||
case *ast.Ident:
|
case *ast.Ident:
|
||||||
if d == nil {
|
if d == nil {
|
||||||
return cjson.Null()
|
return cjson.Null()
|
||||||
|
|||||||
Reference in New Issue
Block a user