4e5a81c493
- modifiche varie per gestire GLOB, LOC e GRID sui dati geometrici - aggiornamenti e miglirie varie - eliminate alcune funzioni lua ormai obsolete (ArcXY e CircleXY).
114 lines
3.6 KiB
C++
114 lines
3.6 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2014-2014
|
|
//----------------------------------------------------------------------------
|
|
// File : API_LUA.cpp Data : 28.09.14 Versione : 1.5i5
|
|
// Contenuto : Funzioni esecuzione LUA per API.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 28.09.14 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "API.h"
|
|
#include "LUA.h"
|
|
#include "/EgtDev/Include/EInAPI.h"
|
|
#include "/EgtDev/Include/EGnStringUtils.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) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtLuaEvalStringExpr( const wchar_t* wsExpr, wchar_t*& wsVal)
|
|
{
|
|
// verifico parametro di ritorno
|
|
if ( &wsVal == nullptr)
|
|
return false ;
|
|
// valuto l'espressione
|
|
string sVal ;
|
|
if ( ! LuaEvalStringExpr( wstrztoA( wsExpr), sVal))
|
|
return FALSE ;
|
|
wsVal = _wcsdup( stringtoW( sVal)) ;
|
|
return (( wsVal == nullptr) ? FALSE : TRUE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtLuaExecLine( const wchar_t* wsLine)
|
|
{
|
|
// disabilito il log dei comandi
|
|
bool bPrevCmdLog = IsCmdLog() ;
|
|
EgtDisableCommandLogger() ;
|
|
// eseguo il comando
|
|
string sLine = wstrztoA( wsLine) ;
|
|
bool bOk = LuaExecLine( sLine) ;
|
|
// ripristino lo stato originale del log dei comandi
|
|
if ( bPrevCmdLog)
|
|
EgtEnableCommandLogger() ;
|
|
// 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) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
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())
|
|
// esecuzione script
|
|
bool bOk = LuaExecFile( sFilePath) ;
|
|
// se richiesto, salvo il comando Lua
|
|
if ( IsCmdLog()) {
|
|
string sLua = "dofile('" + sFilePath + "')" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return ( bOk ? 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) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtLuaGetLastError( wchar_t*& wsError)
|
|
{
|
|
wsError = _wcsdup( stringtoW( LuaGetLastError())) ;
|
|
return (( wsError == nullptr) ? FALSE : TRUE) ;
|
|
} |