16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 12:29:18 +02:00

Refactor Lua bindings to not use FFI anymore

- Lua bindings are no longer using FFI in favor of the "classic" Lua C API.
  - This makes it work properly on native Linux builds.
- Changed the Lua API slightly:
  - Removed the `api.event_preparefunc()` function because it is no longer necessary. Instead, you can pass any function you want without preparing it first.
  - Added an `api.event_exists()` function. Takes a single `name` argument.
  - Any `api.find_*()` functions return `nil` instead of an userdata representing a null pointer when the requested object is not found.
This commit is contained in:
jakubg1
2026-04-01 01:42:54 +02:00
parent 84f86e725c
commit ca8e4aae71
5 changed files with 370 additions and 294 deletions

View File

@@ -591,17 +591,19 @@ private:
#ifdef WITH_LUA
class lua_event : public basic_event {
public:
lua_event(lua::eventhandler_t func);
void init() override;
lua_event(lua_State *L, int ref);
~lua_event() override;
void init() override;
private:
std::string type() const override;
void deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) override;
void run_() override;
void export_as_text_( std::ostream &Output ) const override;
bool is_instant() const override;
std::string type() const override;
void deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) override;
void run_() override;
void export_as_text_( std::ostream &Output ) const override;
bool is_instant() const override;
lua::eventhandler_t lua_func = nullptr;
lua_State *lua_state = nullptr;
int lua_func = LUA_NOREF;
};
#endif