diff options
Diffstat (limited to 'src/input/detail/gen/gen_typeList.cpp')
-rw-r--r-- | src/input/detail/gen/gen_typeList.cpp | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/src/input/detail/gen/gen_typeList.cpp b/src/input/detail/gen/gen_typeList.cpp new file mode 100644 index 0000000..21056f9 --- /dev/null +++ b/src/input/detail/gen/gen_typeList.cpp @@ -0,0 +1,118 @@ +/* + # Copyright (c) 2009 - OpenSLX Project, Computer Center University of Freiburg + # + # This program is free software distributed under the GPL version 2. + # See http://openslx.org/COPYING + # + # If you have any feedback please consult http://openslx.org/feedback and + # send your suggestions, praise, or complaints to feedback@openslx.org + # + # General information about OpenSLX can be found at http://openslx.org/ + # -------------------------------------------------------------------------- + # detail/gen/gen_policyChain.cpp: + # - generate the input_policy::detail::TypeList class + # -------------------------------------------------------------------------- + */ + +#include <iostream> + +using namespace std; + +#define NUM_MAX_ENTRIES 16 + +int main(int, char**) +{ + int i; + + cout << "template<"; + for(i = 0; i < NUM_MAX_ENTRIES; i++) + { + if(i) + cout << ", "; + cout << "typename T" << i << " = void"; + } + cout << ">\nstruct TypeList {\n"; + cout << "typedef T0 head;\n"; + cout << "typedef TypeList<"; + for(i = 1; i < NUM_MAX_ENTRIES; i++) + { + if(i > 1) + cout << ", "; + cout << "T" << i; + } + cout << ", void > tail;\n"; + cout << "};\n"; + + // Contains: + cout << "template<typename Needle, typename Haystack>\n" + "struct Contains { static const int index = -1; static const bool value = false; };\n"; + + // specializations: + cout << "#ifndef DOXYGEN_RUNNING\n"; + for(i = 0; i < NUM_MAX_ENTRIES; i++) + { + int j; + + cout << "template<typename Needle"; + for(j = 0; j < NUM_MAX_ENTRIES; j++) + { + if(j == i) + continue; + cout << ", typename T" << j; + } + cout << ">\nstruct Contains<Needle, TypeList<"; + for(j = 0; j < NUM_MAX_ENTRIES; j++) + { + if(j) + cout << ", "; + if(j == i) + cout << "Needle"; + else + cout << "T" << j; + } + cout << "> >\n{ static const int index = " << i << "; static const bool value = true; };\n"; + } + cout << "#endif\n"; + + // Empty List: + cout << "typedef TypeList<"; + for(i = 0; i < NUM_MAX_ENTRIES; i++) + { + if(i) + cout << ", "; + cout << "void"; + } + cout << " > EmptyList;\n"; + + // Macros: + cout << "#define IMPLICIT_TYPE_LIST_PARAMS(prefix) "; + for(i = 0; i < NUM_MAX_ENTRIES; i++) + { + if(i) + cout << ", "; + cout << "typename prefix##" << i << " = void"; + } + cout << "\n"; + + cout << "#define IMPLICIT_TYPE_LIST_PARAMS_NODEFAULT(prefix) "; + for(i = 0; i < NUM_MAX_ENTRIES; i++) + { + if(i) + cout << ", "; + cout << "typename prefix##" << i; + } + cout << "\n"; + + cout << "#define IMPLICIT_TYPE_LIST_ARGS(prefix) "; + for(i = 0; i < NUM_MAX_ENTRIES; i++) + { + if(i) + cout << ", "; + cout << "prefix##" << i; + } + cout << "\n"; + + cout << "#define IMPLICIT_TYPE_LIST(prefix) ::input_policy::detail::TypeList<IMPLICIT_TYPE_LIST_ARGS(prefix) >\n"; + + return 0; +} |