Thierry FOURNIER | 6f1fd48 | 2015-01-23 14:06:13 +0100 | [diff] [blame] | 1 | #ifndef _TYPES_HLUA_H |
| 2 | #define _TYPES_HLUA_H |
| 3 | |
| 4 | #include <lua.h> |
| 5 | |
Thierry FOURNIER | 380d093 | 2015-01-23 14:27:52 +0100 | [diff] [blame] | 6 | enum hlua_state { |
| 7 | HLUA_STOP = 0, |
| 8 | HLUA_RUN, |
| 9 | }; |
| 10 | |
| 11 | enum hlua_exec { |
| 12 | HLUA_E_OK = 0, |
| 13 | HLUA_E_AGAIN, /* LUA yield, must resume the stack execution later, when |
| 14 | the associatedtask is waked. */ |
| 15 | HLUA_E_ERRMSG, /* LUA stack execution failed with a string error message |
| 16 | in the top of stack. */ |
| 17 | HLUA_E_ERR, /* LUA stack execution failed without error message. */ |
| 18 | }; |
| 19 | |
| 20 | struct hlua { |
| 21 | lua_State *T; /* The LUA stack. */ |
| 22 | int Tref; /* The reference of the stack in coroutine case. |
| 23 | -1 for the main lua stack. */ |
| 24 | int Mref; /* The reference of the memory context in coroutine case. |
| 25 | -1 if the memory context is not used. */ |
| 26 | int nargs; /* The number of arguments in the stack at the start of execution. */ |
| 27 | enum hlua_state state; /* The current execution state. */ |
| 28 | struct task *task; /* The task associated with the lua stack execution. |
| 29 | We must wake this task to continue the task execution */ |
Thierry FOURNIER | 9ff7e6e | 2015-01-23 11:08:20 +0100 | [diff] [blame^] | 30 | struct list com; /* The list head of the signals attached to this task. */ |
Thierry FOURNIER | 380d093 | 2015-01-23 14:27:52 +0100 | [diff] [blame] | 31 | struct ebpt_node node; |
| 32 | }; |
| 33 | |
Thierry FOURNIER | 9ff7e6e | 2015-01-23 11:08:20 +0100 | [diff] [blame^] | 34 | struct hlua_com { |
| 35 | struct list purge_me; /* Part of the list of signals to be purged in the |
| 36 | case of the LUA execution stack crash. */ |
| 37 | struct list wake_me; /* Part of list of signals to be targeted if an |
| 38 | event occurs. */ |
| 39 | struct task *task; /* The task to be wake if an event occurs. */ |
| 40 | }; |
| 41 | |
Thierry FOURNIER | 6f1fd48 | 2015-01-23 14:06:13 +0100 | [diff] [blame] | 42 | #endif /* _TYPES_HLUA_H */ |