MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / bind_unknown

Function bind_unknown

modules/engine/lua/src/build.skr_lua.cpp:234–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232 ((skr::SObjectPtr<skr::SInterface>*)((char*)p + sizeof(void*)))->reset();
233}
234void bind_unknown(lua_State* L)
235{
236 luaL_Reg metamethods[] = {
237 { "__eq", [](lua_State* L) -> int {
238 void* a = *(void**)lua_touserdata(L, 1);
239 void* b = *(void**)lua_touserdata(L, 2);
240 lua_pushboolean(L, a == b);
241 return 1;
242 } },
243 { nullptr, nullptr }
244 };
245 luaL_newmetatable(L, "skr_opaque_t");
246 luaL_register(L, nullptr, metamethods);
247 lua_pop(L, 1);
248 luaL_Reg uniquemetamethods[] = {
249 metamethods[0],
250 metamethods[1],
251 { nullptr, nullptr }
252 };
253 luaL_newmetatable(L, "[unique]skr_opaque_t");
254 luaL_register(L, nullptr, uniquemetamethods);
255 lua_pop(L, 1);
256 luaL_Reg sharedmetamethods[] = {
257 metamethods[0],
258 metamethods[1],
259 { nullptr, nullptr }
260 };
261 luaL_newmetatable(L, "[shared]skr_opaque_t");
262 luaL_register(L, nullptr, sharedmetamethods);
263 lua_pop(L, 1);
264 luaL_Reg objectmetamethods[] = {
265 metamethods[0],
266 metamethods[1],
267 { nullptr, nullptr }
268 };
269 luaL_newmetatable(L, "[object]skr_opaque_t");
270 luaL_register(L, nullptr, objectmetamethods);
271 lua_pop(L, 1);
272}
273
274void skr_lua_close(lua_State* L)
275{

Callers 1

skr_lua_newstateFunction · 0.85

Calls 4

luaL_registerFunction · 0.85
lua_touserdataFunction · 0.50
lua_pushbooleanFunction · 0.50
luaL_newmetatableFunction · 0.50

Tested by

no test coverage detected