gwenhywfar
4.3.3
|
This file contains some macros concerning lists and inheritance. More...
#include <gwenhywfar/gwenhywfarapi.h>
#include <gwenhywfar/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <gwenhywfar/memory.h>
#include <gwenhywfar/list1.h>
Go to the source code of this file.
Macros | |
#define | GWEN_LIST_ADD(typ, sr, head) |
#define | GWEN_LIST_DEL(typ, sr, head) |
#define | GWEN_LIST_INSERT(typ, sr, head) |
This file contains some macros concerning lists and inheritance.
FIRST: Yes, I DO know, macros are very, very bad. When writing these macros I spent much time debugging them, because the compiler is not much of a help here. The validity of a macro is only checked upon invocation, so if you never use a macro it will never be checked.
However, these macros do work just fine and they make some tasks much easier to handle.
The reason for using macros is the lack of templates in C. When writing Gwenhywfar I often faced the fact that some functions always appear with many structs defined. The only difference is the name of those functions and the type of the arguments.
The best example is the handling of lists of structs. In most listable structs there was a variable called next which pointed to the next object in the list. There were also functions like TYPE_next(), TYPE_add(), TYPE_del() etc for list handling. Whenever I improved the list mechanism I had to change ALL code files in order to improve them all.
These macros are now used to facilitate improvements in list or inheritance handling code in C.
NOTE: Please do not change these macros unless you know exactly what you are doing! Bugs in the macros will most probably lead to nearly undebuggable results in code files using them.
You have been warned ;-)
Definition in file misc.h.
#define GWEN_LIST_ADD | ( | typ, | |
sr, | |||
head | |||
) |
Definition at line 82 of file misc.h.
Referenced by GWEN_Logger_AddLogger(), GWEN_MemoryDebug_Decrement(), GWEN_MemoryDebug_Increment(), GWEN_MsgEngine_AddTrustInfo(), and GWEN_XMLProperty_add().
#define GWEN_LIST_DEL | ( | typ, | |
sr, | |||
head | |||
) |
Definition at line 116 of file misc.h.
Referenced by GWEN_LoggerDomain_Del(), and GWEN_XMLProperty_del().
#define GWEN_LIST_INSERT | ( | typ, | |
sr, | |||
head | |||
) |
Definition at line 100 of file misc.h.
Referenced by GWEN_LoggerDomain_Add(), and GWEN_XMLProperty_insert().