refactor api_require function into a machine generated file
This commit is contained in:
parent
a9d7ddc6e1
commit
9003a9124a
|
@ -7,6 +7,7 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "rencache.h"
|
#include "rencache.h"
|
||||||
|
#include "api_require.h"
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -651,50 +652,6 @@ static int f_set_window_opacity(lua_State *L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Symbol table for native plugin loading. Allows for a statically
|
|
||||||
// bound lua library to be used by native plugins.
|
|
||||||
typedef struct {
|
|
||||||
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(absindex), P(arith), P(atpanic), P(callk), P(checkstack),
|
|
||||||
P(close), P(compare), P(concat), P(copy), P(createtable), P(dump),
|
|
||||||
P(error), P(gc), P(getallocf), P(getctx), P(getfield), P(getglobal),
|
|
||||||
P(gethook), P(gethookcount), P(gethookmask), P(getinfo), P(getlocal),
|
|
||||||
P(getmetatable), P(getstack), P(gettable), P(gettop), P(getupvalue),
|
|
||||||
P(getuservalue), P(insert), P(isnumber), P(isstring), P(isuserdata),
|
|
||||||
P(len), P(load), P(newstate), P(newthread), P(newuserdata), P(next),
|
|
||||||
P(pcallk), P(pushboolean), P(pushcclosure), P(pushfstring), P(pushinteger),
|
|
||||||
P(pushlightuserdata), P(pushlstring), P(pushnil), P(pushnumber),
|
|
||||||
P(pushstring), P(pushthread), P(pushunsigned), P(pushvalue),
|
|
||||||
P(pushvfstring), P(rawequal), P(rawget), P(rawgeti), P(rawgetp), P(rawlen),
|
|
||||||
P(rawset), P(rawseti), P(rawsetp), P(remove), P(replace), P(resume),
|
|
||||||
P(setallocf), P(setfield), P(setglobal), P(sethook), P(setlocal),
|
|
||||||
P(setmetatable), P(settable), P(settop), P(setupvalue), P(setuservalue),
|
|
||||||
P(status), P(tocfunction), P(tointegerx), P(tolstring), P(toboolean),
|
|
||||||
P(tonumberx), P(topointer), P(tothread), P(tounsignedx), P(touserdata),
|
|
||||||
P(type), P(typename), P(upvalueid), P(upvaluejoin), P(version), P(xmove),
|
|
||||||
P(yieldk), U(checkversion_), U(getmetafield), U(callmeta), U(tolstring),
|
|
||||||
U(argerror), U(checknumber), U(optnumber), U(checkinteger),
|
|
||||||
U(checkunsigned), 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(len), U(setfuncs), U(getsubtable), U(buffinit),
|
|
||||||
U(prepbuffsize), U(addlstring), U(addstring), U(addvalue), U(pushresult),
|
|
||||||
U(pushresultsize), U(buffinitsize)
|
|
||||||
};
|
|
||||||
for (int i = 0; i < sizeof(nodes) / sizeof(lua_function_node); ++i) {
|
|
||||||
if (strcmp(nodes[i].symbol, symbol) == 0)
|
|
||||||
return nodes[i].address;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int f_load_native_plugin(lua_State *L) {
|
static int f_load_native_plugin(lua_State *L) {
|
||||||
char entrypoint_name[512]; entrypoint_name[sizeof(entrypoint_name) - 1] = '\0';
|
char entrypoint_name[512]; entrypoint_name[sizeof(entrypoint_name) - 1] = '\0';
|
||||||
int result;
|
int result;
|
||||||
|
|
|
@ -0,0 +1,166 @@
|
||||||
|
#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),
|
||||||
|
EXPORT_SYMBOL(luaL_pushmodule),
|
||||||
|
EXPORT_SYMBOL(luaL_openlib),
|
||||||
|
};
|
||||||
|
for (int i = 0; i < sizeof(nodes) / sizeof(fnptr_t); i++)
|
||||||
|
if (strcmp(nodes[i].name, symbol) == 0)
|
||||||
|
return nodes[i].addr;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
Loading…
Reference in New Issue