[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Linking LPeg
- From: Александр Машин <alex.mashin@...>
- Date: Wed, 20 May 2015 02:07:24 +0700
Good time of day,
I am trying to link LPeg library to a very restrictive Lua environment
(which is luasandbox Lua engine for PHP written in C++,
https://github.com/wikimedia/mediawiki-php-luasandbox), which, in
particular, reloads require () function.
I managed to achieve this, more or less, by running this C++ code:
extern "C" int luaopen_lpeg(lua_State*);
lua_call(L, 0, 0);
After that, I get lpeg table in my global namespace and can call
lpeg.P(1), for example.
Unfortunately, getmetatable (lpeg.P(1)) == nil, which makes the library
useless. The metatable seems to be lost or have benn overwritten by some
paranoid sanitation code in luasandbox.
Is there a way to restore or export to Lua global namespace it in C++
somewhere before or after lua_pushcfunction(L, luaopen_lpeg) call?
I will appreciate any help.