[8888] Use ACE for access to script lib

* This allow have more portable code and resolve some related portability problems.
* Also make default script library name lowcase at Windows in same way as used for Unix case.

Thanks to XTZGZoReX for Unix side testing :)
This commit is contained in:
VladimirMangos 2009-11-29 16:04:38 +03:00
parent ce104f6281
commit 01c852fee8
6 changed files with 61 additions and 62 deletions

View file

@ -22,6 +22,8 @@
#include <sys/types.h>
#include <ace/Basic_Types.h>
#include <ace/Default_Constants.h>
#include <ace/OS_NS_dlfcn.h>
#include <ace/ACE_export.h>
#include "Platform/CompilerDefs.h"
@ -37,22 +39,21 @@
# endif //ACE_BYTE_ORDER
#endif //MANGOS_ENDIAN
typedef ACE_SHLIB_HANDLE MANGOS_LIBRARY_HANDLE;
#define MANGOS_SCRIPT_NAME "mangosscript"
#define MANGOS_SCRIPT_SUFFIX ACE_DLL_SUFFIX
#define MANGOS_SCRIPT_PREFIX ACE_DLL_PREFIX
#define MANGOS_LOAD_LIBRARY(libname) ACE_OS::dlopen(libname)
#define MANGOS_CLOSE_LIBRARY(hlib) ACE_OS::dlclose(hlib)
#define MANGOS_GET_PROC_ADDR(hlib,name) ACE_OS::dlsym(hlib,name)
#if PLATFORM == PLATFORM_WINDOWS
# define MANGOS_EXPORT __declspec(dllexport)
# define MANGOS_LIBRARY_HANDLE HMODULE
# define MANGOS_LOAD_LIBRARY(a) LoadLibrary(a)
# define MANGOS_CLOSE_LIBRARY FreeLibrary
# define MANGOS_GET_PROC_ADDR GetProcAddress
# define MANGOS_IMPORT __cdecl
# define MANGOS_SCRIPT_EXT ".dll"
# define MANGOS_SCRIPT_NAME "MaNGOSScript"
# define MANGOS_PATH_MAX MAX_PATH
#else //PLATFORM != PLATFORM_WINDOWS
# define MANGOS_LIBRARY_HANDLE void*
# define MANGOS_EXPORT export
# define MANGOS_LOAD_LIBRARY(a) dlopen(a,RTLD_NOW)
# define MANGOS_CLOSE_LIBRARY dlclose
# define MANGOS_GET_PROC_ADDR dlsym
# if defined(__APPLE_CC__) && defined(BIG_ENDIAN)
# define MANGOS_IMPORT __attribute__ ((longcall))
# elif defined(__x86_64__)
@ -60,8 +61,6 @@
# else
# define MANGOS_IMPORT __attribute__ ((cdecl))
# endif //__APPLE_CC__ && BIG_ENDIAN
# define MANGOS_SCRIPT_EXT ".so"
# define MANGOS_SCRIPT_NAME "libmangosscript"
# define MANGOS_PATH_MAX PATH_MAX
#endif //PLATFORM