xcoll 0.3.3__py3-none-any.whl → 0.3.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of xcoll might be problematic. Click here for more details.

Files changed (317) hide show
  1. xcoll/beam_elements/__init__.py +5 -0
  2. xcoll/beam_elements/absorber.py +2 -1
  3. xcoll/beam_elements/base.py +32 -17
  4. xcoll/beam_elements/collimators_src/absorber.h +5 -0
  5. xcoll/beam_elements/everest.py +14 -25
  6. xcoll/colldb.py +50 -27
  7. xcoll/general.py +1 -1
  8. xcoll/headers/checks.h +7 -1
  9. xcoll/impacts/impacts.py +2 -1
  10. xcoll/impacts/impacts_src/impacts.h +1 -6
  11. xcoll/manager.py +5 -5
  12. xcoll/rf_sweep.py +90 -19
  13. xcoll/scattering_routines/everest/__init__.py +5 -0
  14. xcoll/scattering_routines/everest/everest.py +1 -1
  15. xcoll/scattering_routines/fluka/build_fluka_input.py +58 -0
  16. xcoll/scattering_routines/fluka/flukaio/lib/libFlukaIO64.a +0 -0
  17. xcoll/scattering_routines/fluka/flukaio/lib/libFlukaIO64.so +0 -0
  18. xcoll/scattering_routines/fluka/flukaio/src/Connection.d +68 -48
  19. xcoll/scattering_routines/fluka/flukaio/src/Connection.o +0 -0
  20. xcoll/scattering_routines/fluka/flukaio/src/FlukaIO.d +46 -37
  21. xcoll/scattering_routines/fluka/flukaio/src/FlukaIO.o +0 -0
  22. xcoll/scattering_routines/fluka/flukaio/src/FlukaIOHandshake.d +28 -25
  23. xcoll/scattering_routines/fluka/flukaio/src/FlukaIOHandshake.o +0 -0
  24. xcoll/scattering_routines/fluka/flukaio/src/FlukaIOServer.d +67 -47
  25. xcoll/scattering_routines/fluka/flukaio/src/FlukaIOServer.o +0 -0
  26. xcoll/scattering_routines/fluka/flukaio/src/FortranFlukaIO.d +39 -33
  27. xcoll/scattering_routines/fluka/flukaio/src/FortranFlukaIO.o +0 -0
  28. xcoll/scattering_routines/fluka/flukaio/src/NetIO.d +66 -47
  29. xcoll/scattering_routines/fluka/flukaio/src/NetIO.o +0 -0
  30. {xcoll-0.3.3.dist-info → xcoll-0.3.5.dist-info}/METADATA +3 -2
  31. xcoll-0.3.5.dist-info/NOTICE +2 -0
  32. xcoll-0.3.5.dist-info/RECORD +111 -0
  33. {xcoll-0.3.3.dist-info → xcoll-0.3.5.dist-info}/WHEEL +1 -1
  34. xcoll/beam_elements/collimators_src/base_block.h +0 -14
  35. xcoll/beam_elements/collimators_src/base_collimator.h +0 -14
  36. xcoll/beam_elements/collimators_src/invalid_collimator.h +0 -15
  37. xcoll/install_collimators.py +0 -180
  38. xcoll/scattering_routines/geant4/collimasim/.git +0 -1
  39. xcoll/scattering_routines/geant4/collimasim/.gitignore +0 -12
  40. xcoll/scattering_routines/geant4/collimasim/.gitmodules +0 -3
  41. xcoll/scattering_routines/geant4/collimasim/CMakeLists.txt +0 -26
  42. xcoll/scattering_routines/geant4/collimasim/README.md +0 -21
  43. xcoll/scattering_routines/geant4/collimasim/docs/Makefile +0 -20
  44. xcoll/scattering_routines/geant4/collimasim/docs/make.bat +0 -35
  45. xcoll/scattering_routines/geant4/collimasim/docs/source/collimasim.rst +0 -10
  46. xcoll/scattering_routines/geant4/collimasim/docs/source/conf.py +0 -59
  47. xcoll/scattering_routines/geant4/collimasim/docs/source/index.rst +0 -26
  48. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.appveyor.yml +0 -37
  49. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-format +0 -19
  50. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-tidy +0 -65
  51. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.cmake-format.yaml +0 -73
  52. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.git +0 -1
  53. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CODEOWNERS +0 -9
  54. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CONTRIBUTING.md +0 -386
  55. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +0 -45
  56. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/config.yml +0 -8
  57. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/dependabot.yml +0 -16
  58. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler.yml +0 -8
  59. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler_merged.yml +0 -3
  60. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/pull_request_template.md +0 -19
  61. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/ci.yml +0 -969
  62. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/configure.yml +0 -84
  63. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/format.yml +0 -48
  64. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/labeler.yml +0 -16
  65. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/pip.yml +0 -103
  66. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.gitignore +0 -45
  67. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.pre-commit-config.yaml +0 -151
  68. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.readthedocs.yml +0 -3
  69. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/CMakeLists.txt +0 -297
  70. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/LICENSE +0 -29
  71. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/MANIFEST.in +0 -6
  72. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/README.rst +0 -180
  73. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Doxyfile +0 -23
  74. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Makefile +0 -192
  75. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/_static/theme_overrides.css +0 -11
  76. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/chrono.rst +0 -81
  77. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/custom.rst +0 -93
  78. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/eigen.rst +0 -310
  79. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/functional.rst +0 -109
  80. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/index.rst +0 -43
  81. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/overview.rst +0 -171
  82. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/stl.rst +0 -251
  83. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/strings.rst +0 -305
  84. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/classes.rst +0 -1297
  85. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/embedding.rst +0 -262
  86. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/exceptions.rst +0 -396
  87. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/functions.rst +0 -568
  88. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/misc.rst +0 -337
  89. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/index.rst +0 -13
  90. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/numpy.rst +0 -463
  91. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/object.rst +0 -286
  92. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/utilities.rst +0 -155
  93. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/smart_ptrs.rst +0 -174
  94. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/basics.rst +0 -308
  95. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.py +0 -91
  96. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.rst +0 -95
  97. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/changelog.rst +0 -2050
  98. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/classes.rst +0 -542
  99. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/cmake/index.rst +0 -8
  100. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/compiling.rst +0 -648
  101. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/conf.py +0 -381
  102. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/faq.rst +0 -343
  103. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/index.rst +0 -48
  104. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/installing.rst +0 -105
  105. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/limitations.rst +0 -72
  106. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11-logo.png +0 -0
  107. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.png +0 -0
  108. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.svg +0 -427
  109. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.png +0 -0
  110. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.svg +0 -427
  111. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/reference.rst +0 -130
  112. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/release.rst +0 -96
  113. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/requirements.txt +0 -8
  114. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/upgrade.rst +0 -548
  115. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/attr.h +0 -605
  116. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/buffer_info.h +0 -144
  117. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/cast.h +0 -1432
  118. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/chrono.h +0 -213
  119. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/common.h +0 -2
  120. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/complex.h +0 -65
  121. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/class.h +0 -709
  122. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/common.h +0 -1021
  123. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/descr.h +0 -104
  124. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/init.h +0 -346
  125. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/internals.h +0 -467
  126. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/type_caster_base.h +0 -978
  127. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/typeid.h +0 -55
  128. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eigen.h +0 -606
  129. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/embed.h +0 -284
  130. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eval.h +0 -163
  131. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/functional.h +0 -121
  132. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/gil.h +0 -193
  133. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/iostream.h +0 -275
  134. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/numpy.h +0 -1741
  135. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/operators.h +0 -163
  136. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/options.h +0 -65
  137. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pybind11.h +0 -2497
  138. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pytypes.h +0 -1879
  139. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl/filesystem.h +0 -103
  140. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl.h +0 -375
  141. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl_bind.h +0 -747
  142. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/noxfile.py +0 -88
  143. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__init__.py +0 -11
  144. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__main__.py +0 -52
  145. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.py +0 -12
  146. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.pyi +0 -6
  147. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/commands.py +0 -21
  148. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/py.typed +0 -0
  149. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.py +0 -482
  150. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.pyi +0 -63
  151. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pyproject.toml +0 -41
  152. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.cfg +0 -56
  153. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.py +0 -155
  154. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/CMakeLists.txt +0 -503
  155. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/conftest.py +0 -208
  156. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/constructor_stats.h +0 -275
  157. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/cross_module_gil_utils.cpp +0 -73
  158. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/env.py +0 -33
  159. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/pytest.ini +0 -0
  160. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/test_files.py +0 -279
  161. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/pytest.ini +0 -0
  162. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/test_setuphelper.py +0 -143
  163. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/local_bindings.h +0 -85
  164. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/object.h +0 -179
  165. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_cross_module_tests.cpp +0 -151
  166. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.cpp +0 -91
  167. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.h +0 -85
  168. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pytest.ini +0 -19
  169. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/requirements.txt +0 -12
  170. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.cpp +0 -26
  171. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.py +0 -25
  172. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.cpp +0 -216
  173. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.py +0 -163
  174. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.cpp +0 -286
  175. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.py +0 -536
  176. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.cpp +0 -107
  177. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.py +0 -248
  178. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.cpp +0 -227
  179. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.py +0 -202
  180. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.cpp +0 -84
  181. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.py +0 -210
  182. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.cpp +0 -550
  183. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.py +0 -473
  184. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/CMakeLists.txt +0 -84
  185. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/embed.cpp +0 -21
  186. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +0 -28
  187. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +0 -39
  188. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +0 -46
  189. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/main.cpp +0 -6
  190. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +0 -41
  191. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +0 -35
  192. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +0 -41
  193. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/test.py +0 -10
  194. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.cpp +0 -165
  195. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.py +0 -53
  196. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.cpp +0 -238
  197. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.py +0 -126
  198. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.cpp +0 -141
  199. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.py +0 -117
  200. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.cpp +0 -41
  201. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.py +0 -50
  202. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.cpp +0 -69
  203. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.py +0 -42
  204. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.cpp +0 -348
  205. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.py +0 -771
  206. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/CMakeLists.txt +0 -47
  207. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/catch.cpp +0 -22
  208. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/external_module.cpp +0 -23
  209. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.cpp +0 -326
  210. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.py +0 -15
  211. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.cpp +0 -148
  212. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.py +0 -272
  213. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.cpp +0 -119
  214. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.py +0 -51
  215. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval_call.py +0 -5
  216. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.cpp +0 -285
  217. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.h +0 -12
  218. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.py +0 -265
  219. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.cpp +0 -397
  220. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.py +0 -520
  221. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.cpp +0 -49
  222. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.py +0 -94
  223. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.cpp +0 -125
  224. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.py +0 -331
  225. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.cpp +0 -153
  226. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.py +0 -284
  227. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.cpp +0 -107
  228. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.py +0 -257
  229. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.cpp +0 -412
  230. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.py +0 -517
  231. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.cpp +0 -102
  232. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.py +0 -92
  233. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.cpp +0 -233
  234. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.py +0 -360
  235. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.cpp +0 -472
  236. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.py +0 -593
  237. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.cpp +0 -524
  238. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.py +0 -441
  239. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.cpp +0 -103
  240. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.py +0 -267
  241. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.cpp +0 -73
  242. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.py +0 -59
  243. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.cpp +0 -235
  244. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.py +0 -146
  245. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.cpp +0 -189
  246. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.py +0 -82
  247. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.cpp +0 -560
  248. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.py +0 -651
  249. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.cpp +0 -500
  250. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.py +0 -253
  251. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.cpp +0 -452
  252. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.py +0 -318
  253. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.cpp +0 -342
  254. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.py +0 -291
  255. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.cpp +0 -131
  256. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.py +0 -318
  257. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.cpp +0 -144
  258. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.py +0 -29
  259. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.cpp +0 -66
  260. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.py +0 -44
  261. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.cpp +0 -22
  262. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.py +0 -9
  263. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.cpp +0 -510
  264. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.py +0 -408
  265. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-numpy-scipy.supp +0 -140
  266. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-python.supp +0 -117
  267. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindCatch.cmake +0 -70
  268. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindEigen3.cmake +0 -86
  269. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindPythonLibsNew.cmake +0 -257
  270. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/check-style.sh +0 -44
  271. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/cmake_uninstall.cmake.in +0 -23
  272. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/libsize.py +0 -39
  273. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/make_changelog.py +0 -64
  274. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Common.cmake +0 -402
  275. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Config.cmake.in +0 -233
  276. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11NewTools.cmake +0 -276
  277. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Tools.cmake +0 -214
  278. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pyproject.toml +0 -3
  279. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_global.py.in +0 -65
  280. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_main.py.in +0 -41
  281. xcoll/scattering_routines/geant4/collimasim/pyproject.toml +0 -8
  282. xcoll/scattering_routines/geant4/collimasim/setup.py +0 -144
  283. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.cpp +0 -403
  284. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.hh +0 -100
  285. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.cpp +0 -662
  286. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.hh +0 -110
  287. xcoll/scattering_routines/geant4/collimasim/src/collimasim/__init__.py +0 -8
  288. xcoll/scattering_routines/geant4/collimasim/src/collimasim/bindings.cpp +0 -63
  289. xcoll/scattering_routines/geant4/collimasim/src/collimasim/pyCollimatorPass.py +0 -142
  290. xcoll/scattering_routines/geant4/collimasim/src/collimasim/xtrack_collimator.py +0 -475
  291. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/PKG-INFO +0 -6
  292. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/SOURCES.txt +0 -20
  293. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/dependency_links.txt +0 -1
  294. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/not-zip-safe +0 -1
  295. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/top_level.txt +0 -1
  296. xcoll/scattering_routines/geant4/collimasim/tests/README.md +0 -25
  297. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_new_example.dat +0 -18
  298. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_old_example.dat +0 -68
  299. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_testing.dat +0 -15
  300. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_yaml_example.yaml +0 -110
  301. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps.dat +0 -7
  302. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps_pyat_test.dat +0 -3
  303. xcoll/scattering_routines/geant4/collimasim/tests/resources/collonly_twiss_file_example.tfs +0 -54
  304. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings.gmad +0 -3
  305. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_black_absorber.gmad +0 -3
  306. xcoll/scattering_routines/geant4/collimasim/tests/resources/twiss_file_testing.tfs +0 -51
  307. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat.py +0 -65
  308. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_passmethod.py +0 -59
  309. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_tracking.py +0 -102
  310. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack.py +0 -75
  311. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_angle.py +0 -74
  312. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_colldb_load.py +0 -84
  313. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction.py +0 -159
  314. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tilt.py +0 -80
  315. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking.py +0 -97
  316. xcoll-0.3.3.dist-info/RECORD +0 -391
  317. {xcoll-0.3.3.dist-info → xcoll-0.3.5.dist-info}/LICENSE +0 -0
@@ -1,1021 +0,0 @@
1
- /*
2
- pybind11/detail/common.h -- Basic macros
3
-
4
- Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
5
-
6
- All rights reserved. Use of this source code is governed by a
7
- BSD-style license that can be found in the LICENSE file.
8
- */
9
-
10
- #pragma once
11
-
12
- #define PYBIND11_VERSION_MAJOR 2
13
- #define PYBIND11_VERSION_MINOR 9
14
- #define PYBIND11_VERSION_PATCH 0.dev1
15
-
16
- // Similar to Python's convention: https://docs.python.org/3/c-api/apiabiversion.html
17
- // Additional convention: 0xD = dev
18
- #define PYBIND11_VERSION_HEX 0x020900D1
19
-
20
- #define PYBIND11_NAMESPACE_BEGIN(name) namespace name {
21
- #define PYBIND11_NAMESPACE_END(name) }
22
-
23
- // Robust support for some features and loading modules compiled against different pybind versions
24
- // requires forcing hidden visibility on pybind code, so we enforce this by setting the attribute on
25
- // the main `pybind11` namespace.
26
- #if !defined(PYBIND11_NAMESPACE)
27
- # ifdef __GNUG__
28
- # define PYBIND11_NAMESPACE pybind11 __attribute__((visibility("hidden")))
29
- # else
30
- # define PYBIND11_NAMESPACE pybind11
31
- # endif
32
- #endif
33
-
34
- #if !(defined(_MSC_VER) && __cplusplus == 199711L)
35
- # if __cplusplus >= 201402L
36
- # define PYBIND11_CPP14
37
- # if __cplusplus >= 201703L
38
- # define PYBIND11_CPP17
39
- # endif
40
- # endif
41
- #elif defined(_MSC_VER) && __cplusplus == 199711L
42
- // MSVC sets _MSVC_LANG rather than __cplusplus (supposedly until the standard is fully implemented)
43
- // Unless you use the /Zc:__cplusplus flag on Visual Studio 2017 15.7 Preview 3 or newer
44
- # if _MSVC_LANG >= 201402L
45
- # define PYBIND11_CPP14
46
- # if _MSVC_LANG > 201402L && _MSC_VER >= 1910
47
- # define PYBIND11_CPP17
48
- # endif
49
- # endif
50
- #endif
51
-
52
- // Compiler version assertions
53
- #if defined(__INTEL_COMPILER)
54
- # if __INTEL_COMPILER < 1800
55
- # error pybind11 requires Intel C++ compiler v18 or newer
56
- # elif __INTEL_COMPILER < 1900 && defined(PYBIND11_CPP14)
57
- # error pybind11 supports only C++11 with Intel C++ compiler v18. Use v19 or newer for C++14.
58
- # endif
59
- /* The following pragma cannot be pop'ed:
60
- https://community.intel.com/t5/Intel-C-Compiler/Inline-and-no-inline-warning/td-p/1216764 */
61
- # pragma warning disable 2196 // warning #2196: routine is both "inline" and "noinline"
62
- #elif defined(__clang__) && !defined(__apple_build_version__)
63
- # if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 3)
64
- # error pybind11 requires clang 3.3 or newer
65
- # endif
66
- #elif defined(__clang__)
67
- // Apple changes clang version macros to its Xcode version; the first Xcode release based on
68
- // (upstream) clang 3.3 was Xcode 5:
69
- # if __clang_major__ < 5
70
- # error pybind11 requires Xcode/clang 5.0 or newer
71
- # endif
72
- #elif defined(__GNUG__)
73
- # if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
74
- # error pybind11 requires gcc 4.8 or newer
75
- # endif
76
- #elif defined(_MSC_VER)
77
- // Pybind hits various compiler bugs in 2015u2 and earlier, and also makes use of some stl features
78
- // (e.g. std::negation) added in 2015u3:
79
- # if _MSC_FULL_VER < 190024210
80
- # error pybind11 requires MSVC 2015 update 3 or newer
81
- # endif
82
- #endif
83
-
84
- #if !defined(PYBIND11_EXPORT)
85
- # if defined(WIN32) || defined(_WIN32)
86
- # define PYBIND11_EXPORT __declspec(dllexport)
87
- # else
88
- # define PYBIND11_EXPORT __attribute__ ((visibility("default")))
89
- # endif
90
- #endif
91
-
92
- #if !defined(PYBIND11_EXPORT_EXCEPTION)
93
- # ifdef __MINGW32__
94
- // workaround for:
95
- // error: 'dllexport' implies default visibility, but xxx has already been declared with a different visibility
96
- # define PYBIND11_EXPORT_EXCEPTION
97
- # else
98
- # define PYBIND11_EXPORT_EXCEPTION PYBIND11_EXPORT
99
- # endif
100
- #endif
101
-
102
- // For CUDA, GCC7, GCC8:
103
- // PYBIND11_NOINLINE_FORCED is incompatible with `-Wattributes -Werror`.
104
- // When defining PYBIND11_NOINLINE_FORCED, it is best to also use `-Wno-attributes`.
105
- // However, the measured shared-library size saving when using noinline are only
106
- // 1.7% for CUDA, -0.2% for GCC7, and 0.0% for GCC8 (using -DCMAKE_BUILD_TYPE=MinSizeRel,
107
- // the default under pybind11/tests).
108
- #if !defined(PYBIND11_NOINLINE_FORCED) && \
109
- (defined(__CUDACC__) || (defined(__GNUC__) && (__GNUC__ == 7 || __GNUC__ == 8)))
110
- # define PYBIND11_NOINLINE_DISABLED
111
- #endif
112
-
113
- // The PYBIND11_NOINLINE macro is for function DEFINITIONS.
114
- // In contrast, FORWARD DECLARATIONS should never use this macro:
115
- // https://stackoverflow.com/questions/9317473/forward-declaration-of-inline-functions
116
- #if defined(PYBIND11_NOINLINE_DISABLED) // Option for maximum portability and experimentation.
117
- # define PYBIND11_NOINLINE inline
118
- #elif defined(_MSC_VER)
119
- # define PYBIND11_NOINLINE __declspec(noinline) inline
120
- #else
121
- # define PYBIND11_NOINLINE __attribute__ ((noinline)) inline
122
- #endif
123
-
124
- #if defined(__MINGW32__)
125
- // For unknown reasons all PYBIND11_DEPRECATED member trigger a warning when declared
126
- // whether it is used or not
127
- # define PYBIND11_DEPRECATED(reason)
128
- #elif defined(PYBIND11_CPP14)
129
- # define PYBIND11_DEPRECATED(reason) [[deprecated(reason)]]
130
- #else
131
- # define PYBIND11_DEPRECATED(reason) __attribute__((deprecated(reason)))
132
- #endif
133
-
134
- #if defined(PYBIND11_CPP17)
135
- # define PYBIND11_MAYBE_UNUSED [[maybe_unused]]
136
- #elif defined(_MSC_VER) && !defined(__clang__)
137
- # define PYBIND11_MAYBE_UNUSED
138
- #else
139
- # define PYBIND11_MAYBE_UNUSED __attribute__ ((__unused__))
140
- #endif
141
-
142
- /* Don't let Python.h #define (v)snprintf as macro because they are implemented
143
- properly in Visual Studio since 2015. */
144
- #if defined(_MSC_VER) && _MSC_VER >= 1900
145
- # define HAVE_SNPRINTF 1
146
- #endif
147
-
148
- /// Include Python header, disable linking to pythonX_d.lib on Windows in debug mode
149
- #if defined(_MSC_VER)
150
- # if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 4)
151
- # define HAVE_ROUND 1
152
- # endif
153
- # pragma warning(push)
154
- // C4505: 'PySlice_GetIndicesEx': unreferenced local function has been removed (PyPy only)
155
- # pragma warning(disable: 4505)
156
- # if defined(_DEBUG) && !defined(Py_DEBUG)
157
- # define PYBIND11_DEBUG_MARKER
158
- # undef _DEBUG
159
- # endif
160
- #endif
161
-
162
- // https://en.cppreference.com/w/c/chrono/localtime
163
- #if defined(__STDC_LIB_EXT1__) && !defined(__STDC_WANT_LIB_EXT1__)
164
- # define __STDC_WANT_LIB_EXT1__
165
- #endif
166
-
167
- #ifdef __has_include
168
- // std::optional (but including it in c++14 mode isn't allowed)
169
- # if defined(PYBIND11_CPP17) && __has_include(<optional>)
170
- # define PYBIND11_HAS_OPTIONAL 1
171
- # endif
172
- // std::experimental::optional (but not allowed in c++11 mode)
173
- # if defined(PYBIND11_CPP14) && (__has_include(<experimental/optional>) && \
174
- !__has_include(<optional>))
175
- # define PYBIND11_HAS_EXP_OPTIONAL 1
176
- # endif
177
- // std::variant
178
- # if defined(PYBIND11_CPP17) && __has_include(<variant>)
179
- # define PYBIND11_HAS_VARIANT 1
180
- # endif
181
- #elif defined(_MSC_VER) && defined(PYBIND11_CPP17)
182
- # define PYBIND11_HAS_OPTIONAL 1
183
- # define PYBIND11_HAS_VARIANT 1
184
- #endif
185
-
186
- #include <Python.h>
187
- #include <frameobject.h>
188
- #include <pythread.h>
189
-
190
- /* Python #defines overrides on all sorts of core functions, which
191
- tends to weak havok in C++ codebases that expect these to work
192
- like regular functions (potentially with several overloads) */
193
- #if defined(isalnum)
194
- # undef isalnum
195
- # undef isalpha
196
- # undef islower
197
- # undef isspace
198
- # undef isupper
199
- # undef tolower
200
- # undef toupper
201
- #endif
202
-
203
- #if defined(copysign)
204
- # undef copysign
205
- #endif
206
-
207
- #if defined(_MSC_VER)
208
- # if defined(PYBIND11_DEBUG_MARKER)
209
- # define _DEBUG
210
- # undef PYBIND11_DEBUG_MARKER
211
- # endif
212
- # pragma warning(pop)
213
- #endif
214
-
215
- #include <cstddef>
216
- #include <cstring>
217
- #include <forward_list>
218
- #include <vector>
219
- #include <string>
220
- #include <stdexcept>
221
- #include <exception>
222
- #include <unordered_set>
223
- #include <unordered_map>
224
- #include <memory>
225
- #include <typeindex>
226
- #include <type_traits>
227
- #if defined(__has_include)
228
- # if __has_include(<version>)
229
- # include <version>
230
- # endif
231
- #endif
232
-
233
- // #define PYBIND11_STR_LEGACY_PERMISSIVE
234
- // If DEFINED, pybind11::str can hold PyUnicodeObject or PyBytesObject
235
- // (probably surprising and never documented, but this was the
236
- // legacy behavior until and including v2.6.x). As a side-effect,
237
- // pybind11::isinstance<str>() is true for both pybind11::str and
238
- // pybind11::bytes.
239
- // If UNDEFINED, pybind11::str can only hold PyUnicodeObject, and
240
- // pybind11::isinstance<str>() is true only for pybind11::str.
241
- // However, for Python 2 only (!), the pybind11::str caster
242
- // implicitly decodes bytes to PyUnicodeObject. This is to ease
243
- // the transition from the legacy behavior to the non-permissive
244
- // behavior.
245
-
246
- #if PY_MAJOR_VERSION >= 3 /// Compatibility macros for various Python versions
247
- #define PYBIND11_INSTANCE_METHOD_NEW(ptr, class_) PyInstanceMethod_New(ptr)
248
- #define PYBIND11_INSTANCE_METHOD_CHECK PyInstanceMethod_Check
249
- #define PYBIND11_INSTANCE_METHOD_GET_FUNCTION PyInstanceMethod_GET_FUNCTION
250
- #define PYBIND11_BYTES_CHECK PyBytes_Check
251
- #define PYBIND11_BYTES_FROM_STRING PyBytes_FromString
252
- #define PYBIND11_BYTES_FROM_STRING_AND_SIZE PyBytes_FromStringAndSize
253
- #define PYBIND11_BYTES_AS_STRING_AND_SIZE PyBytes_AsStringAndSize
254
- #define PYBIND11_BYTES_AS_STRING PyBytes_AsString
255
- #define PYBIND11_BYTES_SIZE PyBytes_Size
256
- #define PYBIND11_LONG_CHECK(o) PyLong_Check(o)
257
- #define PYBIND11_LONG_AS_LONGLONG(o) PyLong_AsLongLong(o)
258
- #define PYBIND11_LONG_FROM_SIGNED(o) PyLong_FromSsize_t((ssize_t) (o))
259
- #define PYBIND11_LONG_FROM_UNSIGNED(o) PyLong_FromSize_t((size_t) (o))
260
- #define PYBIND11_BYTES_NAME "bytes"
261
- #define PYBIND11_STRING_NAME "str"
262
- #define PYBIND11_SLICE_OBJECT PyObject
263
- #define PYBIND11_FROM_STRING PyUnicode_FromString
264
- #define PYBIND11_STR_TYPE ::pybind11::str
265
- #define PYBIND11_BOOL_ATTR "__bool__"
266
- #define PYBIND11_NB_BOOL(ptr) ((ptr)->nb_bool)
267
- #define PYBIND11_BUILTINS_MODULE "builtins"
268
- // Providing a separate declaration to make Clang's -Wmissing-prototypes happy.
269
- // See comment for PYBIND11_MODULE below for why this is marked "maybe unused".
270
- #define PYBIND11_PLUGIN_IMPL(name) \
271
- extern "C" PYBIND11_MAYBE_UNUSED PYBIND11_EXPORT PyObject *PyInit_##name(); \
272
- extern "C" PYBIND11_EXPORT PyObject *PyInit_##name()
273
-
274
- #else
275
- #define PYBIND11_INSTANCE_METHOD_NEW(ptr, class_) PyMethod_New(ptr, nullptr, class_)
276
- #define PYBIND11_INSTANCE_METHOD_CHECK PyMethod_Check
277
- #define PYBIND11_INSTANCE_METHOD_GET_FUNCTION PyMethod_GET_FUNCTION
278
- #define PYBIND11_BYTES_CHECK PyString_Check
279
- #define PYBIND11_BYTES_FROM_STRING PyString_FromString
280
- #define PYBIND11_BYTES_FROM_STRING_AND_SIZE PyString_FromStringAndSize
281
- #define PYBIND11_BYTES_AS_STRING_AND_SIZE PyString_AsStringAndSize
282
- #define PYBIND11_BYTES_AS_STRING PyString_AsString
283
- #define PYBIND11_BYTES_SIZE PyString_Size
284
- #define PYBIND11_LONG_CHECK(o) (PyInt_Check(o) || PyLong_Check(o))
285
- #define PYBIND11_LONG_AS_LONGLONG(o) (PyInt_Check(o) ? (long long) PyLong_AsLong(o) : PyLong_AsLongLong(o))
286
- #define PYBIND11_LONG_FROM_SIGNED(o) PyInt_FromSsize_t((ssize_t) o) // Returns long if needed.
287
- #define PYBIND11_LONG_FROM_UNSIGNED(o) PyInt_FromSize_t((size_t) o) // Returns long if needed.
288
- #define PYBIND11_BYTES_NAME "str"
289
- #define PYBIND11_STRING_NAME "unicode"
290
- #define PYBIND11_SLICE_OBJECT PySliceObject
291
- #define PYBIND11_FROM_STRING PyString_FromString
292
- #define PYBIND11_STR_TYPE ::pybind11::bytes
293
- #define PYBIND11_BOOL_ATTR "__nonzero__"
294
- #define PYBIND11_NB_BOOL(ptr) ((ptr)->nb_nonzero)
295
- #define PYBIND11_BUILTINS_MODULE "__builtin__"
296
- // Providing a separate PyInit decl to make Clang's -Wmissing-prototypes happy.
297
- // See comment for PYBIND11_MODULE below for why this is marked "maybe unused".
298
- #define PYBIND11_PLUGIN_IMPL(name) \
299
- static PyObject *pybind11_init_wrapper(); \
300
- extern "C" PYBIND11_MAYBE_UNUSED PYBIND11_EXPORT void init##name(); \
301
- extern "C" PYBIND11_EXPORT void init##name() { \
302
- (void)pybind11_init_wrapper(); \
303
- } \
304
- PyObject *pybind11_init_wrapper()
305
- #endif
306
-
307
- #if PY_VERSION_HEX >= 0x03050000 && PY_VERSION_HEX < 0x03050200
308
- extern "C" {
309
- struct _Py_atomic_address { void *value; };
310
- PyAPI_DATA(_Py_atomic_address) _PyThreadState_Current;
311
- }
312
- #endif
313
-
314
- #define PYBIND11_TRY_NEXT_OVERLOAD ((PyObject *) 1) // special failure return code
315
- #define PYBIND11_STRINGIFY(x) #x
316
- #define PYBIND11_TOSTRING(x) PYBIND11_STRINGIFY(x)
317
- #define PYBIND11_CONCAT(first, second) first##second
318
- #define PYBIND11_ENSURE_INTERNALS_READY \
319
- pybind11::detail::get_internals();
320
-
321
- #define PYBIND11_CHECK_PYTHON_VERSION \
322
- { \
323
- const char *compiled_ver = PYBIND11_TOSTRING(PY_MAJOR_VERSION) \
324
- "." PYBIND11_TOSTRING(PY_MINOR_VERSION); \
325
- const char *runtime_ver = Py_GetVersion(); \
326
- size_t len = std::strlen(compiled_ver); \
327
- if (std::strncmp(runtime_ver, compiled_ver, len) != 0 \
328
- || (runtime_ver[len] >= '0' && runtime_ver[len] <= '9')) { \
329
- PyErr_Format(PyExc_ImportError, \
330
- "Python version mismatch: module was compiled for Python %s, " \
331
- "but the interpreter version is incompatible: %s.", \
332
- compiled_ver, runtime_ver); \
333
- return nullptr; \
334
- } \
335
- }
336
-
337
- #if PY_VERSION_HEX >= 0x03030000
338
-
339
- #define PYBIND11_CATCH_INIT_EXCEPTIONS \
340
- catch (pybind11::error_already_set &e) { \
341
- pybind11::raise_from(e, PyExc_ImportError, "initialization failed"); \
342
- return nullptr; \
343
- } catch (const std::exception &e) { \
344
- PyErr_SetString(PyExc_ImportError, e.what()); \
345
- return nullptr; \
346
- } \
347
-
348
- #else
349
-
350
- #define PYBIND11_CATCH_INIT_EXCEPTIONS \
351
- catch (pybind11::error_already_set &e) { \
352
- PyErr_SetString(PyExc_ImportError, e.what()); \
353
- return nullptr; \
354
- } catch (const std::exception &e) { \
355
- PyErr_SetString(PyExc_ImportError, e.what()); \
356
- return nullptr; \
357
- } \
358
-
359
- #endif
360
-
361
- /** \rst
362
- ***Deprecated in favor of PYBIND11_MODULE***
363
-
364
- This macro creates the entry point that will be invoked when the Python interpreter
365
- imports a plugin library. Please create a `module_` in the function body and return
366
- the pointer to its underlying Python object at the end.
367
-
368
- .. code-block:: cpp
369
-
370
- PYBIND11_PLUGIN(example) {
371
- pybind11::module_ m("example", "pybind11 example plugin");
372
- /// Set up bindings here
373
- return m.ptr();
374
- }
375
- \endrst */
376
- #define PYBIND11_PLUGIN(name) \
377
- PYBIND11_DEPRECATED("PYBIND11_PLUGIN is deprecated, use PYBIND11_MODULE") \
378
- static PyObject *pybind11_init(); \
379
- PYBIND11_PLUGIN_IMPL(name) { \
380
- PYBIND11_CHECK_PYTHON_VERSION \
381
- PYBIND11_ENSURE_INTERNALS_READY \
382
- try { \
383
- return pybind11_init(); \
384
- } PYBIND11_CATCH_INIT_EXCEPTIONS \
385
- } \
386
- PyObject *pybind11_init()
387
-
388
- /** \rst
389
- This macro creates the entry point that will be invoked when the Python interpreter
390
- imports an extension module. The module name is given as the fist argument and it
391
- should not be in quotes. The second macro argument defines a variable of type
392
- `py::module_` which can be used to initialize the module.
393
-
394
- The entry point is marked as "maybe unused" to aid dead-code detection analysis:
395
- since the entry point is typically only looked up at runtime and not referenced
396
- during translation, it would otherwise appear as unused ("dead") code.
397
-
398
- .. code-block:: cpp
399
-
400
- PYBIND11_MODULE(example, m) {
401
- m.doc() = "pybind11 example module";
402
-
403
- // Add bindings here
404
- m.def("foo", []() {
405
- return "Hello, World!";
406
- });
407
- }
408
- \endrst */
409
- #define PYBIND11_MODULE(name, variable) \
410
- static ::pybind11::module_::module_def PYBIND11_CONCAT(pybind11_module_def_, name) \
411
- PYBIND11_MAYBE_UNUSED; \
412
- PYBIND11_MAYBE_UNUSED \
413
- static void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ &); \
414
- PYBIND11_PLUGIN_IMPL(name) { \
415
- PYBIND11_CHECK_PYTHON_VERSION \
416
- PYBIND11_ENSURE_INTERNALS_READY \
417
- auto m = ::pybind11::module_::create_extension_module( \
418
- PYBIND11_TOSTRING(name), nullptr, &PYBIND11_CONCAT(pybind11_module_def_, name)); \
419
- try { \
420
- PYBIND11_CONCAT(pybind11_init_, name)(m); \
421
- return m.ptr(); \
422
- } \
423
- PYBIND11_CATCH_INIT_EXCEPTIONS \
424
- } \
425
- void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ & (variable))
426
-
427
- PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
428
-
429
- using ssize_t = Py_ssize_t;
430
- using size_t = std::size_t;
431
-
432
- template <typename IntType>
433
- inline ssize_t ssize_t_cast(const IntType &val) {
434
- static_assert(sizeof(IntType) <= sizeof(ssize_t), "Implicit narrowing is not permitted.");
435
- return static_cast<ssize_t>(val);
436
- }
437
-
438
- /// Approach used to cast a previously unknown C++ instance into a Python object
439
- enum class return_value_policy : uint8_t {
440
- /** This is the default return value policy, which falls back to the policy
441
- return_value_policy::take_ownership when the return value is a pointer.
442
- Otherwise, it uses return_value::move or return_value::copy for rvalue
443
- and lvalue references, respectively. See below for a description of what
444
- all of these different policies do. */
445
- automatic = 0,
446
-
447
- /** As above, but use policy return_value_policy::reference when the return
448
- value is a pointer. This is the default conversion policy for function
449
- arguments when calling Python functions manually from C++ code (i.e. via
450
- handle::operator()). You probably won't need to use this. */
451
- automatic_reference,
452
-
453
- /** Reference an existing object (i.e. do not create a new copy) and take
454
- ownership. Python will call the destructor and delete operator when the
455
- object’s reference count reaches zero. Undefined behavior ensues when
456
- the C++ side does the same.. */
457
- take_ownership,
458
-
459
- /** Create a new copy of the returned object, which will be owned by
460
- Python. This policy is comparably safe because the lifetimes of the two
461
- instances are decoupled. */
462
- copy,
463
-
464
- /** Use std::move to move the return value contents into a new instance
465
- that will be owned by Python. This policy is comparably safe because the
466
- lifetimes of the two instances (move source and destination) are
467
- decoupled. */
468
- move,
469
-
470
- /** Reference an existing object, but do not take ownership. The C++ side
471
- is responsible for managing the object’s lifetime and deallocating it
472
- when it is no longer used. Warning: undefined behavior will ensue when
473
- the C++ side deletes an object that is still referenced and used by
474
- Python. */
475
- reference,
476
-
477
- /** This policy only applies to methods and properties. It references the
478
- object without taking ownership similar to the above
479
- return_value_policy::reference policy. In contrast to that policy, the
480
- function or property’s implicit this argument (called the parent) is
481
- considered to be the the owner of the return value (the child).
482
- pybind11 then couples the lifetime of the parent to the child via a
483
- reference relationship that ensures that the parent cannot be garbage
484
- collected while Python is still using the child. More advanced
485
- variations of this scheme are also possible using combinations of
486
- return_value_policy::reference and the keep_alive call policy */
487
- reference_internal
488
- };
489
-
490
- PYBIND11_NAMESPACE_BEGIN(detail)
491
-
492
- inline static constexpr int log2(size_t n, int k = 0) { return (n <= 1) ? k : log2(n >> 1, k + 1); }
493
-
494
- // Returns the size as a multiple of sizeof(void *), rounded up.
495
- inline static constexpr size_t size_in_ptrs(size_t s) { return 1 + ((s - 1) >> log2(sizeof(void *))); }
496
-
497
- /**
498
- * The space to allocate for simple layout instance holders (see below) in multiple of the size of
499
- * a pointer (e.g. 2 means 16 bytes on 64-bit architectures). The default is the minimum required
500
- * to holder either a std::unique_ptr or std::shared_ptr (which is almost always
501
- * sizeof(std::shared_ptr<T>)).
502
- */
503
- constexpr size_t instance_simple_holder_in_ptrs() {
504
- static_assert(sizeof(std::shared_ptr<int>) >= sizeof(std::unique_ptr<int>),
505
- "pybind assumes std::shared_ptrs are at least as big as std::unique_ptrs");
506
- return size_in_ptrs(sizeof(std::shared_ptr<int>));
507
- }
508
-
509
- // Forward declarations
510
- struct type_info;
511
- struct value_and_holder;
512
-
513
- struct nonsimple_values_and_holders {
514
- void **values_and_holders;
515
- uint8_t *status;
516
- };
517
-
518
- /// The 'instance' type which needs to be standard layout (need to be able to use 'offsetof')
519
- struct instance {
520
- PyObject_HEAD
521
- /// Storage for pointers and holder; see simple_layout, below, for a description
522
- union {
523
- void *simple_value_holder[1 + instance_simple_holder_in_ptrs()];
524
- nonsimple_values_and_holders nonsimple;
525
- };
526
- /// Weak references
527
- PyObject *weakrefs;
528
- /// If true, the pointer is owned which means we're free to manage it with a holder.
529
- bool owned : 1;
530
- /**
531
- * An instance has two possible value/holder layouts.
532
- *
533
- * Simple layout (when this flag is true), means the `simple_value_holder` is set with a pointer
534
- * and the holder object governing that pointer, i.e. [val1*][holder]. This layout is applied
535
- * whenever there is no python-side multiple inheritance of bound C++ types *and* the type's
536
- * holder will fit in the default space (which is large enough to hold either a std::unique_ptr
537
- * or std::shared_ptr).
538
- *
539
- * Non-simple layout applies when using custom holders that require more space than `shared_ptr`
540
- * (which is typically the size of two pointers), or when multiple inheritance is used on the
541
- * python side. Non-simple layout allocates the required amount of memory to have multiple
542
- * bound C++ classes as parents. Under this layout, `nonsimple.values_and_holders` is set to a
543
- * pointer to allocated space of the required space to hold a sequence of value pointers and
544
- * holders followed `status`, a set of bit flags (1 byte each), i.e.
545
- * [val1*][holder1][val2*][holder2]...[bb...] where each [block] is rounded up to a multiple of
546
- * `sizeof(void *)`. `nonsimple.status` is, for convenience, a pointer to the
547
- * beginning of the [bb...] block (but not independently allocated).
548
- *
549
- * Status bits indicate whether the associated holder is constructed (&
550
- * status_holder_constructed) and whether the value pointer is registered (&
551
- * status_instance_registered) in `registered_instances`.
552
- */
553
- bool simple_layout : 1;
554
- /// For simple layout, tracks whether the holder has been constructed
555
- bool simple_holder_constructed : 1;
556
- /// For simple layout, tracks whether the instance is registered in `registered_instances`
557
- bool simple_instance_registered : 1;
558
- /// If true, get_internals().patients has an entry for this object
559
- bool has_patients : 1;
560
-
561
- /// Initializes all of the above type/values/holders data (but not the instance values themselves)
562
- void allocate_layout();
563
-
564
- /// Destroys/deallocates all of the above
565
- void deallocate_layout();
566
-
567
- /// Returns the value_and_holder wrapper for the given type (or the first, if `find_type`
568
- /// omitted). Returns a default-constructed (with `.inst = nullptr`) object on failure if
569
- /// `throw_if_missing` is false.
570
- value_and_holder get_value_and_holder(const type_info *find_type = nullptr, bool throw_if_missing = true);
571
-
572
- /// Bit values for the non-simple status flags
573
- static constexpr uint8_t status_holder_constructed = 1;
574
- static constexpr uint8_t status_instance_registered = 2;
575
- };
576
-
577
- static_assert(std::is_standard_layout<instance>::value, "Internal error: `pybind11::detail::instance` is not standard layout!");
578
-
579
- /// from __cpp_future__ import (convenient aliases from C++14/17)
580
- #if defined(PYBIND11_CPP14) && (!defined(_MSC_VER) || _MSC_VER >= 1910)
581
- using std::enable_if_t;
582
- using std::conditional_t;
583
- using std::remove_cv_t;
584
- using std::remove_reference_t;
585
- #else
586
- template <bool B, typename T = void> using enable_if_t = typename std::enable_if<B, T>::type;
587
- template <bool B, typename T, typename F> using conditional_t = typename std::conditional<B, T, F>::type;
588
- template <typename T> using remove_cv_t = typename std::remove_cv<T>::type;
589
- template <typename T> using remove_reference_t = typename std::remove_reference<T>::type;
590
- #endif
591
-
592
- /// Index sequences
593
- #if defined(PYBIND11_CPP14)
594
- using std::index_sequence;
595
- using std::make_index_sequence;
596
- #else
597
- template<size_t ...> struct index_sequence { };
598
- template<size_t N, size_t ...S> struct make_index_sequence_impl : make_index_sequence_impl <N - 1, N - 1, S...> { };
599
- template<size_t ...S> struct make_index_sequence_impl <0, S...> { using type = index_sequence<S...>; };
600
- template<size_t N> using make_index_sequence = typename make_index_sequence_impl<N>::type;
601
- #endif
602
-
603
- /// Make an index sequence of the indices of true arguments
604
- template <typename ISeq, size_t, bool...> struct select_indices_impl { using type = ISeq; };
605
- template <size_t... IPrev, size_t I, bool B, bool... Bs> struct select_indices_impl<index_sequence<IPrev...>, I, B, Bs...>
606
- : select_indices_impl<conditional_t<B, index_sequence<IPrev..., I>, index_sequence<IPrev...>>, I + 1, Bs...> {};
607
- template <bool... Bs> using select_indices = typename select_indices_impl<index_sequence<>, 0, Bs...>::type;
608
-
609
- /// Backports of std::bool_constant and std::negation to accommodate older compilers
610
- template <bool B> using bool_constant = std::integral_constant<bool, B>;
611
- template <typename T> struct negation : bool_constant<!T::value> { };
612
-
613
- // PGI/Intel cannot detect operator delete with the "compatible" void_t impl, so
614
- // using the new one (C++14 defect, so generally works on newer compilers, even
615
- // if not in C++17 mode)
616
- #if defined(__PGIC__) || defined(__INTEL_COMPILER)
617
- template<typename... > using void_t = void;
618
- #else
619
- template <typename...> struct void_t_impl { using type = void; };
620
- template <typename... Ts> using void_t = typename void_t_impl<Ts...>::type;
621
- #endif
622
-
623
-
624
- /// Compile-time all/any/none of that check the boolean value of all template types
625
- #if defined(__cpp_fold_expressions) && !(defined(_MSC_VER) && (_MSC_VER < 1916))
626
- template <class... Ts> using all_of = bool_constant<(Ts::value && ...)>;
627
- template <class... Ts> using any_of = bool_constant<(Ts::value || ...)>;
628
- #elif !defined(_MSC_VER)
629
- template <bool...> struct bools {};
630
- template <class... Ts> using all_of = std::is_same<
631
- bools<Ts::value..., true>,
632
- bools<true, Ts::value...>>;
633
- template <class... Ts> using any_of = negation<all_of<negation<Ts>...>>;
634
- #else
635
- // MSVC has trouble with the above, but supports std::conjunction, which we can use instead (albeit
636
- // at a slight loss of compilation efficiency).
637
- template <class... Ts> using all_of = std::conjunction<Ts...>;
638
- template <class... Ts> using any_of = std::disjunction<Ts...>;
639
- #endif
640
- template <class... Ts> using none_of = negation<any_of<Ts...>>;
641
-
642
- template <class T, template<class> class... Predicates> using satisfies_all_of = all_of<Predicates<T>...>;
643
- template <class T, template<class> class... Predicates> using satisfies_any_of = any_of<Predicates<T>...>;
644
- template <class T, template<class> class... Predicates> using satisfies_none_of = none_of<Predicates<T>...>;
645
-
646
- /// Strip the class from a method type
647
- template <typename T> struct remove_class { };
648
- template <typename C, typename R, typename... A> struct remove_class<R (C::*)(A...)> { using type = R (A...); };
649
- template <typename C, typename R, typename... A> struct remove_class<R (C::*)(A...) const> { using type = R (A...); };
650
-
651
- /// Helper template to strip away type modifiers
652
- template <typename T> struct intrinsic_type { using type = T; };
653
- template <typename T> struct intrinsic_type<const T> { using type = typename intrinsic_type<T>::type; };
654
- template <typename T> struct intrinsic_type<T*> { using type = typename intrinsic_type<T>::type; };
655
- template <typename T> struct intrinsic_type<T&> { using type = typename intrinsic_type<T>::type; };
656
- template <typename T> struct intrinsic_type<T&&> { using type = typename intrinsic_type<T>::type; };
657
- template <typename T, size_t N> struct intrinsic_type<const T[N]> { using type = typename intrinsic_type<T>::type; };
658
- template <typename T, size_t N> struct intrinsic_type<T[N]> { using type = typename intrinsic_type<T>::type; };
659
- template <typename T> using intrinsic_t = typename intrinsic_type<T>::type;
660
-
661
- /// Helper type to replace 'void' in some expressions
662
- struct void_type { };
663
-
664
- /// Helper template which holds a list of types
665
- template <typename...> struct type_list { };
666
-
667
- /// Compile-time integer sum
668
- #ifdef __cpp_fold_expressions
669
- template <typename... Ts> constexpr size_t constexpr_sum(Ts... ns) { return (0 + ... + size_t{ns}); }
670
- #else
671
- constexpr size_t constexpr_sum() { return 0; }
672
- template <typename T, typename... Ts>
673
- constexpr size_t constexpr_sum(T n, Ts... ns) { return size_t{n} + constexpr_sum(ns...); }
674
- #endif
675
-
676
- PYBIND11_NAMESPACE_BEGIN(constexpr_impl)
677
- /// Implementation details for constexpr functions
678
- constexpr int first(int i) { return i; }
679
- template <typename T, typename... Ts>
680
- constexpr int first(int i, T v, Ts... vs) { return v ? i : first(i + 1, vs...); }
681
-
682
- constexpr int last(int /*i*/, int result) { return result; }
683
- template <typename T, typename... Ts>
684
- constexpr int last(int i, int result, T v, Ts... vs) { return last(i + 1, v ? i : result, vs...); }
685
- PYBIND11_NAMESPACE_END(constexpr_impl)
686
-
687
- /// Return the index of the first type in Ts which satisfies Predicate<T>. Returns sizeof...(Ts) if
688
- /// none match.
689
- template <template<typename> class Predicate, typename... Ts>
690
- constexpr int constexpr_first() { return constexpr_impl::first(0, Predicate<Ts>::value...); }
691
-
692
- /// Return the index of the last type in Ts which satisfies Predicate<T>, or -1 if none match.
693
- template <template<typename> class Predicate, typename... Ts>
694
- constexpr int constexpr_last() { return constexpr_impl::last(0, -1, Predicate<Ts>::value...); }
695
-
696
- /// Return the Nth element from the parameter pack
697
- template <size_t N, typename T, typename... Ts>
698
- struct pack_element { using type = typename pack_element<N - 1, Ts...>::type; };
699
- template <typename T, typename... Ts>
700
- struct pack_element<0, T, Ts...> { using type = T; };
701
-
702
- /// Return the one and only type which matches the predicate, or Default if none match.
703
- /// If more than one type matches the predicate, fail at compile-time.
704
- template <template<typename> class Predicate, typename Default, typename... Ts>
705
- struct exactly_one {
706
- static constexpr auto found = constexpr_sum(Predicate<Ts>::value...);
707
- static_assert(found <= 1, "Found more than one type matching the predicate");
708
-
709
- static constexpr auto index = found ? constexpr_first<Predicate, Ts...>() : 0;
710
- using type = conditional_t<found, typename pack_element<index, Ts...>::type, Default>;
711
- };
712
- template <template<typename> class P, typename Default>
713
- struct exactly_one<P, Default> { using type = Default; };
714
-
715
- template <template<typename> class Predicate, typename Default, typename... Ts>
716
- using exactly_one_t = typename exactly_one<Predicate, Default, Ts...>::type;
717
-
718
- /// Defer the evaluation of type T until types Us are instantiated
719
- template <typename T, typename... /*Us*/> struct deferred_type { using type = T; };
720
- template <typename T, typename... Us> using deferred_t = typename deferred_type<T, Us...>::type;
721
-
722
- /// Like is_base_of, but requires a strict base (i.e. `is_strict_base_of<T, T>::value == false`,
723
- /// unlike `std::is_base_of`)
724
- template <typename Base, typename Derived> using is_strict_base_of = bool_constant<
725
- std::is_base_of<Base, Derived>::value && !std::is_same<Base, Derived>::value>;
726
-
727
- /// Like is_base_of, but also requires that the base type is accessible (i.e. that a Derived pointer
728
- /// can be converted to a Base pointer)
729
- /// For unions, `is_base_of<T, T>::value` is False, so we need to check `is_same` as well.
730
- template <typename Base, typename Derived> using is_accessible_base_of = bool_constant<
731
- (std::is_same<Base, Derived>::value || std::is_base_of<Base, Derived>::value) && std::is_convertible<Derived *, Base *>::value>;
732
-
733
- template <template<typename...> class Base>
734
- struct is_template_base_of_impl {
735
- template <typename... Us> static std::true_type check(Base<Us...> *);
736
- static std::false_type check(...);
737
- };
738
-
739
- /// Check if a template is the base of a type. For example:
740
- /// `is_template_base_of<Base, T>` is true if `struct T : Base<U> {}` where U can be anything
741
- template <template<typename...> class Base, typename T>
742
- #if !defined(_MSC_VER)
743
- using is_template_base_of = decltype(is_template_base_of_impl<Base>::check((intrinsic_t<T>*)nullptr));
744
- #else // MSVC2015 has trouble with decltype in template aliases
745
- struct is_template_base_of : decltype(is_template_base_of_impl<Base>::check((intrinsic_t<T>*)nullptr)) { };
746
- #endif
747
-
748
- /// Check if T is an instantiation of the template `Class`. For example:
749
- /// `is_instantiation<shared_ptr, T>` is true if `T == shared_ptr<U>` where U can be anything.
750
- template <template<typename...> class Class, typename T>
751
- struct is_instantiation : std::false_type { };
752
- template <template<typename...> class Class, typename... Us>
753
- struct is_instantiation<Class, Class<Us...>> : std::true_type { };
754
-
755
- /// Check if T is std::shared_ptr<U> where U can be anything
756
- template <typename T> using is_shared_ptr = is_instantiation<std::shared_ptr, T>;
757
-
758
- /// Check if T looks like an input iterator
759
- template <typename T, typename = void> struct is_input_iterator : std::false_type {};
760
- template <typename T>
761
- struct is_input_iterator<T, void_t<decltype(*std::declval<T &>()), decltype(++std::declval<T &>())>>
762
- : std::true_type {};
763
-
764
- template <typename T> using is_function_pointer = bool_constant<
765
- std::is_pointer<T>::value && std::is_function<typename std::remove_pointer<T>::type>::value>;
766
-
767
- template <typename F> struct strip_function_object {
768
- // If you are encountering an
769
- // 'error: name followed by "::" must be a class or namespace name'
770
- // with the Intel compiler and a noexcept function here,
771
- // try to use noexcept(true) instead of plain noexcept.
772
- using type = typename remove_class<decltype(&F::operator())>::type;
773
- };
774
-
775
- // Extracts the function signature from a function, function pointer or lambda.
776
- template <typename Function, typename F = remove_reference_t<Function>>
777
- using function_signature_t = conditional_t<
778
- std::is_function<F>::value,
779
- F,
780
- typename conditional_t<
781
- std::is_pointer<F>::value || std::is_member_pointer<F>::value,
782
- std::remove_pointer<F>,
783
- strip_function_object<F>
784
- >::type
785
- >;
786
-
787
- /// Returns true if the type looks like a lambda: that is, isn't a function, pointer or member
788
- /// pointer. Note that this can catch all sorts of other things, too; this is intended to be used
789
- /// in a place where passing a lambda makes sense.
790
- template <typename T> using is_lambda = satisfies_none_of<remove_reference_t<T>,
791
- std::is_function, std::is_pointer, std::is_member_pointer>;
792
-
793
- // [workaround(intel)] Internal error on fold expression
794
- /// Apply a function over each element of a parameter pack
795
- #if defined(__cpp_fold_expressions) && !defined(__INTEL_COMPILER)
796
- // Intel compiler produces an internal error on this fold expression (tested with ICC 19.0.2)
797
- #define PYBIND11_EXPAND_SIDE_EFFECTS(PATTERN) (((PATTERN), void()), ...)
798
- #else
799
- using expand_side_effects = bool[];
800
- #define PYBIND11_EXPAND_SIDE_EFFECTS(PATTERN) (void)pybind11::detail::expand_side_effects{ ((PATTERN), void(), false)..., false }
801
- #endif
802
-
803
- PYBIND11_NAMESPACE_END(detail)
804
-
805
- #if defined(_MSC_VER)
806
- # pragma warning(push)
807
- # pragma warning(disable: 4275) // warning C4275: An exported class was derived from a class that wasn't exported. Can be ignored when derived from a STL class.
808
- #endif
809
- /// C++ bindings of builtin Python exceptions
810
- class PYBIND11_EXPORT_EXCEPTION builtin_exception : public std::runtime_error {
811
- public:
812
- using std::runtime_error::runtime_error;
813
- /// Set the error using the Python C API
814
- virtual void set_error() const = 0;
815
- };
816
- #if defined(_MSC_VER)
817
- # pragma warning(pop)
818
- #endif
819
-
820
- #define PYBIND11_RUNTIME_EXCEPTION(name, type) \
821
- class PYBIND11_EXPORT_EXCEPTION name : public builtin_exception { public: \
822
- using builtin_exception::builtin_exception; \
823
- name() : name("") { } \
824
- void set_error() const override { PyErr_SetString(type, what()); } \
825
- };
826
-
827
- PYBIND11_RUNTIME_EXCEPTION(stop_iteration, PyExc_StopIteration)
828
- PYBIND11_RUNTIME_EXCEPTION(index_error, PyExc_IndexError)
829
- PYBIND11_RUNTIME_EXCEPTION(key_error, PyExc_KeyError)
830
- PYBIND11_RUNTIME_EXCEPTION(value_error, PyExc_ValueError)
831
- PYBIND11_RUNTIME_EXCEPTION(type_error, PyExc_TypeError)
832
- PYBIND11_RUNTIME_EXCEPTION(buffer_error, PyExc_BufferError)
833
- PYBIND11_RUNTIME_EXCEPTION(import_error, PyExc_ImportError)
834
- PYBIND11_RUNTIME_EXCEPTION(cast_error, PyExc_RuntimeError) /// Thrown when pybind11::cast or handle::call fail due to a type casting error
835
- PYBIND11_RUNTIME_EXCEPTION(reference_cast_error, PyExc_RuntimeError) /// Used internally
836
-
837
- [[noreturn]] PYBIND11_NOINLINE void pybind11_fail(const char *reason) { throw std::runtime_error(reason); }
838
- [[noreturn]] PYBIND11_NOINLINE void pybind11_fail(const std::string &reason) { throw std::runtime_error(reason); }
839
-
840
- template <typename T, typename SFINAE = void> struct format_descriptor { };
841
-
842
- PYBIND11_NAMESPACE_BEGIN(detail)
843
- // Returns the index of the given type in the type char array below, and in the list in numpy.h
844
- // The order here is: bool; 8 ints ((signed,unsigned)x(8,16,32,64)bits); float,double,long double;
845
- // complex float,double,long double. Note that the long double types only participate when long
846
- // double is actually longer than double (it isn't under MSVC).
847
- // NB: not only the string below but also complex.h and numpy.h rely on this order.
848
- template <typename T, typename SFINAE = void> struct is_fmt_numeric { static constexpr bool value = false; };
849
- template <typename T> struct is_fmt_numeric<T, enable_if_t<std::is_arithmetic<T>::value>> {
850
- static constexpr bool value = true;
851
- static constexpr int index = std::is_same<T, bool>::value ? 0 : 1 + (
852
- std::is_integral<T>::value ? detail::log2(sizeof(T))*2 + std::is_unsigned<T>::value : 8 + (
853
- std::is_same<T, double>::value ? 1 : std::is_same<T, long double>::value ? 2 : 0));
854
- };
855
- PYBIND11_NAMESPACE_END(detail)
856
-
857
- template <typename T> struct format_descriptor<T, detail::enable_if_t<std::is_arithmetic<T>::value>> {
858
- static constexpr const char c = "?bBhHiIqQfdg"[detail::is_fmt_numeric<T>::index];
859
- static constexpr const char value[2] = { c, '\0' };
860
- static std::string format() { return std::string(1, c); }
861
- };
862
-
863
- #if !defined(PYBIND11_CPP17)
864
-
865
- template <typename T> constexpr const char format_descriptor<
866
- T, detail::enable_if_t<std::is_arithmetic<T>::value>>::value[2];
867
-
868
- #endif
869
-
870
- /// RAII wrapper that temporarily clears any Python error state
871
- struct error_scope {
872
- PyObject *type, *value, *trace;
873
- error_scope() { PyErr_Fetch(&type, &value, &trace); }
874
- ~error_scope() { PyErr_Restore(type, value, trace); }
875
- };
876
-
877
- /// Dummy destructor wrapper that can be used to expose classes with a private destructor
878
- struct nodelete { template <typename T> void operator()(T*) { } };
879
-
880
- PYBIND11_NAMESPACE_BEGIN(detail)
881
- template <typename... Args>
882
- struct overload_cast_impl {
883
- // NOLINTNEXTLINE(modernize-use-equals-default): MSVC 2015 needs this
884
- constexpr overload_cast_impl() {}
885
-
886
- template <typename Return>
887
- constexpr auto operator()(Return (*pf)(Args...)) const noexcept
888
- -> decltype(pf) { return pf; }
889
-
890
- template <typename Return, typename Class>
891
- constexpr auto operator()(Return (Class::*pmf)(Args...), std::false_type = {}) const noexcept
892
- -> decltype(pmf) { return pmf; }
893
-
894
- template <typename Return, typename Class>
895
- constexpr auto operator()(Return (Class::*pmf)(Args...) const, std::true_type) const noexcept
896
- -> decltype(pmf) { return pmf; }
897
- };
898
- PYBIND11_NAMESPACE_END(detail)
899
-
900
- // overload_cast requires variable templates: C++14
901
- #if defined(PYBIND11_CPP14)
902
- #define PYBIND11_OVERLOAD_CAST 1
903
- /// Syntax sugar for resolving overloaded function pointers:
904
- /// - regular: static_cast<Return (Class::*)(Arg0, Arg1, Arg2)>(&Class::func)
905
- /// - sweet: overload_cast<Arg0, Arg1, Arg2>(&Class::func)
906
- template <typename... Args>
907
- static constexpr detail::overload_cast_impl<Args...> overload_cast = {};
908
- // MSVC 2015 only accepts this particular initialization syntax for this variable template.
909
- #endif
910
-
911
- /// Const member function selector for overload_cast
912
- /// - regular: static_cast<Return (Class::*)(Arg) const>(&Class::func)
913
- /// - sweet: overload_cast<Arg>(&Class::func, const_)
914
- static constexpr auto const_ = std::true_type{};
915
-
916
- #if !defined(PYBIND11_CPP14) // no overload_cast: providing something that static_assert-fails:
917
- template <typename... Args> struct overload_cast {
918
- static_assert(detail::deferred_t<std::false_type, Args...>::value,
919
- "pybind11::overload_cast<...> requires compiling in C++14 mode");
920
- };
921
- #endif // overload_cast
922
-
923
- PYBIND11_NAMESPACE_BEGIN(detail)
924
-
925
- // Adaptor for converting arbitrary container arguments into a vector; implicitly convertible from
926
- // any standard container (or C-style array) supporting std::begin/std::end, any singleton
927
- // arithmetic type (if T is arithmetic), or explicitly constructible from an iterator pair.
928
- template <typename T>
929
- class any_container {
930
- std::vector<T> v;
931
- public:
932
- any_container() = default;
933
-
934
- // Can construct from a pair of iterators
935
- template <typename It, typename = enable_if_t<is_input_iterator<It>::value>>
936
- any_container(It first, It last) : v(first, last) { }
937
-
938
- // Implicit conversion constructor from any arbitrary container type with values convertible to T
939
- template <typename Container, typename = enable_if_t<std::is_convertible<decltype(*std::begin(std::declval<const Container &>())), T>::value>>
940
- // NOLINTNEXTLINE(google-explicit-constructor)
941
- any_container(const Container &c) : any_container(std::begin(c), std::end(c)) { }
942
-
943
- // initializer_list's aren't deducible, so don't get matched by the above template; we need this
944
- // to explicitly allow implicit conversion from one:
945
- template <typename TIn, typename = enable_if_t<std::is_convertible<TIn, T>::value>>
946
- any_container(const std::initializer_list<TIn> &c) : any_container(c.begin(), c.end()) { }
947
-
948
- // Avoid copying if given an rvalue vector of the correct type.
949
- // NOLINTNEXTLINE(google-explicit-constructor)
950
- any_container(std::vector<T> &&v) : v(std::move(v)) { }
951
-
952
- // Moves the vector out of an rvalue any_container
953
- // NOLINTNEXTLINE(google-explicit-constructor)
954
- operator std::vector<T> &&() && { return std::move(v); }
955
-
956
- // Dereferencing obtains a reference to the underlying vector
957
- std::vector<T> &operator*() { return v; }
958
- const std::vector<T> &operator*() const { return v; }
959
-
960
- // -> lets you call methods on the underlying vector
961
- std::vector<T> *operator->() { return &v; }
962
- const std::vector<T> *operator->() const { return &v; }
963
- };
964
-
965
- // Forward-declaration; see detail/class.h
966
- std::string get_fully_qualified_tp_name(PyTypeObject*);
967
-
968
- template <typename T>
969
- inline static std::shared_ptr<T> try_get_shared_from_this(std::enable_shared_from_this<T> *holder_value_ptr) {
970
- // Pre C++17, this code path exploits undefined behavior, but is known to work on many platforms.
971
- // Use at your own risk!
972
- // See also https://en.cppreference.com/w/cpp/memory/enable_shared_from_this, and in particular
973
- // the `std::shared_ptr<Good> gp1 = not_so_good.getptr();` and `try`-`catch` parts of the example.
974
- #if defined(__cpp_lib_enable_shared_from_this) && (!defined(_MSC_VER) || _MSC_VER >= 1912)
975
- return holder_value_ptr->weak_from_this().lock();
976
- #else
977
- try {
978
- return holder_value_ptr->shared_from_this();
979
- }
980
- catch (const std::bad_weak_ptr &) {
981
- return nullptr;
982
- }
983
- #endif
984
- }
985
-
986
- // For silencing "unused" compiler warnings in special situations.
987
- template <typename... Args>
988
- #if defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER < 1920 // MSVC 2017
989
- constexpr
990
- #endif
991
- inline void silence_unused_warnings(Args &&...) {}
992
-
993
- // MSVC warning C4100: Unreferenced formal parameter
994
- #if defined(_MSC_VER) && _MSC_VER <= 1916
995
- # define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...) \
996
- detail::silence_unused_warnings(__VA_ARGS__)
997
- #else
998
- # define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...)
999
- #endif
1000
-
1001
- // GCC -Wunused-but-set-parameter All GCC versions (as of July 2021).
1002
- #if defined(__GNUG__) && !defined(__clang__) && !defined(__INTEL_COMPILER)
1003
- # define PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(...) \
1004
- detail::silence_unused_warnings(__VA_ARGS__)
1005
- #else
1006
- # define PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(...)
1007
- #endif
1008
-
1009
- #if defined(_MSC_VER) // All versions (as of July 2021).
1010
-
1011
- // warning C4127: Conditional expression is constant
1012
- constexpr inline bool silence_msvc_c4127(bool cond) { return cond; }
1013
-
1014
- # define PYBIND11_SILENCE_MSVC_C4127(...) ::pybind11::detail::silence_msvc_c4127(__VA_ARGS__)
1015
-
1016
- #else
1017
- # define PYBIND11_SILENCE_MSVC_C4127(...) __VA_ARGS__
1018
- #endif
1019
-
1020
- PYBIND11_NAMESPACE_END(detail)
1021
- PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)