summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-02 00:44:24 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-02 00:44:24 +0000
commite27f3380733a4412007a3f023069615d1218ab96 (patch)
treeb5d9f56ff1a40c430e8fe87b50596b414ec44af4 /include
parent5abd3b1cc5fba26486d71c6a415fae797388ddf3 (diff)
Replace FOREACH_RESULT_MAP with a more readable and flexible do_each_hook/while_each_hook macro pair
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11598 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include')
-rw-r--r--include/modules.h29
1 files changed, 18 insertions, 11 deletions
diff --git a/include/modules.h b/include/modules.h
index 47f495373..9a23a4fc8 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -213,25 +213,32 @@ do { \
} \
} while (0);
-#define FOREACH_RESULT_MAP(y,x,f) \
+/**
+ * Custom module result handling loop. This is a paired macro, and should only
+ * be used with while_each_hook.
+ *
+ * See src/channels.cpp for an example of use.
+ */
+#define DO_EACH_HOOK(z,n,v,args) \
do { \
- EventHandlerIter safei; \
- for (EventHandlerIter _i = ServerInstance->Modules->EventHandlers[y].begin(); _i != ServerInstance->Modules->EventHandlers[y].end(); ) \
+ EventHandlerIter iter_ ## n = z->Modules->EventHandlers[I_ ## n].begin(); \
+ while (iter_ ## n != z->Modules->EventHandlers[I_ ## n].end()) \
{ \
- safei = _i; \
- ++safei; \
+ Module* mod_ ## n = *iter_ ## n; \
+ iter_ ## n ++; \
try \
{ \
- int MOD_RESULT = (*_i)->x ; \
- f; \
+ v = (mod_ ## n)->n args;
+
+#define WHILE_EACH_HOOK(z,n) \
} \
- catch (CoreException& modexcept) \
+ catch (CoreException& except_ ## n) \
{ \
- ServerInstance->Logs->Log("MODULE",DEFAULT,"Exception caught: %s",modexcept.GetReason()); \
+ z->Logs->Log("MODULE",DEFAULT,"Exception caught: %s", (except_ ## n).GetReason()); \
+ (void) mod_ ## n; /* catch mismatched pairs */ \
} \
- _i = safei; \
} \
-} while(0);
+} while(0)
/** Represents a non-local user.
* (in fact, any FD less than -1 does)