You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

81 regels
2.1 KiB

  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. /* pipi_template.h: the magic template preprocessing file
  15. *
  16. * Define the following macros before including this file:
  17. * * TEMPLATE_FLAGS is set to a list of toggle flags, a binary OR of:
  18. * - SET_FLAG_GRAY
  19. * - SET_FLAG_WRAP
  20. * - SET_FLAG_8BIT
  21. * * TEMPLATE_FILE is set to the template file. The following macros
  22. * will be defined when including it. Their value depend on the flags
  23. * specified above:
  24. * - FLAG_GRAY is set to 0 or 1
  25. * - FLAG_WRAP is set to 0 or 1
  26. * - FLAG_8BIT is set to 0 or 1
  27. * - T(x) expands x by adding relevant information, eg. x##_gray_wrap
  28. */
  29. #if !defined FLAG_GRAY
  30. # if (TEMPLATE_FLAGS) & SET_FLAG_GRAY
  31. # define FLAG_GRAY 1
  32. # define T_GRAY(x) CAT(x, _gray)
  33. # include __FILE__
  34. # undef FLAG_GRAY
  35. # undef T_GRAY
  36. # endif
  37. # define FLAG_GRAY 0
  38. # define T_GRAY(x) x
  39. # include __FILE__
  40. # undef FLAG_GRAY
  41. # undef T_GRAY
  42. #elif !defined FLAG_WRAP
  43. # if (TEMPLATE_FLAGS) & SET_FLAG_WRAP
  44. # define FLAG_WRAP 1
  45. # define T_WRAP(x) CAT(x, _wrap)
  46. # include __FILE__
  47. # undef FLAG_WRAP
  48. # undef T_WRAP
  49. # endif
  50. # define FLAG_WRAP 0
  51. # define T_WRAP(x) x
  52. # include __FILE__
  53. # undef FLAG_WRAP
  54. # undef T_WRAP
  55. #elif !defined FLAG_8BIT
  56. # if (TEMPLATE_FLAGS) & SET_FLAG_8BIT
  57. # define FLAG_8BIT 1
  58. # define T_8BIT(x) CAT(x, _8bit)
  59. # include __FILE__
  60. # undef FLAG_8BIT
  61. # undef T_8BIT
  62. # endif
  63. # define FLAG_8BIT 0
  64. # define T_8BIT(x) x
  65. # include __FILE__
  66. # undef FLAG_8BIT
  67. # undef T_8BIT
  68. #else
  69. # define CAT(x, y) x ## y
  70. # define T(x) T_8BIT(T_WRAP(T_GRAY(x)))
  71. # include TEMPLATE_FILE
  72. # undef CAT
  73. # undef S
  74. #endif