feat(lua): Port of NodeMCU Lua53 read-only tables (#2994)
* chore(lua): revert useless c light function change This change was part of the eLua LTR patches (based on 5.1), whereby this feature was already integrated in Lua 5.2. * feat(lua): port of NodeMCU Lua53 read-only tables # Conflicts: # radio/src/lua/CMakeLists.txt # radio/src/lua/api_general.cpp * fix(nv14): missing SDRAM definition * fix: l_mathop * fix: use float functions in drawPower() * fix: ltable resize * fix: correct name is "bit32" * fix: first Lua context must be closed last As the lookup cache is attached to that one * Revert to Lua using double * Ensure byte-code compatibility * Fix possible compatibility issue with `lua_typename`/`luaL_typename` * Fix Bitmap symbol table * Re-add table lib for COLORLCD
This commit is contained in:
@@ -19,10 +19,11 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#define LUA_LIB
|
||||
|
||||
#include <cstdio>
|
||||
#include "lua_api.h"
|
||||
|
||||
#include "lua_api.h"
|
||||
#include "api_filesystem.h"
|
||||
|
||||
// garbage collector for luaDir
|
||||
@@ -33,18 +34,6 @@ static int dir_gc(lua_State* L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void registerDirIter(lua_State* L)
|
||||
{
|
||||
luaL_newmetatable(L, DIR_METATABLE);
|
||||
|
||||
/* set the garbage colector field */
|
||||
lua_pushstring(L, "__gc");
|
||||
lua_pushcfunction(L, dir_gc);
|
||||
lua_settable(L, -3);
|
||||
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
static int dir_iter(lua_State* L)
|
||||
{
|
||||
DIR* dir = (DIR*)lua_touserdata(L, lua_upvalueindex(1));
|
||||
@@ -160,4 +149,21 @@ int luaFstat(lua_State* L)
|
||||
lua_settable(L, -3);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LROT_BEGIN(dir_handle, NULL, LROT_MASK_GC)
|
||||
LROT_FUNCENTRY( __gc, dir_gc )
|
||||
LROT_END(dir_handle, NULL, LROT_MASK_GC)
|
||||
|
||||
LROT_BEGIN(etxdir, NULL, 0)
|
||||
LROT_FUNCENTRY( dir, luaDir )
|
||||
LROT_FUNCENTRY( fstat, luaFstat )
|
||||
LROT_END(etxdir, NULL, 0)
|
||||
|
||||
extern "C" {
|
||||
LUAMOD_API int luaopen_etxdir(lua_State* L) {
|
||||
luaL_rometatable( L, DIR_METATABLE, LROT_TABLEREF(dir_handle));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user