mirror of https://github.com/ecmwf/eccodes.git
Improved parsing to better ignore non-local definitions
This commit is contained in:
parent
3d69469fdc
commit
c5d1a026a3
|
@ -36,14 +36,14 @@ grib_accessor_class_dictionary.cc
|
|||
#grib_accessor_class_g1_half_byte_codeflag.cc
|
||||
grib_accessor_class_g2_mars_labeling.cc
|
||||
grib_accessor_class_g2step_range.cc
|
||||
#grib_accessor_class_gaussian_grid_name.cc
|
||||
grib_accessor_class_gaussian_grid_name.cc
|
||||
grib_accessor_class_gds_not_present_bitmap.cc
|
||||
#grib_accessor_class_group.cc
|
||||
#grib_accessor_class_hash_array.cc
|
||||
grib_accessor_class_group.cc
|
||||
grib_accessor_class_hash_array.cc
|
||||
grib_accessor_class_headers_only.cc
|
||||
grib_accessor_class_ifs_param.cc
|
||||
grib_accessor_class_iterator.cc
|
||||
#grib_accessor_class_label.cc
|
||||
grib_accessor_class_label.cc
|
||||
#grib_accessor_class_md5.cc
|
||||
grib_accessor_class_message_copy.cc
|
||||
grib_accessor_class_nearest.cc
|
||||
|
|
|
@ -31,16 +31,16 @@ class AstCodeCreator:
|
|||
# Note: the preprocessor necessarily parses macros before everything else, so these will
|
||||
# ALWAYS appear at the top of the global declaration
|
||||
self._ast_code.add_global_function_entry(node)
|
||||
else:
|
||||
debug.line("parse_node", f"Ignoring [no file info] node spelling=[{node.spelling}] kind=[{node.kind}]")
|
||||
return
|
||||
elif node.kind == clang.cindex.CursorKind.MACRO_INSTANTIATION:
|
||||
if node.location.file and node.location.file.name == self._cfilepath + self._cfilename:
|
||||
self._ast_code.add_macro_instantiation(node)
|
||||
|
||||
# We ignore any other nodes that aren't local...
|
||||
if node.location.file and node.location.file.name != self._cfilepath + self._cfilename:
|
||||
debug.line("parse_node", f"Ignoring non-local node spelling=[{node.spelling}] file=[{os.path.basename(node.location.file.name)}]")
|
||||
elif node.location.file and node.location.file.name != self._cfilepath + self._cfilename:
|
||||
debug.line("parse_node", f"Ignoring [non-local] node spelling=[{node.spelling}] file=[{os.path.basename(node.location.file.name)}]")
|
||||
return
|
||||
|
||||
if node.kind == clang.cindex.CursorKind.INCLUSION_DIRECTIVE:
|
||||
elif node.kind == clang.cindex.CursorKind.INCLUSION_DIRECTIVE:
|
||||
pass
|
||||
elif node.kind.is_declaration:
|
||||
if node.kind == clang.cindex.CursorKind.FUNCTION_DECL and node.is_definition():
|
||||
|
|
|
@ -409,6 +409,10 @@ class ConversionData:
|
|||
if cpparg:
|
||||
return cpparg
|
||||
|
||||
cppmember = self.cppdata_member_for_cppname(cppname)
|
||||
if cppmember:
|
||||
return cppmember
|
||||
|
||||
buf_map = self.funcsig_buffer_mapping_for_cppname(cppname)
|
||||
if buf_map:
|
||||
return buf_map.cpp_container
|
||||
|
@ -438,6 +442,13 @@ class ConversionData:
|
|||
return True
|
||||
return False
|
||||
|
||||
def cppdata_member_for_cppname(self, cppname):
|
||||
for mapping in self.all_mappings():
|
||||
for key, value in mapping.data_member_mappings.items():
|
||||
if value and value.name == cppname:
|
||||
return value
|
||||
return None
|
||||
|
||||
def cppdata_member_for_cdata_member(self, cmember):
|
||||
for mapping in self.all_mappings():
|
||||
for key, value in mapping.data_member_mappings.items():
|
||||
|
|
|
@ -236,16 +236,17 @@ class GribAccessorConversionValidation(default_conversion_validation.DefaultConv
|
|||
cpparg = self._conversion_data.cpparg_for_cppname(cppstruct_member_access.name)
|
||||
if cpparg and cpparg.decl_spec.type == "AccessorPtr":
|
||||
data_member = cppstruct_member_access.member
|
||||
if data_member.name == "name":
|
||||
data_member.name += "().get().c_str()" # It's read-only so this is ok!
|
||||
if data_member.name == "parent":
|
||||
# For now we'll strip off the parent bit as that is accessing the grib_section, which we'll probably get
|
||||
# another way!
|
||||
updated_cppstruct_member_access = struct_member_access.StructMemberAccess(cppstruct_member_access.access,
|
||||
cppstruct_member_access.name,
|
||||
cppstruct_member_access.index)
|
||||
debug.line("validate_struct_member_access", f"Updating AccessorPtr grib_section access: [{debug.as_debug_string(cppstruct_member_access)}]->[{updated_cppstruct_member_access}]")
|
||||
return updated_cppstruct_member_access
|
||||
if data_member:
|
||||
if data_member.name == "name":
|
||||
data_member.name += "().get().c_str()" # It's read-only so this is ok!
|
||||
if data_member.name == "parent":
|
||||
# For now we'll strip off the parent bit as that is accessing the grib_section, which we'll probably get
|
||||
# another way!
|
||||
updated_cppstruct_member_access = struct_member_access.StructMemberAccess(cppstruct_member_access.access,
|
||||
cppstruct_member_access.name,
|
||||
cppstruct_member_access.index)
|
||||
debug.line("validate_struct_member_access", f"Updating AccessorPtr grib_section access: [{debug.as_debug_string(cppstruct_member_access)}]->[{updated_cppstruct_member_access}]")
|
||||
return updated_cppstruct_member_access
|
||||
|
||||
return super().validate_struct_member_access(cstruct_member_access, cppstruct_member_access)
|
||||
|
||||
|
|
Loading…
Reference in New Issue