mirror of https://github.com/ecmwf/eccodes.git
Fixed issue with member functions being forwartd declared
This commit is contained in:
parent
21f62d27f3
commit
03db6927eb
|
@ -44,26 +44,25 @@ class AstParser:
|
|||
if global_debug_enabled and not include_ast_parser_debugging:
|
||||
debug.disable_debug()
|
||||
|
||||
ccode_objects = code_objects.CodeObjects()
|
||||
parsed_cnode = None
|
||||
|
||||
if isinstance(cnode, list):
|
||||
parsed_cnode = code_objects.CodeObjects()
|
||||
for entry in cnode:
|
||||
cnode_code_object = self.parse_ast_node(entry)
|
||||
if cnode_code_object:
|
||||
ccode_objects.add_code_object(cnode_code_object)
|
||||
parsed_cnode.add_code_object(cnode_code_object)
|
||||
else:
|
||||
debug.line("to_ccode_objects", f"Code object is None for node spelling=[{entry.spelling}] type=[{entry.type.spelling}] kind=[{entry.kind}]")
|
||||
else:
|
||||
cnode_code_object = self.parse_ast_node(cnode)
|
||||
if cnode_code_object:
|
||||
ccode_objects.add_code_object(cnode_code_object)
|
||||
else:
|
||||
parsed_cnode = self.parse_ast_node(cnode)
|
||||
if not parsed_cnode:
|
||||
debug.line("to_ccode_objects", f"Code object is None for node spelling=[{cnode.spelling}] type=[{cnode.type.spelling}] kind=[{cnode.kind}]")
|
||||
|
||||
if global_debug_enabled and not include_ast_parser_debugging:
|
||||
debug.enable_debug()
|
||||
|
||||
return ccode_objects
|
||||
return parsed_cnode
|
||||
|
||||
# Main entry point to parse an AST node and return a CodeInterface objects
|
||||
#
|
||||
|
|
|
@ -3,6 +3,8 @@ import utils.debug as debug
|
|||
import code_object.global_function as global_function
|
||||
import code_object_converter.function_converter as function_converter
|
||||
import code_object_converter.conversion_funcs as conversion_funcs
|
||||
import code_object.code_objects as code_objects
|
||||
import code_object.funcsig as funcsig
|
||||
|
||||
class GlobalFunctionConverter(function_converter.FunctionConverter):
|
||||
def __init__(self, ccode_object) -> None:
|
||||
|
@ -10,7 +12,15 @@ class GlobalFunctionConverter(function_converter.FunctionConverter):
|
|||
assert isinstance(ccode_object, global_function.GlobalFunction), f"Expected GlobalFunction, got type=[{type(ccode_object)}]"
|
||||
|
||||
def create_cpp_code_object(self, conversion_data):
|
||||
cpp_body = conversion_funcs.convert_ccode_object(self._ccode_object.body, conversion_data)
|
||||
cpp_body = code_objects.CodeObjects()
|
||||
|
||||
for entry in self._ccode_object.body.code_objects:
|
||||
if isinstance(entry, funcsig.FuncSig) and entry.name in conversion_data._member_function_names:
|
||||
debug.line("create_cpp_code_object", f"Ignoring member function name=[{entry.name}]")
|
||||
continue
|
||||
|
||||
cpp_code_obj = conversion_funcs.convert_ccode_object(entry, conversion_data)
|
||||
cpp_body.add_code_object(cpp_code_obj)
|
||||
|
||||
return global_function.GlobalFunction(cpp_body)
|
||||
|
|
@ -14,6 +14,7 @@ class ConversionData:
|
|||
self._local_args = {} # Local to the function being processed
|
||||
self._funcsig_mappings = []
|
||||
self._funcsig_pointer_mappings = []
|
||||
self._member_function_names = []
|
||||
|
||||
@property
|
||||
def funcsig_decl_specs(self):
|
||||
|
@ -120,3 +121,11 @@ class ConversionData:
|
|||
return mapping.cppfuncsig_pointer
|
||||
|
||||
return None
|
||||
|
||||
@property
|
||||
def member_function_names(self):
|
||||
return self._member_function_names
|
||||
|
||||
def set_member_function_names(self, mem_func_names):
|
||||
self._member_function_names = []
|
||||
self._member_function_names.extend(mem_func_names)
|
|
@ -16,3 +16,5 @@ grib_accessor_member_funcsig_mapping = [
|
|||
FuncSigMapping( FuncSig("", "destroy", [Arg("grib_context*", ""), Arg("grib_accessor*", "")]),
|
||||
FuncSig("", "Destructor", [None, None]) ),
|
||||
]
|
||||
|
||||
member_function_names = [mapping.cfuncsig.name for mapping in grib_accessor_member_funcsig_mapping]
|
|
@ -127,3 +127,5 @@ grib_accessor_virtual_member_funcsig_mapping = [
|
|||
#FuncSigMapping(FuncSig("int", "next_offset", [Arg("grib_accessor*", "")]),
|
||||
# FuncSig(None, None, [None])),
|
||||
]
|
||||
|
||||
virtual_member_function_names = [mapping.cfuncsig.name for mapping in grib_accessor_virtual_member_funcsig_mapping]
|
||||
|
|
|
@ -1,48 +1,9 @@
|
|||
|
||||
import utils.debug as debug
|
||||
import default.default_ccode as default_ccode
|
||||
import grib_accessor.conversion_data.virtual_member_functions as virtual_member_functions
|
||||
import re
|
||||
|
||||
grib_accessor_virtual_member_functions = [
|
||||
"dump",
|
||||
"next_offset",
|
||||
"string_length",
|
||||
"value_count",
|
||||
"byte_count",
|
||||
"byte_offset",
|
||||
"get_native_type",
|
||||
"sub_section",
|
||||
"pack_missing",
|
||||
"is_missing",
|
||||
"pack_long",
|
||||
"unpack_long",
|
||||
"pack_double",
|
||||
"pack_float",
|
||||
"unpack_double",
|
||||
"unpack_float",
|
||||
"pack_string",
|
||||
"unpack_string",
|
||||
"pack_string_array",
|
||||
"unpack_string_array",
|
||||
"pack_bytes",
|
||||
"unpack_bytes",
|
||||
"pack_expression",
|
||||
"notify_change",
|
||||
"update_size",
|
||||
"preferred_size",
|
||||
"resize",
|
||||
"nearest_smaller_value",
|
||||
"next",
|
||||
"compare",
|
||||
"unpack_double_element",
|
||||
"unpack_float_element",
|
||||
"unpack_double_element",
|
||||
"unpack_float_element",
|
||||
"unpack_double_subarray",
|
||||
"clear",
|
||||
"clone",
|
||||
]
|
||||
|
||||
# Represents a grib_accessor_class_*cc file
|
||||
class GribAccessorCCode(default_ccode.DefaultCCode):
|
||||
def __init__(self, cfilename, accessor_name, accessor_class_name) -> None:
|
||||
|
@ -65,7 +26,7 @@ class GribAccessorCCode(default_ccode.DefaultCCode):
|
|||
return cfuncsig.name == "destroy"
|
||||
|
||||
def is_virtual_member_function(self, cfuncsig):
|
||||
return cfuncsig.name in grib_accessor_virtual_member_functions
|
||||
return cfuncsig.name in virtual_member_functions.virtual_member_function_names
|
||||
|
||||
def is_member_function(self, cfuncsig):
|
||||
if not self.is_virtual_member_function(cfuncsig):
|
||||
|
|
|
@ -6,6 +6,8 @@ import default.default_cppcode as default_cppcode
|
|||
import utils.standard_transforms as standard_transforms
|
||||
from grib_accessor.conversion_data.virtual_member_functions import grib_accessor_virtual_member_funcsig_mapping
|
||||
from grib_accessor.conversion_data.member_functions import grib_accessor_member_funcsig_mapping
|
||||
import grib_accessor.conversion_data.member_functions as member_functions
|
||||
import grib_accessor.conversion_data.virtual_member_functions as virtual_member_functions
|
||||
|
||||
prefix = "grib_accessor_class_"
|
||||
rename = {
|
||||
|
@ -42,6 +44,9 @@ class GribAccessorCCodeConverter(default_ccode_converter.DefaultCCodeConverter):
|
|||
self._conversion_data.set_funcsig_mappings(grib_accessor_virtual_member_funcsig_mapping)
|
||||
for mapping in grib_accessor_member_funcsig_mapping:
|
||||
self._conversion_data.add_to_funcsig_mappings(mapping)
|
||||
# Add the member functions
|
||||
self._conversion_data.set_member_function_names(member_functions.member_function_names +
|
||||
virtual_member_functions.virtual_member_function_names)
|
||||
|
||||
def set_function_specific_conversion_data(self, function_name):
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue