From 38416e7ad2f572937edcddcb2ceef5809bce2982 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 12 May 2023 13:50:06 +0200 Subject: [PATCH] RNA: use correct ui scale type string in generated rna code Previously, it printed the elements of `PropertyScaleType` as floats which does not make sense. It also resulted in compile errors when attempting to compile the generated code as c++ code. Pull Request: https://projects.blender.org/blender/blender/pulls/107724 --- source/blender/makesrna/intern/makesrna.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 47cfb6f8fbf..9a884dd0838 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -615,6 +615,20 @@ static void rna_float_print(FILE *f, float num) } } +static const char *rna_ui_scale_type_string(const PropertyScaleType type) +{ + switch (type) { + case PROP_SCALE_LINEAR: + return "PROP_SCALE_LINEAR"; + case PROP_SCALE_LOG: + return "PROP_SCALE_LOG"; + case PROP_SCALE_CUBIC: + return "PROP_SCALE_CUBIC"; + } + BLI_assert_unreachable(); + return ""; +} + static void rna_int_print(FILE *f, int64_t num) { if (num == INT_MIN) { @@ -4164,8 +4178,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr rna_function_string(fprop->getarray_ex), rna_function_string(fprop->setarray_ex), rna_function_string(fprop->range_ex)); - rna_float_print(f, fprop->ui_scale_type); - fprintf(f, ", "); + fprintf(f, "%s, ", rna_ui_scale_type_string(fprop->ui_scale_type)); rna_float_print(f, fprop->softmin); fprintf(f, ", "); rna_float_print(f, fprop->softmax);