-
Notifications
You must be signed in to change notification settings - Fork 9
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 for luaL_Reg #4
Comments
Well, we need to research what does Emscripten require to pass arrays. From a quick googling up, I've found this: https://github.com/kripken/zee.js/blob/master/post.js#L2 Not too elegant and probably does need a wrapper. I do not have time to look at this right now, unfortunately. But if you will send me a pull request, I'll review and accept it (don't forget to add yourself to AUTHORS in a separate commit, please). Here is a place where to add the wrapper: https://github.com/logiceditor-com/lua5.1.js/blob/master/src/js/lauxlib.h.js#L24 (You may find examples of wrappers below in the same file — look at macro definitions.) |
Thanks! I will give a look at that |
BTW, would be great if you'll be able to do some additional research on this. Maybe there is a less inelegant way. |
Found a temporary workaround: call luaL_register with null and then pass the JS array using lua_pushcfunction and lua_setfield. |
A more advanced Lua<->JS bridge like the one you are thinking about implementing and similar to the one from lua.vm.js would make it so easy. Allow to call the JS objects directly from Lua, no need to register stuff with the C API. |
Good that you've found a workaround! Note that regardless of the existence of the bridge, the aim here is to support as much as Lua C API as possible, so support of luaL_reg is needed anyway. |
BTW, the proper name is |
luaL_register is kind of working. I just don't know how to pass an array of luaL_Reg as the third parameter, so it is creating an empty table :)
The text was updated successfully, but these errors were encountered: