mirror of https://github.com/ecmwf/eccodes.git
concept accessor now converts
This commit is contained in:
parent
fcdb83a1d1
commit
beeb54ef35
|
@ -26,7 +26,7 @@ grib_accessor_class_change_alternative_row_scanning.cc
|
|||
grib_accessor_class_change_scanning_direction.cc
|
||||
grib_accessor_class_codetable_title.cc
|
||||
grib_accessor_class_codetable_units.cc
|
||||
#grib_accessor_class_concept.cc
|
||||
grib_accessor_class_concept.cc
|
||||
#grib_accessor_class_data_apply_bitmap.cc
|
||||
#grib_accessor_class_data_apply_boustrophedonic.cc
|
||||
#grib_accessor_class_data_apply_boustrophedonic_bitmap.cc
|
||||
|
|
|
@ -226,15 +226,16 @@ class AstParser:
|
|||
macro_expression = code_objects.CodeObjects()
|
||||
debug.line("parse_macro_instantiation", f"Found root_expanded_node, kind=[{root_expanded_node.kind}], parsing...")
|
||||
|
||||
# Remove the opening paren so it doesn't cause a double-parse of the top-level node (leading to odd results!)
|
||||
if macro_node_tokens[0] == "(":
|
||||
open_parens_literal = literal.Literal(macro_node_tokens.pop(0))
|
||||
macro_expression.add_code_object(open_parens_literal)
|
||||
if len(macro_node_tokens) > 0:
|
||||
# Remove the opening paren so it doesn't cause a double-parse of the top-level node (leading to odd results!)
|
||||
if macro_node_tokens[0] == "(":
|
||||
open_parens_literal = literal.Literal(macro_node_tokens.pop(0))
|
||||
macro_expression.add_code_object(open_parens_literal)
|
||||
|
||||
while len(macro_node_tokens) > 0:
|
||||
converted_node, macro_node_tokens = self.convert_tokens(macro_node_tokens, root_expanded_node)
|
||||
debug.line("parse_macro_instantiation", f"converted_node=[{debug.as_debug_string(converted_node)}]")
|
||||
macro_expression.add_code_object(converted_node)
|
||||
while len(macro_node_tokens) > 0:
|
||||
converted_node, macro_node_tokens = self.convert_tokens(macro_node_tokens, root_expanded_node)
|
||||
debug.line("parse_macro_instantiation", f"converted_node=[{debug.as_debug_string(converted_node)}]")
|
||||
macro_expression.add_code_object(converted_node)
|
||||
|
||||
macro_inst = macro_instantation.MacroInstantation(macro_name, macro_expression)
|
||||
debug.line("parse_macro_instantiation", f"FINAL MACRO INST=[{macro_inst.as_string()}]")
|
||||
|
|
|
@ -126,7 +126,7 @@ class ConversionData:
|
|||
def cppfuncsig_for_cppfuncname(self, cppfuncname):
|
||||
for mapping in self.all_mappings():
|
||||
for entry in mapping.all_funcsig_mappings:
|
||||
if entry.cppfuncsig != NONE_VALUE and entry.cppfuncsig.name == cppfuncname:
|
||||
if entry.cppfuncsig and entry.cppfuncsig != NONE_VALUE and entry.cppfuncsig.name == cppfuncname:
|
||||
return entry.cppfuncsig
|
||||
return None
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ class VariableDeclarationConverter(code_interface_converter.CodeInterfaceConvert
|
|||
|
||||
cpp_value = conversion_funcs.convert_ccode_object(self._ccode_object.value, conversion_pack)
|
||||
|
||||
debug.line("create_cpp_code_object", f"VariableDeclarationConverter [1] cpp_value=[{debug.as_debug_string(cpp_value)}] for self._ccode_object.value=[{debug.as_debug_string(self._ccode_object.value)}]")
|
||||
|
||||
cpp_variable_declaration = variable_declaration.VariableDeclaration(cpp_variable, cpp_value)
|
||||
return conversion_pack.conversion_validation.validate_variable_declaration(self._ccode_object, cpp_variable_declaration)
|
||||
|
|
@ -237,6 +237,7 @@ class DefaultConversionValidation(conversion_validation.ConversionValidation):
|
|||
# Override as required...
|
||||
def is_cppfunction_returning_container(self, cppfunc_object):
|
||||
cppname = arg_utils.extract_name(cppfunc_object)
|
||||
|
||||
if cppname:
|
||||
cppfuncsig = self._conversion_data.cppfuncsig_for_cppfuncname(cppname)
|
||||
if cppfuncsig and self._conversion_data.is_container_type(cppfuncsig.return_type.type):
|
||||
|
|
|
@ -15,6 +15,7 @@ grib_accessor_base_data_members_map = {
|
|||
DataMember("const char*","set") : DataMember("std::string","set_"),
|
||||
# This is a conversion helper!
|
||||
DataMember("grib_loader*","loader") : DataMember("AccessorLoaderPtr","loader()"),
|
||||
DataMember("grib_action*","creator") : DataMember("GribActionPtr","creator()"),
|
||||
}
|
||||
|
||||
def add_data_member_mappings_to_conversion_data(conversion_data):
|
||||
|
|
|
@ -29,6 +29,7 @@ common_grib_funcbody_type_mappings = {
|
|||
"grib_context*" : NONE_VALUE,
|
||||
"grib_expression*" : "GribExpressionPtr",
|
||||
"grib_codetable*" : "GribCodeTablePtr",
|
||||
"grib_action*" : "GribActionPtr"
|
||||
}
|
||||
|
||||
grib_array_funcbody_type_mappings = {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "GribCpp/GribType.h"
|
||||
#include "GribCpp/GribStatus.h"
|
||||
#include "GribStub/GribVirtualValueStub.h"
|
||||
|
||||
#include "GribStub/GribActionStub.h"
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
@ -77,6 +77,7 @@ public:
|
|||
|
||||
// Conversion helpers...
|
||||
AccessorLoaderPtr loader() const { return nullptr; }
|
||||
GribActionPtr creator() 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...
|
||||
|
|
Loading…
Reference in New Issue