| 146 | }; |
| 147 | |
| 148 | int UnLua::UELib::Open(lua_State* L) |
| 149 | { |
| 150 | lua_newtable(L); |
| 151 | lua_pushstring(L, "__index"); |
| 152 | lua_pushcfunction(L, UE_Index); |
| 153 | lua_rawset(L, -3); |
| 154 | |
| 155 | lua_pushvalue(L, -1); |
| 156 | lua_setmetatable(L, -2); |
| 157 | |
| 158 | lua_pushvalue(L, -1); |
| 159 | lua_pushstring(L, REGISTRY_KEY); |
| 160 | lua_rawset(L, LUA_REGISTRYINDEX); |
| 161 | |
| 162 | luaL_setfuncs(L, UE_Functions, 0); |
| 163 | lua_setglobal(L, NAMESPACE_NAME); |
| 164 | |
| 165 | // global access for legacy support |
| 166 | lua_getglobal(L, LUA_GNAME); |
| 167 | luaL_setfuncs(L, UE_Functions, 0); |
| 168 | lua_pop(L, 1); |
| 169 | |
| 170 | #if WITH_UE4_NAMESPACE == 1 |
| 171 | // 兼容UE4访问 |
| 172 | lua_getglobal(L, NAMESPACE_NAME); |
| 173 | lua_setglobal(L, "UE4"); |
| 174 | #elif WITH_UE4_NAMESPACE == 0 |
| 175 | // 兼容无UE4全局访问 |
| 176 | lua_getglobal(L, LUA_GNAME); |
| 177 | lua_newtable(L); |
| 178 | lua_pushstring(L, "__index"); |
| 179 | lua_getglobal(L, NAMESPACE_NAME); |
| 180 | lua_rawset(L, -3); |
| 181 | lua_setmetatable(L, -2); |
| 182 | #endif |
| 183 | |
| 184 | return 1; |
| 185 | } |
| 186 | |
| 187 | void UnLua::UELib::SetTableForClass(lua_State* L, const char* Name) |
| 188 | { |
nothing calls this directly
no test coverage detected