EgtInterface 1.6e2 :
- esecutore e lua scorporato in EgtExecutor.
This commit is contained in:
+18
-57
@@ -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) ;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user