/* * libpipi Proper image processing implementation library * Copyright (c) 2004-2008 Sam Hocevar * All Rights Reserved * * $Id$ * * This library is free software. It comes without any warranty, to * the extent permitted by applicable law. You can redistribute it * and/or modify it under the terms of the Do What The Fuck You Want * To Public License, Version 2, as published by Sam Hocevar. See * http://sam.zoy.org/wtfpl/COPYING for more details. */ /* pipi_template.h: the magic template preprocessing file * * Define the following macros before including this file: * * TEMPLATE_FLAGS is set to a list of toggle flags, a binary OR of: * - SET_FLAG_GRAY * - SET_FLAG_WRAP * * 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 */ #if !defined FLAG_GRAY # if (TEMPLATE_FLAGS) & SET_FLAG_GRAY # define FLAG_GRAY 1 # include __FILE__ # undef FLAG_GRAY # endif # define FLAG_GRAY 0 # include __FILE__ # undef FLAG_GRAY #elif !defined FLAG_WRAP # if (TEMPLATE_FLAGS) & SET_FLAG_WRAP # define FLAG_WRAP 1 # include __FILE__ # undef FLAG_WRAP # endif # define FLAG_WRAP 0 # include __FILE__ # undef FLAG_WRAP #elif !defined FLAG_8BIT # if (TEMPLATE_FLAGS) & SET_FLAG_8BIT # define FLAG_8BIT 1 # include __FILE__ # undef FLAG_8BIT # endif # define FLAG_8BIT 0 # include __FILE__ # undef FLAG_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 # include TEMPLATE_FILE # undef SUFFIX #endif