Skip to content

Commit b49a186

Browse files
committed
Avoid multiple template instances of boost::python::details::get_signature when multiple calling conventions are enabled
1 parent a5a08bf commit b49a186

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

include/boost/python/signature.hpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,15 @@ struct most_derived
111111
// 'default' calling convention
112112

113113
# define BOOST_PYTHON_FN_CC
114+
# define BOOST_PYTHON_FN_CC_IS_DEFAULT
114115

115116
# define BOOST_PP_ITERATION_PARAMS_1 \
116117
(3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/signature.hpp>))
117118

118119
# include BOOST_PP_ITERATE()
119120

120121
# undef BOOST_PYTHON_FN_CC
122+
# undef BOOST_PYTHON_FN_CC_IS_DEFAULT
121123

122124
// __cdecl calling convention
123125

@@ -141,13 +143,15 @@ struct most_derived
141143
# if defined(BOOST_PYTHON_ENABLE_STDCALL)
142144

143145
# define BOOST_PYTHON_FN_CC __stdcall
146+
# define BOOST_PYTHON_FN_CC_IS_STDCALL
144147

145148
# define BOOST_PP_ITERATION_PARAMS_1 \
146149
(3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/signature.hpp>))
147150

148151
# include BOOST_PP_ITERATE()
149152

150153
# undef BOOST_PYTHON_FN_CC
154+
# undef BOOST_PYTHON_FN_CC_IS_STDCALL
151155

152156
# endif // defined(BOOST_PYTHON_ENABLE_STDCALL)
153157

@@ -156,12 +160,14 @@ struct most_derived
156160
# if defined(BOOST_PYTHON_ENABLE_FASTCALL)
157161

158162
# define BOOST_PYTHON_FN_CC __fastcall
163+
# define BOOST_PYTHON_FN_CC_IS_FASTCALL
159164

160165
# define BOOST_PP_ITERATION_PARAMS_1 \
161166
(3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/signature.hpp>))
162167

163168
# include BOOST_PP_ITERATE()
164169

170+
# undef BOOST_PYTHON_FN_CC_IS_FASTCALL
165171
# undef BOOST_PYTHON_FN_CC
166172

167173
# endif // defined(BOOST_PYTHON_ENABLE_FASTCALL)
@@ -184,8 +190,8 @@ struct most_derived
184190

185191
// as 'get_signature(RT(*)(T0...TN), void* = 0)' is the same
186192
// function as 'get_signature(RT(__cdecl *)(T0...TN), void* = 0)',
187-
// we don't define it twice
188-
# if !defined(BOOST_PYTHON_FN_CC_IS_CDECL)
193+
// we don't define it multiple times (i.e. for __cdecl, __stdcall ...)
194+
# if defined(BOOST_PYTHON_FN_CC_IS_DEFAULT)
189195

190196
template <
191197
class RT BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class T)>
@@ -198,19 +204,21 @@ get_signature(RT(BOOST_PYTHON_FN_CC *)(BOOST_PP_ENUM_PARAMS_Z(1, N, T)), void* =
198204
>();
199205
}
200206

201-
# endif // !defined(BOOST_PYTHON_FN_CC_IS_CDECL)
207+
# endif // BOOST_PYTHON_FN_CC_IS_DEFAULT
202208

203209
# undef N
204210

205211
# define BOOST_PP_ITERATION_PARAMS_2 \
206212
(3, (0, 3, <boost/python/signature.hpp>))
207213
# include BOOST_PP_ITERATE()
208214

209-
#else
215+
#else // BOOST_PP_ITERATION_DEPTH() != 1
210216

211217
# define N BOOST_PP_RELATIVE_ITERATION(1)
212218
# define Q BOOST_PYTHON_CV_QUALIFIER(BOOST_PP_ITERATION())
213219

220+
# if defined(BOOST_PYTHON_FN_CC_IS_DEFAULT)
221+
214222
template <
215223
class RT, class ClassT BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class T)>
216224
inline BOOST_PYTHON_LIST_INC(BOOST_PP_INC(N))<
@@ -245,6 +253,8 @@ get_signature(
245253
>();
246254
}
247255

256+
# endif // BOOST_PYTHON_FN_CC_IS_DEFAULT
257+
248258
# undef Q
249259
# undef N
250260

0 commit comments

Comments
 (0)