| 1 | /* |
|---|
| 2 | * libpipi Pathetic image processing interface library |
|---|
| 3 | * Copyright (c) 2004-2008 Sam Hocevar <sam@zoy.org> |
|---|
| 4 | * All Rights Reserved |
|---|
| 5 | * |
|---|
| 6 | * $Id$ |
|---|
| 7 | * |
|---|
| 8 | * This library is free software. It comes without any warranty, to |
|---|
| 9 | * the extent permitted by applicable law. You can redistribute it |
|---|
| 10 | * and/or modify it under the terms of the Do What The Fuck You Want |
|---|
| 11 | * To Public License, Version 2, as published by Sam Hocevar. See |
|---|
| 12 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
|---|
| 13 | */ |
|---|
| 14 | |
|---|
| 15 | /* pipi_template.h: the magic template preprocessing file |
|---|
| 16 | * |
|---|
| 17 | * Define the following macros before including this file: |
|---|
| 18 | * * TEMPLATE_FLAGS is set to a list of toggle flags, a binary OR of: |
|---|
| 19 | * - SET_FLAG_GRAY |
|---|
| 20 | * - SET_FLAG_WRAP |
|---|
| 21 | * - SET_FLAG_8BIT |
|---|
| 22 | * * TEMPLATE_FILE is set to the template file. The following macros |
|---|
| 23 | * will be defined when including it. Their value depend on the flags |
|---|
| 24 | * specified above: |
|---|
| 25 | * - FLAG_GRAY is set to 0 or 1 |
|---|
| 26 | * - FLAG_WRAP is set to 0 or 1 |
|---|
| 27 | * - FLAG_8BIT is set to 0 or 1 |
|---|
| 28 | * - T(x) expands x by adding relevant information, eg. x##_gray_wrap |
|---|
| 29 | */ |
|---|
| 30 | |
|---|
| 31 | #if !defined FLAG_GRAY |
|---|
| 32 | # if (TEMPLATE_FLAGS) & SET_FLAG_GRAY |
|---|
| 33 | # define FLAG_GRAY 1 |
|---|
| 34 | # define T_GRAY(x) CAT(x, _gray) |
|---|
| 35 | # include __FILE__ |
|---|
| 36 | # undef FLAG_GRAY |
|---|
| 37 | # undef T_GRAY |
|---|
| 38 | # endif |
|---|
| 39 | # define FLAG_GRAY 0 |
|---|
| 40 | # define T_GRAY(x) x |
|---|
| 41 | # include __FILE__ |
|---|
| 42 | # undef FLAG_GRAY |
|---|
| 43 | # undef T_GRAY |
|---|
| 44 | |
|---|
| 45 | #elif !defined FLAG_WRAP |
|---|
| 46 | # if (TEMPLATE_FLAGS) & SET_FLAG_WRAP |
|---|
| 47 | # define FLAG_WRAP 1 |
|---|
| 48 | # define T_WRAP(x) CAT(x, _wrap) |
|---|
| 49 | # include __FILE__ |
|---|
| 50 | # undef FLAG_WRAP |
|---|
| 51 | # undef T_WRAP |
|---|
| 52 | # endif |
|---|
| 53 | # define FLAG_WRAP 0 |
|---|
| 54 | # define T_WRAP(x) x |
|---|
| 55 | # include __FILE__ |
|---|
| 56 | # undef FLAG_WRAP |
|---|
| 57 | # undef T_WRAP |
|---|
| 58 | |
|---|
| 59 | #elif !defined FLAG_8BIT |
|---|
| 60 | # if (TEMPLATE_FLAGS) & SET_FLAG_8BIT |
|---|
| 61 | # define FLAG_8BIT 1 |
|---|
| 62 | # define T_8BIT(x) CAT(x, _8bit) |
|---|
| 63 | # include __FILE__ |
|---|
| 64 | # undef FLAG_8BIT |
|---|
| 65 | # undef T_8BIT |
|---|
| 66 | # endif |
|---|
| 67 | # define FLAG_8BIT 0 |
|---|
| 68 | # define T_8BIT(x) x |
|---|
| 69 | # include __FILE__ |
|---|
| 70 | # undef FLAG_8BIT |
|---|
| 71 | # undef T_8BIT |
|---|
| 72 | |
|---|
| 73 | #else |
|---|
| 74 | # define CAT(x, y) x ## y |
|---|
| 75 | # define T(x) T_8BIT(T_WRAP(T_GRAY(x))) |
|---|
| 76 | # include TEMPLATE_FILE |
|---|
| 77 | # undef CAT |
|---|
| 78 | # undef S |
|---|
| 79 | #endif |
|---|
| 80 | |
|---|