Ticket #3833: boost_python_calling_conventions.patch
File boost_python_calling_conventions.patch, 22.7 KB (added by , 13 years ago) |
---|
-
boost/python/signature.hpp
52 52 // 53 53 // template <class RT, class T0... class TN> 54 54 // inline mpl::vector<RT, T0...TN> 55 // get_signature(RT( *)(T0...TN), void* = 0)55 // get_signature(RT(BOOST_PYTHON_FN_CC *)(T0...TN), void* = 0) 56 56 // { 57 57 // return mpl::list<RT, T0...TN>(); 58 58 // } 59 59 // 60 // where BOOST_PYTHON_FN_CC is a calling convention keyword, can be 61 // 62 // empty, for default calling convention 63 // __cdecl (if BOOST_PYTHON_ENABLE_CDECL is defined) 64 // __stdcall (if BOOST_PYTHON_ENABLE_STDCALL is defined) 65 // __fastcall (if BOOST_PYTHON_ENABLE_FASTCALL is defined) 66 // 60 67 // And, for an appropriate assortment of cv-qualifications:: 61 68 // 62 69 // template <class RT, class ClassT, class T0... class TN> 63 70 // inline mpl::vector<RT, ClassT&, T0...TN> 64 // get_signature(RT( ClassT::*)(T0...TN) cv))71 // get_signature(RT(BOOST_PYTHON_FN_CC ClassT::*)(T0...TN) cv)) 65 72 // { 66 73 // return mpl::list<RT, ClassT&, T0...TN>(); 67 74 // } … … 72 79 // , typename most_derived<Target, ClassT>::type& 73 80 // , T0...TN 74 81 // > 75 // get_signature(RT( ClassT::*)(T0...TN) cv), Target*)82 // get_signature(RT(BOOST_PYTHON_FN_CC ClassT::*)(T0...TN) cv), Target*) 76 83 // { 77 84 // return mpl::list<RT, ClassT&, T0...TN>(); 78 85 // } … … 87 94 // 88 95 // These functions extract the return type, class (for member 89 96 // functions) and arguments of the input signature and stuff them in 90 // an mpl type sequence. Note that cv-qualification is dropped from 97 // an mpl type sequence (the calling convention is dropped). 98 // Note that cv-qualification is dropped from 91 99 // the "hidden this" argument of member functions; that is a 92 100 // necessary sacrifice to ensure that an lvalue from_python converter 93 101 // is used. A pointer is not used so that None will be rejected for … … 100 108 // 101 109 // @group { 102 110 111 // 'default' calling convention 112 113 # define BOOST_PYTHON_FN_CC 114 103 115 # define BOOST_PP_ITERATION_PARAMS_1 \ 104 116 (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/signature.hpp>)) 105 117 106 118 # include BOOST_PP_ITERATE() 119 120 # undef BOOST_PYTHON_FN_CC 121 122 // __cdecl calling convention 123 124 # if defined(BOOST_PYTHON_ENABLE_CDECL) 125 126 # define BOOST_PYTHON_FN_CC __cdecl 127 # define BOOST_PYTHON_FN_CC_IS_CDECL 128 129 # define BOOST_PP_ITERATION_PARAMS_1 \ 130 (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/signature.hpp>)) 131 132 # include BOOST_PP_ITERATE() 133 134 # undef BOOST_PYTHON_FN_CC 135 # undef BOOST_PYTHON_FN_CC_IS_CDECL 136 137 # endif // defined(BOOST_PYTHON_ENABLE_CDECL) 138 139 // __stdcall calling convention 140 141 # if defined(BOOST_PYTHON_ENABLE_STDCALL) 142 143 # define BOOST_PYTHON_FN_CC __stdcall 144 145 # define BOOST_PP_ITERATION_PARAMS_1 \ 146 (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/signature.hpp>)) 147 148 # include BOOST_PP_ITERATE() 149 150 # undef BOOST_PYTHON_FN_CC 151 152 # endif // defined(BOOST_PYTHON_ENABLE_STDCALL) 153 154 // __fastcall calling convention 155 156 # if defined(BOOST_PYTHON_ENABLE_FASTCALL) 157 158 # define BOOST_PYTHON_FN_CC __fastcall 159 160 # define BOOST_PP_ITERATION_PARAMS_1 \ 161 (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/signature.hpp>)) 162 163 # include BOOST_PP_ITERATE() 164 165 # undef BOOST_PYTHON_FN_CC 166 167 # endif // defined(BOOST_PYTHON_ENABLE_FASTCALL) 168 107 169 # undef BOOST_PYTHON_LIST_INC 108 170 109 171 // } … … 120 182 121 183 # define N BOOST_PP_ITERATION() 122 184 185 // as 'get_signature(RT(*)(T0...TN), void* = 0)' is the same 186 // 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) 189 123 190 template < 124 191 class RT BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class T)> 125 192 inline BOOST_PYTHON_LIST_INC(N)< 126 193 RT BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, T)> 127 get_signature(RT( *)(BOOST_PP_ENUM_PARAMS_Z(1, N, T)), void* = 0)194 get_signature(RT(BOOST_PYTHON_FN_CC *)(BOOST_PP_ENUM_PARAMS_Z(1, N, T)), void* = 0) 128 195 { 129 196 return BOOST_PYTHON_LIST_INC(N)< 130 197 RT BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, T) 131 198 >(); 132 199 } 133 200 201 # endif // !defined(BOOST_PYTHON_FN_CC_IS_CDECL) 202 134 203 # undef N 135 204 136 205 # define BOOST_PP_ITERATION_PARAMS_2 \ … … 146 215 class RT, class ClassT BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class T)> 147 216 inline BOOST_PYTHON_LIST_INC(BOOST_PP_INC(N))< 148 217 RT, ClassT& BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, T)> 149 get_signature(RT( ClassT::*)(BOOST_PP_ENUM_PARAMS_Z(1, N, T)) Q)218 get_signature(RT(BOOST_PYTHON_FN_CC ClassT::*)(BOOST_PP_ENUM_PARAMS_Z(1, N, T)) Q) 150 219 { 151 220 return BOOST_PYTHON_LIST_INC(BOOST_PP_INC(N))< 152 221 RT, ClassT& BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, T) … … 165 234 BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, T) 166 235 > 167 236 get_signature( 168 RT( ClassT::*)(BOOST_PP_ENUM_PARAMS_Z(1, N, T)) Q237 RT(BOOST_PYTHON_FN_CC ClassT::*)(BOOST_PP_ENUM_PARAMS_Z(1, N, T)) Q 169 238 , Target* 170 239 ) 171 240 { -
libs/python/test/calling_conventions.cpp
1 // 2 // adapted from bind_stdcall_test.cpp - test for bind.hpp + __stdcall (free functions) 3 // The purpose of this simple test is to determine if a function can be 4 // called from Python with the various existing calling conventions 5 // 6 // Copyright (c) 2001 Peter Dimov and Multi Media Ltd. 7 // 8 // Distributed under the Boost Software License, Version 1.0. (See 9 // accompanying file LICENSE_1_0.txt or copy at 10 // http://www.boost.org/LICENSE_1_0.txt) 11 // 12 13 #if !defined(TEST_INCLUDE_RECURSION) 14 15 #define TEST_INCLUDE_RECURSION 16 17 //------------------------------------------------------------------------------ 18 // this section is the main body of the test extension module 19 20 #define BOOST_PYTHON_ENABLE_CDECL 21 #define BOOST_PYTHON_ENABLE_STDCALL 22 #define BOOST_PYTHON_ENABLE_FASTCALL 23 #include <boost/preprocessor/cat.hpp> 24 #include <boost/preprocessor/stringize.hpp> 25 #include <boost/python.hpp> 26 using namespace boost::python; 27 28 // first define test functions for every calling convention 29 30 #define TEST_DECLARE_FUNCTIONS 31 32 #define TESTED_CALLING_CONVENTION __cdecl 33 #include "calling_conventions.cpp" 34 #undef TESTED_CALLING_CONVENTION 35 36 #define TESTED_CALLING_CONVENTION __stdcall 37 #include "calling_conventions.cpp" 38 #undef TESTED_CALLING_CONVENTION 39 40 #define TESTED_CALLING_CONVENTION __fastcall 41 #include "calling_conventions.cpp" 42 #undef TESTED_CALLING_CONVENTION 43 44 #undef TEST_DECLARE_FUNCTIONS 45 46 // then create a module wrapping the defined functions for every calling convention 47 48 BOOST_PYTHON_MODULE( calling_conventions_ext ) 49 { 50 51 #define TEST_WRAP_FUNCTIONS 52 53 #define TESTED_CALLING_CONVENTION __cdecl 54 #include "calling_conventions.cpp" 55 #undef TESTED_CALLING_CONVENTION 56 57 #define TESTED_CALLING_CONVENTION __stdcall 58 #include "calling_conventions.cpp" 59 #undef TESTED_CALLING_CONVENTION 60 61 #define TESTED_CALLING_CONVENTION __fastcall 62 #include "calling_conventions.cpp" 63 #undef TESTED_CALLING_CONVENTION 64 65 #undef TEST_WRAP_FUNCTIONS 66 67 } 68 69 #else // !defined(TEST_INCLUDE_RECURSION) 70 71 //------------------------------------------------------------------------------ 72 // this section defines the functions to be wrapped 73 74 # if defined(TEST_DECLARE_FUNCTIONS) 75 76 # if !defined(TESTED_CALLING_CONVENTION) 77 # error "One calling convention must be defined" 78 # endif // !defined(TESTED_CALLING_CONVENTION) 79 80 namespace BOOST_PP_CAT(test, TESTED_CALLING_CONVENTION) { 81 82 long TESTED_CALLING_CONVENTION f_0() 83 { 84 return 17041L; 85 } 86 87 long TESTED_CALLING_CONVENTION f_1(long a) 88 { 89 return a; 90 } 91 92 long TESTED_CALLING_CONVENTION f_2(long a, long b) 93 { 94 return a + 10 * b; 95 } 96 97 long TESTED_CALLING_CONVENTION f_3(long a, long b, long c) 98 { 99 return a + 10 * b + 100 * c; 100 } 101 102 long TESTED_CALLING_CONVENTION f_4(long a, long b, long c, long d) 103 { 104 return a + 10 * b + 100 * c + 1000 * d; 105 } 106 107 long TESTED_CALLING_CONVENTION f_5(long a, long b, long c, long d, long e) 108 { 109 return a + 10 * b + 100 * c + 1000 * d + 10000 * e; 110 } 111 112 long TESTED_CALLING_CONVENTION f_6(long a, long b, long c, long d, long e, long f) 113 { 114 return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f; 115 } 116 117 long TESTED_CALLING_CONVENTION f_7(long a, long b, long c, long d, long e, long f, long g) 118 { 119 return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g; 120 } 121 122 long TESTED_CALLING_CONVENTION f_8(long a, long b, long c, long d, long e, long f, long g, long h) 123 { 124 return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; 125 } 126 127 long TESTED_CALLING_CONVENTION f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) 128 { 129 return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; 130 } 131 132 } // namespace test##TESTED_CALLING_CONVENTION 133 134 # endif // defined(TEST_DECLARE_FUNCTIONS) 135 136 //------------------------------------------------------------------------------ 137 // this section wraps the functions 138 139 # if defined(TEST_WRAP_FUNCTIONS) 140 141 # if !defined(TESTED_CALLING_CONVENTION) 142 # error "One calling convention must be defined" 143 # endif // !defined(TESTED_CALLING_CONVENTION) 144 145 def("f_0" BOOST_PP_STRINGIZE(TESTED_CALLING_CONVENTION), &BOOST_PP_CAT(test, TESTED_CALLING_CONVENTION)::f_0); 146 def("f_1" BOOST_PP_STRINGIZE(TESTED_CALLING_CONVENTION), &BOOST_PP_CAT(test, TESTED_CALLING_CONVENTION)::f_1); 147 def("f_2" BOOST_PP_STRINGIZE(TESTED_CALLING_CONVENTION), &BOOST_PP_CAT(test, TESTED_CALLING_CONVENTION)::f_2); 148 def("f_3" BOOST_PP_STRINGIZE(TESTED_CALLING_CONVENTION), &BOOST_PP_CAT(test, TESTED_CALLING_CONVENTION)::f_3); 149 def("f_4" BOOST_PP_STRINGIZE(TESTED_CALLING_CONVENTION), &BOOST_PP_CAT(test, TESTED_CALLING_CONVENTION)::f_4); 150 def("f_5" BOOST_PP_STRINGIZE(TESTED_CALLING_CONVENTION), &BOOST_PP_CAT(test, TESTED_CALLING_CONVENTION)::f_5); 151 def("f_6" BOOST_PP_STRINGIZE(TESTED_CALLING_CONVENTION), &BOOST_PP_CAT(test, TESTED_CALLING_CONVENTION)::f_6); 152 def("f_7" BOOST_PP_STRINGIZE(TESTED_CALLING_CONVENTION), &BOOST_PP_CAT(test, TESTED_CALLING_CONVENTION)::f_7); 153 def("f_8" BOOST_PP_STRINGIZE(TESTED_CALLING_CONVENTION), &BOOST_PP_CAT(test, TESTED_CALLING_CONVENTION)::f_8); 154 def("f_9" BOOST_PP_STRINGIZE(TESTED_CALLING_CONVENTION), &BOOST_PP_CAT(test, TESTED_CALLING_CONVENTION)::f_9); 155 156 # endif // defined(TEST_WRAP_FUNCTIONS) 157 158 #endif // !defined(TEST_INCLUDE_RECURSION) -
libs/python/test/calling_conventions_mf.cpp
1 // 2 // adapted from bind_stdcall_mf_test.cpp - test for bind.hpp + __stdcall (free functions) 3 // The purpose of this simple test is to determine if a function can be 4 // called from Python with the various existing calling conventions 5 // 6 // Copyright (c) 2001 Peter Dimov and Multi Media Ltd. 7 // 8 // Distributed under the Boost Software License, Version 1.0. (See 9 // accompanying file LICENSE_1_0.txt or copy at 10 // http://www.boost.org/LICENSE_1_0.txt) 11 // 12 13 #if !defined(TEST_INCLUDE_RECURSION) 14 15 #define TEST_INCLUDE_RECURSION 16 17 //------------------------------------------------------------------------------ 18 // this section is the main body of the test extension module 19 20 #define BOOST_PYTHON_ENABLE_CDECL 21 #define BOOST_PYTHON_ENABLE_STDCALL 22 #define BOOST_PYTHON_ENABLE_FASTCALL 23 #include <boost/preprocessor/cat.hpp> 24 #include <boost/preprocessor/stringize.hpp> 25 #include <boost/python.hpp> 26 using namespace boost::python; 27 28 // first define test functions for every calling convention 29 30 #define TEST_DECLARE_FUNCTIONS 31 32 #define TESTED_CALLING_CONVENTION __cdecl 33 #include "calling_conventions_mf.cpp" 34 #undef TESTED_CALLING_CONVENTION 35 36 #define TESTED_CALLING_CONVENTION __stdcall 37 #include "calling_conventions_mf.cpp" 38 #undef TESTED_CALLING_CONVENTION 39 40 #define TESTED_CALLING_CONVENTION __fastcall 41 #include "calling_conventions_mf.cpp" 42 #undef TESTED_CALLING_CONVENTION 43 44 #undef TEST_DECLARE_FUNCTIONS 45 46 // then create a module wrapping the defined functions for every calling convention 47 48 BOOST_PYTHON_MODULE( calling_conventions_mf_ext ) 49 { 50 51 #define TEST_WRAP_FUNCTIONS 52 53 #define TESTED_CALLING_CONVENTION __cdecl 54 #include "calling_conventions_mf.cpp" 55 #undef TESTED_CALLING_CONVENTION 56 57 #define TESTED_CALLING_CONVENTION __stdcall 58 #include "calling_conventions_mf.cpp" 59 #undef TESTED_CALLING_CONVENTION 60 61 #define TESTED_CALLING_CONVENTION __fastcall 62 #include "calling_conventions_mf.cpp" 63 #undef TESTED_CALLING_CONVENTION 64 65 #undef TEST_WRAP_FUNCTIONS 66 67 } 68 69 #else // !defined(TEST_INCLUDE_RECURSION) 70 71 //------------------------------------------------------------------------------ 72 // this section defines the functions to be wrapped 73 74 # if defined(TEST_DECLARE_FUNCTIONS) 75 76 # if !defined(TESTED_CALLING_CONVENTION) 77 # error "One calling convention must be defined" 78 # endif // !defined(TESTED_CALLING_CONVENTION) 79 80 namespace BOOST_PP_CAT(test, TESTED_CALLING_CONVENTION) { 81 82 struct X 83 { 84 mutable unsigned int hash; 85 86 X(): hash(0) {} 87 88 void TESTED_CALLING_CONVENTION f0() { f1(17); } 89 void TESTED_CALLING_CONVENTION g0() const { g1(17); } 90 91 void TESTED_CALLING_CONVENTION f1(int a1) { hash = (hash * 17041 + a1) % 32768; } 92 void TESTED_CALLING_CONVENTION g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; } 93 94 void TESTED_CALLING_CONVENTION f2(int a1, int a2) { f1(a1); f1(a2); } 95 void TESTED_CALLING_CONVENTION g2(int a1, int a2) const { g1(a1); g1(a2); } 96 97 void TESTED_CALLING_CONVENTION f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); } 98 void TESTED_CALLING_CONVENTION g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); } 99 100 void TESTED_CALLING_CONVENTION f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); } 101 void TESTED_CALLING_CONVENTION g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); } 102 103 void TESTED_CALLING_CONVENTION f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); } 104 void TESTED_CALLING_CONVENTION g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); } 105 106 void TESTED_CALLING_CONVENTION f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); } 107 void TESTED_CALLING_CONVENTION g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); } 108 109 void TESTED_CALLING_CONVENTION f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); } 110 void TESTED_CALLING_CONVENTION g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); } 111 112 void TESTED_CALLING_CONVENTION f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); } 113 void TESTED_CALLING_CONVENTION g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); } 114 }; 115 116 } // namespace BOOST_PP_CAT(test, TESTED_CALLING_CONVENTION) 117 118 # endif // defined(TEST_DECLARE_FUNCTIONS) 119 120 //------------------------------------------------------------------------------ 121 // this section wraps the functions 122 123 # if defined(TEST_WRAP_FUNCTIONS) 124 125 # if !defined(TESTED_CALLING_CONVENTION) 126 # error "One calling convention must be defined" 127 # endif // !defined(TESTED_CALLING_CONVENTION) 128 129 { 130 131 typedef BOOST_PP_CAT(test, TESTED_CALLING_CONVENTION)::X X; 132 133 class_<X>("X" BOOST_PP_STRINGIZE(TESTED_CALLING_CONVENTION)) 134 .def("f0", &X::f0) 135 .def("g0", &X::g0) 136 .def("f1", &X::f1) 137 .def("g1", &X::g1) 138 .def("f2", &X::f2) 139 .def("g2", &X::g2) 140 .def("f3", &X::f3) 141 .def("g3", &X::g3) 142 .def("f4", &X::f4) 143 .def("g4", &X::g4) 144 .def("f5", &X::f5) 145 .def("g5", &X::g5) 146 .def("f6", &X::f6) 147 .def("g6", &X::g6) 148 .def("f7", &X::f7) 149 .def("g7", &X::g7) 150 .def("f8", &X::f8) 151 .def("g8", &X::g8) 152 .def_readonly("hash", &X::hash) 153 ; 154 155 } 156 157 # endif // defined(TEST_WRAP_FUNCTIONS) 158 159 #endif // !defined(TEST_INCLUDE_RECURSION) -
libs/python/test/calling_conventions_mf.py
1 # Copyright Nicolas Lelong, 2010. Distributed under the Boost 2 # Software License, Version 1.0 (See accompanying 3 # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 """ 5 >>> from calling_conventions_mf_ext import * 6 >>> x = X__cdecl() 7 >>> x.f0() 8 >>> x.g0() 9 >>> x.f1(1) 10 >>> x.g1(1) 11 >>> x.f2(1, 2) 12 >>> x.g2(1, 2) 13 >>> x.f3(1, 2, 3) 14 >>> x.g3(1, 2, 3) 15 >>> x.f4(1, 2, 3, 4) 16 >>> x.g4(1, 2, 3, 4) 17 >>> x.f5(1, 2, 3, 4, 5) 18 >>> x.g5(1, 2, 3, 4, 5) 19 >>> x.f6(1, 2, 3, 4, 5, 6) 20 >>> x.g6(1, 2, 3, 4, 5, 6) 21 >>> x.f7(1, 2, 3, 4, 5, 6, 7) 22 >>> x.g7(1, 2, 3, 4, 5, 6, 7) 23 >>> x.f8(1, 2, 3, 4, 5, 6, 7, 8) 24 >>> x.g8(1, 2, 3, 4, 5, 6, 7, 8) 25 >>> x.hash 26 2155 27 >>> x = X__stdcall() 28 >>> x.f0() 29 >>> x.g0() 30 >>> x.f1(1) 31 >>> x.g1(1) 32 >>> x.f2(1, 2) 33 >>> x.g2(1, 2) 34 >>> x.f3(1, 2, 3) 35 >>> x.g3(1, 2, 3) 36 >>> x.f4(1, 2, 3, 4) 37 >>> x.g4(1, 2, 3, 4) 38 >>> x.f5(1, 2, 3, 4, 5) 39 >>> x.g5(1, 2, 3, 4, 5) 40 >>> x.f6(1, 2, 3, 4, 5, 6) 41 >>> x.g6(1, 2, 3, 4, 5, 6) 42 >>> x.f7(1, 2, 3, 4, 5, 6, 7) 43 >>> x.g7(1, 2, 3, 4, 5, 6, 7) 44 >>> x.f8(1, 2, 3, 4, 5, 6, 7, 8) 45 >>> x.g8(1, 2, 3, 4, 5, 6, 7, 8) 46 >>> x.hash 47 2155 48 >>> x = X__fastcall() 49 >>> x.f0() 50 >>> x.g0() 51 >>> x.f1(1) 52 >>> x.g1(1) 53 >>> x.f2(1, 2) 54 >>> x.g2(1, 2) 55 >>> x.f3(1, 2, 3) 56 >>> x.g3(1, 2, 3) 57 >>> x.f4(1, 2, 3, 4) 58 >>> x.g4(1, 2, 3, 4) 59 >>> x.f5(1, 2, 3, 4, 5) 60 >>> x.g5(1, 2, 3, 4, 5) 61 >>> x.f6(1, 2, 3, 4, 5, 6) 62 >>> x.g6(1, 2, 3, 4, 5, 6) 63 >>> x.f7(1, 2, 3, 4, 5, 6, 7) 64 >>> x.g7(1, 2, 3, 4, 5, 6, 7) 65 >>> x.f8(1, 2, 3, 4, 5, 6, 7, 8) 66 >>> x.g8(1, 2, 3, 4, 5, 6, 7, 8) 67 >>> x.hash 68 2155 69 """ 70 71 def run(args = None): 72 import sys 73 import doctest 74 75 if args is not None: 76 sys.argv = args 77 return doctest.testmod(sys.modules.get(__name__)) 78 79 if __name__ == '__main__': 80 print "running..." 81 import sys 82 status = run()[0] 83 if (status == 0): print "Done." 84 sys.exit(status) -
libs/python/test/calling_conventions.py
1 # Copyright Nicolas Lelong, 2010. Distributed under the Boost 2 # Software License, Version 1.0 (See accompanying 3 # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 """ 5 >>> from calling_conventions_ext import * 6 >>> f_0__cdecl() 7 17041 8 >>> f_1__cdecl(1) 9 1 10 >>> f_2__cdecl(1, 2) 11 21 12 >>> f_3__cdecl(1, 2, 3) 13 321 14 >>> f_4__cdecl(1, 2, 3, 4) 15 4321 16 >>> f_5__cdecl(1, 2, 3, 4, 5) 17 54321 18 >>> f_6__cdecl(1, 2, 3, 4, 5, 6) 19 654321 20 >>> f_7__cdecl(1, 2, 3, 4, 5, 6, 7) 21 7654321 22 >>> f_8__cdecl(1, 2, 3, 4, 5, 6, 7, 8) 23 87654321 24 >>> f_9__cdecl(1, 2, 3, 4, 5, 6, 7, 8, 9) 25 987654321 26 >>> f_0__stdcall() 27 17041 28 >>> f_1__stdcall(1) 29 1 30 >>> f_2__stdcall(1, 2) 31 21 32 >>> f_3__stdcall(1, 2, 3) 33 321 34 >>> f_4__stdcall(1, 2, 3, 4) 35 4321 36 >>> f_5__stdcall(1, 2, 3, 4, 5) 37 54321 38 >>> f_6__stdcall(1, 2, 3, 4, 5, 6) 39 654321 40 >>> f_7__stdcall(1, 2, 3, 4, 5, 6, 7) 41 7654321 42 >>> f_8__stdcall(1, 2, 3, 4, 5, 6, 7, 8) 43 87654321 44 >>> f_9__stdcall(1, 2, 3, 4, 5, 6, 7, 8, 9) 45 987654321 46 >>> f_0__fastcall() 47 17041 48 >>> f_1__fastcall(1) 49 1 50 >>> f_2__fastcall(1, 2) 51 21 52 >>> f_3__fastcall(1, 2, 3) 53 321 54 >>> f_4__fastcall(1, 2, 3, 4) 55 4321 56 >>> f_5__fastcall(1, 2, 3, 4, 5) 57 54321 58 >>> f_6__fastcall(1, 2, 3, 4, 5, 6) 59 654321 60 >>> f_7__fastcall(1, 2, 3, 4, 5, 6, 7) 61 7654321 62 >>> f_8__fastcall(1, 2, 3, 4, 5, 6, 7, 8) 63 87654321 64 >>> f_9__fastcall(1, 2, 3, 4, 5, 6, 7, 8, 9) 65 987654321 66 """ 67 68 def run(args = None): 69 import sys 70 import doctest 71 72 if args is not None: 73 sys.argv = args 74 return doctest.testmod(sys.modules.get(__name__)) 75 76 if __name__ == '__main__': 77 print "running..." 78 import sys 79 status = run()[0] 80 if (status == 0): print "Done." 81 sys.exit(status) -
libs/python/test/Jamfile.v2
184 184 # bpl-test bienstman5 ; 185 185 # } 186 186 187 [ bpl-test calling_conventions ] 188 [ bpl-test calling_conventions_mf ] 189 187 190 # --- unit tests of library components --- 188 191 189 192 [ compile indirect_traits_test.cpp ] -
libs/python/doc/v2/configuration.html
106 106 function from being treated as an exported symbol on platforms which 107 107 support that distinction in-code</td> 108 108 </tr> 109 110 <tr> 111 <td valign="top"><code>BOOST_PYTHON_ENABLE_CDECL</code></td> 112 113 <td valign="top" align="center"><i>not defined</i></td> 114 115 <td valign="top">If defined, allows functions using the <code>__cdecl 116 </code> calling convention to be wrapped.</td> 117 </tr> 118 119 <tr> 120 <td valign="top"><code>BOOST_PYTHON_ENABLE_STDCALL</code></td> 121 122 <td valign="top" align="center"><i>not defined</i></td> 123 124 <td valign="top">If defined, allows functions using the <code>__stdcall 125 </code> calling convention to be wrapped.</td> 126 </tr> 127 128 <tr> 129 <td valign="top"><code>BOOST_PYTHON_ENABLE_FASTCALL</code></td> 130 131 <td valign="top" align="center"><i>not defined</i></td> 132 133 <td valign="top">If defined, allows functions using the <code>__fastcall 134 </code> calling convention to be wrapped.</td> 135 </tr> 109 136 </table> 110 137 111 138 <h2><a name="lib-defined-impl"></a>Library Defined Implementation