From ed2ad3c6e325ea1d072b6b11cf0470cbe1cb6be1 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 4 Oct 2016 07:32:07 +0000 Subject: [PATCH] EgtExecutor : - aggiunta funzione Lua EgtEvalNumExpr. --- LUA_General.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/LUA_General.cpp b/LUA_General.cpp index 3ff741a..b870314 100644 --- a/LUA_General.cpp +++ b/LUA_General.cpp @@ -57,7 +57,26 @@ MyPrint( lua_State* L) //------------------------------------------------------------------------------- static int -SetContext( lua_State* L) +LuaEvalNumExpr( lua_State* L) +{ + // un solo parametro stringa : sExpr + string sExpr ; + LuaCheckParam( L, 1, sExpr) + LuaClearStack( L) ; + // valuto l'espressione + double dVal ; + bool bOk = ExeLuaEvalNumExpr( sExpr, &dVal) ; + // restituisco il risultato + if ( bOk) + LuaSetParam( L, dVal) ; + else + LuaSetParam( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaSetContext( lua_State* L) { // un solo parametro intero int nGseCtx ; @@ -72,7 +91,7 @@ SetContext( lua_State* L) //------------------------------------------------------------------------------- static int -GetContext( lua_State* L) +LuaGetContext( lua_State* L) { // nessun parametro LuaClearStack( L) ; @@ -422,8 +441,9 @@ LuaInstallGeneral( LuaMgr& luaMgr) { bool bOk = ( &luaMgr != nullptr) ; bOk = bOk && luaMgr.RegisterFunction( "print", MyPrint) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtSetContext", SetContext) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtGetContext", GetContext) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtEvalNumExpr", LuaEvalNumExpr) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSetContext", LuaSetContext) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtGetContext", LuaGetContext) ; bOk = bOk && luaMgr.RegisterFunction( "EgtPause", LuaPause) ; bOk = bOk && luaMgr.RegisterFunction( "EgtStartCounter", LuaStartCounter) ; bOk = bOk && luaMgr.RegisterFunction( "EgtStopCounter", LuaStopCounter) ;