mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2025-09-06 08:52:05 +02:00
improvements
This commit is contained in:
parent
0ba59e0b79
commit
52507c9996
5 changed files with 78 additions and 55 deletions
|
@ -19,6 +19,7 @@
|
|||
#include "LuaEngine.h"
|
||||
#include <QTextStream>
|
||||
#include <QMetaMethod>
|
||||
#include <QtGlobal>
|
||||
|
||||
LuaEngine::LuaEngine(QObject *parent, bool loadBaseLibraries) : QObject(parent)
|
||||
{
|
||||
|
@ -32,6 +33,7 @@ LuaEngine::LuaEngine(QObject *parent, bool loadBaseLibraries) : QObject(parent)
|
|||
pushFunction("connect", luaTriggerConnect_p);
|
||||
pushFunction("disconnect", luaTriggerDisconnect_p);
|
||||
pushFunction("luaEngineVersion", luaEngineVersion_p);
|
||||
pushFunction("luaEnginePlatform", luaEnginePlatform_p);
|
||||
}
|
||||
|
||||
LuaEngine::~LuaEngine()
|
||||
|
@ -55,6 +57,30 @@ int LuaEngine::luaEngineVersion_p(lua_State *L_p)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int LuaEngine::luaEnginePlatform_p(lua_State *L_p)
|
||||
{
|
||||
#ifdef Q_OS_ANDROID
|
||||
pushVariant(L_p, "Android");
|
||||
#elif defined(Q_OS_LINUX)
|
||||
pushVariant(L_p, "Linux");
|
||||
#elif defined(Q_OS_FREEBSD)
|
||||
pushVariant(L_p, "FreeBSD");
|
||||
#elif defined(Q_OS_OPENBSD)
|
||||
pushVariant(L_p, "OpenBSD");
|
||||
#elif defined(Q_OS_MACOS)
|
||||
pushVariant(L_p, "macOS");
|
||||
#elif defined(Q_OS_DARWIN)
|
||||
pushVariant(L_p, "Darwin");
|
||||
#elif defined(Q_OS_UNIX)
|
||||
pushVariant(L_p, "Unix");
|
||||
#elif defined(Q_OS_WIN)
|
||||
pushVariant(L_p, "Windows");
|
||||
#else
|
||||
pushVariant(L_p, "Unknown");
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool LuaEngine::executeLuaScript(const QByteArray &data)
|
||||
{
|
||||
int returnCode = luaL_dostring(L, data.data());
|
||||
|
|
|
@ -75,6 +75,7 @@ public:
|
|||
private:
|
||||
lua_State *L;
|
||||
static int luaEngineVersion_p(lua_State *L_p);
|
||||
static int luaEnginePlatform_p(lua_State *L_p);
|
||||
static int luaDeletePointer_p(lua_State *L_p);
|
||||
static int luaTriggerConnect_p(lua_State *L_p);
|
||||
static int luaTriggerDisconnect_p(lua_State *L_p);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue