Permalink
Browse files

Some more cleanup to module loading

Signed-off-by: Uli Schlachter <psychon@znc.in>
  • Loading branch information...
1 parent 80c76c9 commit 26368a6c29139307b7040fe908b6a0de9ed6ef0b @psychon psychon committed Aug 21, 2011
Showing with 5 additions and 15 deletions.
  1. +1 −1 Modules.cpp
  2. +4 −14 Modules.h
View
@@ -839,7 +839,7 @@ bool CModules::LoadModule(const CString& sModule, const CString& sArgs, CModInfo
pModule = Info.GetLoader()(p, pUser, sModule, sDataPath);
break;
case CModInfo::GlobalModule:
- pModule = Info.GetGlobalLoader()(p, sModule, sDataPath);
+ pModule = Info.GetLoader()(p, NULL, sModule, sDataPath);
break;
default:
dlclose(p);
View
@@ -47,26 +47,22 @@ template<class M> CModule* TModLoad(ModHandle p, CUser* pUser,
const CString& sModName, const CString& sModPath) {
return new M(p, pUser, sModName, sModPath);
}
-template<class M> CModule* TModLoadGlobal(ModHandle p,
- const CString& sModName, const CString& sModPath) {
- return new M(p, NULL, sModName, sModPath);
-}
#if HAVE_VISIBILITY
# define MODULE_EXPORT __attribute__((__visibility__("default")))
#else
# define MODULE_EXPORT
#endif
-#define MODCOMMONDEFS(CLASS, DESCRIPTION, TYPE, LOADER) \
+#define MODCOMMONDEFS(CLASS, DESCRIPTION, TYPE) \
extern "C" { \
MODULE_EXPORT bool ZNCModInfo(double dCoreVersion, CModInfo& Info); \
bool ZNCModInfo(double dCoreVersion, CModInfo& Info) { \
if (dCoreVersion != VERSION) \
return false; \
Info.SetDescription(DESCRIPTION); \
Info.AddType(TYPE); \
- LOADER; \
+ Info.SetLoader(TModLoad<CLASS>); \
TModInfo<CLASS>(Info); \
return true; \
} \
@@ -99,13 +95,13 @@ template<class M> CModule* TModLoadGlobal(ModHandle p,
* @see For global modules you need GLOBALMODULEDEFS.
*/
#define MODULEDEFS(CLASS, DESCRIPTION) \
- MODCOMMONDEFS(CLASS, DESCRIPTION, CModInfo::UserModule, Info.SetLoader(TModLoad<CLASS>))
+ MODCOMMONDEFS(CLASS, DESCRIPTION, CModInfo::UserModule)
// !User Module Macros
// Global Module Macros
/** This works exactly like MODULEDEFS, but for global modules. */
#define GLOBALMODULEDEFS(CLASS, DESCRIPTION) \
- MODCOMMONDEFS(CLASS, DESCRIPTION, CModInfo::GlobalModule, Info.SetGlobalLoader(TModLoadGlobal<CLASS>))
+ MODCOMMONDEFS(CLASS, DESCRIPTION, CModInfo::GlobalModule)
// !Global Module Macros
// Forward Declarations
@@ -166,21 +162,18 @@ class CFPTimer : public CTimer {
class CModInfo {
public:
typedef CModule* (*ModLoader)(ModHandle p, CUser* pUser, const CString& sModName, const CString& sModPath);
- typedef CModule* (*GlobalModLoader)(ModHandle p, const CString& sModName, const CString& sModPath);
typedef enum {
GlobalModule,
UserModule
} EModuleType;
CModInfo() {
- m_fGlobalLoader = NULL;
m_fLoader = NULL;
}
CModInfo(const CString& sName, const CString& sPath, EModuleType eType) {
m_sName = sName;
m_sPath = sPath;
- m_fGlobalLoader = NULL;
m_fLoader = NULL;
}
~CModInfo() {}
@@ -215,7 +208,6 @@ class CModInfo {
const CString& GetDescription() const { return m_sDescription; }
const CString& GetWikiPage() const { return m_sWikiPage; }
ModLoader GetLoader() const { return m_fLoader; }
- GlobalModLoader GetGlobalLoader() const { return m_fGlobalLoader; }
// !Getters
// Setters
@@ -224,7 +216,6 @@ class CModInfo {
void SetDescription(const CString& s) { m_sDescription = s; }
void SetWikiPage(const CString& s) { m_sWikiPage = s; }
void SetLoader(ModLoader fLoader) { m_fLoader = fLoader; }
- void SetGlobalLoader(GlobalModLoader fGlobalLoader) { m_fGlobalLoader = fGlobalLoader; }
// !Setters
private:
protected:
@@ -234,7 +225,6 @@ class CModInfo {
CString m_sDescription;
CString m_sWikiPage;
ModLoader m_fLoader;
- GlobalModLoader m_fGlobalLoader;
};
/** A helper class for handling commands in modules. */

0 comments on commit 26368a6

Please sign in to comment.