summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2010-06-08 09:46:05 +0200
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2010-06-08 09:46:05 +0200
commit707e2d3dc96d7396459c053aaf7b3f0319061b99 (patch)
tree61509aa0f58c60ded1ef7b3c67a5fc091701a824 /src
parentf997ebc065f58792bcaf287ff619da344b9b3711 (diff)
Fixing darwin part of the new dll loading code.
Diffstat (limited to 'src')
-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);