blob: 62b591e32f7494295c6d674517ec93febadbef68 [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001
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 Thompson3d613fd2013-10-15 15:39:04 -070011#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 Thompsona28eed82013-08-22 16:21:10 -070014#endif
Jeff Thompson3d613fd2013-10-15 15:39:04 -070015// 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 Thompsona28eed82013-08-22 16:21:10 -070025
26#ifdef __WAVE__
27# pragma wave option(preserve: 0)
28#endif
29
Jeff Thompson3d613fd2013-10-15 15:39:04 -070030#ifndef NDNBOOST_FT_ARITY_LOOP_IS_ITERATING
Jeff Thompsona28eed82013-08-22 16:21:10 -070031
Jeff Thompson3d613fd2013-10-15 15:39:04 -070032# define NDNBOOST_FT_AL_PREPROCESSED \
33 NDNBOOST_FT_AL_FILE(NDNBOOST_FT_al_path,NDNBOOST_FT_FROM_ARITY,NDNBOOST_FT_mfp)
Jeff Thompsona28eed82013-08-22 16:21:10 -070034
Jeff Thompson3d613fd2013-10-15 15:39:04 -070035# 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 Thompsona28eed82013-08-22 16:21:10 -070038 <base_path/arity ## max_arity ## _ ## mfp.hpp>
39
Jeff Thompson3d613fd2013-10-15 15:39:04 -070040# if !defined(NDNBOOST_FT_PREPROCESSING_MODE)
Jeff Thompsona28eed82013-08-22 16:21:10 -070041
Jeff Thompson3d613fd2013-10-15 15:39:04 -070042# 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 Thompsona28eed82013-08-22 16:21:10 -070050# endif
51
Jeff Thompson3d613fd2013-10-15 15:39:04 -070052# if NDNBOOST_FT_FROM_ARITY
53# include NDNBOOST_FT_AL_PREPROCESSED
Jeff Thompsona28eed82013-08-22 16:21:10 -070054# endif
55
Jeff Thompson3d613fd2013-10-15 15:39:04 -070056# elif !defined(NDNBOOST_FT_FROM_ARITY) // single pass preprocessing
57# define NDNBOOST_FT_FROM_ARITY 0
Jeff Thompsona28eed82013-08-22 16:21:10 -070058
Jeff Thompson3d613fd2013-10-15 15:39:04 -070059# elif NDNBOOST_FT_FROM_ARITY > 0 // arity20 includes arity10
60NDNBOOST_PP_EXPAND(#) include NDNBOOST_FT_AL_PREPROCESSED
Jeff Thompsona28eed82013-08-22 16:21:10 -070061# endif
62
Jeff Thompson3d613fd2013-10-15 15:39:04 -070063# undef NDNBOOST_FT_AL_PREPROCESSED
Jeff Thompsona28eed82013-08-22 16:21:10 -070064
Jeff Thompson3d613fd2013-10-15 15:39:04 -070065# undef NDNBOOST_FT_AL_FILE
66# undef NDNBOOST_FT_AL_FILE_I
Jeff Thompsona28eed82013-08-22 16:21:10 -070067
Jeff Thompson3d613fd2013-10-15 15:39:04 -070068# if NDNBOOST_FT_MAX_ARITY > NDNBOOST_FT_FROM_ARITY
Jeff Thompsona28eed82013-08-22 16:21:10 -070069
Jeff Thompson3d613fd2013-10-15 15:39:04 -070070# ifndef NDNBOOST_FT_DETAIL_ARITY_LOOP_HPP_INCLUDED
71# define NDNBOOST_FT_DETAIL_ARITY_LOOP_HPP_INCLUDED
Jeff Thompsona28eed82013-08-22 16:21:10 -070072# 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 Thompson3d613fd2013-10-15 15:39:04 -070084# define NDNBOOST_FT_AL_INCLUDE_FILE <NDNBOOST_FT_al_path/master.hpp>
Jeff Thompsona28eed82013-08-22 16:21:10 -070085
Jeff Thompson3d613fd2013-10-15 15:39:04 -070086# define NDNBOOST_FT_ARITY_LOOP_PREFIX 1
87# include NDNBOOST_FT_AL_INCLUDE_FILE
88# undef NDNBOOST_FT_ARITY_LOOP_PREFIX
Jeff Thompsona28eed82013-08-22 16:21:10 -070089
Jeff Thompson3d613fd2013-10-15 15:39:04 -070090# 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 Thompsona28eed82013-08-22 16:21:10 -070094# else
95# error "loops nested too deeply"
96# endif
97
Jeff Thompson3d613fd2013-10-15 15:39:04 -070098# define NDNBOOST_FT_arity NDNBOOST_PP_ITERATION()
99# define NDNBOOST_FT_n NDNBOOST_PP_INC(NDNBOOST_FT_arity)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700100
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700101# 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 Thompsona28eed82013-08-22 16:21:10 -0700104
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700105# define NDNBOOST_FT_tplargs(prefx) \
106 prefx() R NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_FT_arity,prefx() T)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700107
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700108# if !NDNBOOST_FT_mfp
Jeff Thompsona28eed82013-08-22 16:21:10 -0700109
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700110# 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 Thompsona28eed82013-08-22 16:21:10 -0700114# else
115
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700116# define NDNBOOST_FT_params(prefx) \
117 NDNBOOST_PP_ENUM_SHIFTED_PARAMS(NDNBOOST_FT_arity,prefx() T)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700118
119# endif
120
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700121# if !NDNBOOST_FT_FROM_ARITY
122# define NDNBOOST_PP_ITERATION_LIMITS (NDNBOOST_FT_mfp, NDNBOOST_FT_MAX_ARITY)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700123# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700124# define NDNBOOST_PP_ITERATION_LIMITS \
125 (NDNBOOST_FT_FROM_ARITY+1, NDNBOOST_FT_MAX_ARITY)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700126# endif
127
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700128# define NDNBOOST_FT_ARITY_LOOP_IS_ITERATING 1
129# include NDNBOOST_PP_ITERATE()
130# undef NDNBOOST_FT_ARITY_LOOP_IS_ITERATING
Jeff Thompsona28eed82013-08-22 16:21:10 -0700131
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700132# undef NDNBOOST_FT_arity
133# undef NDNBOOST_FT_params
134# undef NDNBOOST_FT_tplargs
135# undef NDNBOOST_FT_type
Jeff Thompsona28eed82013-08-22 16:21:10 -0700136
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700137# define NDNBOOST_FT_ARITY_LOOP_SUFFIX 1
138# include NDNBOOST_FT_AL_INCLUDE_FILE
139# undef NDNBOOST_FT_ARITY_LOOP_SUFFIX
Jeff Thompsona28eed82013-08-22 16:21:10 -0700140
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700141# undef NDNBOOST_FT_AL_INCLUDE_FILE
Jeff Thompsona28eed82013-08-22 16:21:10 -0700142# endif
143
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700144# undef NDNBOOST_FT_FROM_ARITY
Jeff Thompsona28eed82013-08-22 16:21:10 -0700145
146#else
147# error "attempt to nest arity loops"
148#endif
149