From 1647e76fcf6347c7900733bcf7d4ebe3b83f73d6 Mon Sep 17 00:00:00 2001 From: q-posev Date: Mon, 31 May 2021 16:39:21 +0200 Subject: [PATCH] [WIP] adapt generator for string datasets --- tools/generator.py | 26 ++++++++++++++++---------- tools/generator_tools.py | 10 +++++++--- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/tools/generator.py b/tools/generator.py index 3666cd2..b2092d8 100644 --- a/tools/generator.py +++ b/tools/generator.py @@ -18,12 +18,14 @@ print('Strings I/O currently not supported') # -------------------- GET ATTRIBUTES FROM THE CONFIGURATION ---------------- # group_dict = get_group_dict(trex_config) -detailed_num = get_detailed_num_dict(trex_config) -# helper dictionaries contain group, num or dset names as keys -datasets = get_dset_dict(trex_config) -detailed_dset_nostr, detailed_dset_str = split_dset_dict_detailed(datasets) +detailed_nums = get_detailed_num_dict(trex_config) +# helper dictionaries that contain names of groups, nums or dsets as keys +dsets = get_dset_dict(trex_config) +detailed_dsets_nostr, detailed_dsets_str = split_dset_dict_detailed(dsets) +detailed_dsets = detailed_dsets_nostr.copy() +detailed_dsets.update(detailed_dsets_str) # consistency check for dimensioning variables -check_dim_consistency(detailed_num, datasets) +check_dim_consistency(detailed_nums, dsets) # --------------------------------------------------------------------------- # # -------------------- GET TEMPLATED FILES TO BE POPULATED ------------------ # @@ -40,18 +42,22 @@ files_todo = get_files_todo(source_files) # populate files with iterative scheme, i.e. for unique functions for fname in files_todo['auxiliary']: - iterative_populate_file(fname, template_paths, group_dict, detailed_dset_nostr, detailed_num) + iterative_populate_file(fname, template_paths, group_dict, detailed_dsets, detailed_nums) # populate has/read/write_num functions with recursive scheme for fname in files_todo['num']: - recursive_populate_file(fname, template_paths, detailed_num) + recursive_populate_file(fname, template_paths, detailed_nums) -# populate has/read/write_dset functions with recursive scheme +# populate has/read/write_dset (numerical) functions with recursive scheme for fname in files_todo['dset_data']: - recursive_populate_file(fname, template_paths, detailed_dset_nostr) + recursive_populate_file(fname, template_paths, detailed_dsets_nostr) + +# populate has/read/write_dset (strings) functions with recursive scheme +for fname in files_todo['dset_str']: + recursive_populate_file(fname, template_paths, detailed_dsets_str) # populate group-related functions with mixed (iterative+recursive) scheme [text backend] for fname in files_todo['group']: - special_populate_text_group(fname, template_paths, group_dict, detailed_dset_nostr, detailed_num) + special_populate_text_group(fname, template_paths, group_dict, detailed_dsets_nostr, detailed_nums) # --------------------------------------------------------------------------- # diff --git a/tools/generator_tools.py b/tools/generator_tools.py index 84c0840..e9b0594 100644 --- a/tools/generator_tools.py +++ b/tools/generator_tools.py @@ -485,8 +485,12 @@ def split_dset_dict_detailed (datasets: dict) -> tuple: group_dset_std_dtype_out = '" PRId64 "' group_dset_std_dtype_in = '" SCNd64 "' elif v[0] == 'str': - # TODO - datatype = 'string' + datatype = 'char*' + group_dset_h5_dtype = 'c_s1' + group_dset_f_dtype_default = 'character(len=*)' + group_dset_dtype_default = 'char*' + group_dset_std_dtype_out = 's' + group_dset_std_dtype_in = 's' # add the dset name for templates tmp_dict['group_dset'] = k @@ -527,7 +531,7 @@ def split_dset_dict_detailed (datasets: dict) -> tuple: tmp_dict['group'] = v[2] # split datasets in numeric- and string- based - if (datatype == 'string'): + if (datatype == 'char*'): dset_string_dict[k] = tmp_dict else: dset_numeric_dict[k] = tmp_dict