From b7518f435f0756ead464a309ef44a2bd0798905d Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Thu, 11 Sep 2014 18:15:34 +0200 Subject: [PATCH] CLuaInstance: Add member paramBoolDeprecated() for info... ...when Boolean parameters are passed as a string or number Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/86186e644357368de6337841f0dc4e6251927352 Author: Michael Liebmann Date: 2014-09-11 (Thu, 11 Sep 2014) ------------------ This commit was generated by Migit --- data/locale/deutsch.locale | 3 +++ data/locale/english.locale | 5 ++++- src/gui/luainstance.cpp | 12 ++++++++++++ src/gui/luainstance.h | 1 + src/system/locals.h | 3 +++ src/system/locals_intern.h | 3 +++ 6 files changed, 26 insertions(+), 1 deletion(-) diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 7f5c63ca2..b40ed77bb 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -824,6 +824,9 @@ ledcontroler.off LED1 & LED2 aus ledcontroler.on.all LED1 & LED2 an ledcontroler.on.led1 LED1 an ledcontroler.on.led2 LED2 an +lua.boolparam_deprecated1 Achtung! +lua.boolparam_deprecated2 Die Verwendung von Zahl oder String +lua.boolparam_deprecated3 für einen Boolean Parameter ist veraltet.\n Bitte nutzen Sie native Bool Werte zB: lua.function_deprecated1 Achtung! lua.function_deprecated2 Die Funktion lua.function_deprecated3 ist veraltet,\n bitte nutzen Sie diff --git a/data/locale/english.locale b/data/locale/english.locale index e18b02135..aa9c2b28f 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -824,7 +824,10 @@ ledcontroler.off Led1 & Led2 off ledcontroler.on.all Led1 & Led2 on ledcontroler.on.led1 Led1 on ledcontroler.on.led2 Led2 on -lua.function_deprecated1 Attention! +lua.boolparam_deprecated1 Caution! +lua.boolparam_deprecated2 The use of number or string +lua.boolparam_deprecated3 for a Boolean parameter is deprecated.\n Please use native bool values eg. +lua.function_deprecated1 Caution! lua.function_deprecated2 Function lua.function_deprecated3 is deprecated,\n please use mainmenu.audioplayer Audioplayer diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index d35119557..e759dea0d 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -368,6 +368,18 @@ bool CLuaInstance::_luaL_checkbool(lua_State *L, int numArg) return b; } +void CLuaInstance::paramBoolDeprecated(lua_State *L, const char* val) +{ + lua_Debug ar; + lua_getstack(L, 1, &ar); + lua_getinfo(L, "Sl", &ar); + printf("[Lua Script] \33[1;31m%s\33[0m %s (\33[31m\"%s\"\33[0m)\n %s \33[32mtrue\33[0m.\n (%s:%d)\n", + g_Locale->getText(LOCALE_LUA_BOOLPARAM_DEPRECATED1), + g_Locale->getText(LOCALE_LUA_BOOLPARAM_DEPRECATED2), val, + g_Locale->getText(LOCALE_LUA_BOOLPARAM_DEPRECATED3), + ar.short_src, ar.currentline); +} + void CLuaInstance::functionDeprecated(lua_State *L, const char* oldFunc, const char* newFunc) { lua_Debug ar; diff --git a/src/gui/luainstance.h b/src/gui/luainstance.h index fd34fcc9c..b7d0365c7 100644 --- a/src/gui/luainstance.h +++ b/src/gui/luainstance.h @@ -187,6 +187,7 @@ private: void registerFunctions(); static bool _luaL_checkbool(lua_State *L, int numArg); + static void paramBoolDeprecated(lua_State *L, const char* val1, bool val2); static void functionDeprecated(lua_State *L, const char* oldFunc, const char* newFunc); static lua_Unsigned checkMagicMask(lua_Unsigned &col); diff --git a/src/system/locals.h b/src/system/locals.h index 606675484..85095c85b 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -851,6 +851,9 @@ typedef enum LOCALE_LEDCONTROLER_ON_ALL, LOCALE_LEDCONTROLER_ON_LED1, LOCALE_LEDCONTROLER_ON_LED2, + LOCALE_LUA_BOOLPARAM_DEPRECATED1, + LOCALE_LUA_BOOLPARAM_DEPRECATED2, + LOCALE_LUA_BOOLPARAM_DEPRECATED3, LOCALE_LUA_FUNCTION_DEPRECATED1, LOCALE_LUA_FUNCTION_DEPRECATED2, LOCALE_LUA_FUNCTION_DEPRECATED3, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index b8b37ce45..e63d93203 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -851,6 +851,9 @@ const char * locale_real_names[] = "ledcontroler.on.all", "ledcontroler.on.led1", "ledcontroler.on.led2", + "lua.boolparam_deprecated1", + "lua.boolparam_deprecated2", + "lua.boolparam_deprecated3", "lua.function_deprecated1", "lua.function_deprecated2", "lua.function_deprecated3",