mirror of https://github.com/ecmwf/eccodes.git
Re-added support for parsing parents
This commit is contained in:
parent
aac39e9f67
commit
62f3edcd71
|
@ -27,32 +27,4 @@ class CFileParser:
|
|||
ast_code = creator.create()
|
||||
ast_code_list.append(ast_code)
|
||||
|
||||
# Parse any missing parents not listed
|
||||
self._cli_logger.info("Looking for missing parent files...")
|
||||
|
||||
self._cli_logger.info(" ***** TODO : ADD PARENT SUPPORT BACK IN (DefaultAstCodeConverter???) *****")
|
||||
|
||||
'''
|
||||
parent_ast_code_list = []
|
||||
|
||||
for ast_code_entry in ast_code_list:
|
||||
ast_code_inst = ast_code_entry
|
||||
parent_cfilename = ast_code_inst.parent_cfilename
|
||||
|
||||
while parent_cfilename and parent_cfilename not in ignore_file_list:
|
||||
if parent_cfilename in file_parse_list:
|
||||
break
|
||||
else:
|
||||
self._cli_logger.info("Parsing parent %s of C file %s", parent_cfilename, ast_code_inst.cfilename)
|
||||
file_parse_list.append(parent_cfilename)
|
||||
|
||||
ast_code_gen = ast_code_creator.AstCodeCreator(f)
|
||||
ast_code_inst = ast_code_gen.parse()
|
||||
parent_ast_code_list.append(ast_code_inst)
|
||||
parent_cfilename = ast_code_inst.parent_cfilename
|
||||
|
||||
self._cli_logger.info("Number of missing parent files parsed: %d", len(parent_ast_code_list))
|
||||
ast_code_list.extend(parent_ast_code_list)
|
||||
'''
|
||||
|
||||
return ast_code_list
|
||||
|
|
|
@ -59,9 +59,39 @@ class DefaultConversionManager:
|
|||
debug.line("convert", f"\n\n============================== [PHASE 4: Write C++ files ] END ==============================\n")
|
||||
|
||||
def create_ast_code_list(self):
|
||||
full_ast_code_list = []
|
||||
full_file_list = []
|
||||
|
||||
current_file_list = self._files
|
||||
while len(current_file_list) > 0:
|
||||
additional_ast_code_list, additional_files = self.process_files(current_file_list)
|
||||
full_file_list.extend(current_file_list)
|
||||
full_ast_code_list.extend(additional_ast_code_list)
|
||||
|
||||
current_file_list = []
|
||||
for file in additional_files:
|
||||
if file not in full_file_list:
|
||||
self._cli_logger.info("Found parent file to process: %s", file)
|
||||
current_file_list.append(file)
|
||||
|
||||
return full_ast_code_list
|
||||
|
||||
def process_files(self, files):
|
||||
additional_files = []
|
||||
parser = cfile_parser.CFileParser(self._cli_logger)
|
||||
return parser.to_ast_code_list(self._files, self.ignore_file_list)
|
||||
|
||||
ast_code_list = parser.to_ast_code_list(files, self.ignore_file_list)
|
||||
|
||||
for entry in ast_code_list:
|
||||
parent_file = self.get_parent_filename(entry)
|
||||
if parent_file and parent_file not in self.ignore_file_list and parent_file not in additional_files:
|
||||
additional_files.append(parent_file)
|
||||
|
||||
return ast_code_list, additional_files
|
||||
|
||||
# Override as required...
|
||||
def get_parent_filename(self, ast_code_instance):
|
||||
return None
|
||||
|
||||
def convert_ast_to_ccode(self, ast_code_list):
|
||||
ccode_list = []
|
||||
|
||||
|
|
|
@ -34,5 +34,11 @@ class GribAccessorConversionManager(default_conversion_manager.DefaultConversion
|
|||
]
|
||||
# Conversion-specific : end ==========================================================
|
||||
|
||||
def get_parent_filename(self, ast_code_instance):
|
||||
for node in ast_code_instance.global_function_nodes:
|
||||
if node.type.spelling == "grib_accessor_class *":
|
||||
return node.spelling + ".cc"
|
||||
return None
|
||||
|
||||
# Read by convert.py
|
||||
CONVERSION_MANAGER_CLASS=GribAccessorConversionManager
|
Loading…
Reference in New Issue