MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / pushglobalfuncname

Function pushglobalfuncname

extlibs/lua/src/lauxlib.c:79–97  ·  view source on GitHub ↗

** Search for a name for a function in all loaded modules */

Source from the content-addressed store, hash-verified

77** Search for a name for a function in all loaded modules
78*/
79static int pushglobalfuncname (lua_State *L, lua_Debug *ar) {
80 int top = lua_gettop(L);
81 lua_getinfo(L, "f", ar); /* push function */
82 lua_getfield(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
83 if (findfield(L, top + 1, 2)) {
84 const char *name = lua_tostring(L, -1);
85 if (strncmp(name, LUA_GNAME ".", 3) == 0) { /* name start with '_G.'? */
86 lua_pushstring(L, name + 3); /* push name without prefix */
87 lua_remove(L, -2); /* remove original name */
88 }
89 lua_copy(L, -1, top + 1); /* copy name to proper place */
90 lua_settop(L, top + 1); /* remove table "loaded" an name copy */
91 return 1;
92 }
93 else {
94 lua_settop(L, top); /* remove function and global table */
95 return 0;
96 }
97}
98
99
100static void pushfuncname (lua_State *L, lua_Debug *ar) {

Callers 2

pushfuncnameFunction · 0.85
luaL_argerrorFunction · 0.85

Calls 7

lua_gettopFunction · 0.85
lua_getinfoFunction · 0.85
lua_getfieldFunction · 0.85
findfieldFunction · 0.85
lua_pushstringFunction · 0.85
lua_settopFunction · 0.85
lua_copyFunction · 0.70

Tested by

no test coverage detected