| 324 | } |
| 325 | |
| 326 | int CScriptVarsTable::assign(lua_State* L, int index) |
| 327 | { |
| 328 | clear(); |
| 329 | int save_top = lua_gettop(L); |
| 330 | is_array = false; |
| 331 | |
| 332 | int count = lua_objlen(L, index); // сколько в array части таблицы элементов (непрерывный набор ключей от 1 до X) |
| 333 | string16 tmp; |
| 334 | // предварительное прочесывание как массива выстраивает индексы от 1 до count |
| 335 | for (int i = 1; i <= count; i++) |
| 336 | { |
| 337 | is_array = true; |
| 338 | lua_pushinteger(L, i); |
| 339 | lua_gettable(L, index); |
| 340 | set(L, _itoa(i, tmp, 10), lua_gettop(L), LUA_TNUMBER); |
| 341 | lua_pop(L, 1); // извлечь значение из стека |
| 342 | } |
| 343 | lua_settop(L, save_top); |
| 344 | lua_pushnil(L); // начало перебора таблицы |
| 345 | while (lua_next(L, index) != 0) |
| 346 | { |
| 347 | set(L, -2, -1); |
| 348 | lua_pop(L, 1); // извлечь значение из стека |
| 349 | } |
| 350 | lua_settop(L, save_top); |
| 351 | return size(); |
| 352 | } |
| 353 | |
| 354 | void CScriptVarsTable::get(lua_State* L, LPCSTR k, bool unpack) |
| 355 | { |
no test coverage detected