llcppsigfetch:collect public methods
This commit is contained in:
@@ -300,7 +300,7 @@ func (ct *Converter) ProcessFuncDecl(cursor clang.Cursor) *ast.FuncDecl {
|
|||||||
fn.IsInline = true
|
fn.IsInline = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if cursor.Kind == clang.CursorCXXMethod || cursor.Kind == clang.CursorDestructor || cursor.Kind == clang.CursorConstructor {
|
if isMethod(cursor) {
|
||||||
if cursor.Kind == clang.CursorDestructor {
|
if cursor.Kind == clang.CursorDestructor {
|
||||||
fn.IsDestructor = true
|
fn.IsDestructor = true
|
||||||
}
|
}
|
||||||
@@ -466,7 +466,7 @@ type visitMethodsContext struct {
|
|||||||
|
|
||||||
func visitMethods(cursor, parent clang.Cursor, clientData unsafe.Pointer) clang.ChildVisitResult {
|
func visitMethods(cursor, parent clang.Cursor, clientData unsafe.Pointer) clang.ChildVisitResult {
|
||||||
ctx := (*visitMethodsContext)(clientData)
|
ctx := (*visitMethodsContext)(clientData)
|
||||||
if cursor.Kind == clang.CursorCXXMethod || cursor.Kind == clang.CursorConstructor || cursor.Kind == clang.CursorDestructor {
|
if isMethod(cursor) && cursor.CXXAccessSpecifier() != clang.CXXPrivate {
|
||||||
method := ctx.converter.ProcessFuncDecl(cursor)
|
method := ctx.converter.ProcessFuncDecl(cursor)
|
||||||
if method != nil {
|
if method != nil {
|
||||||
*ctx.methods = append(*ctx.methods, method)
|
*ctx.methods = append(*ctx.methods, method)
|
||||||
@@ -653,6 +653,9 @@ func toToken(tok clang.Token) token.Token {
|
|||||||
return token.Token(tok.Kind() + 1)
|
return token.Token(tok.Kind() + 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func isMethod(cursor clang.Cursor) bool {
|
||||||
|
return cursor.Kind == clang.CursorCXXMethod || cursor.Kind == clang.CursorConstructor || cursor.Kind == clang.CursorDestructor
|
||||||
|
}
|
||||||
|
|
||||||
func qualifiedExpr(name string) ast.Expr {
|
func qualifiedExpr(name string) ast.Expr {
|
||||||
parts := strings.Split(name, "::")
|
parts := strings.Split(name, "::")
|
||||||
|
|||||||
@@ -9,26 +9,33 @@ func main() {
|
|||||||
func TestClassDecl() {
|
func TestClassDecl() {
|
||||||
testCases := []string{
|
testCases := []string{
|
||||||
`class A {
|
`class A {
|
||||||
|
public:
|
||||||
int a;
|
int a;
|
||||||
int b;
|
int b;
|
||||||
};`,
|
};`,
|
||||||
`class A {
|
`class A {
|
||||||
|
public:
|
||||||
int a;
|
int a;
|
||||||
int b;
|
int b;
|
||||||
float foo(int a,double b);
|
float foo(int a,double b);
|
||||||
|
private:
|
||||||
|
void bar();
|
||||||
};`,
|
};`,
|
||||||
`class A {
|
`class A {
|
||||||
|
public:
|
||||||
A();
|
A();
|
||||||
explicit A();
|
explicit A();
|
||||||
~A();
|
~A();
|
||||||
static inline void foo();
|
static inline void foo();
|
||||||
};`,
|
};`,
|
||||||
`class Base {
|
`class Base {
|
||||||
|
public:
|
||||||
Base();
|
Base();
|
||||||
virtual ~Base();
|
virtual ~Base();
|
||||||
virtual void foo();
|
virtual void foo();
|
||||||
};
|
};
|
||||||
class Derived : public Base {
|
class Derived : public Base {
|
||||||
|
public:
|
||||||
Derived();
|
Derived();
|
||||||
~Derived() override;
|
~Derived() override;
|
||||||
void foo() override;
|
void foo() override;
|
||||||
|
|||||||
@@ -18,10 +18,12 @@ func TestScope() {
|
|||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
`class a {
|
`class a {
|
||||||
|
public:
|
||||||
void foo();
|
void foo();
|
||||||
};`,
|
};`,
|
||||||
`namespace a {
|
`namespace a {
|
||||||
class b {
|
class b {
|
||||||
|
public:
|
||||||
void foo();
|
void foo();
|
||||||
};
|
};
|
||||||
}`,
|
}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user