mirror of https://github.com/ecmwf/eccodes.git
Added default constructor if no C version exists
This commit is contained in:
parent
963c28a1de
commit
542ed863a2
|
@ -38,6 +38,8 @@ class DefaultCCodeConverter:
|
||||||
# Post-processing
|
# Post-processing
|
||||||
self.run_post_processing()
|
self.run_post_processing()
|
||||||
|
|
||||||
|
self.validate_code_elements()
|
||||||
|
|
||||||
return cppcode.CppCode(self._code_info, self._code_elements)
|
return cppcode.CppCode(self._code_info, self._code_elements)
|
||||||
|
|
||||||
# ============================== Setup functions: start ==============================
|
# ============================== Setup functions: start ==============================
|
||||||
|
@ -160,6 +162,9 @@ class DefaultCCodeConverter:
|
||||||
|
|
||||||
# ============================== Post-processing: end ==============================
|
# ============================== Post-processing: end ==============================
|
||||||
|
|
||||||
|
# Override for any final validation of the new cppcode object
|
||||||
|
def validate_code_elements(self):
|
||||||
|
pass
|
||||||
|
|
||||||
# Helper for consistent debug output!
|
# Helper for consistent debug output!
|
||||||
def dump_function(self, def_name, cppfunc):
|
def dump_function(self, def_name, cppfunc):
|
||||||
|
|
|
@ -22,7 +22,8 @@ import grib_accessor.supporting.data_member_mappings as data_member_mappings
|
||||||
import grib_accessor.grib_accessor_conversion_pack.grib_accessor_type_info as grib_accessor_type_info
|
import grib_accessor.grib_accessor_conversion_pack.grib_accessor_type_info as grib_accessor_type_info
|
||||||
import grib_accessor.grib_accessor_conversion_pack.grib_accessor_container_utils as grib_accessor_container_utils
|
import grib_accessor.grib_accessor_conversion_pack.grib_accessor_container_utils as grib_accessor_container_utils
|
||||||
import code_object_converter.conversion_pack.arg_utils as arg_utils
|
import code_object_converter.conversion_pack.arg_utils as arg_utils
|
||||||
|
import code_object.compound_statement as compound_statement
|
||||||
|
import code_object.constructor_function as constructor_function
|
||||||
|
|
||||||
prefix = "grib_accessor_class_"
|
prefix = "grib_accessor_class_"
|
||||||
rename = {
|
rename = {
|
||||||
|
@ -165,3 +166,18 @@ class GribAccessorCCodeConverter(default_ccode_converter.DefaultCCodeConverter):
|
||||||
|
|
||||||
if mismatch_found:
|
if mismatch_found:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
def validate_code_elements(self):
|
||||||
|
if not self._code_elements.constructor:
|
||||||
|
# We need to create a default constructor to ensure the InitData is passed up the construction hierarchy correctly!
|
||||||
|
cppconstructor_funcsig = self._conversion_pack.conversion_data.cppfuncsig_for_cfuncname("init")
|
||||||
|
assert cppconstructor_funcsig
|
||||||
|
cppconstructor_body = compound_statement.CompoundStatement()
|
||||||
|
cppconstructor = constructor_function.ConstructorFunction(cppconstructor_funcsig,
|
||||||
|
cppconstructor_body,
|
||||||
|
self._conversion_pack.conversion_data.info.class_name,
|
||||||
|
self._conversion_pack.conversion_data.info.super_class_name)
|
||||||
|
debug.line("validate_cppcode", f"No constructor found, adding a default=[{debug.as_debug_string(cppconstructor)}]")
|
||||||
|
self._code_elements.add_constructor(cppconstructor)
|
||||||
|
|
||||||
|
super().validate_code_elements()
|
||||||
|
|
Loading…
Reference in New Issue