lua-users home
lua-l archive

Re: Availability of 5.2-compatible libraries

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


On Wed, Jan 18, 2012 at 6:33 AM, Rob Kendrick <rjek@rjek.com> wrote:
> I've seen threads mention ways of getting things to build for 5.2: is
> there an automated way of forcing these changes yet?  (ie, a header to
> include, etc) or must it be done manually for each (possibly abandoned)
> library I wish to use with 5.2?
The preprocessor value to check is LUA_VERSION_NUM.
I found these conditionals useful when making a portable version of winapi:
#if LUA_VERSION_NUM > 501
#define lua_objlen lua_rawlen
#endif
luaL_register doesn't exist; this is the equivalent for modifying a metatable
 luaL_newmetatable(L,Window_MT);
#if LUA_VERSION_NUM > 501
 luaL_setfuncs(L,Window_methods,0);
#else
 luaL_register(L,NULL,Window_methods);
#endif
and here's a little hack so that the 'winapi' table is available
globally (I need this because the library has embedded Lua code
referring to winapi)
#if LUA_VERSION_NUM > 501
 lua_newtable(L);
 luaL_setfuncs (L,winapi_funs,0);
 lua_pushvalue(L,-1);
 lua_setglobal(L,"winapi");
#else
 luaL_register(L,"winapi",winapi_funs);
#endif
Anything involving function enivronments has to be rewritten, of course
steve d.

AltStyle によって変換されたページ (->オリジナル) /