From c22e9d2925ae7efc2aef3c22c965050f5dc6babe Mon Sep 17 00:00:00 2001 From: q-posev Date: Mon, 20 Sep 2021 17:00:05 +0200 Subject: [PATCH] put back sanity check that dimensioning variables are positive --- src/templates_front/templator_front.org | 3 ++- tools/generator_tools.py | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/templates_front/templator_front.org b/src/templates_front/templator_front.org index cedb399..4b55613 100644 --- a/src/templates_front/templator_front.org +++ b/src/templates_front/templator_front.org @@ -1181,6 +1181,7 @@ trexio_exit_code trexio_write_$group_num$_64 (trexio_t* const file, const $group_num_dtype_double$ num) { if (file == NULL) return TREXIO_INVALID_ARG_1; + //if (num < 0L) return TREXIO_INVALID_ARG_2; /* this line is uncommented by the generator for dimensioning variables; do NOT remove! */ if (trexio_has_$group_num$(file) == TREXIO_SUCCESS) return TREXIO_ATTR_ALREADY_EXISTS; switch (file->back_end) { @@ -1244,7 +1245,7 @@ trexio_write_$group_num$_32 (trexio_t* const file, const $group_num_dtype_single { if (file == NULL) return TREXIO_INVALID_ARG_1; - //if (num < 0 ) return TREXIO_INVALID_ARG_2; + //if (num < 0) return TREXIO_INVALID_ARG_2; /* this line is uncommented by the generator for dimensioning variables; do NOT remove! */ if (trexio_has_$group_num$(file) == TREXIO_SUCCESS) return TREXIO_ATTR_ALREADY_EXISTS; switch (file->back_end) { diff --git a/tools/generator_tools.py b/tools/generator_tools.py index f4fbd92..8394adf 100644 --- a/tools/generator_tools.py +++ b/tools/generator_tools.py @@ -129,6 +129,12 @@ def recursive_populate_file(fname: str, paths: dict, detailed_source: dict) -> N f_out.write(templine) num_written = [] continue + # special case to uncomment check for positive dimensioning variables in templates + elif 'uncommented by the generator for dimensioning' in line: + # only uncomment and write the line if `num` is in the name + if 'num' in item: + templine = line.replace('//', '') + f_out.write(templine) # general case of recursive replacement of inline triggers else: populated_line = recursive_replace_line(line, triggers, detailed_source[item])