mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2025-09-09 18:26:28 +02:00
added quit + CLI
This commit is contained in:
parent
50dddccf27
commit
2a3aa0af59
6 changed files with 169 additions and 1 deletions
|
@ -18,6 +18,7 @@
|
|||
#define LUA_LIB
|
||||
#include "LuaEngine.h"
|
||||
#include "LuaEngineRegistry.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QTextStream>
|
||||
#include <QMetaMethod>
|
||||
|
||||
|
@ -30,11 +31,13 @@ LuaEngine::LuaEngine(QObject *parent, bool loadBaseLibraries) : QObject(parent)
|
|||
|
||||
pushVariant("DeleteInstant", 0);
|
||||
pushVariant("DeleteLater", 1);
|
||||
pushVariant("CLIExecuted", "CLIExecuted");
|
||||
pushFunction("delete", luaObjectDelete_p);
|
||||
pushFunction("connect", luaTriggerConnect_p);
|
||||
pushFunction("disconnect", luaTriggerDisconnect_p);
|
||||
pushFunction("getObjectParent", luaObjectGetParent_p);
|
||||
pushFunction("setObjectParent", luaObjectSetParent_p);
|
||||
pushFunction("luaEngineQuit", luaEngineQuit_p);
|
||||
pushFunction("luaEngineVersion", luaEngineVersion_p);
|
||||
pushFunction("luaEnginePlatform", luaEnginePlatform_p);
|
||||
}
|
||||
|
@ -62,6 +65,21 @@ int LuaEngine::luaEngineWriter_p(lua_State *L_p, const void *buffer, size_t size
|
|||
return 0;
|
||||
}
|
||||
|
||||
int LuaEngine::luaEngineQuit_p(lua_State *L_p)
|
||||
{
|
||||
int argumentCount = getArgumentCount(L_p);
|
||||
if (argumentCount == 1) {
|
||||
bool ok;
|
||||
int retcode = getVariant(L_p, 1).toInt(&ok);
|
||||
if (ok) {
|
||||
QCoreApplication::exit(retcode);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
QCoreApplication::quit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LuaEngine::luaEngineVersion_p(lua_State *L_p)
|
||||
{
|
||||
pushVariant(L_p, "0.1");
|
||||
|
|
|
@ -76,6 +76,7 @@ public:
|
|||
private:
|
||||
lua_State *L;
|
||||
static int luaEngineWriter_p(lua_State *L_p, const void *buffer, size_t size, void *array);
|
||||
static int luaEngineQuit_p(lua_State *L_p);
|
||||
static int luaEngineVersion_p(lua_State *L_p);
|
||||
static int luaEnginePlatform_p(lua_State *L_p);
|
||||
static int luaObjectDelete_p(lua_State *L_p);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue