MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / CallMetaFunction

Function CallMetaFunction

emmy_debugger/src/debugger/emmy_debugger.cpp:263–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261}
262
263bool CallMetaFunction(lua_State *L, int valueIndex, const char *method, int numResults, int &result) {
264 if (lua_getmetatable(L, valueIndex)) {
265 const int metaIndex = lua_gettop(L);
266 if (!lua_isnil(L, metaIndex)) {
267 lua_pushstring(L, method);
268 lua_rawget(L, metaIndex);
269 if (lua_isnil(L, -1)) {
270 // The meta-method doesn't exist.
271 lua_pop(L, 1);
272 lua_remove(L, metaIndex);
273 return false;
274 }
275 lua_pushvalue(L, valueIndex);
276 result = lua_pcall(L, 1, numResults, 0);
277 }
278 lua_remove(L, metaIndex);
279 return true;
280 }
281 return false;
282}
283
284std::string ToPointer(lua_State *L, int index) {
285 const void *pointer = lua_topointer(L, index);

Callers 1

GetVariableMethod · 0.85

Calls 7

lua_getmetatableFunction · 0.50
lua_gettopFunction · 0.50
lua_pushstringFunction · 0.50
lua_rawgetFunction · 0.50
lua_removeFunction · 0.50
lua_pushvalueFunction · 0.50
lua_pcallFunction · 0.50

Tested by

no test coverage detected