tomaka / hlua

Rust library to interface with Lua
MIT License
507 stars 48 forks source link

Porting to lua 5.1 #203

Open moonshadow565 opened 5 years ago

moonshadow565 commented 5 years ago

This isn't a proposal or a request for feature; it's more of me asking for help on some issues I have been facing with this endeavur. So far it has been pretty trivial to get this to run on 5.1. It has been simple simple as:

All of tests pass except one problematic case where it crashes.

  1. Using clousures that capture refrences: https://github.com/moonshadow565/hlua/blob/dc1eb4ea9d9dd7f7228e2e674aa1b3033b616af8/hlua/src/functions_write.rs#L541

  2. Passing clousures as refrences: https://github.com/moonshadow565/hlua/blob/dc1eb4ea9d9dd7f7228e2e674aa1b3033b616af8/hlua/tests/userdata.rs#L216

Somehow those references get dropped and turn into 0 reference leading into segfault. Any idea of why this might be happening?

As an afterthought, I don't really think there should be much of trouble being compatible with both Lua 5.1 and 5.2 and even 5.3. An example would be https://github.com/ThePhD/sol2. Which is a powerful, light and safe C++14 wrapper around Lua compatible with 5.1, 5.2 and 5.3 lua versions.

If this doesn't work I'm afraid I'll only be left with an option of writing scripting API in C++ and exposing it as C API to rust.