Go to the documentation of this file.
29 #include <gwenhywfar/gwenhywfarapi.h>
30 #include <gwenhywfar/types.h>
34 #ifndef GWEN_DUMMY_EMPTY_ARG
37 # define GWEN_DUMMY_EMPTY_ARG
258 #define GWEN_LIST_ELEMENT(t) \
259 GWEN_LIST1_ELEMENT *_list1_element;
267 #define GWEN_LIST_FUNCTION_LIB_DEFS_CONST(t, pr, decl) \
268 typedef GWEN_LIST1 t##_LIST; \
269 typedef int GWENHYWFAR_CB (*t##_LIST_SORT_FN)(const t *a, const t *b, int ascending); \
272 decl t* pr##_List_First(const t##_LIST *l); \
273 decl t* pr##_List_Last(const t##_LIST *l); \
274 decl t* pr##_List_Next(const t *element); \
275 decl t* pr##_List_Previous(const t *element); \
276 decl uint32_t pr##_List_GetCount(const t##_LIST *l); \
277 decl int pr##_List_HasElement(const t##_LIST *l, const t *element); \
278 decl t##_LIST_SORT_FN pr##_List_SetSortFn(t##_LIST *l, t##_LIST_SORT_FN fn); \
279 decl void pr##_List_Sort(t##_LIST *l, int ascending);
282 #define GWEN_LIST_FUNCTION_LIB_DEFS_NOCONST(t, pr, decl) \
283 typedef GWEN_LIST1_ELEMENT t##_LIST_ELEMENT; \
285 decl void pr##_List_Clear(t##_LIST *l); \
286 decl t##_LIST* pr##_List_new(); \
287 decl void pr##_List_free(t##_LIST *l); \
288 decl int pr##_List_AddList(t##_LIST *dst, t##_LIST *l); \
289 decl int pr##_List_Add(t *element, t##_LIST *list); \
290 decl int pr##_List_Insert(t *element, t##_LIST *list); \
291 decl int pr##_List_Del(t *element); \
294 #define GWEN_LIST_FUNCTION_DEFS_CONST(t, pr) \
295 GWEN_LIST_FUNCTION_LIB_DEFS_CONST(t, pr, GWEN_DUMMY_EMPTY_ARG)
297 #define GWEN_LIST_FUNCTION_DEFS_NOCONST(t, pr) \
298 GWEN_LIST_FUNCTION_LIB_DEFS_NOCONST(t, pr, GWEN_DUMMY_EMPTY_ARG)
349 #define GWEN_LIST_FUNCTION_LIB_DEFS(t, pr, decl) \
350 GWEN_LIST_FUNCTION_LIB_DEFS_CONST(t, pr, decl) \
351 GWEN_LIST_FUNCTION_LIB_DEFS_NOCONST(t, pr, decl)
358 #define GWEN_LIST_FUNCTION_DEFS(t, pr) \
359 GWEN_LIST_FUNCTION_LIB_DEFS(t, pr, GWEN_DUMMY_EMPTY_ARG)
367 #define GWEN_LIST_FUNCTIONS(t, pr) \
369 int pr##_List_Add(t *element, t##_LIST *l) { \
370 return GWEN_List1_Add(l, element->_list1_element); \
373 int pr##_List_AddList(t##_LIST *dst, t##_LIST *l) { \
374 return GWEN_List1_AddList(dst, l); \
377 int pr##_List_Insert(t *element, t##_LIST *l) { \
378 return GWEN_List1_Insert(l, element->_list1_element); \
381 int pr##_List_Del(t *element){ \
382 return GWEN_List1_Del(element->_list1_element); \
385 t* pr##_List_First(const t##_LIST *l) { \
386 if (l) return (t*)GWEN_List1_GetFirst(l);\
390 t* pr##_List_Last(const t##_LIST *l) { \
391 if (l) return (t*) GWEN_List1_GetLast(l);\
395 void pr##_List_Clear(t##_LIST *l) { \
397 while( (el=GWEN_List1_GetFirst(l)) ) {\
403 int pr##_List_HasElement(const t##_LIST *l, const t *element) { \
405 el=(t*)GWEN_List1_GetFirst(l); \
409 el=(const t*)GWEN_List1Element_GetNext(el->_list1_element); \
414 t##_LIST* pr##_List_new(){\
415 return (t##_LIST*)GWEN_List1_new(); \
418 void pr##_List_free(t##_LIST *l) {\
421 GWEN_List1_free(l); \
425 t* pr##_List_Next(const t *element) { \
426 return (t*)GWEN_List1Element_GetNext(element->_list1_element);\
429 t* pr##_List_Previous(const t *element) { \
430 return (t*)GWEN_List1Element_GetPrevious(element->_list1_element);\
433 uint32_t pr##_List_GetCount(const t##_LIST *l){\
434 return GWEN_List1_GetCount(l);\
437 t##_LIST_SORT_FN pr##_List_SetSortFn(t##_LIST *l, t##_LIST_SORT_FN fn) { \
438 return (t##_LIST_SORT_FN) GWEN_List1_SetSortFn(l, (GWEN_LIST1_SORT_FN) fn); \
441 void pr##_List_Sort(t##_LIST *l, int ascending){\
442 GWEN_List1_Sort(l, ascending);\
450 #define GWEN_LIST_INIT(t, element) \
451 element->_list1_element=GWEN_List1Element_new(element);
459 #define GWEN_LIST_FINI(t, element) \
460 if (element && element->_list1_element) { \
461 GWEN_List1Element_free(element->_list1_element); \
462 element->_list1_element=0; \