feat(util/lua_list): allow Lua list objects to be moved between states
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
fca65a9d69
commit
bc1a91496a
1 changed files with 4 additions and 0 deletions
|
@ -67,8 +67,12 @@ list<T> to_list_ ## T ## _ext(lua_State * L, int idx) { \
|
|||
else \
|
||||
return table_to_list<T>(L, idx, ToVal); \
|
||||
} \
|
||||
static void list_ ## T ## _migrate(lua_State * src, int i, lua_State * tgt) { \
|
||||
push_list_ ## T(tgt, to_list_ ## T(src, i)); \
|
||||
} \
|
||||
static void open_list_ ## T(lua_State * L) { \
|
||||
luaL_newmetatable(L, list_ ## T ## _mt); \
|
||||
set_migrate_fn_field(L, -1, list_ ## T ## _migrate); \
|
||||
lua_pushvalue(L, -1); \
|
||||
lua_setfield(L, -2, "__index"); \
|
||||
setfuncs(L, list_ ## T ## _m, 0); \
|
||||
|
|
Loading…
Reference in a new issue