revert system.c
do not generate the exported symbols with the script
This commit is contained in:
parent
68eb6810d9
commit
b42f48782b
|
@ -42,10 +42,6 @@ import_sym() {
|
|||
grep '^LUA' | grep -v "$IGNORE_SYM" | sed -e "s/$sym_regex/\tIMPORT_SYMBOL(\3, \2, \4);/"
|
||||
}
|
||||
|
||||
export_sym() {
|
||||
grep '^LUA' | grep -v "$IGNORE_SYM" | sed -e "s/$sym_regex/\t\tEXPORT_SYMBOL(\3),/"
|
||||
}
|
||||
|
||||
decl() {
|
||||
echo "/** $(basename "$1") **/"
|
||||
echo
|
||||
|
@ -65,11 +61,6 @@ decl_import() {
|
|||
uncomment $1 | onelineize | import_sym
|
||||
}
|
||||
|
||||
decl_export() {
|
||||
uncomment $1 | onelineize | export_sym
|
||||
}
|
||||
|
||||
|
||||
generate_header() {
|
||||
local LUA_PATH="$1"
|
||||
echo "#ifndef LITE_XL_PLUGIN_API"
|
||||
|
@ -113,58 +104,14 @@ generate_header() {
|
|||
echo "#endif"
|
||||
}
|
||||
|
||||
generate_api_require() {
|
||||
local LUA_PATH="$1"
|
||||
echo "#ifndef API_REQUIRE_H"
|
||||
echo "#define API_REQUIRE_H"
|
||||
echo "/**"
|
||||
echo "This file contains the function api_require that"
|
||||
echo "returns a function pointer with it's corresponding name."
|
||||
echo
|
||||
echo "This file is automatically generated. DO NOT MODIFY."
|
||||
echo "**/"
|
||||
echo
|
||||
echo
|
||||
echo "#include <string.h>"
|
||||
echo "#include <stddef.h>"
|
||||
echo '#include "lua.h"'
|
||||
echo '#include "lauxlib.h"'
|
||||
echo
|
||||
echo "typedef struct fnptr_s {"
|
||||
echo -e "\tconst char* name;"
|
||||
echo -e "\tvoid *addr;"
|
||||
echo "} fnptr_t;"
|
||||
echo
|
||||
echo "#define EXPORT_SYMBOL(SYM) { #SYM, (void*)(SYM) }"
|
||||
echo "static void *api_require(const char *symbol) {"
|
||||
echo -e "\tstatic fnptr_t nodes[] = {"
|
||||
|
||||
decl_export "$LUA_PATH/lua.h"
|
||||
decl_export "$LUA_PATH/lauxlib.h"
|
||||
|
||||
echo -e "\t};"
|
||||
echo -e "\tfor (int i = 0; i < sizeof(nodes) / sizeof(fnptr_t); i++)"
|
||||
echo -e "\t\tif (strcmp(nodes[i].name, symbol) == 0)"
|
||||
echo -e "\t\t\treturn nodes[i].addr;"
|
||||
echo -e "\tfprintf(stderr, \"warning: %s cannot be exported.\", symbol);"
|
||||
echo -e "\treturn NULL;"
|
||||
echo "}"
|
||||
echo "#endif"
|
||||
}
|
||||
|
||||
show_help() {
|
||||
echo -e "Usage: $0 <OPTIONS> prefix"
|
||||
echo
|
||||
echo -e "Available options:"
|
||||
echo
|
||||
echo -e "-a\t--api-header\tGenerate lite_xl_plugin_api.h"
|
||||
echo -e "-b\t--api-require\tGenerate api_require.h"
|
||||
echo -e "-p\t--prefix\tSet prefix (where to find lua.h and lauxlib.h)"
|
||||
}
|
||||
|
||||
main() {
|
||||
local header=0
|
||||
local require=0
|
||||
local prefix=""
|
||||
|
||||
for i in "$@"; do
|
||||
|
@ -173,14 +120,6 @@ main() {
|
|||
show_help
|
||||
exit 0
|
||||
;;
|
||||
-a|--api-header)
|
||||
header=1
|
||||
shift
|
||||
;;
|
||||
-b|--api-require)
|
||||
require=1
|
||||
shift
|
||||
;;
|
||||
-p|--prefix)
|
||||
prefix="$2"
|
||||
shift
|
||||
|
@ -191,14 +130,7 @@ main() {
|
|||
esac
|
||||
done
|
||||
|
||||
if [[ "$header" -eq 1 ]]; then
|
||||
generate_header "$prefix"
|
||||
elif [[ "$require" -eq 1 ]]; then
|
||||
generate_api_require "$prefix"
|
||||
else
|
||||
show_help
|
||||
exit 1
|
||||
fi
|
||||
generate_header "$prefix"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include <sys/stat.h>
|
||||
#include "api.h"
|
||||
#include "rencache.h"
|
||||
#include "api_require.h"
|
||||
#ifdef _WIN32
|
||||
#include <direct.h>
|
||||
#include <windows.h>
|
||||
|
@ -652,6 +651,58 @@ static int f_set_window_opacity(lua_State *L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
typedef struct lua_function_node {
|
||||
const char *symbol;
|
||||
void *address;
|
||||
} lua_function_node;
|
||||
|
||||
#define P(FUNC) { "lua_" #FUNC, (void*)(lua_##FUNC) }
|
||||
#define U(FUNC) { "luaL_" #FUNC, (void*)(luaL_##FUNC) }
|
||||
static void* api_require(const char* symbol) {
|
||||
static lua_function_node nodes[] = {
|
||||
P(atpanic), P(checkstack),
|
||||
P(close), P(concat), P(copy), P(createtable), P(dump),
|
||||
P(error), P(gc), P(getallocf), P(getfield),
|
||||
P(gethook), P(gethookcount), P(gethookmask), P(getinfo), P(getlocal),
|
||||
P(getmetatable), P(getstack), P(gettable), P(gettop), P(getupvalue),
|
||||
P(insert), P(isnumber), P(isstring), P(isuserdata),
|
||||
P(load), P(newstate), P(newthread), P(newuserdata), P(next),
|
||||
P(pushboolean), P(pushcclosure), P(pushfstring), P(pushinteger),
|
||||
P(pushlightuserdata), P(pushlstring), P(pushnil), P(pushnumber),
|
||||
P(pushstring), P(pushthread), P(pushvalue),
|
||||
P(pushvfstring), P(rawequal), P(rawget), P(rawgeti),
|
||||
P(rawset), P(rawseti), P(remove), P(replace), P(resume),
|
||||
P(setallocf), P(setfield), P(sethook), P(setlocal),
|
||||
P(setmetatable), P(settable), P(settop), P(setupvalue),
|
||||
P(status), P(tocfunction), P(tointegerx), P(tolstring), P(toboolean),
|
||||
P(tonumberx), P(topointer), P(tothread), P(touserdata),
|
||||
P(type), P(typename), P(upvalueid), P(upvaluejoin), P(version), P(xmove),
|
||||
U(getmetafield), U(callmeta), U(argerror), U(checknumber), U(optnumber),
|
||||
U(checkinteger), U(checkstack), U(checktype), U(checkany),
|
||||
U(newmetatable), U(setmetatable), U(testudata), U(checkudata), U(where),
|
||||
U(error), U(fileresult), U(execresult), U(ref), U(unref), U(loadstring),
|
||||
U(newstate), U(setfuncs), U(buffinit), U(addlstring), U(addstring),
|
||||
U(addvalue), U(pushresult),
|
||||
#if LUA_VERSION_NUM >= 502
|
||||
P(absindex), P(arith), P(callk), P(compare), P(getctx), P(getglobal), P(getuservalue),
|
||||
P(len), P(pcallk), P(pushunsigned), P(rawgetp), P(rawlen), P(rawsetp), P(setglobal),
|
||||
P(iscfunction), P(setuservalue), P(tounsignedx), P(yieldk),
|
||||
U(checkversion_), U(tolstring), U(checkunsigned), U(len), U(getsubtable), U(prepbuffsize),
|
||||
U(pushresultsize), U(buffinitsize), U(checklstring), U(checkoption), U(gsub), U(loadbufferx),
|
||||
U(loadfilex), U(optinteger), U(optlstring), U(optunsigned), U(requiref), U(traceback)
|
||||
#else
|
||||
P(objlen)
|
||||
#endif
|
||||
|
||||
};
|
||||
for (int i = 0; i < sizeof(nodes) / sizeof(lua_function_node); ++i) {
|
||||
if (strcmp(nodes[i].symbol, symbol) == 0)
|
||||
return nodes[i].address;
|
||||
}
|
||||
fprintf(stderr, "WARNING: %s is not available\n", symbol);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int f_load_native_plugin(lua_State *L) {
|
||||
char entrypoint_name[512]; entrypoint_name[sizeof(entrypoint_name) - 1] = '\0';
|
||||
int result;
|
||||
|
|
|
@ -1,167 +0,0 @@
|
|||
#ifndef API_REQUIRE_H
|
||||
#define API_REQUIRE_H
|
||||
/**
|
||||
This file contains the function api_require that
|
||||
returns a function pointer with it's corresponding name.
|
||||
|
||||
This file is automatically generated. DO NOT MODIFY.
|
||||
**/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
|
||||
typedef struct fnptr_s {
|
||||
const char* name;
|
||||
void *addr;
|
||||
} fnptr_t;
|
||||
|
||||
#define EXPORT_SYMBOL(SYM) { #SYM, (void*)(SYM) }
|
||||
static void *api_require(const char *symbol) {
|
||||
static fnptr_t nodes[] = {
|
||||
EXPORT_SYMBOL(lua_newstate),
|
||||
EXPORT_SYMBOL(lua_close),
|
||||
EXPORT_SYMBOL(lua_newthread),
|
||||
EXPORT_SYMBOL(lua_atpanic),
|
||||
EXPORT_SYMBOL(lua_version),
|
||||
EXPORT_SYMBOL(lua_absindex),
|
||||
EXPORT_SYMBOL(lua_gettop),
|
||||
EXPORT_SYMBOL(lua_settop),
|
||||
EXPORT_SYMBOL(lua_pushvalue),
|
||||
EXPORT_SYMBOL(lua_remove),
|
||||
EXPORT_SYMBOL(lua_insert),
|
||||
EXPORT_SYMBOL(lua_replace),
|
||||
EXPORT_SYMBOL(lua_copy),
|
||||
EXPORT_SYMBOL(lua_checkstack),
|
||||
EXPORT_SYMBOL(lua_xmove),
|
||||
EXPORT_SYMBOL(lua_isnumber),
|
||||
EXPORT_SYMBOL(lua_isstring),
|
||||
EXPORT_SYMBOL(lua_iscfunction),
|
||||
EXPORT_SYMBOL(lua_isuserdata),
|
||||
EXPORT_SYMBOL(lua_type),
|
||||
EXPORT_SYMBOL(lua_typename),
|
||||
EXPORT_SYMBOL(lua_tonumberx),
|
||||
EXPORT_SYMBOL(lua_tointegerx),
|
||||
EXPORT_SYMBOL(lua_tounsignedx),
|
||||
EXPORT_SYMBOL(lua_toboolean),
|
||||
EXPORT_SYMBOL(lua_tolstring),
|
||||
EXPORT_SYMBOL(lua_rawlen),
|
||||
EXPORT_SYMBOL(lua_tocfunction),
|
||||
EXPORT_SYMBOL(lua_touserdata),
|
||||
EXPORT_SYMBOL(lua_tothread),
|
||||
EXPORT_SYMBOL(lua_topointer),
|
||||
EXPORT_SYMBOL(lua_arith),
|
||||
EXPORT_SYMBOL(lua_rawequal),
|
||||
EXPORT_SYMBOL(lua_compare),
|
||||
EXPORT_SYMBOL(lua_pushnil),
|
||||
EXPORT_SYMBOL(lua_pushnumber),
|
||||
EXPORT_SYMBOL(lua_pushinteger),
|
||||
EXPORT_SYMBOL(lua_pushunsigned),
|
||||
EXPORT_SYMBOL(lua_pushlstring),
|
||||
EXPORT_SYMBOL(lua_pushstring),
|
||||
EXPORT_SYMBOL(lua_pushvfstring),
|
||||
EXPORT_SYMBOL(lua_pushfstring),
|
||||
EXPORT_SYMBOL(lua_pushcclosure),
|
||||
EXPORT_SYMBOL(lua_pushboolean),
|
||||
EXPORT_SYMBOL(lua_pushlightuserdata),
|
||||
EXPORT_SYMBOL(lua_pushthread),
|
||||
EXPORT_SYMBOL(lua_getglobal),
|
||||
EXPORT_SYMBOL(lua_gettable),
|
||||
EXPORT_SYMBOL(lua_getfield),
|
||||
EXPORT_SYMBOL(lua_rawget),
|
||||
EXPORT_SYMBOL(lua_rawgeti),
|
||||
EXPORT_SYMBOL(lua_rawgetp),
|
||||
EXPORT_SYMBOL(lua_createtable),
|
||||
EXPORT_SYMBOL(lua_newuserdata),
|
||||
EXPORT_SYMBOL(lua_getmetatable),
|
||||
EXPORT_SYMBOL(lua_getuservalue),
|
||||
EXPORT_SYMBOL(lua_setglobal),
|
||||
EXPORT_SYMBOL(lua_settable),
|
||||
EXPORT_SYMBOL(lua_setfield),
|
||||
EXPORT_SYMBOL(lua_rawset),
|
||||
EXPORT_SYMBOL(lua_rawseti),
|
||||
EXPORT_SYMBOL(lua_rawsetp),
|
||||
EXPORT_SYMBOL(lua_setmetatable),
|
||||
EXPORT_SYMBOL(lua_setuservalue),
|
||||
EXPORT_SYMBOL(lua_callk),
|
||||
EXPORT_SYMBOL(lua_getctx),
|
||||
EXPORT_SYMBOL(lua_pcallk),
|
||||
EXPORT_SYMBOL(lua_load),
|
||||
EXPORT_SYMBOL(lua_dump),
|
||||
EXPORT_SYMBOL(lua_yieldk),
|
||||
EXPORT_SYMBOL(lua_resume),
|
||||
EXPORT_SYMBOL(lua_status),
|
||||
EXPORT_SYMBOL(lua_gc),
|
||||
EXPORT_SYMBOL(lua_error),
|
||||
EXPORT_SYMBOL(lua_next),
|
||||
EXPORT_SYMBOL(lua_concat),
|
||||
EXPORT_SYMBOL(lua_len),
|
||||
EXPORT_SYMBOL(lua_getallocf),
|
||||
EXPORT_SYMBOL(lua_setallocf),
|
||||
EXPORT_SYMBOL(lua_getstack),
|
||||
EXPORT_SYMBOL(lua_getinfo),
|
||||
EXPORT_SYMBOL(lua_getlocal),
|
||||
EXPORT_SYMBOL(lua_setlocal),
|
||||
EXPORT_SYMBOL(lua_getupvalue),
|
||||
EXPORT_SYMBOL(lua_setupvalue),
|
||||
EXPORT_SYMBOL(lua_upvalueid),
|
||||
EXPORT_SYMBOL(lua_upvaluejoin),
|
||||
EXPORT_SYMBOL(lua_sethook),
|
||||
EXPORT_SYMBOL(lua_gethook),
|
||||
EXPORT_SYMBOL(lua_gethookmask),
|
||||
EXPORT_SYMBOL(lua_gethookcount),
|
||||
EXPORT_SYMBOL(luaL_checkversion_),
|
||||
EXPORT_SYMBOL(luaL_getmetafield),
|
||||
EXPORT_SYMBOL(luaL_callmeta),
|
||||
EXPORT_SYMBOL(luaL_tolstring),
|
||||
EXPORT_SYMBOL(luaL_argerror),
|
||||
EXPORT_SYMBOL(luaL_checklstring),
|
||||
EXPORT_SYMBOL(luaL_optlstring),
|
||||
EXPORT_SYMBOL(luaL_checknumber),
|
||||
EXPORT_SYMBOL(luaL_optnumber),
|
||||
EXPORT_SYMBOL(luaL_checkinteger),
|
||||
EXPORT_SYMBOL(luaL_optinteger),
|
||||
EXPORT_SYMBOL(luaL_checkunsigned),
|
||||
EXPORT_SYMBOL(luaL_optunsigned),
|
||||
EXPORT_SYMBOL(luaL_checkstack),
|
||||
EXPORT_SYMBOL(luaL_checktype),
|
||||
EXPORT_SYMBOL(luaL_checkany),
|
||||
EXPORT_SYMBOL(luaL_newmetatable),
|
||||
EXPORT_SYMBOL(luaL_setmetatable),
|
||||
EXPORT_SYMBOL(luaL_testudata),
|
||||
EXPORT_SYMBOL(luaL_checkudata),
|
||||
EXPORT_SYMBOL(luaL_where),
|
||||
EXPORT_SYMBOL(luaL_error),
|
||||
EXPORT_SYMBOL(luaL_checkoption),
|
||||
EXPORT_SYMBOL(luaL_fileresult),
|
||||
EXPORT_SYMBOL(luaL_execresult),
|
||||
EXPORT_SYMBOL(luaL_ref),
|
||||
EXPORT_SYMBOL(luaL_unref),
|
||||
EXPORT_SYMBOL(luaL_loadfilex),
|
||||
EXPORT_SYMBOL(luaL_loadbufferx),
|
||||
EXPORT_SYMBOL(luaL_loadstring),
|
||||
EXPORT_SYMBOL(luaL_newstate),
|
||||
EXPORT_SYMBOL(luaL_len),
|
||||
EXPORT_SYMBOL(luaL_gsub),
|
||||
EXPORT_SYMBOL(luaL_setfuncs),
|
||||
EXPORT_SYMBOL(luaL_getsubtable),
|
||||
EXPORT_SYMBOL(luaL_traceback),
|
||||
EXPORT_SYMBOL(luaL_requiref),
|
||||
EXPORT_SYMBOL(luaL_buffinit),
|
||||
EXPORT_SYMBOL(luaL_prepbuffsize),
|
||||
EXPORT_SYMBOL(luaL_addlstring),
|
||||
EXPORT_SYMBOL(luaL_addstring),
|
||||
EXPORT_SYMBOL(luaL_addvalue),
|
||||
EXPORT_SYMBOL(luaL_pushresult),
|
||||
EXPORT_SYMBOL(luaL_pushresultsize),
|
||||
EXPORT_SYMBOL(luaL_buffinitsize),
|
||||
};
|
||||
for (int i = 0; i < sizeof(nodes) / sizeof(fnptr_t); i++)
|
||||
if (strcmp(nodes[i].name, symbol) == 0)
|
||||
return nodes[i].addr;
|
||||
fprintf(stderr, "warning: %s cannot be exported.", symbol);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue