Skip to content

Commit

Permalink
feat: Add conditional compilation directives infos to the CXXTerraNode (
Browse files Browse the repository at this point in the history
#44)

- Add conditional compilation directives infos to the CXXTerraNode
- Fix the `lenOfArrayType` can not get the correct num from the std type
  • Loading branch information
littleGnAl authored Dec 1, 2023
1 parent 5dd8149 commit 1767ab7
Show file tree
Hide file tree
Showing 9 changed files with 404 additions and 210 deletions.
42 changes: 42 additions & 0 deletions cxx-parser/__integration_test__/cxx_parser.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,22 @@ describe('cxx_parser', () => {
"attributes":[],
"base_clazzs":[],
"comment":"",
"conditional_compilation_directives_infos": [],
"constructors":[],
"file_path":"${preProcessParseFilesDir}/file1.h",
"member_variables":[
{
"__TYPE":"MemberVariable",
"access_specifier":"",
"attributes": [],
"comment":"",
"conditional_compilation_directives_infos":[],
"file_path":"${preProcessParseFilesDir}/file1.h",
"is_mutable":false,
"name":"a",
"namespaces": [],
"parent_name": "AAA",
"source": "",
"type":{
"__TYPE":"SimpleType",
"is_builtin_type":true,
Expand Down Expand Up @@ -121,15 +128,22 @@ describe('cxx_parser', () => {
"attributes":[],
"base_clazzs":[],
"comment":"",
"conditional_compilation_directives_infos": [],
"constructors":[],
"file_path":"${preProcessParseFilesDir}/file1.h",
"member_variables":[
{
"__TYPE":"MemberVariable",
"access_specifier":"",
"attributes": [],
"comment":"",
"conditional_compilation_directives_infos": [],
"file_path":"${preProcessParseFilesDir}/file1.h",
"is_mutable":false,
"name":"a",
"namespaces": [],
"parent_name": "AAA",
"source": "",
"type":{
"__TYPE":"SimpleType",
"is_builtin_type":true,
Expand Down Expand Up @@ -195,15 +209,22 @@ describe('cxx_parser', () => {
"attributes":[],
"base_clazzs":[],
"comment":"",
"conditional_compilation_directives_infos": [],
"constructors":[],
"file_path":"${preProcessParseFilesDir}/file1.h",
"member_variables":[
{
"__TYPE":"MemberVariable",
"access_specifier":"",
"attributes": [],
"comment":"",
"conditional_compilation_directives_infos": [],
"file_path":"${preProcessParseFilesDir}/file1.h",
"is_mutable":false,
"name":"a",
"namespaces": [],
"parent_name": "",
"source": "",
"type":{
"__TYPE":"SimpleType",
"is_builtin_type":true,
Expand Down Expand Up @@ -268,11 +289,17 @@ describe('cxx_parser', () => {
"__TYPE":"Enumz",
"attributes":[],
"comment":"",
"conditional_compilation_directives_infos": [],
"enum_constants": [
{
"__TYPE": "EnumConstant",
"attributes": [],
"comment":"",
"conditional_compilation_directives_infos": [],
"file_path": "",
"name": "A",
"namespaces": [],
"parent_name": "MyEnum",
"source": "0",
"value": "0"
}
Expand Down Expand Up @@ -330,11 +357,17 @@ describe('cxx_parser', () => {
"__TYPE":"Enumz",
"attributes":[],
"comment":"",
"conditional_compilation_directives_infos": [],
"enum_constants": [
{
"__TYPE": "EnumConstant",
"attributes": [],
"comment":"",
"conditional_compilation_directives_infos": [],
"file_path": "",
"name": "A",
"namespaces": [],
"parent_name": "",
"source": "0",
"value": "0"
}
Expand Down Expand Up @@ -390,6 +423,7 @@ describe('cxx_parser', () => {
"__TYPE": "TypeAlias",
"attributes": [],
"comment": "",
"conditional_compilation_directives_infos": [],
"file_path":"${preProcessParseFilesDir}/file1.h",
"name": "view_t",
"namespaces": [],
Expand Down Expand Up @@ -455,15 +489,22 @@ describe('cxx_parser', () => {
"attributes":[],
"base_clazzs":[],
"comment":"",
"conditional_compilation_directives_infos":[],
"constructors":[],
"file_path":"${preProcessParseFilesDir}/file1.h",
"member_variables":[
{
"__TYPE":"MemberVariable",
"access_specifier":"",
"attributes": [],
"comment":"",
"conditional_compilation_directives_infos": [],
"file_path":"${preProcessParseFilesDir}/file1.h",
"is_mutable":false,
"name":"a",
"namespaces": [],
"parent_name": "AAA",
"source": "",
"type":{
"__TYPE":"SimpleType",
"is_builtin_type":true,
Expand All @@ -485,6 +526,7 @@ describe('cxx_parser', () => {
"__TYPE": "TypeAlias",
"attributes": [],
"comment": "",
"conditional_compilation_directives_infos": [],
"file_path":"${preProcessParseFilesDir}/file1.h",
"name": "view_t",
"namespaces": [],
Expand Down
9 changes: 9 additions & 0 deletions cxx-parser/__tests__/unit_test/cxx_terra_node_ext.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,13 @@ describe('cxx_terra_node_ext', () => {
let len = simpleType.lenOfArrayType();
expect(len).toBe('10');
});

it('lenOfArrayType can get len of array type from std type', () => {
let simpleType = new SimpleType();
simpleType.kind = SimpleTypeKind.array_t;
simpleType.source = 'uint8_t[10]';

let len = simpleType.lenOfArrayType();
expect(len).toBe('10');
});
});
6 changes: 3 additions & 3 deletions cxx-parser/cxx/cppast_backend/src/main.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "terra.hpp"
#include "utils.hpp"
#include "terra_utils.hpp"
#include <cxxopts.hpp>
#include <filesystem>
#include <fstream>
Expand Down Expand Up @@ -125,8 +125,8 @@ int main(int argc, char **argv) {

std::vector<std::string> pre_processed_files;
std::filesystem::path tmp_path = pre_process_dir;
PreProcessVisitFiles(tmp_path, visit_files, pre_processed_files,
is_dump_json);
terra::PreProcessVisitFiles(tmp_path, visit_files, pre_processed_files,
is_dump_json);

if (is_dump_json) {
DumpJson(include_header_dirs, pre_processed_files, defines, output_dir);
Expand Down
199 changes: 0 additions & 199 deletions cxx-parser/cxx/cppast_backend/src/utils.hpp

This file was deleted.

Loading

0 comments on commit 1767ab7

Please sign in to comment.