| 631 | } |
| 632 | |
| 633 | bool CScriptEngine::namespace_loaded(const char* name, bool remove_from_stack) // KRodin: видимо, функция проверяет, загружен ли скрипт. |
| 634 | { |
| 635 | #ifdef DEBUG |
| 636 | int start = lua_gettop(lua()); |
| 637 | #endif |
| 638 | lua_pushstring(lua(), GlobalNamespace); |
| 639 | lua_rawget(lua(), LUA_GLOBALSINDEX); |
| 640 | string256 S2; |
| 641 | xr_strcpy(S2, name); |
| 642 | auto S = S2; |
| 643 | for (;;) |
| 644 | { |
| 645 | if (!xr_strlen(S)) |
| 646 | { |
| 647 | VERIFY(lua_gettop(lua()) >= 1); |
| 648 | lua_pop(lua(), 1); |
| 649 | VERIFY(start == lua_gettop(lua())); |
| 650 | return false; |
| 651 | } |
| 652 | auto S1 = strchr(S, '.'); |
| 653 | if (S1) |
| 654 | *S1 = 0; |
| 655 | lua_pushstring(lua(), S); |
| 656 | lua_rawget(lua(), -2); |
| 657 | if (lua_isnil(lua(), -1)) |
| 658 | { |
| 659 | // lua_settop(lua(),0); |
| 660 | VERIFY(lua_gettop(lua()) >= 2); |
| 661 | lua_pop(lua(), 2); |
| 662 | VERIFY(start == lua_gettop(lua())); |
| 663 | return false; // there is no namespace! |
| 664 | } |
| 665 | else if (!lua_istable(lua(), -1)) |
| 666 | { |
| 667 | // lua_settop(lua(), 0); |
| 668 | VERIFY(lua_gettop(lua()) >= 1); |
| 669 | lua_pop(lua(), 1); |
| 670 | VERIFY(start == lua_gettop(lua())); |
| 671 | R_ASSERT3(false, "Error : the namespace is already being used by the non-table object! Name: ", S); |
| 672 | return false; |
| 673 | } |
| 674 | lua_remove(lua(), -2); |
| 675 | if (S1) |
| 676 | S = ++S1; |
| 677 | else |
| 678 | break; |
| 679 | } |
| 680 | if (!remove_from_stack) |
| 681 | VERIFY(lua_gettop(lua()) == start + 1); |
| 682 | else |
| 683 | { |
| 684 | VERIFY(lua_gettop(lua()) >= 1); |
| 685 | lua_pop(lua(), 1); |
| 686 | VERIFY(lua_gettop(lua()) == start); |
| 687 | } |
| 688 | return true; |
| 689 | } |
| 690 |
nothing calls this directly
no test coverage detected