| 275 | |
| 276 | |
| 277 | static void **ll_register (lua_State *L, const char *path) { |
| 278 | void **plib; |
| 279 | lua_pushfstring(L, "%s%s", LIBPREFIX, path); |
| 280 | lua_gettable(L, LUA_REGISTRYINDEX); /* check library in registry? */ |
| 281 | if (!lua_isnil(L, -1)) /* is there an entry? */ |
| 282 | plib = (void **)lua_touserdata(L, -1); |
| 283 | else { /* no entry yet; create one */ |
| 284 | lua_pop(L, 1); |
| 285 | plib = (void **)lua_newuserdata(L, sizeof(const void *)); |
| 286 | *plib = NULL; |
| 287 | luaL_getmetatable(L, "_LOADLIB"); |
| 288 | lua_setmetatable(L, -2); |
| 289 | lua_pushfstring(L, "%s%s", LIBPREFIX, path); |
| 290 | lua_pushvalue(L, -2); |
| 291 | lua_settable(L, LUA_REGISTRYINDEX); |
| 292 | } |
| 293 | return plib; |
| 294 | } |
| 295 | |
| 296 | |
| 297 | /* |
no test coverage detected