|
|
@@ -18,77 +18,63 @@ |
|
|
|
* * TEMPLATE_FLAGS is set to a list of toggle flags, a binary OR of: |
|
|
|
* - SET_FLAG_GRAY |
|
|
|
* - SET_FLAG_WRAP |
|
|
|
* - SET_FLAG_8BIT |
|
|
|
* * TEMPLATE_FILE is set to the template file. The following macros |
|
|
|
* will be defined when including it. Their value depend on the flags |
|
|
|
* specified above: |
|
|
|
* - FLAG_GRAY is set to 0 or 1 |
|
|
|
* - FLAG_WRAP is set to 0 or 1 |
|
|
|
* - SUFFIX(x) expands x by adding relevant information, eg. x##_gray_wrap |
|
|
|
* - FLAG_8BIT is set to 0 or 1 |
|
|
|
* - T(x) expands x by adding relevant information, eg. x##_gray_wrap |
|
|
|
*/ |
|
|
|
|
|
|
|
#if !defined FLAG_GRAY |
|
|
|
# if (TEMPLATE_FLAGS) & SET_FLAG_GRAY |
|
|
|
# define FLAG_GRAY 1 |
|
|
|
# define T_GRAY(x) CAT(x, _gray) |
|
|
|
# include __FILE__ |
|
|
|
# undef FLAG_GRAY |
|
|
|
# undef T_GRAY |
|
|
|
# endif |
|
|
|
# define FLAG_GRAY 0 |
|
|
|
# define T_GRAY(x) x |
|
|
|
# include __FILE__ |
|
|
|
# undef FLAG_GRAY |
|
|
|
# undef T_GRAY |
|
|
|
|
|
|
|
#elif !defined FLAG_WRAP |
|
|
|
# if (TEMPLATE_FLAGS) & SET_FLAG_WRAP |
|
|
|
# define FLAG_WRAP 1 |
|
|
|
# define T_WRAP(x) CAT(x, _wrap) |
|
|
|
# include __FILE__ |
|
|
|
# undef FLAG_WRAP |
|
|
|
# undef T_WRAP |
|
|
|
# endif |
|
|
|
# define FLAG_WRAP 0 |
|
|
|
# define T_WRAP(x) x |
|
|
|
# include __FILE__ |
|
|
|
# undef FLAG_WRAP |
|
|
|
# undef T_WRAP |
|
|
|
|
|
|
|
#elif !defined FLAG_8BIT |
|
|
|
# if (TEMPLATE_FLAGS) & SET_FLAG_8BIT |
|
|
|
# define FLAG_8BIT 1 |
|
|
|
# define T_8BIT(x) CAT(x, _8bit) |
|
|
|
# include __FILE__ |
|
|
|
# undef FLAG_8BIT |
|
|
|
# undef T_8BIT |
|
|
|
# endif |
|
|
|
# define FLAG_8BIT 0 |
|
|
|
# define T_8BIT(x) x |
|
|
|
# include __FILE__ |
|
|
|
# undef FLAG_8BIT |
|
|
|
# undef T_8BIT |
|
|
|
|
|
|
|
#else |
|
|
|
/* FIXME: I couldn't find a way to do this in one preprocessor pass, |
|
|
|
* too many levels of indirection seem to be needed. */ |
|
|
|
# if FLAG_8BIT |
|
|
|
# if FLAG_WRAP |
|
|
|
# if FLAG_GRAY |
|
|
|
# define SUFFIX(x) x##_gray_wrap_8bit |
|
|
|
# else |
|
|
|
# define SUFFIX(x) x##_wrap_8bit |
|
|
|
# endif |
|
|
|
# else |
|
|
|
# if FLAG_GRAY |
|
|
|
# define SUFFIX(x) x##_gray_8bit |
|
|
|
# else |
|
|
|
# define SUFFIX(x) x##_8bit |
|
|
|
# endif |
|
|
|
# endif |
|
|
|
# else |
|
|
|
# if FLAG_WRAP |
|
|
|
# if FLAG_GRAY |
|
|
|
# define SUFFIX(x) x##_gray_wrap |
|
|
|
# else |
|
|
|
# define SUFFIX(x) x##_wrap |
|
|
|
# endif |
|
|
|
# else |
|
|
|
# if FLAG_GRAY |
|
|
|
# define SUFFIX(x) x##_gray |
|
|
|
# else |
|
|
|
# define SUFFIX(x) x |
|
|
|
# endif |
|
|
|
# endif |
|
|
|
# endif |
|
|
|
# define CAT(x, y) x ## y |
|
|
|
# define T(x) T_8BIT(T_WRAP(T_GRAY(x))) |
|
|
|
# include TEMPLATE_FILE |
|
|
|
# undef SUFFIX |
|
|
|
# undef CAT |
|
|
|
# undef S |
|
|
|
#endif |
|
|
|
|