From 67e09363f365d5f0924b78c07993519095901d1e Mon Sep 17 00:00:00 2001 From: Nicolas Noble Date: Wed, 3 Dec 2008 04:36:07 -0800 Subject: Implementing Darwin support. --- src/lua-plugin.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/lua-plugin.cc b/src/lua-plugin.cc index 817c35b..e80f0f8 100644 --- a/src/lua-plugin.cc +++ b/src/lua-plugin.cc @@ -1,13 +1,21 @@ #include +#if defined(_WIN32) +#define SHARED_EXT "dll" +#elif defined(__APPLE__) +#define SHARED_EXT "dylib" +#else +#define SHARED_EXT "so" +#endif + typedef void(*init_ptr_t)(Lua *); -#ifdef _WIN32 +#if defined(_WIN32) #include void LuaLoadPlugin(const String & _fname, Lua * L) throw (GeneralException) { HMODULE handle; - String fname = _fname + ".dll"; + String fname = _fname + "." SHARED_EXT; Base::printm(M_INFO, "Loading library " + fname + "\n"); @@ -30,7 +38,7 @@ void LuaLoadPlugin(const String & _fname, Lua * L) throw (GeneralException) { #include void LuaLoadPlugin(const String & fname, Lua * L) throw (GeneralException) { - void * handle = dlopen(("./" + fname + ".so").to_charp(), RTLD_NOW | RTLD_GLOBAL); + void * handle = dlopen(("./" + fname + "." SHARED_EXT).to_charp(), RTLD_NOW | RTLD_GLOBAL); Base::printm(M_INFO, "Loading library " + fname + "\n"); -- cgit v1.2.3