diff --git a/src/clang_convert/default/default_conversion_pack/default_conversion_validation.py b/src/clang_convert/default/default_conversion_pack/default_conversion_validation.py index 129ca2317..ed663a469 100755 --- a/src/clang_convert/default/default_conversion_pack/default_conversion_validation.py +++ b/src/clang_convert/default/default_conversion_pack/default_conversion_validation.py @@ -112,11 +112,11 @@ class DefaultConversionValidation(conversion_validation.ConversionValidation): # If we've got a StructMemberAccess object, we're probably dealing with a container... cppleft = cppbinary_operation.left_operand - if isinstance(cppleft, struct_member_access.StructMemberAccess): - cppbinary_op = cppbinary_operation.binary_op - cppright = cppbinary_operation.right_operand + cppbinary_op = cppbinary_operation.binary_op + cppright = cppbinary_operation.right_operand - if cppbinary_op.is_assignment(): + if cppbinary_op.is_assignment(): + if isinstance(cppleft, struct_member_access.StructMemberAccess): cpparg = self._conversion_data.cpparg_for_cppname(cppleft.name) if cppleft.member: if cppleft.member.name == "size()": @@ -140,6 +140,12 @@ class DefaultConversionValidation(conversion_validation.ConversionValidation): cppleft.index = "[0]" debug.line("validate_binary_operation", f"Assigning number to container, so updating it to access first element: cppleft=[{debug.as_debug_string(cppleft)}] cppright_value=[{cppright_value}]") return binary_operation.BinaryOperation(cppleft, cppbinary_op, cppright) + + elif cppbinary_op.is_comparison(): + cpparg = arg_utils.to_cpparg(cppleft, self._conversion_data) + if cpparg and self._conversion_data.is_container_type(cpparg.decl_spec.type): + cppleft = literal.Literal(f"{cpparg.name}.size()") + return binary_operation.BinaryOperation(cppleft, cppbinary_op, cppright) return cppbinary_operation diff --git a/src/clang_convert/grib_accessor/grib_accessor_conversion_pack/grib_accessor_conversion_validation.py b/src/clang_convert/grib_accessor/grib_accessor_conversion_pack/grib_accessor_conversion_validation.py index 41ca9524e..8b2e161bb 100755 --- a/src/clang_convert/grib_accessor/grib_accessor_conversion_pack/grib_accessor_conversion_validation.py +++ b/src/clang_convert/grib_accessor/grib_accessor_conversion_pack/grib_accessor_conversion_validation.py @@ -43,10 +43,13 @@ class GribAccessorConversionValidation(default_conversion_validation.DefaultConv cpp_body = compound_statement.CompoundStatement() cpp_body.add_code_object(as_commented_out_code("C++ implementation not yet available.")) - cpp_body.add_code_object(as_commented_out_code("Commented C body provided below for reference:\n")) + cpp_body.add_code_object(as_commented_out_code("Current C++ conversion provided below (disabled, for reference only):\n")) + cpp_body.add_code_object(literal.Literal(f"#if 0")) - for entry in cvirtual_member_function.body.code_objects: - cpp_body.add_code_object(as_commented_out_code(entry)) + for entry in cppvirtual_member_function.body.code_objects: + cpp_body.add_code_object(entry) + + cpp_body.add_code_object(literal.Literal(f"#endif // 0")) cpp_body.add_code_object(literal.Literal(f"\nreturn {self._conversion_data.info.super_class_name}::{cppvirtual_member_function.funcsig_as_call};")) return virtual_member_function.VirtualMemberFunction(cppvirtual_member_function.funcsig, cpp_body, cppvirtual_member_function.class_name) @@ -124,7 +127,7 @@ class GribAccessorConversionValidation(default_conversion_validation.DefaultConv cpp_expression = cppreturn_statement.expression.as_string() if cpp_expression == "0": updated_cpp_expression = literal.Literal("GribStatus::SUCCESS") - else: + elif not cpp_expression.startswith("GribStatus"): updated_cpp_expression = literal.Literal(f"static_cast({cpp_expression})") if updated_cpp_expression: