blob: d05f59c5eb5b167048cad7204cf98b120b46b062 [file] [log] [blame]
Thierry FOURNIER6f1fd482015-01-23 14:06:13 +01001#ifndef _TYPES_HLUA_H
2#define _TYPES_HLUA_H
3
4#include <lua.h>
5
Thierry FOURNIER2ba18a22015-01-23 14:07:08 +01006#define CLASS_CORE "Core"
7
Thierry FOURNIER380d0932015-01-23 14:27:52 +01008enum hlua_state {
9 HLUA_STOP = 0,
10 HLUA_RUN,
11};
12
13enum hlua_exec {
14 HLUA_E_OK = 0,
15 HLUA_E_AGAIN, /* LUA yield, must resume the stack execution later, when
16 the associatedtask is waked. */
17 HLUA_E_ERRMSG, /* LUA stack execution failed with a string error message
18 in the top of stack. */
19 HLUA_E_ERR, /* LUA stack execution failed without error message. */
20};
21
22struct hlua {
23 lua_State *T; /* The LUA stack. */
24 int Tref; /* The reference of the stack in coroutine case.
25 -1 for the main lua stack. */
26 int Mref; /* The reference of the memory context in coroutine case.
27 -1 if the memory context is not used. */
28 int nargs; /* The number of arguments in the stack at the start of execution. */
29 enum hlua_state state; /* The current execution state. */
30 struct task *task; /* The task associated with the lua stack execution.
31 We must wake this task to continue the task execution */
Thierry FOURNIER9ff7e6e2015-01-23 11:08:20 +010032 struct list com; /* The list head of the signals attached to this task. */
Thierry FOURNIER380d0932015-01-23 14:27:52 +010033 struct ebpt_node node;
34};
35
Thierry FOURNIER9ff7e6e2015-01-23 11:08:20 +010036struct hlua_com {
37 struct list purge_me; /* Part of the list of signals to be purged in the
38 case of the LUA execution stack crash. */
39 struct list wake_me; /* Part of list of signals to be targeted if an
40 event occurs. */
41 struct task *task; /* The task to be wake if an event occurs. */
42};
43
Thierry FOURNIERa4a0f3d2015-01-23 12:08:30 +010044/* This is a part of the list containing references to functions
45 * called at the initialisation time.
46 */
47struct hlua_init_function {
48 struct list l;
49 int function_ref;
50};
51
Thierry FOURNIER6f1fd482015-01-23 14:06:13 +010052#endif /* _TYPES_HLUA_H */