Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

95 linhas
2.5 KiB

  1. /*
  2. * libpipi Proper image processing implementation 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. * * TEMPLATE_FILE is set to the template file. The following macros
  21. * will be defined when including it. Their value depend on the flags
  22. * specified above:
  23. * - FLAG_GRAY is set to 0 or 1
  24. * - FLAG_WRAP is set to 0 or 1
  25. * - SUFFIX(x) expands x by adding relevant information, eg. x##_gray_wrap
  26. */
  27. #if !defined FLAG_GRAY
  28. # if (TEMPLATE_FLAGS) & SET_FLAG_GRAY
  29. # define FLAG_GRAY 1
  30. # include __FILE__
  31. # undef FLAG_GRAY
  32. # endif
  33. # define FLAG_GRAY 0
  34. # include __FILE__
  35. # undef FLAG_GRAY
  36. #elif !defined FLAG_WRAP
  37. # if (TEMPLATE_FLAGS) & SET_FLAG_WRAP
  38. # define FLAG_WRAP 1
  39. # include __FILE__
  40. # undef FLAG_WRAP
  41. # endif
  42. # define FLAG_WRAP 0
  43. # include __FILE__
  44. # undef FLAG_WRAP
  45. #elif !defined FLAG_8BIT
  46. # if (TEMPLATE_FLAGS) & SET_FLAG_8BIT
  47. # define FLAG_8BIT 1
  48. # include __FILE__
  49. # undef FLAG_8BIT
  50. # endif
  51. # define FLAG_8BIT 0
  52. # include __FILE__
  53. # undef FLAG_8BIT
  54. #else
  55. /* FIXME: I couldn't find a way to do this in one preprocessor pass,
  56. * too many levels of indirection seem to be needed. */
  57. # if FLAG_8BIT
  58. # if FLAG_WRAP
  59. # if FLAG_GRAY
  60. # define SUFFIX(x) x##_gray_wrap_8bit
  61. # else
  62. # define SUFFIX(x) x##_wrap_8bit
  63. # endif
  64. # else
  65. # if FLAG_GRAY
  66. # define SUFFIX(x) x##_gray_8bit
  67. # else
  68. # define SUFFIX(x) x##_8bit
  69. # endif
  70. # endif
  71. # else
  72. # if FLAG_WRAP
  73. # if FLAG_GRAY
  74. # define SUFFIX(x) x##_gray_wrap
  75. # else
  76. # define SUFFIX(x) x##_wrap
  77. # endif
  78. # else
  79. # if FLAG_GRAY
  80. # define SUFFIX(x) x##_gray
  81. # else
  82. # define SUFFIX(x) x
  83. # endif
  84. # endif
  85. # endif
  86. # include TEMPLATE_FILE
  87. # undef SUFFIX
  88. #endif