| 1010 | } |
| 1011 | |
| 1012 | LuaValue LuaEngine::contextGetPath(int handleIndex, String path) { |
| 1013 | lua_checkstack(m_state, 2); |
| 1014 | pushHandle(m_state, handleIndex); |
| 1015 | |
| 1016 | std::string utf8Path = path.takeUtf8(); |
| 1017 | char* utf8Ptr = &utf8Path[0]; |
| 1018 | size_t utf8Size = utf8Path.size(); |
| 1019 | |
| 1020 | size_t subPathStart = 0; |
| 1021 | for (size_t i = 0; i < utf8Size; ++i) { |
| 1022 | if (utf8Path[i] == '.') { |
| 1023 | utf8Path[i] = '\0'; |
| 1024 | |
| 1025 | lua_getfield(m_state, -1, utf8Ptr + subPathStart); |
| 1026 | lua_remove(m_state, -2); |
| 1027 | |
| 1028 | if (lua_type(m_state, -1) != LUA_TTABLE) { |
| 1029 | lua_pop(m_state, 1); |
| 1030 | return LuaNil; |
| 1031 | } |
| 1032 | |
| 1033 | subPathStart = i + 1; |
| 1034 | } |
| 1035 | } |
| 1036 | |
| 1037 | lua_getfield(m_state, -1, utf8Ptr + subPathStart); |
| 1038 | lua_remove(m_state, -2); |
| 1039 | |
| 1040 | return popLuaValue(m_state); |
| 1041 | } |
| 1042 | |
| 1043 | void LuaEngine::contextSetPath(int handleIndex, String path, LuaValue const& value) { |
| 1044 | lua_checkstack(m_state, 3); |
no test coverage detected