From 1557a76225a556a07970311a06b5d9734e36ae8e Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Thu, 22 Aug 2024 11:28:19 +0800 Subject: [PATCH] llcppsigfetch:split test directory --- chore/_xtool/llcppsigfetch/parse/cvt.go | 1 - .../cvt_test/decl_test/class_test/class.go | 22 + .../cvt_test/decl_test/class_test/llgo.expect | 169 ++ .../decl_test/comment_test/comment.go | 37 + .../decl_test/comment_test/llgo.expect | 292 +++ .../parse/cvt_test/decl_test/decl.go | 173 -- .../cvt_test/decl_test/enum_test/enum.go | 28 + .../cvt_test/decl_test/enum_test/llgo.expect | 140 ++ .../cvt_test/decl_test/func_test/func.go | 23 + .../cvt_test/decl_test/func_test/llgo.expect | 438 ++++ .../parse/cvt_test/decl_test/llgo.expect | 1823 ----------------- .../cvt_test/decl_test/scope_test/llgo.expect | 213 ++ .../cvt_test/decl_test/scope_test/scope.go | 30 + .../decl_test/struct_test/llgo.expect | 257 +++ .../cvt_test/decl_test/struct_test/struct.go | 28 + .../decl_test/typedef_test/llgo.expect | 200 ++ .../decl_test/typedef_test/typedef.go | 24 + .../cvt_test/decl_test/union_test/llgo.expect | 113 + .../cvt_test/decl_test/union_test/union.go | 21 + .../cvt_test/preprocess_test/llgo.expect | 4 - chore/_xtool/llcppsigfetch/parse/dump.go | 5 +- chore/llcppg/ast/ast.go | 1 - 22 files changed, 2037 insertions(+), 2005 deletions(-) create mode 100644 chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/class_test/class.go create mode 100644 chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/class_test/llgo.expect create mode 100644 chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/comment_test/comment.go create mode 100644 chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/comment_test/llgo.expect delete mode 100644 chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/decl.go create mode 100644 chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/enum_test/enum.go create mode 100644 chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/enum_test/llgo.expect create mode 100644 chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/func_test/func.go create mode 100644 chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/func_test/llgo.expect delete mode 100644 chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/llgo.expect create mode 100644 chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/scope_test/llgo.expect create mode 100644 chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/scope_test/scope.go create mode 100644 chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/struct_test/llgo.expect create mode 100644 chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/struct_test/struct.go create mode 100644 chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/typedef_test/llgo.expect create mode 100644 chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/typedef_test/typedef.go create mode 100644 chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/union_test/llgo.expect create mode 100644 chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/union_test/union.go diff --git a/chore/_xtool/llcppsigfetch/parse/cvt.go b/chore/_xtool/llcppsigfetch/parse/cvt.go index e6f3c6a8..c92afa49 100644 --- a/chore/_xtool/llcppsigfetch/parse/cvt.go +++ b/chore/_xtool/llcppsigfetch/parse/cvt.go @@ -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), diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/class_test/class.go b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/class_test/class.go new file mode 100644 index 00000000..747688f9 --- /dev/null +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/class_test/class.go @@ -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) +} diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/class_test/llgo.expect b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/class_test/llgo.expect new file mode 100644 index 00000000..b8542bd2 --- /dev/null +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/class_test/llgo.expect @@ -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 diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/comment_test/comment.go b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/comment_test/comment.go new file mode 100644 index 00000000..12010b72 --- /dev/null +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/comment_test/comment.go @@ -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) +} diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/comment_test/llgo.expect b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/comment_test/llgo.expect new file mode 100644 index 00000000..6ec789be --- /dev/null +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/comment_test/llgo.expect @@ -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 diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/decl.go b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/decl.go deleted file mode 100644 index 577afd85..00000000 --- a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/decl.go +++ /dev/null @@ -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) -} diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/enum_test/enum.go b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/enum_test/enum.go new file mode 100644 index 00000000..8ed4cba7 --- /dev/null +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/enum_test/enum.go @@ -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) +} diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/enum_test/llgo.expect b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/enum_test/llgo.expect new file mode 100644 index 00000000..c4965551 --- /dev/null +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/enum_test/llgo.expect @@ -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 diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/func_test/func.go b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/func_test/func.go new file mode 100644 index 00000000..4bebe5aa --- /dev/null +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/func_test/func.go @@ -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) +} diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/func_test/llgo.expect b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/func_test/llgo.expect new file mode 100644 index 00000000..98a83ac2 --- /dev/null +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/func_test/llgo.expect @@ -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 diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/llgo.expect b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/llgo.expect deleted file mode 100644 index cc9d4027..00000000 --- a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/llgo.expect +++ /dev/null @@ -1,1823 +0,0 @@ -#stdout -TestFuncDecl Case 1: -{ - "temp.h": { - "path": "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": { - "path": "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": { - "path": "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": { - "path": "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": { - "path": "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": { - "path": "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": { - "path": "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": { - "path": "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": [] - } -} - -TestScope Case 1: -{ - "temp.h": { - "path": "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": { - "path": "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": { - "path": "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": { - "path": "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": { - "path": "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": [] - } -} - -TestComment Case 1: -{ - "temp.h": { - "path": "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": { - "path": "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": { - "path": "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": { - "path": "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": { - "path": "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": { - "path": "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": { - "path": "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": { - "path": "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": { - "path": "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": [] - } -} - -TestStructDecl Case 1: -{ - "temp.h": { - "path": "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": { - "path": "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": { - "path": "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": { - "path": "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": [] - } -} - -TestClassDecl Case 1: -{ - "temp.h": { - "path": "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": { - "path": "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": [] - } -} - -TestUnionDecl Case 1: -{ - "temp.h": { - "path": "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": { - "path": "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": [] - } -} - -TestEnumDecl Case 1: -{ - "temp.h": { - "path": "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": { - "path": "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": { - "path": "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": [] - } -} - -TestTypeDefDecl Case 1: -{ - "temp.h": { - "path": "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": { - "path": "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": { - "path": "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 diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/scope_test/llgo.expect b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/scope_test/llgo.expect new file mode 100644 index 00000000..fd8ce82c --- /dev/null +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/scope_test/llgo.expect @@ -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 diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/scope_test/scope.go b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/scope_test/scope.go new file mode 100644 index 00000000..4c6985ce --- /dev/null +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/scope_test/scope.go @@ -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) +} diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/struct_test/llgo.expect b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/struct_test/llgo.expect new file mode 100644 index 00000000..16b90baf --- /dev/null +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/struct_test/llgo.expect @@ -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 diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/struct_test/struct.go b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/struct_test/struct.go new file mode 100644 index 00000000..fd14b720 --- /dev/null +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/struct_test/struct.go @@ -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) +} diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/typedef_test/llgo.expect b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/typedef_test/llgo.expect new file mode 100644 index 00000000..4eed90e6 --- /dev/null +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/typedef_test/llgo.expect @@ -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 diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/typedef_test/typedef.go b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/typedef_test/typedef.go new file mode 100644 index 00000000..81daceca --- /dev/null +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/typedef_test/typedef.go @@ -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) +} diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/union_test/llgo.expect b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/union_test/llgo.expect new file mode 100644 index 00000000..7c0943df --- /dev/null +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/union_test/llgo.expect @@ -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 diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/union_test/union.go b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/union_test/union.go new file mode 100644 index 00000000..1f5f7942 --- /dev/null +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/union_test/union.go @@ -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) +} diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/preprocess_test/llgo.expect b/chore/_xtool/llcppsigfetch/parse/cvt_test/preprocess_test/llgo.expect index 3332d313..9e9f5b3d 100644 --- a/chore/_xtool/llcppsigfetch/parse/cvt_test/preprocess_test/llgo.expect +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/preprocess_test/llgo.expect @@ -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" diff --git a/chore/_xtool/llcppsigfetch/parse/dump.go b/chore/_xtool/llcppsigfetch/parse/dump.go index ce5b8240..2f2e71dd 100644 --- a/chore/_xtool/llcppsigfetch/parse/dump.go +++ b/chore/_xtool/llcppsigfetch/parse/dump.go @@ -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 diff --git a/chore/llcppg/ast/ast.go b/chore/llcppg/ast/ast.go index 6f924a4a..46c16dc3 100644 --- a/chore/llcppg/ast/ast.go +++ b/chore/llcppg/ast/ast.go @@ -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"`