Incorporated some suggestions, and some functions.

This commit is contained in:
Adam Harrison 2021-09-20 23:33:12 -04:00
parent fbc11c00eb
commit 3ca127793a
2 changed files with 8 additions and 11 deletions

View File

@ -21,16 +21,9 @@ package.path = USERDIR .. '/?.lua;' .. package.path
package.path = USERDIR .. '/?/init.lua;' .. package.path
local dynamic_suffix = MACOS and 'lib' or (WINDOWS and 'dll' or 'so')
package.cpath = DATADIR .. '/?.' .. dynamic_suffix .. ';' .. package.cpath
package.cpath = USERDIR .. '/?.' .. dynamic_suffix .. ';' .. package.cpath
package.cpath = DATADIR .. '/?.' .. dynamic_suffix .. ";" .. USERDIR .. '/?.' .. dynamic_suffix
package.searchers[3] = function(modname)
local s,e = 0
repeat
e = package.cpath:find(";", s) or #package.cpath
local path = package.cpath:sub(s, e - 1):gsub("?", modname:gsub("%.", "/"))
if system.get_file_info(path) then
local path = package.searchpath(modname, package.cpath)
if not path then return nil end
return system.load_native_plugin, path
end
s = e + 1
until s > #package.cpath
end

View File

@ -50,6 +50,8 @@ echo "typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* u
LUA_HEADERS=`pkg-config --cflags lua5.2 | sed 's/^-I//' | sed 's/$/\/*.h/'`
grep -h "^LUA\(LIB\)*_API" $LUA_HEADERS | sed "s/LUA\(LIB\)*_API //" | sed "s/(lua/(*lua/" | grep -v ",\s*$" | sed "s/^/static /"
grep -h "#define luaL*_" $LUA_HEADERS | grep -v "\\\s*$" | grep -v "\(assert\|lock\)" | grep -v "\(asm\|int32\)" | grep -v "#define lua_number2integer(i,n)\s*lua_number2int(i, n)"
echo "#define lua_pushliteral(L, s) lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)"
echo "#define lua_pushglobaltable(L) lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS)"
echo "#define IMPORT_SYMBOL(name, ret, ...) name = (ret (*)(__VA_ARGS__))symbol(#name)"
echo "static void lite_xl_plugin_init(void* XL) {"
echo "\tvoid* (*symbol)(const char*) = (void* (*)(const char*))XL;"
@ -228,6 +230,8 @@ static void (*luaL_openlibs) (lua_State *L);
#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
#define lua_str2number(s,p) strtod((s), (p))
#define lua_strx2number(s,p) strtod((s), (p))
#define lua_pushliteral(L, s) lua_pushlstring(L, s, (sizeof(s)/sizeof(char))-1)
#define lua_pushglobaltable(L) lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS)
#define IMPORT_SYMBOL(name, ret, ...) name = (ret (*)(__VA_ARGS__))symbol(#name)
static void lite_xl_plugin_init(void* XL) {
void* (*symbol)(const char*) = (void* (*)(const char*))XL;