mirror of
https://github.com/anope/anope.git
synced 2026-06-26 23:16:39 +02:00
More CMake work, mostly to handle both *nix and Windows builds.
Also some tweaks to generation files (like version.sh) to take both input and output files as arguments, to handle CMake when it's used for an out-of-source build. git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1836 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
+20
-4
@@ -111,10 +111,26 @@ static bool IsOneOfModuleTypeLoaded(MODType mt)
|
||||
return false;
|
||||
}
|
||||
|
||||
/* This code was found online at http://www.linuxjournal.com/article/3687#comment-26593
|
||||
*
|
||||
* This function will take a pointer from either dlsym or GetProcAddress and cast it in
|
||||
* a way that won't cause C++ warnings/errors to come up.
|
||||
*/
|
||||
template <class TYPE>
|
||||
TYPE function_cast(ano_module_t symbol)
|
||||
{
|
||||
union {
|
||||
ano_module_t symbol;
|
||||
TYPE function;
|
||||
} cast;
|
||||
cast.symbol = symbol;
|
||||
return cast.function;
|
||||
}
|
||||
|
||||
int ModuleManager::LoadModule(const std::string &modname, User * u)
|
||||
{
|
||||
const char *err;
|
||||
Module * (*func) (const std::string &);
|
||||
Module *(*func)(const std::string &);
|
||||
int ret = 0;
|
||||
|
||||
if (modname.empty())
|
||||
@@ -158,7 +174,7 @@ int ModuleManager::LoadModule(const std::string &modname, User * u)
|
||||
}
|
||||
|
||||
ano_modclearerr();
|
||||
func = reinterpret_cast<Module *(*)(const std::string &)>(ano_modsym(handle, "init_module"));
|
||||
func = function_cast<Module *(*)(const std::string &)>(ano_modsym(handle, "init_module"));
|
||||
if (func == NULL && (err = ano_moderr()) != NULL)
|
||||
{
|
||||
alog("No magical init function found, not an Anope module");
|
||||
@@ -255,11 +271,11 @@ void ModuleManager::DeleteModule(Module *m)
|
||||
handle = m->handle;
|
||||
|
||||
ano_modclearerr();
|
||||
destroy_func = reinterpret_cast<void (*)(Module *)>(ano_modsym(m->handle, "destroy_module"));
|
||||
destroy_func = function_cast<void (*)(Module *)>(ano_modsym(m->handle, "destroy_module"));
|
||||
if (destroy_func == NULL && (err = ano_moderr()) != NULL)
|
||||
{
|
||||
alog("No magical destroy function found, chancing delete...");
|
||||
delete m; /* we just have to change they haven't overwrote the delete operator then... */
|
||||
delete m; /* we just have to chance they haven't overwrote the delete operator then... */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user