MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / tryfuncTM

Function tryfuncTM

libraries/AP_Scripting/lua/src/ldo.c:324–334  ·  view source on GitHub ↗

** Check whether __call metafield of 'func' is a function. If so, put ** it in stack below original 'func' so that 'luaD_precall' can call ** it. Raise an error if __call metafield is not a function. */

Source from the content-addressed store, hash-verified

322** it. Raise an error if __call metafield is not a function.
323*/
324static void tryfuncTM (lua_State *L, StkId func) {
325 const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL);
326 StkId p;
327 if (!ttisfunction(tm))
328 luaG_typeerror(L, func, "call");
329 /* Open a hole inside the stack at 'func' */
330 for (p = L->top; p > func; p--)
331 setobjs2s(L, p, p-1);
332 L->top++; /* slot ensured by caller */
333 setobj2s(L, func, tm); /* tag method is the new function to be called */
334}
335
336
337/*

Callers 1

luaD_precallFunction · 0.85

Calls 2

luaT_gettmbyobjFunction · 0.85
luaG_typeerrorFunction · 0.85

Tested by

no test coverage detected