Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:34:15

0001 
0002 // Copyright (C) 2009-2012 Lorenzo Caminiti
0003 // Distributed under the Boost Software License, Version 1.0
0004 // (see accompanying file LICENSE_1_0.txt or a copy at
0005 // http://www.boost.org/LICENSE_1_0.txt)
0006 // Home at http://www.boost.org/libs/local_function
0007 
0008 #ifndef BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_APPEND_HPP_
0009 #define BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_APPEND_HPP_
0010 
0011 #include <boost/local_function/aux_/preprocessor/traits/decl_returns.hpp>
0012 #include <boost/local_function/aux_/preprocessor/traits/decl_params.hpp>
0013 #include <boost/local_function/aux_/preprocessor/traits/decl_const_binds.hpp>
0014 #include <boost/local_function/aux_/preprocessor/traits/decl_binds.hpp>
0015 #include <boost/local_function/aux_/preprocessor/traits/decl_error.hpp>
0016 #include <boost/local_function/aux_/preprocessor/traits/param.hpp>
0017 #include <boost/local_function/detail/preprocessor/keyword/return.hpp>
0018 #include <boost/preprocessor/facilities/empty.hpp>
0019 #include <boost/preprocessor/arithmetic/dec.hpp>
0020 #include <boost/preprocessor/list/append.hpp>
0021 #include <boost/preprocessor/list/size.hpp>
0022 #include <boost/preprocessor/list/at.hpp>
0023 #include <boost/preprocessor/list/first_n.hpp>
0024 
0025 // PRIVATE //
0026 
0027 #define BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_APPEND_PARAM_DEFAULT_( \
0028         params, default_value) \
0029     /* `DEC` ok because precondition that unbinds are not nil-list */ \
0030     BOOST_PP_LIST_APPEND( \
0031         BOOST_PP_LIST_FIRST_N(BOOST_PP_DEC(BOOST_PP_LIST_SIZE(params)), \
0032                 params) \
0033     , \
0034         ( /* list 2-tuple */ \
0035             ( /* (param_decl, default) 2-tuple */ \
0036                 BOOST_LOCAL_FUNCTION_AUX_PP_PARAM_TRAITS_DECL( \
0037                         BOOST_PP_LIST_AT(params, BOOST_PP_DEC( \
0038                                 BOOST_PP_LIST_SIZE(params)))) \
0039             , \
0040                 default_value BOOST_PP_EMPTY \
0041             ) \
0042         , \
0043             BOOST_PP_NIL \
0044         ) \
0045     )
0046 
0047 // PUBLIC //
0048 
0049 // return_type: `return result_type`.
0050 #define BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_APPEND_RETURN( \
0051         decl_traits, return_type) \
0052     ( /* returns */ \
0053         BOOST_PP_LIST_APPEND( \
0054                 BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_RETURNS(decl_traits), \
0055                 ( BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_RETURN_REMOVE_FRONT( \
0056                   return_type), BOOST_PP_NIL ) ) \
0057     , /* params and defaults */ \
0058         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_PARAMS(decl_traits) \
0059     , /* const-bind vars */ \
0060         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_CONST_BINDS(decl_traits) \
0061     , /* const-bind `this` types */ \
0062         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_CONST_BIND_THIS_TYPES( \
0063                 decl_traits) \
0064     , /* bind vars */ \
0065         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_BINDS(decl_traits) \
0066     , /* bind `this` types */ \
0067         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_BIND_THIS_TYPES(decl_traits) \
0068     , /* error message (if any) */ \
0069         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_ERROR(decl_traits) \
0070     )
0071 
0072 
0073 // param_decl: `[auto | register] type_ name_`.
0074 #define BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_APPEND_PARAM( \
0075         decl_traits, param_decl) \
0076     ( /* returns */ \
0077         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_RETURNS(decl_traits) \
0078     , /* params and defaults */ \
0079         BOOST_PP_LIST_APPEND( \
0080                 BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_PARAMS(decl_traits), \
0081                 /* append param (with no default -- EMPTY) */ \
0082                 ( (param_decl, BOOST_PP_EMPTY), BOOST_PP_NIL ) ) \
0083     , /* const-bind vars */ \
0084         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_CONST_BINDS(decl_traits) \
0085     , /* const-bind `this` types */ \
0086         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_CONST_BIND_THIS_TYPES( \
0087                 decl_traits) \
0088     , /* bind vars */ \
0089         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_BINDS(decl_traits) \
0090     , /* bind `this` types */ \
0091         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_BIND_THIS_TYPES(decl_traits) \
0092     , /* error message (if any) */ \
0093         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_ERROR(decl_traits) \
0094     )
0095 
0096 // default_value: a valid parameter default value (`-1`, etc).
0097 // Precondition: already added unbinds are not nil-list.
0098 #define BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_APPEND_PARAM_DEFAULT( \
0099         decl_traits, default_value) \
0100     ( /* returns */ \
0101         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_RETURNS(decl_traits) \
0102     , /* unbind params and defaults */ \
0103         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_APPEND_PARAM_DEFAULT_( \
0104                 BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_PARAMS(decl_traits), \
0105                 default_value) /* append default to last added param */ \
0106     , /* const-bind vars */ \
0107         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_CONST_BINDS(decl_traits) \
0108     , /* const-bind `this` types */ \
0109         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_CONST_BIND_THIS_TYPES( \
0110                 decl_traits) \
0111     , /* bind vars */ \
0112         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_BINDS(decl_traits) \
0113     , /* bind `this` types */ \
0114         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_BIND_THIS_TYPES(decl_traits) \
0115     , /* error message (if any) */ \
0116         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_ERROR(decl_traits) \
0117     )
0118 
0119 // var_without_type: `[&] var_` (var_ != this).
0120 // var_with_type: `PP_EMPTY | type [&] var_` (var_ != this).
0121 #define BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_APPEND_BIND( \
0122         decl_traits, var_without_type, var_with_type) \
0123     ( /* returns */ \
0124         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_RETURNS(decl_traits) \
0125     , /* params and defaults */ \
0126         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_PARAMS(decl_traits) \
0127     , /* const-bind vars */ \
0128         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_CONST_BINDS(decl_traits) \
0129     , /* const-bind `this` types */ \
0130         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_CONST_BIND_THIS_TYPES( \
0131                 decl_traits) \
0132     , /* bind vars */ \
0133         BOOST_PP_LIST_APPEND( \
0134                 BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_BINDS(decl_traits), \
0135                 ( (var_without_type, var_with_type), BOOST_PP_NIL ) ) \
0136     , /* bind `this` types */ \
0137         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_BIND_THIS_TYPES(decl_traits) \
0138     , /* error message (if any) */ \
0139         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_ERROR(decl_traits) \
0140     )
0141 
0142 // this_type: `PP_EMPTY | type`.
0143 #define BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_APPEND_BIND_THIS_TYPE( \
0144         decl_traits, this_type) \
0145     ( /* returns */ \
0146         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_RETURNS(decl_traits) \
0147     , /* params and defaults */ \
0148         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_PARAMS(decl_traits) \
0149     , /* const-bind vars */ \
0150         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_CONST_BINDS(decl_traits) \
0151     , /* const-bind `this` types */ \
0152         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_CONST_BIND_THIS_TYPES( \
0153                 decl_traits) \
0154     , /* bind vars */ \
0155         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_BINDS(decl_traits) \
0156     , /* bind `this` types */ \
0157         BOOST_PP_LIST_APPEND( \
0158                 BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_BIND_THIS_TYPES( \
0159                         decl_traits), \
0160                 ( (this_type), BOOST_PP_NIL ) ) \
0161     , /* error message (if any) */ \
0162         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_ERROR(decl_traits) \
0163     ) 
0164 
0165 // var_without_type: `[&] var_` (var_ != this).
0166 // var_with_type: `BOOST_PP_EMPTY | type_ [&] name_` (var_ != this).
0167 #define BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_APPEND_CONST_BIND( \
0168         decl_traits, var_without_type, var_with_type) \
0169     ( /* returns */ \
0170         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_RETURNS(decl_traits) \
0171     , /* params and defaults */ \
0172         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_PARAMS(decl_traits) \
0173     , /* const-bind vars */ \
0174         BOOST_PP_LIST_APPEND( \
0175                 BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_CONST_BINDS( \
0176                         decl_traits), \
0177                 ( (var_without_type, var_with_type), BOOST_PP_NIL ) ) \
0178     , /* const-bind `this` types */ \
0179         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_CONST_BIND_THIS_TYPES( \
0180                 decl_traits) \
0181     , /* bind vars */ \
0182         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_BINDS(decl_traits) \
0183     , /* bind `this` types */ \
0184         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_BIND_THIS_TYPES(decl_traits) \
0185     , /* error message (if any) */ \
0186         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_ERROR(decl_traits) \
0187     ) 
0188 
0189 // this_type: `PP_EMPTY | type`.
0190 #define BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_APPEND_CONST_BIND_THIS_TYPE( \
0191         decl_traits, this_type) \
0192     ( /* returns */ \
0193         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_RETURNS(decl_traits) \
0194     , /* params and defaults */ \
0195         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_PARAMS(decl_traits) \
0196     , /* const-bind vars */ \
0197         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_CONST_BINDS(decl_traits) \
0198     , /* const-bind `this` types */ \
0199         BOOST_PP_LIST_APPEND( \
0200                 BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_CONST_BIND_THIS_TYPES( \
0201                         decl_traits), \
0202                 ( (this_type), BOOST_PP_NIL ) ) \
0203     , /* bind vars */ \
0204         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_BINDS(decl_traits) \
0205     , /* bind `this` types */ \
0206         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_BIND_THIS_TYPES(decl_traits) \
0207     , /* error message (if any) */ \
0208         BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_ERROR(decl_traits) \
0209     )
0210 
0211 #endif // #include guard
0212