1
0
mirror of https://github.com/anope/anope.git synced 2026-07-02 23:03:12 +02:00

New MODULE_INIT macro. I'm going to regret this.

git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1546 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
Robin Burchell w00t@inspircd.org
2008-11-04 20:28:49 +00:00
parent 6956999bd5
commit d4140b3c26
2 changed files with 38 additions and 8 deletions
+13 -3
View File
@@ -105,7 +105,6 @@ typedef enum { MOD_OP_LOAD, MOD_OP_UNLOAD } ModuleOperation;
typedef struct Command_ Command;
typedef struct CommandHash_ CommandHash;
typedef struct Module_ Module;
typedef struct ModuleLang_ ModuleLang;
typedef struct ModuleHash_ ModuleHash;
typedef struct ModuleQueue_ ModuleQueue;
@@ -134,7 +133,10 @@ struct ModuleLang_ {
char **argv;
};
struct Module_ {
class Module
{
public:
// XXX :(
char *name;
char *filename;
void *handle;
@@ -152,9 +154,17 @@ struct Module_ {
void (*hostHelp)(User *u); /* 6 */
void (*helpHelp)(User *u); /* 7 */
/* CommandHash *cmdList[MAX_CMD_HASH]; */
MessageHash *msgList[MAX_CMD_HASH];
ModuleLang lang[NUM_LANGS];
/** Creates and initialises a new module.
* @param loadernick The nickname of the user loading the module.
*/
Module(const std::string &loadernick);
/** Destroys a module, freeing resources it has allocated.
*/
~Module();
};
struct ModuleHash_ {
+25 -5
View File
@@ -179,16 +179,36 @@ extern int strncasecmp(const char *, const char *, size_t);
#endif
#ifndef _WIN32
#define MODULE_INIT(x) \
extern "C" int anope_modinit(int argc, char **argv) \
/** This definition is used as shorthand for the various classes
* and functions needed to make a module loadable by the OS.
* It defines the class factory and external init_module function.
*/
#ifdef _WIN32
#define MODULE_INIT(y) \
extern "C" DllExport Module *init_module(const std::string &creator) \
{ \
return AnopeInit(argc, argv); \
return new y(creator); \
} \
BOOLEAN WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved) \
{ \
switch ( nReason ) \
{ \
case DLL_PROCESS_ATTACH: \
case DLL_PROCESS_DETACH: \
break; \
} \
return TRUE; \
}
#else
#error Not yet supported on Windows, XXX
#define MODULE_INIT(y) \
extern "C" DllExport Module *init_module(const std::string &creator) \
{ \
return new y(creator); \
}
#endif
/* Miscellaneous definitions. */
#include "defs.h"
#include "slist.h"