| 945 | } |
| 946 | |
| 947 | bool CScriptObject::Clone(IScriptObject *pObj) |
| 948 | { |
| 949 | //BEGIN_CHECK_STACK |
| 950 | _GUARD_STACK(m_pLS); |
| 951 | int top = lua_gettop(m_pLS); |
| 952 | |
| 953 | if (!lua_xgetref(m_pLS, pObj->GetRef())) |
| 954 | return false; |
| 955 | if (!_GET_THIS()) |
| 956 | return false; |
| 957 | |
| 958 | int srcTable = top + 1; |
| 959 | int trgTable = top + 2; |
| 960 | |
| 961 | lua_pushnil(m_pLS); // first key |
| 962 | while (lua_next(m_pLS, srcTable) != 0) |
| 963 | { |
| 964 | // `key' is at index -2 and `value' at index -1 |
| 965 | lua_pushvalue(m_pLS, - 2); // Push again index. |
| 966 | lua_pushvalue(m_pLS, - 2); // Push value. |
| 967 | SET_FUNCTION(m_pLS, trgTable); |
| 968 | lua_pop(m_pLS, 1); // pop value, leave index. |
| 969 | } |
| 970 | //lua_settop(m_pLS, top); // Restore stack. |
| 971 | //END_CHECK_STACK |
| 972 | |
| 973 | return true; |
| 974 | } |
| 975 | |
| 976 | |
| 977 |
no test coverage detected