//---------------------------------------------------------------------------- // EgalTech 2014-2015 //---------------------------------------------------------------------------- // File : EXE_LUA.cpp Data : 05.05.15 Versione : 1.6e1 // Contenuto : Funzioni esecuzione LUA per EXE. // // // // Modifiche : 28.09.14 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "EXE.h" #include "LUA_Base.h" #include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EgtStringConverter.h" using namespace std ; //----------------------------------------------------------------------------- bool ExeLuaEvalNumExpr( const string& sExpr, double* pdVal) { // verifico parametro di ritorno if ( pdVal == nullptr) return false ; // valuto l'espressione return LuaEvalNumExpr( sExpr, *pdVal) ; } //----------------------------------------------------------------------------- bool ExeLuaEvalStringExpr( const string& sExpr, string& sVal) { // verifico parametro di ritorno if ( &sVal == nullptr) return false ; // valuto l'espressione return LuaEvalStringExpr( sExpr, sVal) ; } //----------------------------------------------------------------------------- bool ExeLuaExecLine( const string& sLine) { // disabilito log dei comandi e salvo stato precedente bool bPrevCmdLog = SetCmdLog( false) ; // eseguo il comando bool bOk = LuaExecLine( sLine) ; // ripristino lo stato originale del log dei comandi SetCmdLog( bPrevCmdLog) ; // se richiesto, salvo il comando Lua if ( IsCmdLog()) { string sLua = sLine + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco il risultato return bOk ; } //----------------------------------------------------------------------------- bool ExeLuaExecFile( const string& sFilePath) { // emetto info string sInfo = "Exec File = " + sFilePath ; LOG_INFO( GetLogger(), sInfo.c_str()) // disabilito il log dei comandi bool bPrevCmdLog = IsCmdLog() ; ExeDisableCommandLogger() ; // esecuzione script bool bOk = LuaExecFile( sFilePath) ; // ripristino lo stato originale del log dei comandi if ( bPrevCmdLog) ExeEnableCommandLogger() ; // se richiesto, salvo il comando Lua if ( IsCmdLog()) { string sLuaPath = sFilePath ; ReplaceString( sLuaPath, "\\", "\\\\") ; string sLua = "dofile('" + sLuaPath + "')" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco il risultato return bOk ; } //----------------------------------------------------------------------------- bool ExeLuaRequire( const string& sFilePath) { // emetto info string sInfo = "Require Library = " + sFilePath ; LOG_INFO( GetLogger(), sInfo.c_str()) // eseguo il comando return LuaRequire( sFilePath) ; } //----------------------------------------------------------------------------- bool ExeLuaGetLastError( string& sError) { // verifico parametro di ritorno if ( &sError == nullptr) return false ; sError = LuaGetLastError() ; return true ; }