Files
EgtInterface/API_Lua.cpp
T
DarioS fefea90082 EgtInterface :
- a EgtLuaExecFile aggiunto parametro bLogInfo.
2023-02-27 17:24:00 +01:00

228 lines
7.2 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 "/EgtDev/Include/EInAPI.h"
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EgtStringConverter.h"
using namespace std ;
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaCreateGlobTable( const wchar_t* wsVar)
{
return ( ExeLuaCreateGlobTable( wstrztoA( wsVar)) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaSetGlobBoolVar( const wchar_t* wsVar, BOOL bVal)
{
return ( ExeLuaSetGlobBoolVar( wstrztoA( wsVar), ( bVal != FALSE)) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaSetGlobIntVar( const wchar_t* wsVar, int nVal)
{
return ( ExeLuaSetGlobIntVar( wstrztoA( wsVar), nVal) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaSetGlobNumVar( const wchar_t* wsVar, double dVal)
{
return ( ExeLuaSetGlobNumVar( wstrztoA( wsVar), dVal) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaSetGlobStringVar( const wchar_t* wsVar, const wchar_t* wsVal)
{
return ( ExeLuaSetGlobStringVar( wstrztoA( wsVar), wstrztoA( wsVal)) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaSetGlobVectorVar( const wchar_t* wsVar, const double vtVal[3])
{
if ( vtVal == nullptr)
return FALSE ;
return ( ExeLuaSetGlobVectorVar( wstrztoA( wsVar), vtVal) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaSetGlobPointVar( const wchar_t* wsVar, const double ptVal[3])
{
if ( ptVal == nullptr)
return FALSE ;
return ( ExeLuaSetGlobPointVar( wstrztoA( wsVar), ptVal) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaGetGlobBoolVar( const wchar_t* wsVar, BOOL* pbVal)
{
bool bVal ;
if ( ! ExeLuaGetGlobBoolVar( wstrztoA( wsVar), &bVal))
return FALSE ;
if ( pbVal != nullptr)
*pbVal = ( bVal ? TRUE : FALSE) ;
return TRUE ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaGetGlobIntVar( const wchar_t* wsVar, int* pnVal)
{
return ( ExeLuaGetGlobIntVar( wstrztoA( wsVar), pnVal) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaGetGlobNumVar( const wchar_t* wsVar, double* pdVal)
{
return ( ExeLuaGetGlobNumVar( wstrztoA( wsVar), pdVal) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaGetGlobStringVar( const wchar_t* wsVar, wchar_t*& wsVal)
{
// verifico parametro di ritorno
if ( &wsVal == nullptr)
return FALSE ;
// recupero il valore della variabile
string sVal ;
if ( ! ExeLuaGetGlobStringVar( wstrztoA( wsVar), sVal))
return FALSE ;
// alloco buffer di ritorno ed eseguo copia
wsVal = _wcsdup( stringtoW( sVal)) ;
return (( wsVal == nullptr) ? FALSE : TRUE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaGetGlobVectorVar( const wchar_t* wsVar, double vtVal[3])
{
// verifico parametro di ritorno
if ( vtVal == nullptr)
return FALSE ;
// recupero il valore della variabile
Vector3d vtTmp ;
if ( ! ExeLuaGetGlobVectorVar( wstrztoA( wsVar), vtTmp))
return FALSE ;
VEC_FROM_3D( vtVal, vtTmp)
return TRUE ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaGetGlobPointVar( const wchar_t* wsVar, double ptVal[3])
{
// verifico parametro di ritorno
if ( ptVal == nullptr)
return FALSE ;
// recupero il valore della variabile
Point3d ptTmp ;
if ( ! ExeLuaGetGlobPointVar( wstrztoA( wsVar), ptTmp))
return FALSE ;
VEC_FROM_3D( ptVal, ptTmp)
return TRUE ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaResetGlobVar( const wchar_t* wsVar)
{
return ( ExeLuaResetGlobVar( wstrztoA( wsVar)) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaExistsFunction( const wchar_t* wsFun)
{
return ( ExeLuaExistsFunction( wstrztoA( wsFun)) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaCallFunction( const wchar_t* wsFun)
{
return ( ExeLuaCallFunction( wstrztoA( wsFun)) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaEvalNumExpr( const wchar_t* wsExpr, double* pdVal)
{
return ( ExeLuaEvalNumExpr( 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 ( ! ExeLuaEvalStringExpr( wstrztoA( wsExpr), sVal))
return FALSE ;
// alloco buffer di ritorno ed eseguo copia
wsVal = _wcsdup( stringtoW( sVal)) ;
return (( wsVal == nullptr) ? FALSE : TRUE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaExecLine( const wchar_t* wsLine)
{
return ( ExeLuaExecLine( wstrztoA( wsLine)) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaExecFile( const wchar_t* wsFilePath, BOOL bLogInfo)
{
return ( ExeLuaExecFile( wstrztoA( wsFilePath), bLogInfo != FALSE) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaRequire( const wchar_t* wsFilePath)
{
return ( ExeLuaRequire( wstrztoA( wsFilePath)) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtLuaGetLastError( wchar_t*& wsError)
{
// 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) ;
}