Skip to content

Commit

Permalink
++
Browse files Browse the repository at this point in the history
  • Loading branch information
littleGnAl committed Nov 21, 2023
1 parent edf4552 commit d664fc9
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 41 deletions.
132 changes: 91 additions & 41 deletions cxx-parser/__integration_test__/cxx_parser.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ describe('cxx_parser', () => {
fs.writeFileSync(
file1Path,
`
struct AAA {
int a;
};
`
struct AAA {
int a;
};
`
);

let checkSum = generateChecksum([file1Path]);
Expand All @@ -41,45 +41,45 @@ struct AAA {

// TODO(littlegnal): Should move the tmp/*.h to the build dir in the future
const expectedJson = `
[
{
"__TYPE":"CXXFile",
"file_path":"${preProcessParseFilesDir}/file1.h",
"nodes":[
[
{
"__TYPE":"Struct",
"attributes":[],
"base_clazzs":[],
"comment":"",
"constructors":[],
"__TYPE":"CXXFile",
"file_path":"${preProcessParseFilesDir}/file1.h",
"member_variables":[
"nodes":[
{
"__TYPE":"MemberVariable",
"access_specifier":"",
"is_mutable":false,
"name":"a",
"type":{
"__TYPE":"SimpleType",
"is_builtin_type":true,
"is_const":false,
"kind":100,
"name":"int",
"source":"int",
"template_arguments":[]
}
"__TYPE":"Struct",
"attributes":[],
"base_clazzs":[],
"comment":"",
"constructors":[],
"file_path":"${preProcessParseFilesDir}/file1.h",
"member_variables":[
{
"__TYPE":"MemberVariable",
"access_specifier":"",
"is_mutable":false,
"name":"a",
"type":{
"__TYPE":"SimpleType",
"is_builtin_type":true,
"is_const":false,
"kind":100,
"name":"int",
"source":"int",
"template_arguments":[]
}
}
],
"methods":[],
"name":"AAA",
"namespaces":[],
"parent_name":"${preProcessParseFilesDir}/file1.h",
"source":""
}
],
"methods":[],
"name":"AAA",
"namespaces":[],
"parent_name":"${preProcessParseFilesDir}/file1.h",
"source":""
]
}
]
}
]
`;
`;

let json = dumpCXXAstJson(new TerraContext(tmpDir), [], [file1Path], []);

Expand All @@ -97,6 +97,7 @@ struct AAA {
file1Path,
`
typedef struct AAA {
int a;
} AAA;
`
);
Expand All @@ -121,7 +122,23 @@ struct AAA {
"comment":"",
"constructors":[],
"file_path":"${preProcessParseFilesDir}/file1.h",
"member_variables":[],
"member_variables":[
{
"__TYPE":"MemberVariable",
"access_specifier":"",
"is_mutable":false,
"name":"a",
"type":{
"__TYPE":"SimpleType",
"is_builtin_type":true,
"is_const":false,
"kind":100,
"name":"int",
"source":"int",
"template_arguments":[]
}
}
],
"methods":[],
"name":"AAA",
"namespaces":[],
Expand Down Expand Up @@ -153,6 +170,7 @@ struct AAA {
file1Path,
`
typedef struct {
int a;
} AAA;
`
);
Expand All @@ -177,7 +195,23 @@ struct AAA {
"comment":"",
"constructors":[],
"file_path":"${preProcessParseFilesDir}/file1.h",
"member_variables":[],
"member_variables":[
{
"__TYPE":"MemberVariable",
"access_specifier":"",
"is_mutable":false,
"name":"a",
"type":{
"__TYPE":"SimpleType",
"is_builtin_type":true,
"is_const":false,
"kind":100,
"name":"int",
"source":"int",
"template_arguments":[]
}
}
],
"methods":[],
"name":"AAA",
"namespaces":[],
Expand Down Expand Up @@ -209,6 +243,7 @@ struct AAA {
file1Path,
`
typedef enum MyEnum {
A = 0,
} MyEnum;
`
);
Expand All @@ -231,7 +266,14 @@ struct AAA {
"attributes":[],
"base_clazzs":[],
"comment":"",
"enum_constants":[],
"enum_constants": [
{
"__TYPE": "EnumConstant",
"name": "A",
"source": "0",
"value": "0"
}
],
"file_path":"${preProcessParseFilesDir}/file1.h",
"name":"MyEnum",
"namespaces":[],
Expand Down Expand Up @@ -263,6 +305,7 @@ struct AAA {
file1Path,
`
typedef enum {
A = 0,
} MyEnum;
`
);
Expand All @@ -285,7 +328,14 @@ struct AAA {
"attributes":[],
"base_clazzs":[],
"comment":"",
"enum_constants":[],
"enum_constants": [
{
"__TYPE": "EnumConstant",
"name": "A",
"source": "0",
"value": "0"
}
],
"file_path":"${preProcessParseFilesDir}/file1.h",
"name":"MyEnum",
"namespaces":[],
Expand Down
2 changes: 2 additions & 0 deletions cxx-parser/cxx/terra/include/terra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,8 @@ namespace terra
std::cout << "[type_alias_t] type name: " << cpp_type_alias.name() << ", under type: " << cppast::to_string(cpp_type_alias.underlying_type())
<< std::endl;
}

return true;
}

if (e.kind() == cppast::cpp_entity_kind::class_t && !info.is_old_entity())
Expand Down

0 comments on commit d664fc9

Please sign in to comment.