llcppsigfetch:split test directory
This commit is contained in:
@@ -144,7 +144,6 @@ func (ct *Converter) GetCurFile() *ast.File {
|
||||
file, ok := ct.Files[ct.curLoc.File]
|
||||
if !ok {
|
||||
file = &ast.File{
|
||||
Path: ct.curLoc.File,
|
||||
Decls: make([]ast.Decl, 0),
|
||||
Includes: make([]*ast.Include, 0),
|
||||
Macros: make([]*ast.Macro, 0),
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import test "github.com/goplus/llgo/chore/_xtool/llcppsigfetch/parse/cvt_test"
|
||||
|
||||
func main() {
|
||||
TestClassDecl()
|
||||
}
|
||||
|
||||
func TestClassDecl() {
|
||||
testCases := []string{
|
||||
`class A {
|
||||
int a;
|
||||
int b;
|
||||
};`,
|
||||
`class A {
|
||||
int a;
|
||||
int b;
|
||||
float foo(int a,double b);
|
||||
};`,
|
||||
}
|
||||
test.RunTest("TestClassDecl", testCases)
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
#stdout
|
||||
TestClassDecl Case 1:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": {
|
||||
"Name": "A"
|
||||
},
|
||||
"Name": {
|
||||
"Name": "A"
|
||||
},
|
||||
"Type": {
|
||||
"Tag": 3,
|
||||
"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": []
|
||||
}
|
||||
}
|
||||
|
||||
TestClassDecl Case 2:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": {
|
||||
"Name": "A"
|
||||
},
|
||||
"Name": {
|
||||
"Name": "A"
|
||||
},
|
||||
"Type": {
|
||||
"Tag": 3,
|
||||
"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": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": {
|
||||
"Name": "A"
|
||||
},
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": [{
|
||||
"Type": {
|
||||
"Kind": 6,
|
||||
"Flags": 0
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Comment": {
|
||||
"List": []
|
||||
},
|
||||
"Names": [{
|
||||
"Name": "a"
|
||||
}]
|
||||
}, {
|
||||
"Type": {
|
||||
"Kind": 8,
|
||||
"Flags": 16
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Comment": {
|
||||
"List": []
|
||||
},
|
||||
"Names": [{
|
||||
"Name": "b"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
"Ret": {
|
||||
"Kind": 8,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#stderr
|
||||
|
||||
#exit 0
|
||||
@@ -0,0 +1,37 @@
|
||||
package main
|
||||
|
||||
import test "github.com/goplus/llgo/chore/_xtool/llcppsigfetch/parse/cvt_test"
|
||||
|
||||
func main() {
|
||||
TestComment()
|
||||
}
|
||||
|
||||
func TestComment() {
|
||||
testCases := []string{
|
||||
`// not read comment 1
|
||||
void foo();`,
|
||||
`/* not read comment 2 */
|
||||
void foo();`,
|
||||
`/// comment
|
||||
void foo();`,
|
||||
`/** comment */
|
||||
void foo();`,
|
||||
`/*! comment */
|
||||
void foo();`,
|
||||
`/// comment 1
|
||||
/// comment 2
|
||||
void foo();`,
|
||||
`/*! comment 1 */
|
||||
/*! comment 2 */
|
||||
void foo();`,
|
||||
`/** comment 1 */
|
||||
/** comment 1 */
|
||||
void foo();`,
|
||||
`/**
|
||||
* comment 1
|
||||
* comment 2
|
||||
*/
|
||||
void foo();`,
|
||||
}
|
||||
test.RunTest("TestComment", testCases)
|
||||
}
|
||||
@@ -0,0 +1,292 @@
|
||||
#stdout
|
||||
TestComment Case 1:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": []
|
||||
},
|
||||
"Ret": {
|
||||
"Kind": 0,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestComment Case 2:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": []
|
||||
},
|
||||
"Ret": {
|
||||
"Kind": 0,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestComment Case 3:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": [{
|
||||
"Text": "/// comment"
|
||||
}]
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": []
|
||||
},
|
||||
"Ret": {
|
||||
"Kind": 0,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestComment Case 4:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": [{
|
||||
"Text": "/** comment */"
|
||||
}]
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": []
|
||||
},
|
||||
"Ret": {
|
||||
"Kind": 0,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestComment Case 5:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": [{
|
||||
"Text": "/*! comment */"
|
||||
}]
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": []
|
||||
},
|
||||
"Ret": {
|
||||
"Kind": 0,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestComment Case 6:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": [{
|
||||
"Text": "/// comment 1"
|
||||
}, {
|
||||
"Text": "/// comment 2"
|
||||
}]
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": []
|
||||
},
|
||||
"Ret": {
|
||||
"Kind": 0,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestComment Case 7:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": [{
|
||||
"Text": "/*! comment 1 */"
|
||||
}, {
|
||||
"Text": "/*! comment 2 */"
|
||||
}]
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": []
|
||||
},
|
||||
"Ret": {
|
||||
"Kind": 0,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestComment Case 8:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": [{
|
||||
"Text": "/** comment 1 */"
|
||||
}, {
|
||||
"Text": "/** comment 1 */"
|
||||
}]
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": []
|
||||
},
|
||||
"Ret": {
|
||||
"Kind": 0,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestComment Case 9:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": [{
|
||||
"Text": "/**"
|
||||
}, {
|
||||
"Text": " * comment 1"
|
||||
}, {
|
||||
"Text": " * comment 2"
|
||||
}, {
|
||||
"Text": " */"
|
||||
}]
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": []
|
||||
},
|
||||
"Ret": {
|
||||
"Kind": 0,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#stderr
|
||||
|
||||
#exit 0
|
||||
@@ -1,173 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
test "github.com/goplus/llgo/chore/_xtool/llcppsigfetch/parse/cvt_test"
|
||||
)
|
||||
|
||||
func main() {
|
||||
TestFuncDecl()
|
||||
TestScope()
|
||||
TestComment()
|
||||
TestStructDecl()
|
||||
TestClassDecl()
|
||||
TestUnionDecl()
|
||||
TestEnumDecl()
|
||||
TestTypeDefDecl()
|
||||
}
|
||||
|
||||
func TestFuncDecl() {
|
||||
testCases := []string{
|
||||
`void foo();`,
|
||||
`void foo(int a);`,
|
||||
`float foo(int a,double b);`,
|
||||
|
||||
`void foo(char* str, double x);`,
|
||||
`float* foo(char* str, double x);`,
|
||||
`float* foo(char*** str, double x);`,
|
||||
|
||||
`float* foo(char str[], double x);`,
|
||||
`float* foo(int arr[3][4]);`,
|
||||
}
|
||||
test.RunTest("TestFuncDecl", testCases)
|
||||
}
|
||||
|
||||
func TestScope() {
|
||||
testCases := []string{
|
||||
`void foo();`,
|
||||
`namespace a {
|
||||
void foo();
|
||||
}`,
|
||||
`namespace a {
|
||||
namespace b {
|
||||
void foo();
|
||||
}
|
||||
}`,
|
||||
`class a {
|
||||
void foo();
|
||||
};`,
|
||||
`namespace a {
|
||||
class b {
|
||||
void foo();
|
||||
};
|
||||
}`,
|
||||
}
|
||||
test.RunTest("TestScope", testCases)
|
||||
}
|
||||
|
||||
func TestComment() {
|
||||
testCases := []string{
|
||||
`// not read comment 1
|
||||
void foo();`,
|
||||
`/* not read comment 2 */
|
||||
void foo();`,
|
||||
`/// comment
|
||||
void foo();`,
|
||||
`/** comment */
|
||||
void foo();`,
|
||||
`/*! comment */
|
||||
void foo();`,
|
||||
`/// comment 1
|
||||
/// comment 2
|
||||
void foo();`,
|
||||
`/*! comment 1 */
|
||||
/*! comment 2 */
|
||||
void foo();`,
|
||||
`/** comment 1 */
|
||||
/** comment 1 */
|
||||
void foo();`,
|
||||
`/**
|
||||
* comment 1
|
||||
* comment 2
|
||||
*/
|
||||
void foo();`,
|
||||
}
|
||||
test.RunTest("TestComment", testCases)
|
||||
}
|
||||
|
||||
func TestStructDecl() {
|
||||
testCases := []string{
|
||||
`struct {
|
||||
int a;
|
||||
};`,
|
||||
`struct A {
|
||||
int a;
|
||||
int b;
|
||||
};`,
|
||||
`struct A {
|
||||
int a, b;
|
||||
};`,
|
||||
`struct A {
|
||||
int a;
|
||||
int b;
|
||||
float foo(int a,double b);;
|
||||
};`,
|
||||
}
|
||||
test.RunTest("TestStructDecl", testCases)
|
||||
}
|
||||
|
||||
func TestUnionDecl() {
|
||||
testCases := []string{
|
||||
`union {
|
||||
int a;
|
||||
int b;
|
||||
};`,
|
||||
`union A {
|
||||
int a;
|
||||
int b;
|
||||
};`,
|
||||
}
|
||||
test.RunTest("TestUnionDecl", testCases)
|
||||
}
|
||||
|
||||
func TestClassDecl() {
|
||||
testCases := []string{
|
||||
`class A {
|
||||
int a;
|
||||
int b;
|
||||
};`,
|
||||
`class A {
|
||||
int a;
|
||||
int b;
|
||||
float foo(int a,double b);;
|
||||
};`,
|
||||
}
|
||||
test.RunTest("TestClassDecl", testCases)
|
||||
}
|
||||
|
||||
func TestEnumDecl() {
|
||||
testCases := []string{
|
||||
`enum Foo {
|
||||
a,
|
||||
b,
|
||||
c,
|
||||
};`,
|
||||
`enum Foo {
|
||||
a = 1,
|
||||
b = 2,
|
||||
c = 4,
|
||||
};`,
|
||||
`enum Foo {
|
||||
a = 1,
|
||||
b,
|
||||
c,
|
||||
};`,
|
||||
}
|
||||
test.RunTest("TestEnumDecl", testCases)
|
||||
}
|
||||
|
||||
func TestTypeDefDecl() {
|
||||
testCases := []string{
|
||||
`typedef int INT;`,
|
||||
`typedef int INT;
|
||||
typedef INT STANDARD_INT;`,
|
||||
`struct StructFoo {};
|
||||
union UnionFoo {};
|
||||
class ClassFoo {};
|
||||
enum EnumFoo {};
|
||||
typedef StructFoo STRUCT_FOO;
|
||||
typedef UnionFoo UNION_FOO;
|
||||
typedef ClassFoo CLASS_FOO;
|
||||
typedef EnumFoo ENUM_FOO;`,
|
||||
}
|
||||
test.RunTest("TestTypeDefDecl", testCases)
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import test "github.com/goplus/llgo/chore/_xtool/llcppsigfetch/parse/cvt_test"
|
||||
|
||||
func main() {
|
||||
TestEnumDecl()
|
||||
}
|
||||
|
||||
func TestEnumDecl() {
|
||||
testCases := []string{
|
||||
`enum Foo {
|
||||
a,
|
||||
b,
|
||||
c,
|
||||
};`,
|
||||
`enum Foo {
|
||||
a = 1,
|
||||
b = 2,
|
||||
c = 4,
|
||||
};`,
|
||||
`enum Foo {
|
||||
a = 1,
|
||||
b,
|
||||
c,
|
||||
};`,
|
||||
}
|
||||
test.RunTest("TestEnumDecl", testCases)
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
#stdout
|
||||
TestEnumDecl Case 1:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "Foo"
|
||||
},
|
||||
"Items": [{
|
||||
"Name": {
|
||||
"Name": "a"
|
||||
},
|
||||
"Value": {
|
||||
"Kind": 0,
|
||||
"Value": "0"
|
||||
}
|
||||
}, {
|
||||
"Name": {
|
||||
"Name": "b"
|
||||
},
|
||||
"Value": {
|
||||
"Kind": 0,
|
||||
"Value": "1"
|
||||
}
|
||||
}, {
|
||||
"Name": {
|
||||
"Name": "c"
|
||||
},
|
||||
"Value": {
|
||||
"Kind": 0,
|
||||
"Value": "2"
|
||||
}
|
||||
}]
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestEnumDecl Case 2:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "Foo"
|
||||
},
|
||||
"Items": [{
|
||||
"Name": {
|
||||
"Name": "a"
|
||||
},
|
||||
"Value": {
|
||||
"Kind": 0,
|
||||
"Value": "1"
|
||||
}
|
||||
}, {
|
||||
"Name": {
|
||||
"Name": "b"
|
||||
},
|
||||
"Value": {
|
||||
"Kind": 0,
|
||||
"Value": "2"
|
||||
}
|
||||
}, {
|
||||
"Name": {
|
||||
"Name": "c"
|
||||
},
|
||||
"Value": {
|
||||
"Kind": 0,
|
||||
"Value": "4"
|
||||
}
|
||||
}]
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestEnumDecl Case 3:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "Foo"
|
||||
},
|
||||
"Items": [{
|
||||
"Name": {
|
||||
"Name": "a"
|
||||
},
|
||||
"Value": {
|
||||
"Kind": 0,
|
||||
"Value": "1"
|
||||
}
|
||||
}, {
|
||||
"Name": {
|
||||
"Name": "b"
|
||||
},
|
||||
"Value": {
|
||||
"Kind": 0,
|
||||
"Value": "2"
|
||||
}
|
||||
}, {
|
||||
"Name": {
|
||||
"Name": "c"
|
||||
},
|
||||
"Value": {
|
||||
"Kind": 0,
|
||||
"Value": "3"
|
||||
}
|
||||
}]
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#stderr
|
||||
|
||||
#exit 0
|
||||
@@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import test "github.com/goplus/llgo/chore/_xtool/llcppsigfetch/parse/cvt_test"
|
||||
|
||||
func main() {
|
||||
TestFuncDecl()
|
||||
}
|
||||
|
||||
func TestFuncDecl() {
|
||||
testCases := []string{
|
||||
`void foo();`,
|
||||
`void foo(int a);`,
|
||||
`float foo(int a,double b);`,
|
||||
|
||||
`void foo(char* str, double x);`,
|
||||
`float* foo(char* str, double x);`,
|
||||
`float* foo(char*** str, double x);`,
|
||||
|
||||
`float* foo(char str[], double x);`,
|
||||
`float* foo(int arr[3][4]);`,
|
||||
}
|
||||
test.RunTest("TestFuncDecl", testCases)
|
||||
}
|
||||
@@ -0,0 +1,438 @@
|
||||
#stdout
|
||||
TestFuncDecl Case 1:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": []
|
||||
},
|
||||
"Ret": {
|
||||
"Kind": 0,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestFuncDecl Case 2:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": [{
|
||||
"Type": {
|
||||
"Kind": 6,
|
||||
"Flags": 0
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Comment": {
|
||||
"List": []
|
||||
},
|
||||
"Names": [{
|
||||
"Name": "a"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
"Ret": {
|
||||
"Kind": 0,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestFuncDecl Case 3:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": [{
|
||||
"Type": {
|
||||
"Kind": 6,
|
||||
"Flags": 0
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Comment": {
|
||||
"List": []
|
||||
},
|
||||
"Names": [{
|
||||
"Name": "a"
|
||||
}]
|
||||
}, {
|
||||
"Type": {
|
||||
"Kind": 8,
|
||||
"Flags": 16
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Comment": {
|
||||
"List": []
|
||||
},
|
||||
"Names": [{
|
||||
"Name": "b"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
"Ret": {
|
||||
"Kind": 8,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestFuncDecl Case 4:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": [{
|
||||
"Type": {
|
||||
"X": {
|
||||
"Kind": 2,
|
||||
"Flags": 1
|
||||
}
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Comment": {
|
||||
"List": []
|
||||
},
|
||||
"Names": [{
|
||||
"Name": "str"
|
||||
}]
|
||||
}, {
|
||||
"Type": {
|
||||
"Kind": 8,
|
||||
"Flags": 16
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Comment": {
|
||||
"List": []
|
||||
},
|
||||
"Names": [{
|
||||
"Name": "x"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
"Ret": {
|
||||
"Kind": 0,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestFuncDecl Case 5:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": [{
|
||||
"Type": {
|
||||
"X": {
|
||||
"Kind": 2,
|
||||
"Flags": 1
|
||||
}
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Comment": {
|
||||
"List": []
|
||||
},
|
||||
"Names": [{
|
||||
"Name": "str"
|
||||
}]
|
||||
}, {
|
||||
"Type": {
|
||||
"Kind": 8,
|
||||
"Flags": 16
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Comment": {
|
||||
"List": []
|
||||
},
|
||||
"Names": [{
|
||||
"Name": "x"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
"Ret": {
|
||||
"X": {
|
||||
"Kind": 8,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestFuncDecl Case 6:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": [{
|
||||
"Type": {
|
||||
"X": {
|
||||
"X": {
|
||||
"X": {
|
||||
"Kind": 2,
|
||||
"Flags": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Comment": {
|
||||
"List": []
|
||||
},
|
||||
"Names": [{
|
||||
"Name": "str"
|
||||
}]
|
||||
}, {
|
||||
"Type": {
|
||||
"Kind": 8,
|
||||
"Flags": 16
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Comment": {
|
||||
"List": []
|
||||
},
|
||||
"Names": [{
|
||||
"Name": "x"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
"Ret": {
|
||||
"X": {
|
||||
"Kind": 8,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestFuncDecl Case 7:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": [{
|
||||
"Type": {
|
||||
"Elt": {
|
||||
"Kind": 2,
|
||||
"Flags": 1
|
||||
},
|
||||
"Len": null
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Comment": {
|
||||
"List": []
|
||||
},
|
||||
"Names": [{
|
||||
"Name": "str"
|
||||
}]
|
||||
}, {
|
||||
"Type": {
|
||||
"Kind": 8,
|
||||
"Flags": 16
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Comment": {
|
||||
"List": []
|
||||
},
|
||||
"Names": [{
|
||||
"Name": "x"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
"Ret": {
|
||||
"X": {
|
||||
"Kind": 8,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestFuncDecl Case 8:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": [{
|
||||
"Type": {
|
||||
"Elt": {
|
||||
"Elt": {
|
||||
"Kind": 6,
|
||||
"Flags": 0
|
||||
},
|
||||
"Len": {
|
||||
"Kind": 0,
|
||||
"Value": "4"
|
||||
}
|
||||
},
|
||||
"Len": {
|
||||
"Kind": 0,
|
||||
"Value": "3"
|
||||
}
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Comment": {
|
||||
"List": []
|
||||
},
|
||||
"Names": [{
|
||||
"Name": "arr"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
"Ret": {
|
||||
"X": {
|
||||
"Kind": 8,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#stderr
|
||||
|
||||
#exit 0
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,213 @@
|
||||
#stdout
|
||||
TestScope Case 1:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": []
|
||||
},
|
||||
"Ret": {
|
||||
"Kind": 0,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestScope Case 2:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": {
|
||||
"Name": "a"
|
||||
},
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": []
|
||||
},
|
||||
"Ret": {
|
||||
"Kind": 0,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestScope Case 3:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": {
|
||||
"X": {
|
||||
"Name": "b"
|
||||
},
|
||||
"Parent": {
|
||||
"Name": "a"
|
||||
}
|
||||
},
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": []
|
||||
},
|
||||
"Ret": {
|
||||
"Kind": 0,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestScope Case 4:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": {
|
||||
"Name": "a"
|
||||
},
|
||||
"Name": {
|
||||
"Name": "a"
|
||||
},
|
||||
"Type": {
|
||||
"Tag": 3,
|
||||
"Fields": {
|
||||
"List": []
|
||||
},
|
||||
"Methods": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": {
|
||||
"Name": "a"
|
||||
},
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": []
|
||||
},
|
||||
"Ret": {
|
||||
"Kind": 0,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestScope Case 5:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": {
|
||||
"X": {
|
||||
"Name": "b"
|
||||
},
|
||||
"Parent": {
|
||||
"Name": "a"
|
||||
}
|
||||
},
|
||||
"Name": {
|
||||
"Name": "b"
|
||||
},
|
||||
"Type": {
|
||||
"Tag": 3,
|
||||
"Fields": {
|
||||
"List": []
|
||||
},
|
||||
"Methods": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": {
|
||||
"X": {
|
||||
"Name": "b"
|
||||
},
|
||||
"Parent": {
|
||||
"Name": "a"
|
||||
}
|
||||
},
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": []
|
||||
},
|
||||
"Ret": {
|
||||
"Kind": 0,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#stderr
|
||||
|
||||
#exit 0
|
||||
@@ -0,0 +1,30 @@
|
||||
package main
|
||||
|
||||
import test "github.com/goplus/llgo/chore/_xtool/llcppsigfetch/parse/cvt_test"
|
||||
|
||||
func main() {
|
||||
TestScope()
|
||||
}
|
||||
|
||||
func TestScope() {
|
||||
testCases := []string{
|
||||
`void foo();`,
|
||||
`namespace a {
|
||||
void foo();
|
||||
}`,
|
||||
`namespace a {
|
||||
namespace b {
|
||||
void foo();
|
||||
}
|
||||
}`,
|
||||
`class a {
|
||||
void foo();
|
||||
};`,
|
||||
`namespace a {
|
||||
class b {
|
||||
void foo();
|
||||
};
|
||||
}`,
|
||||
}
|
||||
test.RunTest("TestScope", testCases)
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
#stdout
|
||||
TestStructDecl Case 1:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": null,
|
||||
"Type": {
|
||||
"Tag": 0,
|
||||
"Fields": {
|
||||
"List": [{
|
||||
"Type": {
|
||||
"Kind": 6,
|
||||
"Flags": 0
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Comment": {
|
||||
"List": []
|
||||
},
|
||||
"Names": [{
|
||||
"Name": "a"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
"Methods": []
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestStructDecl Case 2:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "A"
|
||||
},
|
||||
"Type": {
|
||||
"Tag": 0,
|
||||
"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 3:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "A"
|
||||
},
|
||||
"Type": {
|
||||
"Tag": 0,
|
||||
"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": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "A"
|
||||
},
|
||||
"Type": {
|
||||
"Tag": 0,
|
||||
"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": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": [{
|
||||
"Type": {
|
||||
"Kind": 6,
|
||||
"Flags": 0
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Comment": {
|
||||
"List": []
|
||||
},
|
||||
"Names": [{
|
||||
"Name": "a"
|
||||
}]
|
||||
}, {
|
||||
"Type": {
|
||||
"Kind": 8,
|
||||
"Flags": 16
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Comment": {
|
||||
"List": []
|
||||
},
|
||||
"Names": [{
|
||||
"Name": "b"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
"Ret": {
|
||||
"Kind": 8,
|
||||
"Flags": 0
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#stderr
|
||||
|
||||
#exit 0
|
||||
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import test "github.com/goplus/llgo/chore/_xtool/llcppsigfetch/parse/cvt_test"
|
||||
|
||||
func main() {
|
||||
TestStructDecl()
|
||||
}
|
||||
|
||||
func TestStructDecl() {
|
||||
testCases := []string{
|
||||
`struct {
|
||||
int a;
|
||||
};`,
|
||||
`struct A {
|
||||
int a;
|
||||
int b;
|
||||
};`,
|
||||
`struct A {
|
||||
int a, b;
|
||||
};`,
|
||||
`struct A {
|
||||
int a;
|
||||
int b;
|
||||
float foo(int a,double b);;
|
||||
};`,
|
||||
}
|
||||
test.RunTest("TestStructDecl", testCases)
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
#stdout
|
||||
TestTypeDefDecl Case 1:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "INT"
|
||||
},
|
||||
"Type": {
|
||||
"Kind": 6,
|
||||
"Flags": 0
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestTypeDefDecl Case 2:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "INT"
|
||||
},
|
||||
"Type": {
|
||||
"Kind": 6,
|
||||
"Flags": 0
|
||||
}
|
||||
}, {
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "STANDARD_INT"
|
||||
},
|
||||
"Type": {
|
||||
"Name": "INT"
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestTypeDefDecl Case 3:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "StructFoo"
|
||||
},
|
||||
"Type": {
|
||||
"Tag": 0,
|
||||
"Fields": {
|
||||
"List": []
|
||||
},
|
||||
"Methods": []
|
||||
}
|
||||
}, {
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "UnionFoo"
|
||||
},
|
||||
"Type": {
|
||||
"Tag": 1,
|
||||
"Fields": {
|
||||
"List": []
|
||||
},
|
||||
"Methods": []
|
||||
}
|
||||
}, {
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": {
|
||||
"Name": "ClassFoo"
|
||||
},
|
||||
"Name": {
|
||||
"Name": "ClassFoo"
|
||||
},
|
||||
"Type": {
|
||||
"Tag": 3,
|
||||
"Fields": {
|
||||
"List": []
|
||||
},
|
||||
"Methods": []
|
||||
}
|
||||
}, {
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "EnumFoo"
|
||||
},
|
||||
"Items": []
|
||||
}, {
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "STRUCT_FOO"
|
||||
},
|
||||
"Type": {
|
||||
"Name": "StructFoo"
|
||||
}
|
||||
}, {
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "UNION_FOO"
|
||||
},
|
||||
"Type": {
|
||||
"Name": "UnionFoo"
|
||||
}
|
||||
}, {
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "CLASS_FOO"
|
||||
},
|
||||
"Type": {
|
||||
"Name": "ClassFoo"
|
||||
}
|
||||
}, {
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "ENUM_FOO"
|
||||
},
|
||||
"Type": {
|
||||
"Name": "EnumFoo"
|
||||
}
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#stderr
|
||||
|
||||
#exit 0
|
||||
@@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import test "github.com/goplus/llgo/chore/_xtool/llcppsigfetch/parse/cvt_test"
|
||||
|
||||
func main() {
|
||||
TestTypeDefDecl()
|
||||
}
|
||||
|
||||
func TestTypeDefDecl() {
|
||||
testCases := []string{
|
||||
`typedef int INT;`,
|
||||
`typedef int INT;
|
||||
typedef INT STANDARD_INT;`,
|
||||
`struct StructFoo {};
|
||||
union UnionFoo {};
|
||||
class ClassFoo {};
|
||||
enum EnumFoo {};
|
||||
typedef StructFoo STRUCT_FOO;
|
||||
typedef UnionFoo UNION_FOO;
|
||||
typedef ClassFoo CLASS_FOO;
|
||||
typedef EnumFoo ENUM_FOO;`,
|
||||
}
|
||||
test.RunTest("TestTypeDefDecl", testCases)
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
#stdout
|
||||
TestUnionDecl Case 1:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": null,
|
||||
"Type": {
|
||||
"Tag": 1,
|
||||
"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": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "A"
|
||||
},
|
||||
"Type": {
|
||||
"Tag": 1,
|
||||
"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": []
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#stderr
|
||||
|
||||
#exit 0
|
||||
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import test "github.com/goplus/llgo/chore/_xtool/llcppsigfetch/parse/cvt_test"
|
||||
|
||||
func main() {
|
||||
TestUnionDecl()
|
||||
}
|
||||
|
||||
func TestUnionDecl() {
|
||||
testCases := []string{
|
||||
`union {
|
||||
int a;
|
||||
int b;
|
||||
};`,
|
||||
`union A {
|
||||
int a;
|
||||
int b;
|
||||
};`,
|
||||
}
|
||||
test.RunTest("TestUnionDecl", testCases)
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
TestDefine Case 1:
|
||||
{
|
||||
"temp.h": {
|
||||
"path": "temp.h",
|
||||
"decls": [],
|
||||
"includes": [],
|
||||
"macros": [{
|
||||
@@ -18,7 +17,6 @@ TestDefine Case 1:
|
||||
TestDefine Case 2:
|
||||
{
|
||||
"temp.h": {
|
||||
"path": "temp.h",
|
||||
"decls": [],
|
||||
"includes": [],
|
||||
"macros": [{
|
||||
@@ -37,7 +35,6 @@ TestDefine Case 2:
|
||||
TestDefine Case 3:
|
||||
{
|
||||
"temp.h": {
|
||||
"path": "temp.h",
|
||||
"decls": [],
|
||||
"includes": [],
|
||||
"macros": [{
|
||||
@@ -89,7 +86,6 @@ TestDefine Case 3:
|
||||
TestInclude Case 1:
|
||||
{
|
||||
"temp.h": {
|
||||
"path": "temp.h",
|
||||
"decls": [],
|
||||
"includes": [{
|
||||
"Path": "foo.h"
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
|
||||
func MarshalASTFiles(files map[string]*ast.File) *cjson.JSON {
|
||||
root := cjson.Object()
|
||||
for _, file := range files {
|
||||
root.SetItem(c.AllocaCStr(file.Path), MarshalASTFile(file))
|
||||
for path, file := range files {
|
||||
root.SetItem(c.AllocaCStr(path), MarshalASTFile(file))
|
||||
}
|
||||
return root
|
||||
}
|
||||
@@ -22,7 +22,6 @@ func MarshalASTFile(file *ast.File) *cjson.JSON {
|
||||
decls.AddItem(MarshalASTDecl(decl))
|
||||
}
|
||||
|
||||
root.SetItem(c.Str("path"), cjson.String(c.AllocaCStr(file.Path)))
|
||||
root.SetItem(c.Str("decls"), decls)
|
||||
|
||||
// json:includes,omitempty
|
||||
|
||||
@@ -370,7 +370,6 @@ func (*Macro) ppdNode() {}
|
||||
// ------------------------------------------------
|
||||
|
||||
type File struct {
|
||||
Path string `json:"path"`
|
||||
Decls []Decl `json:"decls"`
|
||||
Includes []*Include `json:"includes,omitempty"`
|
||||
Macros []*Macro `json:"macros,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user