MCPcopy Create free account
hub / github.com/F-Stack/f-stack / generic_reader

Function generic_reader

app/redis-6.2.6/deps/lua/src/lbaselib.c:297–312  ·  view source on GitHub ↗

** Reader for generic `load' function: `lua_load' uses the ** stack for internal stuff, so the reader cannot change the ** stack top. Instead, it keeps its resulting string in a ** reserved slot inside the stack. */

Source from the content-addressed store, hash-verified

295** reserved slot inside the stack.
296*/
297static const char *generic_reader (lua_State *L, void *ud, size_t *size) {
298 (void)ud; /* to avoid warnings */
299 luaL_checkstack(L, 2, "too many nested functions");
300 lua_pushvalue(L, 1); /* get function */
301 lua_call(L, 0, 1); /* call it */
302 if (lua_isnil(L, -1)) {
303 *size = 0;
304 return NULL;
305 }
306 else if (lua_isstring(L, -1)) {
307 lua_replace(L, 3); /* save string in a reserved stack slot */
308 return lua_tolstring(L, 3, size);
309 }
310 else luaL_error(L, "reader function must return a string");
311 return NULL; /* to avoid warnings */
312}
313
314
315static int luaB_load (lua_State *L) {

Callers

nothing calls this directly

Calls 7

lua_callFunction · 0.85
luaL_checkstackFunction · 0.70
lua_pushvalueFunction · 0.70
lua_isstringFunction · 0.70
lua_replaceFunction · 0.70
lua_tolstringFunction · 0.70
luaL_errorFunction · 0.70

Tested by

no test coverage detected