lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 8 December 2012 12:28, Philipp Kraus <philipp.kraus@flashpixx.de> wrote:
>
> Am 08.12.2012 um 11:40 schrieb Luiz Henrique de Figueiredo:
>
>>>  luaL_register(L,"org.conman.math",reg_math);
>>>  Never had a problem.
>>
>> This no longer works is 5.2 because in 5.1 luaL_register called
>> (the undocumented and badly named) luaL_findtable which did that magic,
>> but 5.2 lacks luaL_findtable.
>>
>> If you want to keep this way of registering your libraries is 5.2,
>> but don't want to use or require LUA_COMPAT_MODULE when build Lua,
>> you can copy luaL_findtable from the 5.2 source and use this version
>> of luaL_register:
>>
>> void luaL_register(lua_State *L, const char *libname, const luaL_Reg *l) {
>>  lua_pushglobaltable(L);
>>  luaL_findtable(L,-1,libname,0);
>>  luaL_setfuncs(L,l,0);
>> }
>>
>
> The findtable call does not exists. I have include the files
> #include <lua.h>
> #include <lauxlib.h>
> #include <lualib.h>
>
> Do I have forgot an include? I'm using Lua 5.2.1
>
> Thanks
>
> Phil
>

If you want to keep this way of registering your libraries is 5.2,
but don't want to use or require LUA_COMPAT_MODULE when build Lua,
you can copy luaL_findtable from the 5.2 source and use this version
of luaL_register:


You will find it in lauxlib.c line 764 guarded by a LUA_COMPAT_MODULE macro.