Convert to a true DLL engine

This commit is contained in:
2023-02-21 15:28:45 -05:00
parent 3eebe7dc33
commit 98c1b2d599
4 changed files with 62 additions and 25 deletions

View File

@@ -158,12 +158,10 @@
#include "wrap-set.hpp"
#include <cstring>
extern "C" {
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
#include "eris.h"
}
class LuaSlot : public eng::nevernew {
protected:

View File

@@ -217,17 +217,11 @@ static int console_read(char *bytes, int nbytes) {
return read(0, bytes, nbytes);
}
// Load the DLL if it's not already loaded. Stores
// the handle in a global variable.
static void load_engine_dll() {
// Not actually implemented yet. Currently, the engine
// is linked right into the executable.
}
static void call_init_engine_wrapper(EngineWrapper *w) {
load_engine_dll();
using InitFn = void (*)(EngineWrapper *);
InitFn initfn = (InitFn)dlsym(RTLD_DEFAULT, "init_engine_wrapper");
void *dll_handle = dlopen("./luprex.so", RTLD_NOW | RTLD_LOCAL);
assert(dll_handle != nullptr);
InitFn initfn = (InitFn)dlsym(dll_handle, "init_engine_wrapper");
assert(initfn != nullptr);
initfn(w);
}