expects two tables on the lua stack: 1: destination 2: source
| 31 | // 1: destination |
| 32 | // 2: source |
| 33 | void copy_member_table(lua_State* L) |
| 34 | { |
| 35 | lua_pushnil(L); |
| 36 | |
| 37 | while (lua_next(L, -2)) |
| 38 | { |
| 39 | lua_pushstring(L, "__init"); |
| 40 | if (lua_equal(L, -1, -3)) |
| 41 | { |
| 42 | lua_pop(L, 2); |
| 43 | continue; |
| 44 | } |
| 45 | else lua_pop(L, 1); // __init string |
| 46 | |
| 47 | lua_pushstring(L, "__finalize"); |
| 48 | if (lua_equal(L, -1, -3)) |
| 49 | { |
| 50 | lua_pop(L, 2); |
| 51 | continue; |
| 52 | } |
| 53 | else lua_pop(L, 1); // __finalize string |
| 54 | |
| 55 | lua_pushvalue(L, -2); // copy key |
| 56 | lua_insert(L, -2); |
| 57 | lua_settable(L, -5); |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | |
| 62 |
no test coverage detected