Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 1 | |
| 2 | // (C) Copyright Tobias Schwinger |
| 3 | // |
| 4 | // Use modification and distribution are subject to the boost Software License, |
| 5 | // Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt). |
| 6 | |
| 7 | //------------------------------------------------------------------------------ |
| 8 | |
| 9 | // no include guards, this file is intended for multiple inclusion |
| 10 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 11 | #ifndef NDNBOOST_FT_PREPROCESSING_MODE |
| 12 | // input: NDNBOOST_FT_mfp 0 or 1 <=> member function pointer? |
| 13 | // input: NDNBOOST_FT_type_name NDNBOOST_FT_type --> "R (* ..._type_name)()" (pass2) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 14 | #endif |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 15 | // input: NDNBOOST_FT_syntax type macro to use |
| 16 | // input: NDNBOOST_FT_cc empty or cc specifier |
| 17 | // input: NDNBOOST_FT_ell empty or "..." |
| 18 | // input: NDNBOOST_FT_cv empty or cv qualifiers |
| 19 | // input: NDNBOOST_FT_flags single decimal integer encoding the flags |
| 20 | // output: NDNBOOST_FT_n number of component types (arity+1) |
| 21 | // output: NDNBOOST_FT_arity current arity |
| 22 | // output: NDNBOOST_FT_type macro that expands to the type |
| 23 | // output: NDNBOOST_FT_tplargs(p) template arguments with given prefix |
| 24 | // output: NDNBOOST_FT_params(p) parameters with given prefix |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 25 | |
| 26 | #ifdef __WAVE__ |
| 27 | # pragma wave option(preserve: 0) |
| 28 | #endif |
| 29 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 30 | #ifndef NDNBOOST_FT_ARITY_LOOP_IS_ITERATING |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 31 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 32 | # define NDNBOOST_FT_AL_PREPROCESSED \ |
| 33 | NDNBOOST_FT_AL_FILE(NDNBOOST_FT_al_path,NDNBOOST_FT_FROM_ARITY,NDNBOOST_FT_mfp) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 34 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 35 | # define NDNBOOST_FT_AL_FILE(base_path,max_arity,mfp) \ |
| 36 | NDNBOOST_FT_AL_FILE_I(base_path,max_arity,mfp) |
| 37 | # define NDNBOOST_FT_AL_FILE_I(base_path,max_arity,mfp) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 38 | <base_path/arity ## max_arity ## _ ## mfp.hpp> |
| 39 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 40 | # if !defined(NDNBOOST_FT_PREPROCESSING_MODE) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 41 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 42 | # if NDNBOOST_FT_MAX_ARITY < 10 |
| 43 | # define NDNBOOST_FT_FROM_ARITY 0 |
| 44 | # elif NDNBOOST_FT_MAX_ARITY < 20 |
| 45 | # define NDNBOOST_FT_FROM_ARITY 10 |
| 46 | # elif NDNBOOST_FT_MAX_ARITY < 30 |
| 47 | # define NDNBOOST_FT_FROM_ARITY 20 |
| 48 | # elif NDNBOOST_FT_MAX_ARITY < 40 |
| 49 | # define NDNBOOST_FT_FROM_ARITY 30 |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 50 | # endif |
| 51 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 52 | # if NDNBOOST_FT_FROM_ARITY |
| 53 | # include NDNBOOST_FT_AL_PREPROCESSED |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 54 | # endif |
| 55 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 56 | # elif !defined(NDNBOOST_FT_FROM_ARITY) // single pass preprocessing |
| 57 | # define NDNBOOST_FT_FROM_ARITY 0 |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 58 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 59 | # elif NDNBOOST_FT_FROM_ARITY > 0 // arity20 includes arity10 |
| 60 | NDNBOOST_PP_EXPAND(#) include NDNBOOST_FT_AL_PREPROCESSED |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 61 | # endif |
| 62 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 63 | # undef NDNBOOST_FT_AL_PREPROCESSED |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 64 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 65 | # undef NDNBOOST_FT_AL_FILE |
| 66 | # undef NDNBOOST_FT_AL_FILE_I |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 67 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 68 | # if NDNBOOST_FT_MAX_ARITY > NDNBOOST_FT_FROM_ARITY |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 69 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 70 | # ifndef NDNBOOST_FT_DETAIL_ARITY_LOOP_HPP_INCLUDED |
| 71 | # define NDNBOOST_FT_DETAIL_ARITY_LOOP_HPP_INCLUDED |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 72 | # include <ndnboost/preprocessor/cat.hpp> |
| 73 | # include <ndnboost/preprocessor/tuple/eat.hpp> |
| 74 | # include <ndnboost/preprocessor/control/if.hpp> |
| 75 | # include <ndnboost/preprocessor/arithmetic/inc.hpp> |
| 76 | # include <ndnboost/preprocessor/facilities/empty.hpp> |
| 77 | # include <ndnboost/preprocessor/facilities/expand.hpp> |
| 78 | # include <ndnboost/preprocessor/iteration/iterate.hpp> |
| 79 | # include <ndnboost/preprocessor/repetition/enum_params.hpp> |
| 80 | # include <ndnboost/preprocessor/repetition/enum_shifted_params.hpp> |
| 81 | # include <ndnboost/preprocessor/repetition/enum_trailing_params.hpp> |
| 82 | # endif |
| 83 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 84 | # define NDNBOOST_FT_AL_INCLUDE_FILE <NDNBOOST_FT_al_path/master.hpp> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 85 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 86 | # define NDNBOOST_FT_ARITY_LOOP_PREFIX 1 |
| 87 | # include NDNBOOST_FT_AL_INCLUDE_FILE |
| 88 | # undef NDNBOOST_FT_ARITY_LOOP_PREFIX |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 89 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 90 | # if !NDNBOOST_PP_IS_ITERATING |
| 91 | # define NDNBOOST_PP_FILENAME_1 NDNBOOST_FT_AL_INCLUDE_FILE |
| 92 | # elif NDNBOOST_PP_ITERATION_DEPTH() == 1 |
| 93 | # define NDNBOOST_PP_FILENAME_2 NDNBOOST_FT_AL_INCLUDE_FILE |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 94 | # else |
| 95 | # error "loops nested too deeply" |
| 96 | # endif |
| 97 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 98 | # define NDNBOOST_FT_arity NDNBOOST_PP_ITERATION() |
| 99 | # define NDNBOOST_FT_n NDNBOOST_PP_INC(NDNBOOST_FT_arity) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 100 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 101 | # define NDNBOOST_FT_type \ |
| 102 | NDNBOOST_FT_syntax(NDNBOOST_FT_cc,NDNBOOST_FT_type_name NDNBOOST_PP_EMPTY)\ |
| 103 | (NDNBOOST_FT_params(NDNBOOST_PP_EMPTY) NDNBOOST_FT_ell) NDNBOOST_FT_cv |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 104 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 105 | # define NDNBOOST_FT_tplargs(prefx) \ |
| 106 | prefx() R NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_FT_arity,prefx() T) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 107 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 108 | # if !NDNBOOST_FT_mfp |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 109 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 110 | # define NDNBOOST_FT_params(prefx) \ |
| 111 | NDNBOOST_PP_IF(NDNBOOST_FT_arity,NDNBOOST_PP_ENUM_PARAMS, \ |
| 112 | NDNBOOST_FT_nullary_param NDNBOOST_PP_TUPLE_EAT(2))( \ |
| 113 | NDNBOOST_FT_arity,prefx() T) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 114 | # else |
| 115 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 116 | # define NDNBOOST_FT_params(prefx) \ |
| 117 | NDNBOOST_PP_ENUM_SHIFTED_PARAMS(NDNBOOST_FT_arity,prefx() T) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 118 | |
| 119 | # endif |
| 120 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 121 | # if !NDNBOOST_FT_FROM_ARITY |
| 122 | # define NDNBOOST_PP_ITERATION_LIMITS (NDNBOOST_FT_mfp, NDNBOOST_FT_MAX_ARITY) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 123 | # else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 124 | # define NDNBOOST_PP_ITERATION_LIMITS \ |
| 125 | (NDNBOOST_FT_FROM_ARITY+1, NDNBOOST_FT_MAX_ARITY) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 126 | # endif |
| 127 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 128 | # define NDNBOOST_FT_ARITY_LOOP_IS_ITERATING 1 |
| 129 | # include NDNBOOST_PP_ITERATE() |
| 130 | # undef NDNBOOST_FT_ARITY_LOOP_IS_ITERATING |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 131 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 132 | # undef NDNBOOST_FT_arity |
| 133 | # undef NDNBOOST_FT_params |
| 134 | # undef NDNBOOST_FT_tplargs |
| 135 | # undef NDNBOOST_FT_type |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 136 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 137 | # define NDNBOOST_FT_ARITY_LOOP_SUFFIX 1 |
| 138 | # include NDNBOOST_FT_AL_INCLUDE_FILE |
| 139 | # undef NDNBOOST_FT_ARITY_LOOP_SUFFIX |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 140 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 141 | # undef NDNBOOST_FT_AL_INCLUDE_FILE |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 142 | # endif |
| 143 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 144 | # undef NDNBOOST_FT_FROM_ARITY |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 145 | |
| 146 | #else |
| 147 | # error "attempt to nest arity loops" |
| 148 | #endif |
| 149 | |