summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-06-26 17:01:33 -0400
committerattilamolnar <attilamolnar@hush.com>2013-08-04 16:08:57 +0200
commit8710724b5518ae9858309e548514f76e620a8459 (patch)
treecb4efb99580cb8957353848a9dc34d5a83ab172e /include
parent36f93c0e7f8a980943237b0b28138ade86f5e573 (diff)
Change the syntax of FOREACH macros to be less dumb.
Diffstat (limited to 'include')
-rw-r--r--include/modules.h16
1 files changed, 7 insertions, 9 deletions
diff --git a/include/modules.h b/include/modules.h
index 8ef646a08..52e41a1fc 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -119,17 +119,18 @@ struct ModResult {
/**
* This #define allows us to call a method in all
* loaded modules in a readable simple way, e.g.:
- * 'FOREACH_MOD(I_OnConnect,OnConnect(user));'
+ * 'FOREACH_MOD(OnConnect,(user));'
*/
#define FOREACH_MOD(y,x) do { \
EventHandlerIter safei; \
- for (EventHandlerIter _i = ServerInstance->Modules->EventHandlers[y].begin(); _i != ServerInstance->Modules->EventHandlers[y].end(); ) \
+ IntModuleList& _handlers = ServerInstance->Modules->EventHandlers[I_ ## y]; \
+ for (EventHandlerIter _i = _handlers.begin(); _i != _handlers.end(); ) \
{ \
safei = _i; \
++safei; \
try \
{ \
- (*_i)->x ; \
+ (*_i)->y x ; \
} \
catch (CoreException& modexcept) \
{ \
@@ -147,21 +148,18 @@ struct ModResult {
*/
#define DO_EACH_HOOK(n,v,args) \
do { \
- EventHandlerIter iter_ ## n = ServerInstance->Modules->EventHandlers[I_ ## n].begin(); \
- while (iter_ ## n != ServerInstance->Modules->EventHandlers[I_ ## n].end()) \
+ IntModuleList& _handlers = ServerInstance->Modules->EventHandlers[I_ ## n]; \
+ for (EventHandlerIter _i = _handlers.begin(); _i != _handlers.end(); ++_i) \
{ \
- Module* mod_ ## n = *iter_ ## n; \
- iter_ ## n ++; \
try \
{ \
- v = (mod_ ## n)->n args;
+ v = (*_i)->n args;
#define WHILE_EACH_HOOK(n) \
} \
catch (CoreException& except_ ## n) \
{ \
ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, "Exception caught: %s", (except_ ## n).GetReason()); \
- (void) mod_ ## n; /* catch mismatched pairs */ \
} \
} \
} while(0)