summaryrefslogtreecommitdiff
path: root/src/plugins/pglist.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/pglist.h')
-rw-r--r--src/plugins/pglist.h69
1 files changed, 52 insertions, 17 deletions
diff --git a/src/plugins/pglist.h b/src/plugins/pglist.h
index 5541493..777b19c 100644
--- a/src/plugins/pglist.h
+++ b/src/plugins/pglist.h
@@ -69,25 +69,60 @@ GPluginModule **get_all_plugins(size_t *);
* Définitions des opérations appliquables à une catégories de greffons.
*/
-#define process_all_plugins_for(tp, cst, fc) \
- do \
- { \
- size_t __count; \
- GPluginModule **__list; \
- size_t __i; \
- __list = get_all_plugins(&__count); \
- for (__i = 0; __i < __count; __i++) \
- { \
- if (G_TYPE_CHECK_INSTANCE_TYPE(__list[__i], tp)) \
- fc(cst(__list[__i])); \
- unref_object(__list[__i]); \
- } \
- if (__list != NULL) \
- free(__list); \
- } \
+#define process_all_plugins_for(tp, cst, fc) \
+ do \
+ { \
+ size_t __count; \
+ GPluginModule **__list; \
+ size_t __i; \
+ GPluginModule *__pg; \
+ __list = get_all_plugins(&__count); \
+ for (__i = 0; __i < __count; __i++) \
+ { \
+ __pg = __list[__i]; \
+ if (G_TYPE_CHECK_INSTANCE_TYPE(__pg, tp)) \
+ fc(cst(__pg)); \
+ unref_object(__pg); \
+ } \
+ if (__list != NULL) \
+ free(__list); \
+ } \
while (0)
-
+#define accumulate_from_all_plugins(tp, cst, fc, atp, cnt) \
+ ({ \
+ atp *__acc_list; \
+ size_t __count; \
+ GPluginModule **__list; \
+ size_t __i; \
+ GPluginModule *__pg; \
+ size_t __tmp_count; \
+ atp *__tmp_list; \
+ *cnt = 0; \
+ __acc_list = NULL; \
+ __list = get_all_plugins(&__count); \
+ for (__i = 0; __i < __count; __i++) \
+ { \
+ __pg = __list[__i]; \
+ if (G_TYPE_CHECK_INSTANCE_TYPE(__pg, tp)) \
+ { \
+ __tmp_list = fc(cst(__pg), &__tmp_count); \
+ if (__tmp_list != NULL) \
+ { \
+ __acc_list = realloc(__acc_list, \
+ (*cnt + __tmp_count) * sizeof(atp)); \
+ memcpy(&__acc_list[*cnt], __tmp_list, \
+ __tmp_count * sizeof(atp)); \
+ *cnt += __tmp_count; \
+ free(__tmp_list); \
+ } \
+ } \
+ unref_object(__pg); \
+ } \
+ if (__list != NULL) \
+ free(__list); \
+ __acc_list; \
+ })