ScummVM API documentation
te_lua_thread.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef TETRAEDGE_TE_TE_LUA_THREAD_H
23 #define TETRAEDGE_TE_TE_LUA_THREAD_H
24 
25 #include "common/array.h"
26 #include "common/str.h"
27 #include "common/fs.h"
28 
29 struct lua_State;
30 
31 namespace Tetraedge {
32 
33 class TeLuaContext;
34 class TeVariant;
35 
36 class TeLuaThread {
37 public:
38  TeLuaThread(TeLuaContext *context);
39 
40  ~TeLuaThread();
41 
42  static TeLuaThread *create(TeLuaContext *context);
43 
44  void execute(const Common::String &str);
45  void execute(const Common::String &str, const TeVariant &p1);
46  void execute(const Common::String &str, const TeVariant &p1, const TeVariant &p2);
47  void execute(const Common::String &str, const TeVariant &p1, const TeVariant &p2, const TeVariant &p3);
48 
49  void executeFile(const Common::Path &node);
50  void pushValue(const TeVariant &val);
51 
52  void release();
53 
54  void resume();
55  void resume(const TeVariant &p1);
56  void resume(const TeVariant &p1, const TeVariant &p2);
57  void resume(const TeVariant &p1, const TeVariant &p2, const TeVariant &p3);
58 
59  static TeLuaThread *threadFromState(lua_State *state);
60  int yield();
61 
62  static void cleanup();
63 
64 private:
65  void _resume(int nargs);
66 
67  void applyScriptWorkarounds(char *buf, const Common::String &fileName);
68 
69  lua_State *_luaThread;
70  uint64 _resumeCount;
71  int _bottomRef;
72  int _lastResumeResult;
73  bool _released;
74 
75  static Common::Array<TeLuaThread *> *threadList();
76  static Common::Array<TeLuaThread *> *_threadList;
77 
78 };
79 
80 } // end namespace Tetraedge
81 
82 #endif // TETRAEDGE_TE_TE_LUA_THREAD_H
Definition: str.h:59
Definition: detection.h:27
Definition: array.h:52
Definition: path.h:52
Definition: lstate.h:100
Definition: te_variant.h:30
Definition: te_lua_context.h:42
Definition: te_lua_thread.h:36