MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / generic_reader

Function generic_reader

third-party/lua-5.5.0/src/lbaselib.c:380–394  ·  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

378** reserved slot inside the stack.
379*/
380static const char *generic_reader (lua_State *L, void *ud, size_t *size) {
381 (void)(ud); /* not used */
382 luaL_checkstack(L, 2, "too many nested functions");
383 lua_pushvalue(L, 1); /* get function */
384 lua_call(L, 0, 1); /* call it */
385 if (lua_isnil(L, -1)) {
386 lua_pop(L, 1); /* pop result */
387 *size = 0;
388 return NULL;
389 }
390 else if (l_unlikely(!lua_isstring(L, -1)))
391 luaL_error(L, "reader function must return a string");
392 lua_replace(L, RESERVEDSLOT); /* save string in reserved slot */
393 return lua_tolstring(L, RESERVEDSLOT, size);
394}
395
396
397static int luaB_load (lua_State *L) {

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected