-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathLuaEngine.h
More file actions
38 lines (28 loc) · 895 Bytes
/
LuaEngine.h
File metadata and controls
38 lines (28 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef LUAENGINE_H
#define LUAENGINE_H
#include <QThread>
#include <string>
#include <atomic>
#include <lua.hpp>
#include "LuaBindings.h"
class LuaEngine : public QThread {
Q_OBJECT
public:
explicit LuaEngine(const std::string &script, QObject* parent)
: QThread(parent), m_script(script), m_shouldStop(false) {}
void requestStop();
std::string getReturnedString() const { return m_returnedString; }
static std::string preprocess(const std::string& script);
protected:
void run() override;
private:
void executeLuaScript(const std::string &scriptText);
void initLua();
void closeLua();
static void luaHookCallback(lua_State* L, lua_Debug* ar);
lua_State* L = nullptr;
std::string m_script;
std::atomic<bool> m_shouldStop;
std::string m_returnedString; // Store any string returned by the script
};
#endif //LUAENGINE_H