MCPcopy Create free account
hub / github.com/axmolengine/axmol / check_function_pointer

Function check_function_pointer

3rdparty/lua/sol/sol.hpp:20479–20502  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20477 namespace stack_detail {
20478 template <typename Function, typename Handler>
20479 bool check_function_pointer(lua_State* L, int index, Handler&& handler, record& tracking) noexcept {
20480#if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE)
20481 tracking.use(1);
20482 bool success = lua_iscfunction(L, index) == 1;
20483 if (success) {
20484 // there must be at LEAST 2 upvalues; otherwise, we didn't serialize it.
20485 const char* upvalue_name = lua_getupvalue(L, index, 2);
20486 lua_pop(L, 1);
20487 success = upvalue_name != nullptr;
20488 }
20489 if (!success) {
20490 // expected type, actual type
20491 handler(
20492 L, index, type::function, type_of(L, index), "type must be a Lua C Function gotten from a function pointer serialized by sol2");
20493 }
20494 return success;
20495#else
20496 (void)L;
20497 (void)index;
20498 (void)handler;
20499 (void)tracking;
20500 return false;
20501#endif
20502 }
20503
20504 template <typename Function>
20505 Function* get_function_pointer(lua_State* L, int index, record& tracking) noexcept {

Callers

nothing calls this directly

Calls 4

lua_iscfunctionFunction · 0.85
lua_getupvalueFunction · 0.85
type_ofFunction · 0.85
useMethod · 0.80

Tested by

no test coverage detected