MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / get_func_by_ref

Function get_func_by_ref

lua/sp.c:2997–3021  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2995}
2996
2997static int get_func_by_ref(Lua L, const char *entry, char **err)
2998{
2999 // return function to call on the lua stack
3000 lua_getglobal(L, "_SP");
3001 lua_pushstring(L, "cdb2_func_refs");
3002 lua_gettable(L, -2); // result, _SP{}
3003 if (!lua_istable(L, -1)) {
3004 goto bad;
3005 }
3006 lua_remove(L, 1); // _SP{}
3007 lua_pushstring(L, entry);
3008 lua_gettable(L, -2);
3009 if (!lua_isfunction(L, -1)) {
3010 goto bad;
3011 }
3012 lua_remove(L, 1); // cdb2_func_refs
3013 // return with function on stack
3014 return 0;
3015
3016bad:
3017 // return with nothing on the stack
3018 lua_settop(L, 0);
3019 *err = strdup("get_func_by_ref failed");
3020 return -1;
3021}
3022
3023// return 'main' function to call on the lua stack
3024static int get_func_by_name(Lua L, const char *func, char **err)

Callers

nothing calls this directly

Calls 5

lua_pushstringFunction · 0.85
lua_gettableFunction · 0.85
lua_removeFunction · 0.85
lua_settopFunction · 0.85
strdupFunction · 0.50

Tested by

no test coverage detected