mirror of https://github.com/ecmwf/eccodes.git
Fixed convert issues for several level 2 accessors
This commit is contained in:
parent
c5d1a026a3
commit
8702f56f22
|
@ -47,16 +47,16 @@ grib_accessor_class_label.cc
|
|||
#grib_accessor_class_md5.cc
|
||||
grib_accessor_class_message_copy.cc
|
||||
grib_accessor_class_nearest.cc
|
||||
#grib_accessor_class_non_alpha.cc
|
||||
grib_accessor_class_non_alpha.cc
|
||||
grib_accessor_class_number_of_values_data_raw_packing.cc
|
||||
grib_accessor_class_pack_bufr_values.cc
|
||||
grib_accessor_class_packing_type.cc
|
||||
grib_accessor_class_position.cc
|
||||
grib_accessor_class_raw.cc
|
||||
#grib_accessor_class_section.cc
|
||||
grib_accessor_class_section.cc
|
||||
grib_accessor_class_section_pointer.cc
|
||||
grib_accessor_class_smart_table_column.cc
|
||||
#grib_accessor_class_step_human_readable.cc
|
||||
grib_accessor_class_step_human_readable.cc
|
||||
grib_accessor_class_to_double.cc
|
||||
grib_accessor_class_to_integer.cc
|
||||
grib_accessor_class_to_string.cc
|
||||
|
@ -69,7 +69,7 @@ grib_accessor_class_uint64_little_endian.cc
|
|||
grib_accessor_class_uint8.cc
|
||||
grib_accessor_class_unpack_bufr_values.cc
|
||||
grib_accessor_class_values.cc
|
||||
#grib_accessor_class_variable.cc
|
||||
grib_accessor_class_variable.cc
|
||||
grib_accessor_class_when.cc
|
||||
#
|
||||
# LEVEL 3
|
||||
|
|
|
@ -273,7 +273,13 @@ class AstParser:
|
|||
|
||||
def parse_RETURN_STMT(self, node):
|
||||
children = list(node.get_children())
|
||||
assert len(children) == 1, f"Expected exactly one child for return statement"
|
||||
child_count = len(children)
|
||||
|
||||
if child_count == 0:
|
||||
# Empty return statement, i.e. return;
|
||||
return return_statement.ReturnStatement(literal.Literal(""))
|
||||
|
||||
assert child_count == 1, f"Expected at most one child for return statement, not [{child_count}]"
|
||||
return_value = children[0]
|
||||
|
||||
tokens = [token.spelling for token in node.get_tokens()]
|
||||
|
|
|
@ -6,19 +6,19 @@ class CFileParser:
|
|||
self._cli_logger = cli_logger
|
||||
|
||||
def to_ast_code_list(self, files, ignore_file_list):
|
||||
file_parse_list = []
|
||||
processed_files_list = []
|
||||
|
||||
if files[0].endswith("input_files"):
|
||||
f = open(files[0], "r")
|
||||
for entry in f:
|
||||
if not entry.startswith("#"):
|
||||
file_parse_list.append(entry.rstrip())
|
||||
processed_files_list.append(entry.rstrip())
|
||||
else:
|
||||
file_parse_list = files
|
||||
processed_files_list = files
|
||||
|
||||
ast_code_list = []
|
||||
|
||||
for f in file_parse_list:
|
||||
for f in processed_files_list:
|
||||
if f in ignore_file_list:
|
||||
self._cli_logger.info("Ignoring C file %s", f)
|
||||
else:
|
||||
|
@ -27,4 +27,4 @@ class CFileParser:
|
|||
ast_code = creator.create()
|
||||
ast_code_list.append(ast_code)
|
||||
|
||||
return ast_code_list
|
||||
return ast_code_list, processed_files_list
|
||||
|
|
|
@ -4,7 +4,7 @@ import code_object.arg as arg
|
|||
|
||||
# Represent a return statement of the form return EXPR;
|
||||
#
|
||||
# EXPR is the expression being returned...
|
||||
# EXPR is the expression being returned, which can be None to mean: return;
|
||||
class ReturnStatement(code_interface.CodeInterface):
|
||||
def __init__(self, expression) -> None:
|
||||
self._expression = expression
|
||||
|
|
|
@ -24,6 +24,10 @@ class BinaryOperationConverter(code_interface_converter.CodeInterfaceConverter):
|
|||
debug.line("create_cpp_code_object", f"cpp_left_operand=[{debug.as_debug_string(cpp_left_operand)}] => returning commented out code")
|
||||
return as_commented_out_code(self._ccode_object, f"Removed invalid binary operation")
|
||||
|
||||
if cpp_right_operand is None or cpp_right_operand == NONE_VALUE:
|
||||
debug.line("create_cpp_code_object", f"cpp_right_operand=[{debug.as_debug_string(cpp_left_operand)}] => returning commented out code")
|
||||
return as_commented_out_code(self._ccode_object, f"Removed invalid binary operation")
|
||||
|
||||
cppbinary_operation = binary_operation.BinaryOperation(cpp_left_operand, cpp_binary_op, cpp_right_operand)
|
||||
|
||||
return conversion_pack.conversion_validation.validate_binary_operation(self._ccode_object, cppbinary_operation)
|
||||
|
|
|
@ -64,11 +64,12 @@ class DefaultConversionManager:
|
|||
|
||||
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)
|
||||
additional_ast_code_list, processed_files, additional_files = self.process_files(current_file_list)
|
||||
full_file_list.extend(processed_files)
|
||||
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)
|
||||
|
@ -79,14 +80,16 @@ class DefaultConversionManager:
|
|||
def process_files(self, files):
|
||||
additional_files = []
|
||||
parser = cfile_parser.CFileParser(self._cli_logger)
|
||||
ast_code_list = parser.to_ast_code_list(files, self.ignore_file_list)
|
||||
ast_code_list, processed_files = 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:
|
||||
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
|
||||
return ast_code_list, processed_files, additional_files
|
||||
|
||||
# Override as required...
|
||||
def get_parent_filename(self, ast_code_instance):
|
||||
|
|
|
@ -13,9 +13,13 @@ grib_accessor_base_data_members_map = {
|
|||
DataMember("int","dirty") : DataMember("int","dirty_", mutable=True),
|
||||
DataMember("grib_virtual_value*","vvalue") : DataMember("GribVirtualValuePtr","vvalue_"),
|
||||
DataMember("const char*","set") : DataMember("std::string","set_"),
|
||||
# This is a conversion helper!
|
||||
# These are conversion helpers!
|
||||
DataMember("grib_loader*","loader") : DataMember("AccessorLoaderPtr","loader()"),
|
||||
DataMember("grib_action*","creator") : DataMember("GribActionPtr","creator()"),
|
||||
DataMember("grib_section*","sub_section") : DataMember("GribSectionPtr","subSection()"),
|
||||
DataMember("grib_section*","sub_section") : DataMember("GribSectionPtr","subSection()"),
|
||||
DataMember("grib_accessor*","next") : DataMember("AccessorPtr","next()"),
|
||||
DataMember("grib_accessor*","attributes") : DataMember("std::vector<AccessorPtr>","attributes_"),
|
||||
}
|
||||
|
||||
def add_data_member_mappings_to_conversion_data(conversion_data):
|
||||
|
|
|
@ -33,7 +33,6 @@ public:
|
|||
// Required to support C -> C++ Conversion - Start
|
||||
long byteCount() const;
|
||||
long byteOffset() const;
|
||||
|
||||
// Required to support C -> C++ Conversion - End
|
||||
|
||||
template<typename T>
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "GribCpp/GribStatus.h"
|
||||
#include "GribStub/GribVirtualValueStub.h"
|
||||
#include "GribStub/GribActionStub.h"
|
||||
#include "GribStub/GribSectionStub.h"
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
@ -76,8 +77,10 @@ public:
|
|||
virtual GribStatus unpackSubArray(std::vector<double> &values, std::size_t start) const;
|
||||
|
||||
// Conversion helpers...
|
||||
AccessorLoaderPtr loader() const { return nullptr; }
|
||||
GribActionPtr creator() const { return nullptr; }
|
||||
AccessorLoaderPtr loader() const { return nullptr; }
|
||||
GribActionPtr creator() const { return nullptr; }
|
||||
GribSectionPtr subSection() const { return nullptr; }
|
||||
AccessorPtr next() const { return nullptr; }
|
||||
|
||||
// Ideally these would be private, but that makes the conversion much harder so they are protected instead
|
||||
// This will be revisited later...
|
||||
|
@ -90,6 +93,9 @@ protected:
|
|||
int dirty_{};
|
||||
GribVirtualValuePtr vvalue_{};
|
||||
std::string set_{};
|
||||
|
||||
// Conversion helpers...
|
||||
std::vector<AccessorPtr> attributes_;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
namespace eccodes::accessor {
|
||||
|
||||
struct GribSection
|
||||
{
|
||||
//grib_accessor* owner;
|
||||
//grib_handle* h; /** < Handles of all accessors and buffer */
|
||||
//grib_accessor* aclength; /** < block of the length of the block */
|
||||
//grib_block_of_accessors* block; /** < block */
|
||||
//grib_action* branch; /** < branch that created the block */
|
||||
size_t length;
|
||||
size_t padding;
|
||||
};
|
||||
|
||||
using GribSectionPtr = std::shared_ptr<GribSection>;
|
||||
|
||||
}
|
Loading…
Reference in New Issue