summaryrefslogtreecommitdiff
path: root/src/lua-plugin.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua-plugin.cc')
-rw-r--r--src/lua-plugin.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/lua-plugin.cc b/src/lua-plugin.cc
index 54dcefc..d05efad 100644
--- a/src/lua-plugin.cc
+++ b/src/lua-plugin.cc
@@ -91,6 +91,10 @@ void LuaLoadPlugin(const String & fname, Lua * L) throw (GeneralException) {
}
#if defined(__APPLE__)
+#include <mach/vm_map.h>
+#include <mach-o/dyld.h>
+#include <mach/mach_init.h>
+
void LuaLoadPlugin(Handle * h, Lua * L) throw (GeneralException) {
Byte * buffer;
NSObjectFileImage image;
@@ -100,8 +104,10 @@ void LuaLoadPlugin(Handle * h, Lua * L) throw (GeneralException) {
if (NSCreateObjectFileImageFromMemory(buffer, h->GetSize(), &image) != NSObjectFileImageSuccess)
throw("Can't load library " + h->GetName() + " from memory.");
+
+ NSModule module;
- if (!NSLinkModule(image, h->GetName().get_charp(), NSLINKMODULE_OPTION_PRIVATE))
+ if (!(module = NSLinkModule(image, h->GetName().to_charp(), NSLINKMODULE_OPTION_PRIVATE)))
throw("Can't link library " + h->GetName() + " from memory.");
NSSymbol symbol = NSLookupSymbolInModule(module, "init_plugin");
@@ -109,7 +115,7 @@ void LuaLoadPlugin(Handle * h, Lua * L) throw (GeneralException) {
if (!init_ptr) {
NSDestroyObjectFileImage(image);
- throw GeneralException("No init pointer on plugin " + fname);
+ throw GeneralException("No init pointer on plugin " + h->GetName());
}
Base::printm(M_INFO, "Library loaded, init ptr = %p\n", init_ptr);