From e6cbee74bf04dc4ceee610139b51dcb76bc92329 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 14 Sep 2015 00:16:49 +0200 Subject: [PATCH] Tools: Fix param code generation to generate correct union access based on type. Generate #error C-code for unknown types to prevent silent failure. --- Tools/px_generate_params.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Tools/px_generate_params.py b/Tools/px_generate_params.py index 2642206f3c..0efe778683 100755 --- a/Tools/px_generate_params.py +++ b/Tools/px_generate_params.py @@ -71,14 +71,19 @@ for group in root: if not start_name: start_name = param.attrib["name"] end_name = param.attrib["name"] + val_str = "#error UNKNOWN PARAM TYPE, FIX px_generate_params.py" + if (param.attrib["type"] == "FLOAT"): + val_str = ".val.f = " + elif (param.attrib["type"] == "INT32"): + val_str = ".val.i = " i+=1 src += """ { "%s", PARAM_TYPE_%s, - .val.f = %s + %s%s }, -""" % (param.attrib["name"], param.attrib["type"], param.attrib["default"]) +""" % (param.attrib["name"], param.attrib["type"], val_str, param.attrib["default"]) src += """ %d };