mirror of https://github.com/ecmwf/eccodes.git
Added remaining base conversion validators
This commit is contained in:
parent
1d2e1c7518
commit
48b7cadeca
|
@ -26,7 +26,7 @@ class ArgConverter(code_interface_converter.CodeInterfaceConverter):
|
|||
cpp_arg = self.convert_funcbody_arg()
|
||||
|
||||
debug.line("create_cpp_code_object", f"ArgConverter [OUT] cpp_arg=[{debug.as_debug_string(cpp_arg)}]")
|
||||
return cpp_arg
|
||||
return conversion_pack.conversion_validation.validate_arg(self._ccode_object, cpp_arg)
|
||||
|
||||
def convert_funcsig_arg(self):
|
||||
carg = self._ccode_object
|
||||
|
|
|
@ -13,4 +13,5 @@ class ArrayAccessConverter(code_interface_converter.CodeInterfaceConverter):
|
|||
cpp_name = conversion_funcs.convert_ccode_object(self._ccode_object.name, conversion_pack)
|
||||
cpp_index = conversion_funcs.convert_ccode_object(self._ccode_object.index, conversion_pack)
|
||||
|
||||
return array_access.ArrayAccess(cpp_name, cpp_index)
|
||||
cpparray_access = array_access.ArrayAccess(cpp_name, cpp_index)
|
||||
return conversion_pack.conversion_validation.validate_array_access(self._ccode_object, cpparray_access)
|
||||
|
|
|
@ -20,4 +20,4 @@ class CodeObjectsConverter(code_interface_converter.CodeInterfaceConverter):
|
|||
converted_object = conversion_funcs.convert_ccode_object(entry, conversion_pack)
|
||||
cpp_code_objects.add_code_object(converted_object)
|
||||
|
||||
return cpp_code_objects
|
||||
return conversion_pack.conversion_validation.validate_code_objects(self._ccode_object, cpp_code_objects)
|
||||
|
|
|
@ -14,4 +14,5 @@ class ConditionalOperationConverter(code_interface_converter.CodeInterfaceConver
|
|||
cpp_true_expression = conversion_funcs.convert_ccode_object(self._ccode_object.true_expression, conversion_pack)
|
||||
cpp_false_expression = conversion_funcs.convert_ccode_object(self._ccode_object.false_expression, conversion_pack)
|
||||
|
||||
return conditional_operation.ConditionalOperation(cpp_bool_expression, cpp_true_expression, cpp_false_expression)
|
||||
cppconditional_operation = conditional_operation.ConditionalOperation(cpp_bool_expression, cpp_true_expression, cpp_false_expression)
|
||||
return conversion_pack.conversion_validation.validate_conditional_operation(self._ccode_object, cppconditional_operation)
|
||||
|
|
|
@ -12,5 +12,7 @@ class ConstructorFunctionConverter(member_function_converter.MemberFunctionConve
|
|||
def create_cpp_code_object(self, conversion_pack):
|
||||
cpp_funcsig = conversion_funcs.convert_ccode_object(self._ccode_object.funcsig, conversion_pack)
|
||||
cpp_body = conversion_funcs.convert_ccode_object(self._ccode_object.body, conversion_pack)
|
||||
return constructor_function.ConstructorFunction(cpp_funcsig, cpp_body, conversion_pack.conversion_data.info.class_name, conversion_pack.conversion_data.info.super_class_name)
|
||||
|
||||
cppconstructor_function = constructor_function.ConstructorFunction(cpp_funcsig, cpp_body, conversion_pack.conversion_data.info.class_name, conversion_pack.conversion_data.info.super_class_name)
|
||||
return conversion_pack.conversion_validation.validate_constructor_function(self._ccode_object, cppconstructor_function)
|
||||
|
|
@ -12,23 +12,101 @@ class ConversionValidation:
|
|||
# ---------- CodeObject Validation : Begin -----------------------------------------------------
|
||||
# Perform full validation of converted C++ function call
|
||||
# The callee mapping is provided to check e.g. the function call is using the correct references etc
|
||||
def validate_function_call(self, cfunction_call, cppfunction_call, callee_funcsig_mapping):
|
||||
return cppfunction_call
|
||||
|
||||
def validate_variable_declaration(self, cvariable_declaration, cppvariable_declaration):
|
||||
return cppvariable_declaration
|
||||
|
||||
def validate_unary_operation(self, cunary_operation, cppunary_operation):
|
||||
return cppunary_operation
|
||||
def validate_arg(self, carg, cpparg):
|
||||
return cpparg
|
||||
|
||||
def validate_array_access(self, carray_access, cpparray_access):
|
||||
return cpparray_access
|
||||
|
||||
def validate_binary_operation(self, cbinary_operation, cppbinary_operation):
|
||||
return cppbinary_operation
|
||||
|
||||
def validate_code_objects(self, ccode_objects, cppcode_objects):
|
||||
return cppcode_objects
|
||||
|
||||
def validate_compound_statement(self, ccompound_statement, cppcompound_statement):
|
||||
return cppcompound_statement
|
||||
|
||||
def validate_conditional_operation(self, cconditional_operation, cppconditional_operation):
|
||||
return cppconditional_operation
|
||||
|
||||
def validate_constructor_function(self, cconstructor_function, cppconstructor_function):
|
||||
return cppconstructor_function
|
||||
|
||||
def validate_data_member(self, cdata_member, cppdata_member):
|
||||
return cppdata_member
|
||||
|
||||
def validate_declaration_specifier(self, cdeclaration_specifier, cppdeclaration_specifier):
|
||||
return cppdeclaration_specifier
|
||||
|
||||
def validate_destructor_function(self, cdestructor_function, cppdestructor_function):
|
||||
return cppdestructor_function
|
||||
|
||||
def validate_for_statement(self, cfor_statement, cppfor_statement):
|
||||
return cppfor_statement
|
||||
|
||||
def validate_funcsig(self, cfuncsig, cppfuncsig):
|
||||
return cppfuncsig
|
||||
|
||||
def validate_funcsig_pointer(self, cfuncsig_pointer, cppfuncsig_pointer):
|
||||
return cppfuncsig_pointer
|
||||
|
||||
def validate_function_call(self, cfunction_call, cppfunction_call, callee_funcsig_mapping):
|
||||
return cppfunction_call
|
||||
|
||||
def validate_function(self, cfunction, cppfunction):
|
||||
return cppfunction
|
||||
|
||||
def validate_global_function(self, cglobal_function, cppglobal_function):
|
||||
return cppglobal_function
|
||||
|
||||
def validate_if_statement(self, cif_statement, cppif_statement):
|
||||
return cppif_statement
|
||||
|
||||
def validate_init_list(self, cinit_list, cppinit_list):
|
||||
return cppinit_list
|
||||
|
||||
def validate_literal(self, cliteral, cppliteral):
|
||||
return cppliteral
|
||||
|
||||
def validate_macro_definition(self, cmacro_definition, cppmacro_definition):
|
||||
return cppmacro_definition
|
||||
|
||||
def validate_macro_instantiation(self, cmacro_instantiation, cppmacro_instantiation):
|
||||
return cppmacro_instantiation
|
||||
|
||||
def validate_member_function(self, cmember_function, cppmember_function):
|
||||
return cppmember_function
|
||||
|
||||
def validate_operation(self, coperation, cppoperation):
|
||||
return cppoperation
|
||||
|
||||
def validate_paren_expression(self, cparen_expression, cppparen_expression):
|
||||
return cppparen_expression
|
||||
|
||||
def validate_return_statement(self, creturn_statement, cppreturn_statement):
|
||||
return cppreturn_statement
|
||||
|
||||
def validate_struct_arg(self, cstruct_arg, cppstruct_arg):
|
||||
return cppstruct_arg
|
||||
|
||||
def validate_struct_member_access(self, cstruct_member_access, cppstruct_member_access):
|
||||
return cppstruct_member_access
|
||||
|
||||
def validate_unary_expression(self, cunary_expression, cppunary_expression):
|
||||
return cppunary_expression
|
||||
|
||||
def validate_unary_operation(self, cunary_operation, cppunary_operation):
|
||||
return cppunary_operation
|
||||
|
||||
def validate_value_declaration_reference(self, cvalue_declaration_reference, cppvalue_declaration_reference):
|
||||
return cppvalue_declaration_reference
|
||||
|
||||
def validate_variable_declaration(self, cvariable_declaration, cppvariable_declaration):
|
||||
return cppvariable_declaration
|
||||
|
||||
def validate_virtual_member_function(self, cvirtual_member_function, cppvirtual_member_function):
|
||||
return cppvirtual_member_function
|
||||
|
||||
# ---------- CodeObject Validation : End -----------------------------------------------------
|
||||
|
||||
|
|
@ -40,4 +40,4 @@ class DataMemberConverter(arg_converter.ArgConverter):
|
|||
debug.line("create_cpp_code_object", f"Adding data member mapping cmember=[{debug.as_debug_string(cmember)}] cppmember=[{debug.as_debug_string(cppmember)}]")
|
||||
|
||||
debug.line("create_cpp_code_object", f"DataMemberConverter [OUT] cppmember=[{debug.as_debug_string(cppmember)}]")
|
||||
return cppmember
|
||||
return conversion_pack.conversion_validation.validate_data_member(cmember, cppmember)
|
||||
|
|
|
@ -26,5 +26,5 @@ class DeclSpecConverter(code_interface_converter.CodeInterfaceConverter):
|
|||
conversion_pack.conversion_data.add_funcbody_type_mapping(cdecl_spec, cpp_decl_spec)
|
||||
debug.line("create_cpp_code_object", f"DeclSpecConverter [OUT] DeclSpec conversion: [{cdecl_spec.as_string()}] [{cdecl_spec}] -> [{cpp_decl_spec.as_string()}]")
|
||||
|
||||
return cpp_decl_spec
|
||||
return conversion_pack.conversion_validation.validate_declaration_specifier(cdecl_spec, cpp_decl_spec)
|
||||
|
|
@ -13,5 +13,6 @@ class DestructorFunctionConverter(member_function_converter.MemberFunctionConver
|
|||
cpp_funcsig = conversion_funcs.convert_ccode_object(self._ccode_object.funcsig, conversion_pack)
|
||||
cpp_body = conversion_funcs.convert_ccode_object(self._ccode_object.body, conversion_pack)
|
||||
|
||||
return destructor_function.DestructorFunction(cpp_funcsig, cpp_body)
|
||||
cppdestructor_function = destructor_function.DestructorFunction(cpp_funcsig, cpp_body)
|
||||
return conversion_pack.conversion_validation.validate_destructor_function(self._ccode_object, cppdestructor_function)
|
||||
|
|
@ -15,5 +15,6 @@ class ForStatementConverter(code_interface_converter.CodeInterfaceConverter):
|
|||
cpp_iteration_expression = conversion_funcs.convert_ccode_object(self._ccode_object.iteration_expression, conversion_pack)
|
||||
cpp_statement = conversion_funcs.convert_ccode_object(self._ccode_object.statement, conversion_pack)
|
||||
|
||||
return for_statement.ForStatement(cpp_init_statement, cpp_condition, cpp_iteration_expression, cpp_statement)
|
||||
cppfor_statement = for_statement.ForStatement(cpp_init_statement, cpp_condition, cpp_iteration_expression, cpp_statement)
|
||||
return conversion_pack.conversion_validation.validate_for_statement(self._ccode_object, cppfor_statement)
|
||||
|
|
@ -44,8 +44,8 @@ class FuncSigConverter(code_interface_converter.CodeInterfaceConverter):
|
|||
# Update the settings that we don't need (want?) to store in the map
|
||||
cppfuncsig.is_declaration = cfuncsig.is_declaration
|
||||
|
||||
return cppfuncsig
|
||||
|
||||
return conversion_pack.conversion_validation.validate_funcsig(cfuncsig, cppfuncsig)
|
||||
|
||||
# The following functions are called when there isn't a stored mapping, so we need to work the mappings out!
|
||||
|
||||
def is_cpp_static(self):
|
||||
|
|
|
@ -43,4 +43,4 @@ class FuncSigPointerConverter(funcsig_converter.FuncSigConverter):
|
|||
# Update the settings that we don't need (want?) to store in the map
|
||||
cppfuncsig_pointer.is_declaration = self._ccode_object.is_declaration
|
||||
|
||||
return cppfuncsig_pointer
|
||||
return conversion_pack.conversion_validation.validate_funcsig_pointer(self._ccode_object, cppfuncsig_pointer)
|
|
@ -13,5 +13,6 @@ class FunctionConverter(code_interface_converter.CodeInterfaceConverter):
|
|||
cpp_funcsig = conversion_funcs.convert_ccode_object(self._ccode_object.funcsig, conversion_pack)
|
||||
cpp_body = conversion_funcs.convert_ccode_object(self._ccode_object.body, conversion_pack)
|
||||
|
||||
return function.Function(cpp_funcsig, cpp_body)
|
||||
cppfunction = function.Function(cpp_funcsig, cpp_body)
|
||||
return conversion_pack.conversion_validation.validate_function(self._ccode_object, cppfunction)
|
||||
|
|
@ -23,5 +23,6 @@ class GlobalFunctionConverter(function_converter.FunctionConverter):
|
|||
cpp_code_obj = conversion_funcs.convert_ccode_object(entry, self._conversion_pack)
|
||||
cpp_body.add_code_object(cpp_code_obj)
|
||||
|
||||
return global_function.GlobalFunction(cpp_body)
|
||||
cppglobal_function = global_function.GlobalFunction(cpp_body)
|
||||
return conversion_pack.conversion_validation.validate_global_function(self._ccode_object, cppglobal_function)
|
||||
|
||||
|
|
|
@ -17,4 +17,4 @@ class InitListConverter(code_interface_converter.CodeInterfaceConverter):
|
|||
cpp_entry = conversion_funcs.convert_ccode_object(entry, conversion_pack)
|
||||
cpp_init_list.add_entry(cpp_entry)
|
||||
|
||||
return cpp_init_list
|
||||
return conversion_pack.conversion_validation.validate_init_list(self._ccode_object, cpp_init_list)
|
||||
|
|
|
@ -11,4 +11,5 @@ class MacroDefinitionConverter(code_interface_converter.CodeInterfaceConverter):
|
|||
|
||||
def create_cpp_code_object(self, conversion_pack):
|
||||
# For now, just return a copy...
|
||||
return macro_definition.MacroDefinition(self._ccode_object.as_lines())
|
||||
cppmacro_defintion = macro_definition.MacroDefinition(self._ccode_object.as_lines())
|
||||
return conversion_pack.conversion_validation.validate_macro_definition(self._ccode_object, cppmacro_defintion)
|
||||
|
|
|
@ -13,5 +13,6 @@ class MemberFunctionConverter(function_converter.FunctionConverter):
|
|||
cpp_funcsig = conversion_funcs.convert_ccode_object(self._ccode_object.funcsig, conversion_pack)
|
||||
cpp_body = conversion_funcs.convert_ccode_object(self._ccode_object.body, conversion_pack)
|
||||
|
||||
return member_function.MemberFunction(cpp_funcsig, cpp_body)
|
||||
cppmember_function = member_function.MemberFunction(cpp_funcsig, cpp_body)
|
||||
return conversion_pack.conversion_validation.validate_member_function(self._ccode_object, cppmember_function)
|
||||
|
|
@ -11,4 +11,5 @@ class OperationConverter(code_interface_converter.CodeInterfaceConverter):
|
|||
|
||||
def create_cpp_code_object(self, conversion_pack):
|
||||
# By default we just return a copy of the value
|
||||
return operation.Operation(self._ccode_object.value)
|
||||
cppoperation = operation.Operation(self._ccode_object.value)
|
||||
return conversion_pack.conversion_validation.validate_operation(self._ccode_object, cppoperation)
|
||||
|
|
|
@ -12,4 +12,5 @@ class ParenExpressionConverter(code_interface_converter.CodeInterfaceConverter):
|
|||
def create_cpp_code_object(self, conversion_pack):
|
||||
cpp_expression = conversion_funcs.convert_ccode_object(self._ccode_object.expression, conversion_pack)
|
||||
|
||||
return paren_expression.ParenExpression(cpp_expression)
|
||||
cppparen_expression = paren_expression.ParenExpression(cpp_expression)
|
||||
return conversion_pack.conversion_validation.validate_paren_expression(self._ccode_object, cppparen_expression)
|
||||
|
|
|
@ -12,4 +12,5 @@ class ReturnStatementConverter(code_interface_converter.CodeInterfaceConverter):
|
|||
def create_cpp_code_object(self, conversion_pack):
|
||||
cpp_expression = conversion_funcs.convert_ccode_object(self._ccode_object.expression, conversion_pack)
|
||||
|
||||
return return_statement.ReturnStatement(cpp_expression)
|
||||
cppreturn_statement = return_statement.ReturnStatement(cpp_expression)
|
||||
return conversion_pack.conversion_validation.validate_return_statement(self._ccode_object, cppreturn_statement)
|
||||
|
|
|
@ -26,4 +26,5 @@ class StructArgConverter(code_interface_converter.CodeInterfaceConverter):
|
|||
cpp_member = conversion_funcs.convert_ccode_object(member, conversion_pack)
|
||||
cpp_members.append(cpp_member)
|
||||
|
||||
return struct_arg.StructArg(cpp_decl_spec.type, cpp_members)
|
||||
cppstruct_arg = struct_arg.StructArg(cpp_decl_spec.type, cpp_members)
|
||||
return conversion_pack.conversion_validation.validate_struct_arg(self._ccode_object, cppstruct_arg)
|
||||
|
|
|
@ -28,4 +28,5 @@ class StructMemberAccessConverter(code_interface_converter.CodeInterfaceConverte
|
|||
cpp_index = conversion_funcs.convert_ccode_object(cstruct_member_access.index, conversion_pack)
|
||||
cpp_member = conversion_funcs.convert_ccode_object(cstruct_member_access.member, conversion_pack)
|
||||
|
||||
return struct_member_access.StructMemberAccess(cpp_access, cpp_name, cpp_index, cpp_member)
|
||||
cppstruct_member_access = struct_member_access.StructMemberAccess(cpp_access, cpp_name, cpp_index, cpp_member)
|
||||
return conversion_pack.conversion_validation.validate_struct_member_access(self._ccode_object, cppstruct_member_access)
|
||||
|
|
|
@ -13,4 +13,5 @@ class UnaryExpressionConverter(code_interface_converter.CodeInterfaceConverter):
|
|||
cpp_keyword = conversion_funcs.convert_ccode_object(self._ccode_object.keyword, conversion_pack)
|
||||
cpp_expression = conversion_funcs.convert_ccode_object(self._ccode_object.expression, conversion_pack)
|
||||
|
||||
return unary_expression.UnaryExpression(cpp_keyword, cpp_expression)
|
||||
cppunary_expression = unary_expression.UnaryExpression(cpp_keyword, cpp_expression)
|
||||
return conversion_pack.conversion_validation.validate_unary_expression(self._ccode_object, cppunary_expression)
|
||||
|
|
|
@ -39,4 +39,5 @@ class ValueDeclarationReferenceConverter(code_interface_converter.CodeInterfaceC
|
|||
cppdecl_ref_expr_value = conversion_funcs.convert_ccode_object(cdecl_ref_expr_value, conversion_pack)
|
||||
debug.line("create_cpp_code_object", f"ValueDeclarationReferenceConverter [4] cdecl_ref_expr_value=[{debug.as_debug_string(cdecl_ref_expr_value)}] cppdecl_ref_expr_value=[{debug.as_debug_string(cppdecl_ref_expr_value)}]")
|
||||
|
||||
return value_declaration_reference.ValueDeclarationReference(cppdecl_ref_expr_value)
|
||||
cppvalue_declaration_reference = value_declaration_reference.ValueDeclarationReference(cppdecl_ref_expr_value)
|
||||
return conversion_pack.conversion_validation.validate_value_declaration_reference(self._ccode_object, cppvalue_declaration_reference)
|
||||
|
|
|
@ -21,7 +21,5 @@ class VariableDeclarationConverter(code_interface_converter.CodeInterfaceConvert
|
|||
cpp_value = conversion_funcs.convert_ccode_object(self._ccode_object.value, conversion_pack)
|
||||
|
||||
cpp_variable_declaration = variable_declaration.VariableDeclaration(cpp_variable, cpp_value)
|
||||
cpp_variable_declaration = conversion_pack.conversion_validation.validate_variable_declaration(self._ccode_object, cpp_variable_declaration)
|
||||
|
||||
return cpp_variable_declaration
|
||||
return conversion_pack.conversion_validation.validate_variable_declaration(self._ccode_object, cpp_variable_declaration)
|
||||
|
|
@ -13,5 +13,6 @@ class VirtualMemberFunctionConverter(member_function_converter.MemberFunctionCon
|
|||
cpp_funcsig = conversion_funcs.convert_ccode_object(self._ccode_object.funcsig, conversion_pack)
|
||||
cpp_body = conversion_funcs.convert_ccode_object(self._ccode_object.body, conversion_pack)
|
||||
|
||||
return virtual_member_function.VirtualMemberFunction(cpp_funcsig, cpp_body)
|
||||
cppvirtual_member_function = virtual_member_function.VirtualMemberFunction(cpp_funcsig, cpp_body)
|
||||
return conversion_pack.conversion_validation.validate_virtual_member_function(self._ccode_object, cppvirtual_member_function)
|
||||
|
Loading…
Reference in New Issue