33 #include "../../core/translator/Translator.h" 34 #include "../core/Exception.h" 37 #include <QtLua/State> 38 #include <QtLua/TableTreeModel> 39 #include <QtLua/Console> 44 #include <QTextStream> 50 void stdinHack(lua_State *
L, FILE *in, FILE *out, FILE *err) {
52 lua_getglobal(L,
"io");
53 lua_pushstring(L,
"open");
55 lua_getuservalue(L, -1);
56 lua_getglobal(L,
"io");
58 lua_pushstring(L,
"stdin");
60 pf = (FILE **)lua_touserdata(L, -1);
62 lua_rawseti(L, -3, 1);
64 lua_pushstring(L,
"stdout");
66 pf = (FILE **)lua_touserdata(L, -1);
68 lua_rawseti(L, -3, 2);
70 lua_pushstring(L,
"stderr");
72 pf = (FILE **)lua_touserdata(L, -1);
79 std::unique_ptr<QtLua::State>
state;
106 m_pimpl->state.reset(
new QtLua::State());
107 m_pimpl->state->openlib(QtLua::AllLibs);
109 connect(
m_pimpl->state.get(), SIGNAL(
output(
const QString&)),
this,
110 SLOT(
write(
const QString&)), Qt::UniqueConnection);
111 QFile script(
m_pimpl->m_filename);
112 script.open(QIODevice::ReadOnly);
113 QTextStream in(&script);
114 m_pimpl->state->exec(in.readAll());
120 QThread::currentThread()->usleep(1);
149 TE_TR(
"TerraLib Virtual Machine for the Lua Programming Language"));
157 TE_TR(
"This Virtual Machine allows applications to execute lua scripts." 158 "\nAll the TerraLib API will be available for TerraLib programmers " 159 "in the Lua environment"));
std::unique_ptr< QtLua::State > state
The Lua environment (or state).
void write(const QString &str)
std::string getName() const
#define TE_TR(message)
It marks a string in order to get translated.
std::unique_ptr< Impl > m_pimpl
void setFileName(QString file)
setFileName Sets the file that will be used in the Virtual Machine.
std::string getDescription() const
Returns a brief description about the underlying Virtual Machine.
void stdinHack(lua_State *L, FILE *in, FILE *out, FILE *err)
std::string getTitle() const
Return the title of Virtual Machine: a name that can be used by applications to show in a GUI...
Implementation of a virtual machine for the Lua Programming Language.
void output(QString msg)
output Signal emmited when the Virtual Machine receives a string.
~VirtualMachine()
Virtual destructor.
std::string readline()
readline Method to be used by the language of the Virtual Machine when doing a input operation...
file(WRITE ${CMAKE_BINARY_DIR}/config_qhelp.cmake"configure_file (${TERRALIB_ABSOLUTE_ROOT_DIR}/doc/qhelp/help.qhcp.in ${CMAKE_BINARY_DIR}/share/terraview/help/help.qhcp @ONLY)") add_custom_command(OUTPUT del_dir COMMAND $