TheLinx / lao

A library for audio output through Lua.
http://thelinx.github.com/lao/
18 stars 2 forks source link

No luaL_register in 5.2 #2

Closed peterbillam closed 7 years ago

peterbillam commented 10 years ago

Hi. I get: /usr/local/lib/lua/5.2/ao.so: undefined symbol: luaL_register which reminds me of a change I had to make in my midialsa.lua

if LUA_VERSION_NUM >= 502

luaL_setfuncs(L, prv, 0);    /* 5.2 */
return 0;

else

luaL_register(L, NULL, prv); /* 5.1 */
return 0;

endif

YMMV ... Regards, Peter

TheLinx commented 10 years ago

Would you mind making a pull request with this? I don't have a Lua development environment set up right now, so I would like to rely on you.

peterbillam commented 10 years ago

I can't get it working; but the following code works if I also edit ao_example.lua from require("ao") to local ao=require("ao")

if LUA_VERSION_NUM >= 502

lua_newtable(L);
luaL_setfuncs(L, ao, 0);

else

luaL_register(L, "ao", ao); /\* 5.1 */

endif

BUT: I can't work out how to put table ao into the calling namespace, I've never done it before. See: http://www.lua.org/manual/5.2/manual.html#luaL_setfuncs

Normally, luarocks detects which lua it's running under and installs accordingly. Currently the Makefile has 5.1 hardwired so it'll have to change, though I'm not sure how your rockspec is generated. ( For me, making the rockspec is part of my development cycle, and I've always used build = { type="builtin", ... } )

I get warnings in l_initialize, l_shutdown and l___gc about parameter L being unused, which is true.

Of course if you can generate a rockspec, I will eagerly check that it installs under 5.2 ...

bartbes commented 10 years ago

Adding the two lines lua_pushvalue(L, -1); lua_setglobal(L, "ao");

Should restore old behaviour, though of course the reason lua 5.2 changed this is because they want the newer, explicit behaviour.

TheLinx commented 10 years ago

So everything is working as intended? Can't say I'm very familiar with 5.2.