From 1c789c66c318985cd05b551086f7819faceaf95d Mon Sep 17 00:00:00 2001 From: Michael du Breuil Date: Tue, 28 Jul 2020 14:40:15 -0700 Subject: [PATCH] AP_Scripting: Fix generator for nullable types with multiple return values --- libraries/AP_Scripting/generator/src/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libraries/AP_Scripting/generator/src/main.c b/libraries/AP_Scripting/generator/src/main.c index ae94e7e3d7..6a709fd455 100644 --- a/libraries/AP_Scripting/generator/src/main.c +++ b/libraries/AP_Scripting/generator/src/main.c @@ -1556,8 +1556,9 @@ void emit_userdata_method(const struct userdata *data, const struct method *meth arg_index++; arg = arg->next; } + fprintf(source, " return %d;\n", return_count); fprintf(source, " } else {\n"); - fprintf(source, " lua_pushnil(L);\n"); + fprintf(source, " return 0;\n"); fprintf(source, " }\n"); } else { fprintf(source, " lua_pushboolean(L, data);\n"); @@ -1601,7 +1602,9 @@ void emit_userdata_method(const struct userdata *data, const struct method *meth break; } - fprintf(source, " return %d;\n", return_count); + if ((method->return_type.type != TYPE_BOOLEAN) || ((method->flags & TYPE_FLAGS_NULLABLE) == 0)) { + fprintf(source, " return %d;\n", return_count); + } fprintf(source, "}\n\n"); }