select_from_python_test.cpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. // Copyright David Abrahams 2004. 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. #include <boost/python/converter/arg_from_python.hpp>
  5. #include <boost/python/type_id.hpp>
  6. #include <iostream>
  7. // gcc 2.95.x, MIPSpro 7.3.1.3 and IBM XL for Linux linker seem to demand this definition
  8. #if (defined(__GNUC__) && (__GNUC__ < 3)) \
  9. || (defined(__sgi) && defined(__EDG_VERSION__) && (__EDG_VERSION__ == 238)) \
  10. || (defined(__IBMCPP__) && defined(__linux__))
  11. namespace boost { namespace python {
  12. BOOST_PYTHON_DECL bool handle_exception_impl(function0<void>)
  13. {
  14. return true;
  15. }
  16. }}
  17. #endif
  18. int result;
  19. #define ASSERT_SAME(T1,T2) \
  20. if (!is_same< T1, T2 >::value) { \
  21. std::cout << "*********************\n"; \
  22. std::cout << python::type_id< T1 >() << " != " << python::type_id< T2 >() << "\n"; \
  23. std::cout << "*********************\n"; \
  24. result = 1; \
  25. }
  26. int main()
  27. {
  28. using namespace boost::python::converter;
  29. using namespace boost;
  30. ASSERT_SAME(
  31. select_arg_from_python<int>::type, arg_rvalue_from_python<int>
  32. );
  33. ASSERT_SAME(
  34. select_arg_from_python<int const>::type, arg_rvalue_from_python<int const>
  35. );
  36. ASSERT_SAME(
  37. select_arg_from_python<int volatile>::type, arg_rvalue_from_python<int volatile>
  38. );
  39. ASSERT_SAME(
  40. select_arg_from_python<int const volatile>::type, arg_rvalue_from_python<int const volatile>
  41. );
  42. ASSERT_SAME(
  43. select_arg_from_python<int*>::type, pointer_arg_from_python<int*>
  44. );
  45. ASSERT_SAME(
  46. select_arg_from_python<int const*>::type, pointer_arg_from_python<int const*>
  47. );
  48. ASSERT_SAME(
  49. select_arg_from_python<int volatile*>::type, pointer_arg_from_python<int volatile*>
  50. );
  51. ASSERT_SAME(
  52. select_arg_from_python<int const volatile*>::type, pointer_arg_from_python<int const volatile*>
  53. );
  54. ASSERT_SAME(
  55. select_arg_from_python<int&>::type, reference_arg_from_python<int&>
  56. );
  57. ASSERT_SAME(
  58. select_arg_from_python<int const&>::type, arg_rvalue_from_python<int const&>
  59. );
  60. ASSERT_SAME(
  61. select_arg_from_python<int volatile&>::type, reference_arg_from_python<int volatile&>
  62. );
  63. ASSERT_SAME(
  64. select_arg_from_python<int const volatile&>::type, reference_arg_from_python<int const volatile&>
  65. );
  66. ASSERT_SAME(
  67. select_arg_from_python<int*&>::type, reference_arg_from_python<int*&>
  68. );
  69. ASSERT_SAME(
  70. select_arg_from_python<int const*&>::type, reference_arg_from_python<int const*&>
  71. );
  72. ASSERT_SAME(
  73. select_arg_from_python<int volatile*&>::type, reference_arg_from_python<int volatile*&>
  74. );
  75. ASSERT_SAME(
  76. select_arg_from_python<int const volatile*&>::type, reference_arg_from_python<int const volatile*&>
  77. );
  78. ASSERT_SAME(
  79. select_arg_from_python<int* const&>::type, pointer_cref_arg_from_python<int*const&>
  80. );
  81. ASSERT_SAME(
  82. select_arg_from_python<int const* const&>::type, pointer_cref_arg_from_python<int const*const&>
  83. );
  84. ASSERT_SAME(
  85. select_arg_from_python<int volatile* const&>::type, pointer_cref_arg_from_python<int volatile*const&>
  86. );
  87. ASSERT_SAME(
  88. select_arg_from_python<int const volatile* const&>::type, pointer_cref_arg_from_python<int const volatile*const&>
  89. );
  90. ASSERT_SAME(
  91. select_arg_from_python<int*volatile&>::type, reference_arg_from_python<int*volatile&>
  92. );
  93. ASSERT_SAME(
  94. select_arg_from_python<int const*volatile&>::type, reference_arg_from_python<int const*volatile&>
  95. );
  96. ASSERT_SAME(
  97. select_arg_from_python<int volatile*volatile&>::type, reference_arg_from_python<int volatile*volatile&>
  98. );
  99. ASSERT_SAME(
  100. select_arg_from_python<int const volatile*volatile&>::type, reference_arg_from_python<int const volatile*volatile&>
  101. );
  102. ASSERT_SAME(
  103. select_arg_from_python<int*const volatile&>::type, reference_arg_from_python<int*const volatile&>
  104. );
  105. ASSERT_SAME(
  106. select_arg_from_python<int const*const volatile&>::type, reference_arg_from_python<int const*const volatile&>
  107. );
  108. ASSERT_SAME(
  109. select_arg_from_python<int volatile*const volatile&>::type, reference_arg_from_python<int volatile*const volatile&>
  110. );
  111. ASSERT_SAME(
  112. select_arg_from_python<int const volatile*const volatile&>::type, reference_arg_from_python<int const volatile*const volatile&>
  113. );
  114. return result;
  115. }