MCPcopy Create free account
hub / github.com/defold/defold / GetLuaFunctionRefInfo

Function GetLuaFunctionRefInfo

engine/script/src/script.cpp:2081–2093  ·  view source on GitHub ↗

* Get information about where a Lua function is defined * @param L lua state * @param stack_index which index on the stack that contains the lua function ref * @param out_function_info pointer to the function information that is filled out * @return true on success, out_function_info is only touched if the function succeeds */

Source from the content-addressed store, hash-verified

2079 * @return true on success, out_function_info is only touched if the function succeeds
2080 */
2081 static bool GetLuaFunctionRefInfo(lua_State* L, int stack_index, LuaFunctionInfo* out_function_info)
2082 {
2083 lua_Debug ar;
2084 lua_pushvalue(L, stack_index);
2085 if (lua_getinfo(L, ">Sn", &ar))
2086 {
2087 out_function_info->m_FileName = &ar.source[1]; // Skip source prefix character
2088 out_function_info->m_LineNumber = ar.linedefined;
2089 out_function_info->m_OptionalName = ar.name;
2090 return true;
2091 }
2092 return false;
2093 }
2094
2095 // Fast length limited string concatenation that assume we already point to
2096 // the end of the string. Returns the new end of the string so we do not need

Callers 1

GetProfilerStringFunction · 0.85

Calls 2

lua_pushvalueFunction · 0.85
lua_getinfoFunction · 0.85

Tested by

no test coverage detected