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 | 2ba18a2 | 2015-01-23 14:07:08 +0100 | [diff] [blame] | 6 | #define CLASS_CORE "Core" |
| 7 | |
Thierry FOURNIER | 380d093 | 2015-01-23 14:27:52 +0100 | [diff] [blame] | 8 | enum hlua_state { |
| 9 | HLUA_STOP = 0, |
| 10 | HLUA_RUN, |
| 11 | }; |
| 12 | |
| 13 | enum 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 | |
| 22 | struct 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 FOURNIER | 9ff7e6e | 2015-01-23 11:08:20 +0100 | [diff] [blame] | 32 | 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] | 33 | struct ebpt_node node; |
| 34 | }; |
| 35 | |
Thierry FOURNIER | 9ff7e6e | 2015-01-23 11:08:20 +0100 | [diff] [blame] | 36 | struct 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 FOURNIER | a4a0f3d | 2015-01-23 12:08:30 +0100 | [diff] [blame] | 44 | /* This is a part of the list containing references to functions |
| 45 | * called at the initialisation time. |
| 46 | */ |
| 47 | struct hlua_init_function { |
| 48 | struct list l; |
| 49 | int function_ref; |
| 50 | }; |
| 51 | |
Thierry FOURNIER | 6f1fd48 | 2015-01-23 14:06:13 +0100 | [diff] [blame] | 52 | #endif /* _TYPES_HLUA_H */ |