MCPcopy Create free account
hub / github.com/Tencent/UnLua / Open

Method Open

Plugins/UnLua/Source/UnLua/Private/UELib.cpp:148–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146};
147
148int 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
187void UnLua::UELib::SetTableForClass(lua_State* L, const char* Name)
188{

Callers

nothing calls this directly

Calls 7

lua_pushstringFunction · 0.85
lua_rawsetFunction · 0.85
lua_pushvalueFunction · 0.85
lua_setmetatableFunction · 0.85
luaL_setfuncsFunction · 0.85
lua_setglobalFunction · 0.85
lua_getglobalFunction · 0.85

Tested by

no test coverage detected