From 707e2d3dc96d7396459c053aaf7b3f0319061b99 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Tue, 8 Jun 2010 09:46:05 +0200 Subject: Fixing darwin part of the new dll loading code. --- src/lua-plugin.cc | 10 ++++++++-- 1 file 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 +#include +#include + 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); -- cgit v1.2.3