** 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. */
| 295 | ** reserved slot inside the stack. |
| 296 | */ |
| 297 | static 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 | |
| 315 | static int luaB_load (lua_State *L) { |
nothing calls this directly
no test coverage detected