123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #pragma once
- #include <AP_Common/AP_Common.h>
- #include <AP_Param/AP_Param.h>
- #include <setjmp.h>
- #include <AP_Filesystem/posix_compat.h>
- #include "lua_bindings.h"
- class lua_scripts
- {
- public:
- lua_scripts(const AP_Int32 &vm_steps, const AP_Int32 &heap_size, const AP_Int8 &debug_level);
-
- lua_scripts(const lua_scripts &other) = delete;
- lua_scripts &operator=(const lua_scripts&) = delete;
-
- void run(void);
- static bool overtime;
- private:
- typedef struct script_info {
- int lua_ref;
- uint64_t next_run_ms;
- char *name;
- script_info *next;
- } script_info;
- script_info *load_script(lua_State *L, char *filename);
- void load_all_scripts_in_dir(lua_State *L, const char *dirname);
- void run_next_script(lua_State *L);
- void remove_script(lua_State *L, script_info *script);
-
- void reschedule_script(script_info *script);
- script_info *scripts;
-
-
- static void hook(lua_State *L, lua_Debug *ar);
-
- static int atpanic(lua_State *L);
- static jmp_buf panic_jmp;
- lua_State *lua_state;
- const AP_Int32 & _vm_steps;
- const AP_Int8 & _debug_level;
- static void *alloc(void *ud, void *ptr, size_t osize, size_t nsize);
- static void *_heap;
- };
|