Less C code, and more namespacing is better.
This commit is contained in:
parent
c01c5a23b0
commit
e13529444f
|
@ -22,6 +22,7 @@ package.path = USERDIR .. '/?/init.lua;' .. package.path
|
|||
|
||||
local dynamic_suffix = MACOS and 'lib' or (WINDOWS and 'dll' or 'so')
|
||||
package.cpath = DATADIR .. '/?.' .. dynamic_suffix .. ";" .. USERDIR .. '/?.' .. dynamic_suffix
|
||||
package.native_plugins = {}
|
||||
package.searchers[3] = function(modname)
|
||||
local path = package.searchpath(modname, package.cpath)
|
||||
if not path then return nil end
|
||||
|
|
|
@ -690,7 +690,8 @@ static int f_load_native_plugin(lua_State* L) {
|
|||
void* library = SDL_LoadObject(path);
|
||||
if (name == 0 || !library)
|
||||
return luaL_error(L, "Unable to load %s: %s", name, SDL_GetError());
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, "native_plugins");
|
||||
lua_getglobal(L, "package");
|
||||
lua_getfield(L, -1, "native_plugins");
|
||||
lua_pushlightuserdata(L, library);
|
||||
lua_setfield(L, -2, name);
|
||||
lua_pop(L, 1);
|
||||
|
|
|
@ -152,9 +152,6 @@ init_lua:
|
|||
lua_setglobal(L, "LINUX");
|
||||
#endif
|
||||
|
||||
lua_newtable(L);
|
||||
lua_setfield(L, LUA_REGISTRYINDEX, "native_plugins");
|
||||
|
||||
const char *init_lite_code = \
|
||||
"local core\n"
|
||||
"xpcall(function()\n"
|
||||
|
|
Loading…
Reference in New Issue