| 636 | } |
| 637 | |
| 638 | int CScriptObject::Count() |
| 639 | { |
| 640 | _GUARD_STACK(m_pLS); |
| 641 | int top = lua_gettop(m_pLS); |
| 642 | |
| 643 | int nCount=0; |
| 644 | if (!_GET_THIS()) |
| 645 | return -1; |
| 646 | |
| 647 | int trgTable = top + 1; |
| 648 | |
| 649 | lua_pushnil(m_pLS); // first key |
| 650 | while (lua_next(m_pLS, trgTable) != 0) |
| 651 | { |
| 652 | // `key' is at index -2 and `value' at index -1 |
| 653 | nCount++; |
| 654 | lua_pop(m_pLS, 1); // pop value, leave index. |
| 655 | } |
| 656 | //lua_settop(m_pLS, top); // Restore stack. |
| 657 | return nCount; |
| 658 | } |
| 659 | |
| 660 | bool CScriptObject::GetAt(int nIdx, int &nVal) |
| 661 | { |
no test coverage detected