Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support fo LuaU #182

Open
gudzpoz opened this issue Jun 6, 2024 Discussed in #178 · 1 comment
Open

Add support fo LuaU #182

gudzpoz opened this issue Jun 6, 2024 Discussed in #178 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@gudzpoz
Copy link
Owner

gudzpoz commented Jun 6, 2024

Discussed in #178

Originally posted by osp54 June 2, 2024
Сan you add support for LuaU? It has compatibility with lua51(in embedding too), and is its typed superset.

@gudzpoz gudzpoz added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Jun 6, 2024
@gudzpoz
Copy link
Owner Author

gudzpoz commented Jun 6, 2024

LuaU is not fully compatible with Lua 5.1 C API. And to add to it, the incompatibilities are not well documented yet, making it extra hard to support or to catch up with any breaking changes that might follow.

Currently I don't think I have enough motivation (or energy) to support it (since it can potentially break too many things), but I will happily review any PR that aim to bring such support.

I will summarize the challenges here for anybody that is willing to work on this:

  • __gc is not supported in LuaU, while LuaJava uses it to cooperate with Java GC. The code using __gc is under jni/luajava/jua.cpp and you will need to rewrite it for LuaU by presumably using lua_newuserdatadtor along with a bunch of #if macros.
  • The Lua C bindings in LuaNatives are generated with scripts under scripts/ that scrape lua.org manuals. Since LuaU does not offer a manual page, you will probably need to write a script to parse the C header files instead.
  • LuaU may not provide all C API in the LuaNatives interface. If not, you will need to implement those functions yourself, similar to
    static void luaL_setmetatable(lua_State * L, const char * tname) {
    luaL_getmetatable(L, tname);
    lua_setmetatable(L, -2);
    }
  • LuaU uses C++ and CMake. (By comparison, Lua 5.N uses plain C and allows amalgamation builds.) And you will need a rather complex building script like luajit/build.gradle to first get a static libluau.a library and then link jnigen code against it. I consider this step most challenging (and a bit tiresome) as we need to support all those platforms...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant