From d9929aadd369bb2290841e3e16f8636c4d87f430 Mon Sep 17 00:00:00 2001 From: Marrub Date: Mon, 17 Oct 2016 19:12:31 -0400 Subject: [PATCH] LinkList: Add Lth_ListForEach and Lth_ListFor This uses some extensions David JUST implemented into GDCC. --- lithos_c/inc/Lth_callback.h | 5 +++++ lithos_c/inc/Lth_linklist.h | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/lithos_c/inc/Lth_callback.h b/lithos_c/inc/Lth_callback.h index c6af274..44bcdcc 100644 --- a/lithos_c/inc/Lth_callback.h +++ b/lithos_c/inc/Lth_callback.h @@ -46,6 +46,11 @@ Lth_X(SIGUPDATE , update, void, struct Lth_Context *, struct Lth_Control *) (name).data[cbIter - 1](__VA_ARGS__); \ } \ while(0) +#define Lth_ControlCall(ctrl, name, ...) \ + Lth_ListForEach(Lth_Control *owner, ctrl->descendants) \ + Lth_Call(owner->cb.name, __VA_ARGS__); \ + \ + Lth_Call(ctrl->cb.name, __VA_ARGS__) //----------------------------------------------------------------------------| diff --git a/lithos_c/inc/Lth_linklist.h b/lithos_c/inc/Lth_linklist.h index 53c3824..f3bc420 100644 --- a/lithos_c/inc/Lth_linklist.h +++ b/lithos_c/inc/Lth_linklist.h @@ -17,6 +17,14 @@ #include +#define Lth_ListForEach(tmpv, lst) \ + for(Lth_LinkList *list = (lst); list; list = list->next) \ + __with(tmpv = list->owner;) +#define Lth_ListFor(tmpv, lst) \ + for(Lth_LinkList *list = (lst); list;) \ + __with(Lth_LinkList *next = list->next, **prev = list->prev; \ + tmpv = list->owner;) + //----------------------------------------------------------------------------| // Type Definitions |