From 668f77010f72fd251b4c6f14bb10ffebff686dff Mon Sep 17 00:00:00 2001 From: Marrub Date: Wed, 19 Oct 2016 10:00:41 -0400 Subject: [PATCH] Types: Add Lth_Vector macro --- lithos_c/inc/Lth_callback.h | 4 +++- lithos_c/inc/Lth_types.h | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lithos_c/inc/Lth_callback.h b/lithos_c/inc/Lth_callback.h index ef58fa1..b72758e 100644 --- a/lithos_c/inc/Lth_callback.h +++ b/lithos_c/inc/Lth_callback.h @@ -30,6 +30,8 @@ Lth_X(SIGUPDATE , update, void, struct Lth_Control *) #elif !defined(lithos3__Lth_callback_h) #define lithos3__Lth_callback_h +#include "Lth_types.h" + #define Lth_Callback(name) ((Lth_Callback_t)(name)) #define Lth_Call(name, ...) \ do \ @@ -70,7 +72,7 @@ typedef void (*Lth_Callback_t)(void); typedef struct Lth_CallbackSet { #define Lth_X(sig, name, ret, ...) \ - struct { Lth_##sig##_t *data; size_t size; } name; + Lth_Vector(Lth_##sig##_t) name; #include "Lth_callback.h" } Lth_CallbackSet; diff --git a/lithos_c/inc/Lth_types.h b/lithos_c/inc/Lth_types.h index f6fdb9f..e0b7866 100644 --- a/lithos_c/inc/Lth_types.h +++ b/lithos_c/inc/Lth_types.h @@ -16,6 +16,10 @@ #define Lth_Inherits(name) [[__anonymous]] name _super #define Lth_Mixin(name) [[__anonymous]] name _##name +#define Lth_Vector(type) struct { type *data; size_t size; } +#define Lth_VectorForEach(tmpv, vec) \ + for(tmpv = (vec).data; tmpv != (vec).data + (vec).size; tmpv++) + // Type Definitions ----------------------------------------------------------|