hlua icon indicating copy to clipboard operation
hlua copied to clipboard

Porting to lua 5.1

Open moonshadow565 opened this issue 7 years ago • 0 comments

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:

  • changing Debug struct and few constants
  • compiling with https://github.com/keplerproject/lua-compat-5.2 to provide missing functions
  • removing few functions that aren't provided with lua-compat-5.2 but are unused anyways
  • changing few macros You can see changes here: https://github.com/tomaka/hlua/compare/master...moonshadow565:lua51compat52

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.

moonshadow565 avatar Oct 26 '18 08:10 moonshadow565