| 260 | |
| 261 | |
| 262 | static void **ll_register (lua_State *L, const char *path) { |
| 263 | void **plib; |
| 264 | lua_pushfstring(L, "%s%s", LIBPREFIX, path); |
| 265 | lua_gettable(L, LUA_REGISTRYINDEX); /* check library in registry? */ |
| 266 | if (!lua_isnil(L, -1)) /* is there an entry? */ |
| 267 | plib = (void **)lua_touserdata(L, -1); |
| 268 | else { /* no entry yet; create one */ |
| 269 | lua_pop(L, 1); |
| 270 | plib = (void **)lua_newuserdata(L, sizeof(const void *)); |
| 271 | *plib = NULL; |
| 272 | luaL_getmetatable(L, "_LOADLIB"); |
| 273 | lua_setmetatable(L, -2); |
| 274 | lua_pushfstring(L, "%s%s", LIBPREFIX, path); |
| 275 | lua_pushvalue(L, -2); |
| 276 | lua_settable(L, LUA_REGISTRYINDEX); |
| 277 | } |
| 278 | return plib; |
| 279 | } |
| 280 | |
| 281 | |
| 282 | /* |
no test coverage detected