31 #ifndef GWEN_DUMMY_EMPTY_ARG 34 # define GWEN_DUMMY_EMPTY_ARG 278 #define GWEN_TREE_ELEMENT(t) \ 279 GWEN_TREE_ELEMENT *_tree_element; 287 #define GWEN_TREE_FUNCTION_LIB_DEFS_CONST(t, pr, decl) \ 288 typedef GWEN_TREE t##_TREE; \ 290 decl t* pr##_Tree_GetFirst(const t##_TREE *l); \ 291 decl t* pr##_Tree_GetLast(const t##_TREE *l); \ 292 decl t* pr##_Tree_GetNext(const t *element); \ 293 decl t* pr##_Tree_GetPrevious(const t *element); \ 294 decl t* pr##_Tree_GetBelow(const t *element); \ 295 decl uint32_t pr##_Tree_GetCount(const t##_TREE *l); \ 296 decl int pr##_Tree_HasElement(const t##_TREE *l, const t *element); \ 297 decl t* pr##_Tree_GetFirstChild(const t *element); \ 298 decl t* pr##_Tree_GetLastChild(const t *element); \ 299 decl uint32_t pr##_Tree_GetChildrenCount(const t *element); \ 300 decl t* pr##_Tree_GetParent(const t *element); 303 #define GWEN_TREE_FUNCTION_LIB_DEFS_NOCONST(t, pr, decl) \ 304 typedef GWEN_TREE_ELEMENT t##_TREE_ELEMENT; \ 306 decl void pr##_Tree_Clear(t##_TREE *l); \ 307 decl t##_TREE* pr##_Tree_new(); \ 308 decl void pr##_Tree_free(t##_TREE *l); \ 309 decl void pr##_Tree_AddList(t##_TREE *dst, t##_TREE *l); \ 310 decl void pr##_Tree_Add(t##_TREE *list, t *element); \ 311 decl void pr##_Tree_Insert(t##_TREE *list, t *element); \ 312 decl void pr##_Tree_Del(t *element); \ 314 decl void pr##_Tree_AddChild(t *where, t *element); \ 315 decl void pr##_Tree_InsertChild(t *where, t *element); \ 317 decl int pr##_Tree_HasChildElement(const t *who, const t *element); \ 318 decl void pr##_Tree_ClearChildren(t *element); \ 321 #define GWEN_TREE_FUNCTION_DEFS_CONST(t, pr) \ 322 GWEN_TREE_FUNCTION_LIB_DEFS_CONST(t, pr, GWEN_DUMMY_EMPTY_ARG) 324 #define GWEN_TREE_FUNCTION_DEFS_NOCONST(t, pr) \ 325 GWEN_TREE_FUNCTION_LIB_DEFS_NOCONST(t, pr, GWEN_DUMMY_EMPTY_ARG) 375 #define GWEN_TREE_FUNCTION_LIB_DEFS(t, pr, decl) \ 376 GWEN_TREE_FUNCTION_LIB_DEFS_CONST(t, pr, decl) \ 377 GWEN_TREE_FUNCTION_LIB_DEFS_NOCONST(t, pr, decl) 384 #define GWEN_TREE_FUNCTION_DEFS(t, pr) \ 385 GWEN_TREE_FUNCTION_LIB_DEFS(t, pr, GWEN_DUMMY_EMPTY_ARG) 393 #define GWEN_TREE_FUNCTIONS(t, pr) \ 395 void pr##_Tree_Add(t##_TREE *l, t *element) { \ 397 assert(element->_tree_element);\ 398 GWEN_Tree_Add(l, element->_tree_element); \ 401 void pr##_Tree_AddList(t##_TREE *dst, t##_TREE *l) { \ 402 GWEN_Tree_AddList(dst, l); \ 405 void pr##_Tree_Insert(t##_TREE *l, t *element) { \ 407 assert(element->_tree_element);\ 408 GWEN_Tree_Insert(l, element->_tree_element); \ 411 void pr##_Tree_Del(t *element){ \ 413 assert(element->_tree_element);\ 414 GWEN_Tree_Del(element->_tree_element); \ 417 t* pr##_Tree_GetFirst(const t##_TREE *l) { \ 418 if (l) return (t*)GWEN_Tree_GetFirst(l);\ 422 t* pr##_Tree_GetLast(const t##_TREE *l) { \ 423 if (l) return (t*) GWEN_Tree_GetLast(l);\ 427 void pr##_Tree_Clear(t##_TREE *l) { \ 429 while( (el=GWEN_Tree_GetFirst(l)) ) {\ 431 pr##_Tree_ClearChildren(el); \ 436 int pr##_Tree_HasElement(const t##_TREE *l, const t *element) { \ 438 el=(t*)GWEN_Tree_GetFirst(l); \ 442 el=(const t*)GWEN_TreeElement_GetBelow(el->_tree_element); \ 447 t##_TREE* pr##_Tree_new(){\ 448 return (t##_TREE*)GWEN_Tree_new(); \ 451 void pr##_Tree_free(t##_TREE *l) {\ 458 t* pr##_Tree_GetNext(const t *element) { \ 460 assert(element->_tree_element);\ 461 return (t*)GWEN_TreeElement_GetNext(element->_tree_element);\ 464 t* pr##_Tree_GetPrevious(const t *element) { \ 466 assert(element->_tree_element);\ 467 return (t*)GWEN_TreeElement_GetPrevious(element->_tree_element);\ 470 t* pr##_Tree_GetBelow(const t *element) { \ 472 assert(element->_tree_element);\ 473 return (t*)GWEN_TreeElement_GetBelow(element->_tree_element);\ 476 uint32_t pr##_Tree_GetCount(const t##_TREE *l){\ 477 return GWEN_Tree_GetCount(l);\ 480 int pr##_Tree_HasChildElement(const t *who, const t *element) { \ 482 el=(const t*)GWEN_TreeElement_GetFirstChild(who->_tree_element); \ 486 el=(const t*)GWEN_TreeElement_GetNext(el->_tree_element); \ 491 void pr##_Tree_AddChild(t *where, t *element) { \ 493 assert(where->_tree_element);\ 495 assert(element->_tree_element);\ 496 GWEN_Tree_AddChild(where->_tree_element, element->_tree_element); \ 499 void pr##_Tree_InsertChild(t *where, t *element) { \ 501 assert(where->_tree_element);\ 503 assert(element->_tree_element);\ 504 GWEN_Tree_InsertChild(where->_tree_element, element->_tree_element); \ 507 void pr##_Tree_ClearChildren(t *element) { \ 509 while( (c=GWEN_TreeElement_GetFirstChild(element->_tree_element)) ) {\ 510 pr##_Tree_ClearChildren(c);\ 516 t* pr##_Tree_GetFirstChild(const t *element) { \ 518 assert(element->_tree_element);\ 519 return (t*)GWEN_TreeElement_GetFirstChild(element->_tree_element);\ 522 t* pr##_Tree_GetLastChild(const t *element) { \ 524 assert(element->_tree_element);\ 525 return (t*)GWEN_TreeElement_GetLastChild(element->_tree_element);\ 528 uint32_t pr##_Tree_GetChildrenCount(const t *element){\ 529 return GWEN_TreeElement_GetChildrenCount(element->_tree_element);\ 532 t* pr##_Tree_GetParent(const t *element) { \ 534 assert(element->_tree_element);\ 535 return (t*)GWEN_TreeElement_GetParent(element->_tree_element);\ 545 #define GWEN_TREE_INIT(t, element) \ 546 element->_tree_element=GWEN_TreeElement_new(element); 554 #define GWEN_TREE_FINI(t, element) \ 555 if (element && element->_tree_element) { \ 556 GWEN_TreeElement_free(element->_tree_element); \ 557 element->_tree_element=0; \ GWENHYWFAR_API void * GWEN_TreeElement_GetLastChild(const GWEN_TREE_ELEMENT *el)
struct GWEN_TREE_ELEMENT GWEN_TREE_ELEMENT
GWENHYWFAR_API void * GWEN_Tree_GetFirst(const GWEN_TREE *l)
GWENHYWFAR_API void * GWEN_TreeElement_GetParent(const GWEN_TREE_ELEMENT *el)
GWENHYWFAR_API void GWEN_Tree_AddList(GWEN_TREE *dest, GWEN_TREE *l)
GWENHYWFAR_API int GWEN_Tree_GetCount(const GWEN_TREE *l)
GWENHYWFAR_API void GWEN_Tree_free(GWEN_TREE *l)
GWENHYWFAR_API void * GWEN_TreeElement_GetFirstChild(const GWEN_TREE_ELEMENT *el)
GWENHYWFAR_API void GWEN_Tree_InsertChild(GWEN_TREE_ELEMENT *where, GWEN_TREE_ELEMENT *el)
GWENHYWFAR_API void * GWEN_Tree_GetLast(const GWEN_TREE *l)
GWENHYWFAR_API void GWEN_Tree_Del(GWEN_TREE_ELEMENT *el)
GWENHYWFAR_API void * GWEN_TreeElement_GetNext(const GWEN_TREE_ELEMENT *el)
GWENHYWFAR_API void * GWEN_TreeElement_GetPrevious(const GWEN_TREE_ELEMENT *el)
GWENHYWFAR_API GWEN_TREE_ELEMENT * GWEN_TreeElement_new(void *d)
GWENHYWFAR_API void GWEN_Tree_AddChild(GWEN_TREE_ELEMENT *where, GWEN_TREE_ELEMENT *el)
GWENHYWFAR_API uint32_t GWEN_TreeElement_GetChildrenCount(const GWEN_TREE_ELEMENT *el)
GWENHYWFAR_API GWEN_TREE * GWEN_Tree_new(void)
GWENHYWFAR_API void GWEN_Tree_Insert(GWEN_TREE *l, GWEN_TREE_ELEMENT *el)
struct GWEN_TREE GWEN_TREE
GWENHYWFAR_API void * GWEN_TreeElement_GetBelow(const GWEN_TREE_ELEMENT *el)
GWENHYWFAR_API void GWEN_TreeElement_free(GWEN_TREE_ELEMENT *el)
GWENHYWFAR_API void GWEN_Tree_Add(GWEN_TREE *l, GWEN_TREE_ELEMENT *el)