Added factory registration

This commit is contained in:
kevstone 2024-02-23 13:17:54 +00:00
parent afa0b6f57b
commit eb31cd5cd5
4 changed files with 26 additions and 0 deletions

View File

@ -18,6 +18,9 @@ class CodeInfo:
self._function_calls = [] # List all function calls made whilst converting (for post-processing)
self._non_const_member_function_names = [] # default to const unless told otherwise!
# A place to add any specific data, usually as "identifier", data pairs
self._custom_data = {}
@property
def file_name(self):
return self._file_name
@ -86,3 +89,10 @@ class CodeInfo:
def add_non_const_member_function_name(self, name):
if name not in self._non_const_member_function_names:
self._non_const_member_function_names.append(name)
@property
def custom_data(self):
return self._custom_data
def add_custom_data(self, identifier, data):
self._custom_data[identifier] = data

View File

@ -27,6 +27,10 @@ class CppCode:
def class_name(self):
return self._code_info.class_name
@property
def class_name_camel_case(self):
return self.class_name[0].lower() + self.class_name[1:]
@property
def super_class_name(self):
return self._code_info.super_class_name
@ -51,6 +55,10 @@ class CppCode:
def source_file_includes(self):
return self._code_info.source_includes
@property
def custom_data(self):
return self._code_info.custom_data
# ============================== CodeInfo properties: end ==============================
# ============================== CodeElements properties: start ==============================

View File

@ -76,6 +76,10 @@ class GribAccessorCCodeConverter(default_ccode_converter.DefaultCCodeConverter):
info.add_namespace("eccodes")
info.add_namespace("accessor")
factory_name = self._ccode.class_name.replace(prefix, "")
info.add_custom_data("factory_name", factory_name)
debug.line("create_code_info", f"Set factory_name=[{factory_name}]")
return info
def function_specific_conversion_pack_updates(self, cfunction_name, conv_pack):

View File

@ -22,4 +22,8 @@ namespace {{ c.nested_namespaces }} {
{{ func.as_string() }}
{% endfor %}
namespace {
AccessorBuilder<{{ c.class_name }}> {{ c.class_name_camel_case }}Builder(AccessorType("{{ c.custom_data["factory_name"] }}"));
}
} // namespace {{ c.nested_namespaces }}