50b2d271ac
- aggiunto interprete Lua - portate in interfaccia API molte funzioni di base.
120 lines
3.4 KiB
C++
120 lines
3.4 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2014-2014
|
|
//----------------------------------------------------------------------------
|
|
// File : LUA_Exchange.cpp Data : 29.09.14 Versione : 1.5i5
|
|
// Contenuto : Funzioni generali per LUA.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 29.09.14 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "LUA.h"
|
|
#include "API.h"
|
|
#include "/EgtDev/Include/EInAPI.h"
|
|
#include "/EgtDev/Include/EgnStringUtils.h"
|
|
#include "/EgtDev/Extern/Lua/Include/lua.hpp"
|
|
|
|
using namespace std ;
|
|
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaImportDxf( lua_State* L)
|
|
{
|
|
// 1 parametro : path del file da importare
|
|
string sFilePath ;
|
|
LuaCheckParam( L, 1, sFilePath)
|
|
LuaClearStack( L) ;
|
|
// apro il file
|
|
bool bOk = ( EgtImportDxf( LuaGetGseContext(), sFilePath) != FALSE) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaImportStl( lua_State* L)
|
|
{
|
|
// 1 parametro : path del file da importare
|
|
string sFilePath ;
|
|
LuaCheckParam( L, 1, sFilePath)
|
|
LuaClearStack( L) ;
|
|
// apro il file
|
|
bool bOk = ( EgtImportStl( LuaGetGseContext(), sFilePath) != FALSE) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaImportCnc( lua_State* L)
|
|
{
|
|
// 1 parametro : path del file da importare
|
|
string sFilePath ;
|
|
LuaCheckParam( L, 1, sFilePath)
|
|
LuaClearStack( L) ;
|
|
// apro il file
|
|
bool bOk = ( EgtImportCnc( LuaGetGseContext(), sFilePath) != FALSE) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaExportDxf( lua_State* L)
|
|
{
|
|
// 2 parametri, GroupId e path del file da esportare
|
|
int nGroupId ;
|
|
LuaCheckParam( L, 1, nGroupId)
|
|
string sFilePath ;
|
|
LuaCheckParam( L, 2, sFilePath)
|
|
LuaClearStack( L) ;
|
|
// apro il file
|
|
bool bOk = ( EgtExportDxf( LuaGetGseContext(), nGroupId, sFilePath) != FALSE) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaExportStl( lua_State* L)
|
|
{
|
|
// 2 parametri, GroupId e path del file da esportare
|
|
int nGroupId ;
|
|
LuaCheckParam( L, 1, nGroupId)
|
|
string sFilePath ;
|
|
LuaCheckParam( L, 2, sFilePath)
|
|
LuaClearStack( L) ;
|
|
// apro il file
|
|
bool bOk = ( EgtExportStl( LuaGetGseContext(), nGroupId, sFilePath) != FALSE) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
bool
|
|
LuaInstallExchange( lua_State* L)
|
|
{
|
|
try {
|
|
lua_register( L, "EgtImportDxf", LuaImportDxf) ;
|
|
lua_register( L, "EgtImportStl", LuaImportStl) ;
|
|
lua_register( L, "EgtImportCnc", LuaImportCnc) ;
|
|
lua_register( L, "EgtExportDxf", LuaExportDxf) ;
|
|
lua_register( L, "EgtExportStl", LuaExportStl) ;
|
|
}
|
|
catch ( ...) {
|
|
return false ;
|
|
}
|
|
return true ;
|
|
}
|