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:
Leonardo de Moura 2014-05-08 18:49:27 -07:00
parent fca65a9d69
commit bc1a91496a

View file

@ -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); \