** 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. */
| 368 | ** reserved slot inside the stack. |
| 369 | */ |
| 370 | static const char *generic_reader (lua_State *L, void *ud, size_t *size) { |
| 371 | (void)(ud); /* not used */ |
| 372 | luaL_checkstack(L, 2, "too many nested functions"); |
| 373 | lua_pushvalue(L, 1); /* get function */ |
| 374 | lua_call(L, 0, 1); /* call it */ |
| 375 | if (lua_isnil(L, -1)) { |
| 376 | lua_pop(L, 1); /* pop result */ |
| 377 | *size = 0; |
| 378 | return NULL; |
| 379 | } |
| 380 | else if (l_unlikely(!lua_isstring(L, -1))) |
| 381 | luaL_error(L, "reader function must return a string"); |
| 382 | lua_replace(L, RESERVEDSLOT); /* save string in reserved slot */ |
| 383 | return lua_tolstring(L, RESERVEDSLOT, size); |
| 384 | } |
| 385 | |
| 386 | |
| 387 | static int luaB_load (lua_State *L) { |
nothing calls this directly
no test coverage detected