EgtInterface 1.6e2 :

- esecutore e lua scorporato in EgtExecutor.
This commit is contained in:
Dario Sassi
2015-05-05 22:14:56 +00:00
parent e7ee6d9255
commit 8bc0e986b2
60 changed files with 454 additions and 16260 deletions
+18 -57
View File
@@ -14,23 +14,17 @@
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "API.h"
#include "LUA_Base.h"
#include "/EgtDev/Include/EInAPI.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EGnStringConverter.h"
using namespace std ;
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaEvalNumExpr( const wchar_t* wsExpr, double* pdVal)
{
// verifico parametro di ritorno
if ( pdVal == nullptr)
return FALSE ;
// valuto l'espressione
return ( LuaEvalNumExpr( wstrztoA( wsExpr), *pdVal) ? TRUE : FALSE) ;
return ( ExeLuaEvalNumExpr( wstrztoA( wsExpr), pdVal) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
@@ -39,11 +33,12 @@ __stdcall EgtLuaEvalStringExpr( const wchar_t* wsExpr, wchar_t*& wsVal)
{
// verifico parametro di ritorno
if ( &wsVal == nullptr)
return false ;
return FALSE ;
// valuto l'espressione
string sVal ;
if ( ! LuaEvalStringExpr( wstrztoA( wsExpr), sVal))
if ( ! ExeLuaEvalStringExpr( wstrztoA( wsExpr), sVal))
return FALSE ;
// alloco buffer di ritorno ed eseguo copia
wsVal = _wcsdup( stringtoW( sVal)) ;
return (( wsVal == nullptr) ? FALSE : TRUE) ;
}
@@ -52,69 +47,35 @@ __stdcall EgtLuaEvalStringExpr( const wchar_t* wsExpr, wchar_t*& wsVal)
BOOL
__stdcall EgtLuaExecLine( const wchar_t* wsLine)
{
// disabilito log dei comandi e salvo stato precedente
bool bPrevCmdLog = SetCmdLog( false) ;
// eseguo il comando
string sLine = wstrztoA( wsLine) ;
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 ? TRUE : FALSE) ;
return ( ExeLuaExecLine( wstrztoA( wsLine)) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaExecFile( const wchar_t* wsFilePath)
{
// converto nome file
string sFilePath = wstrztoA( wsFilePath) ;
// emetto info
string sInfo = "Exec File = " + sFilePath ;
LOG_INFO( GetLogger(), sInfo.c_str())
// disabilito il log dei comandi
bool bPrevCmdLog = IsCmdLog() ;
EgtDisableCommandLogger() ;
// esecuzione script
bool bOk = LuaExecFile( sFilePath) ;
// ripristino lo stato originale del log dei comandi
if ( bPrevCmdLog)
EgtEnableCommandLogger() ;
// 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 ? TRUE : FALSE) ;
return ( ExeLuaExecFile( wstrztoA( wsFilePath)) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaRequire( const wchar_t* wsFilePath)
{
// converto nome file
string sFilePath = wstrztoA( wsFilePath) ;
// emetto info
string sInfo = "Require Library = " + sFilePath ;
LOG_INFO( GetLogger(), sInfo.c_str())
// eseguo il comando
return ( LuaRequire( sFilePath) ? TRUE : FALSE) ;
return ( ExeLuaRequire( wstrztoA( wsFilePath)) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaGetLastError( wchar_t*& wsError)
{
wsError = _wcsdup( stringtoW( LuaGetLastError())) ;
// verifico parametro di ritorno
if ( &wsError == nullptr)
return FALSE ;
// recupero l'errore
string sError ;
if ( ! ExeLuaGetLastError( sError))
return FALSE ;
// alloco buffer di ritorno ed eseguo copia
wsError = _wcsdup( stringtoW( sError)) ;
return (( wsError == nullptr) ? FALSE : TRUE) ;
}
}