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,709 +0,0 @@
1
- /*
2
- pybind11/detail/class.h: Python C API implementation details for py::class_
3
-
4
- Copyright (c) 2017 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
- #include "../attr.h"
13
- #include "../options.h"
14
-
15
- PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
16
- PYBIND11_NAMESPACE_BEGIN(detail)
17
-
18
- #if PY_VERSION_HEX >= 0x03030000 && !defined(PYPY_VERSION)
19
- # define PYBIND11_BUILTIN_QUALNAME
20
- # define PYBIND11_SET_OLDPY_QUALNAME(obj, nameobj)
21
- #else
22
- // In pre-3.3 Python, we still set __qualname__ so that we can produce reliable function type
23
- // signatures; in 3.3+ this macro expands to nothing:
24
- # define PYBIND11_SET_OLDPY_QUALNAME(obj, nameobj) setattr((PyObject *) obj, "__qualname__", nameobj)
25
- #endif
26
-
27
- inline std::string get_fully_qualified_tp_name(PyTypeObject *type) {
28
- #if !defined(PYPY_VERSION)
29
- return type->tp_name;
30
- #else
31
- auto module_name = handle((PyObject *) type).attr("__module__").cast<std::string>();
32
- if (module_name == PYBIND11_BUILTINS_MODULE)
33
- return type->tp_name;
34
- else
35
- return std::move(module_name) + "." + type->tp_name;
36
- #endif
37
- }
38
-
39
- inline PyTypeObject *type_incref(PyTypeObject *type) {
40
- Py_INCREF(type);
41
- return type;
42
- }
43
-
44
- #if !defined(PYPY_VERSION)
45
-
46
- /// `pybind11_static_property.__get__()`: Always pass the class instead of the instance.
47
- extern "C" inline PyObject *pybind11_static_get(PyObject *self, PyObject * /*ob*/, PyObject *cls) {
48
- return PyProperty_Type.tp_descr_get(self, cls, cls);
49
- }
50
-
51
- /// `pybind11_static_property.__set__()`: Just like the above `__get__()`.
52
- extern "C" inline int pybind11_static_set(PyObject *self, PyObject *obj, PyObject *value) {
53
- PyObject *cls = PyType_Check(obj) ? obj : (PyObject *) Py_TYPE(obj);
54
- return PyProperty_Type.tp_descr_set(self, cls, value);
55
- }
56
-
57
- /** A `static_property` is the same as a `property` but the `__get__()` and `__set__()`
58
- methods are modified to always use the object type instead of a concrete instance.
59
- Return value: New reference. */
60
- inline PyTypeObject *make_static_property_type() {
61
- constexpr auto *name = "pybind11_static_property";
62
- auto name_obj = reinterpret_steal<object>(PYBIND11_FROM_STRING(name));
63
-
64
- /* Danger zone: from now (and until PyType_Ready), make sure to
65
- issue no Python C API calls which could potentially invoke the
66
- garbage collector (the GC will call type_traverse(), which will in
67
- turn find the newly constructed type in an invalid state) */
68
- auto heap_type = (PyHeapTypeObject *) PyType_Type.tp_alloc(&PyType_Type, 0);
69
- if (!heap_type)
70
- pybind11_fail("make_static_property_type(): error allocating type!");
71
-
72
- heap_type->ht_name = name_obj.inc_ref().ptr();
73
- #ifdef PYBIND11_BUILTIN_QUALNAME
74
- heap_type->ht_qualname = name_obj.inc_ref().ptr();
75
- #endif
76
-
77
- auto type = &heap_type->ht_type;
78
- type->tp_name = name;
79
- type->tp_base = type_incref(&PyProperty_Type);
80
- type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
81
- type->tp_descr_get = pybind11_static_get;
82
- type->tp_descr_set = pybind11_static_set;
83
-
84
- if (PyType_Ready(type) < 0)
85
- pybind11_fail("make_static_property_type(): failure in PyType_Ready()!");
86
-
87
- setattr((PyObject *) type, "__module__", str("pybind11_builtins"));
88
- PYBIND11_SET_OLDPY_QUALNAME(type, name_obj);
89
-
90
- return type;
91
- }
92
-
93
- #else // PYPY
94
-
95
- /** PyPy has some issues with the above C API, so we evaluate Python code instead.
96
- This function will only be called once so performance isn't really a concern.
97
- Return value: New reference. */
98
- inline PyTypeObject *make_static_property_type() {
99
- auto d = dict();
100
- PyObject *result = PyRun_String(R"(\
101
- class pybind11_static_property(property):
102
- def __get__(self, obj, cls):
103
- return property.__get__(self, cls, cls)
104
-
105
- def __set__(self, obj, value):
106
- cls = obj if isinstance(obj, type) else type(obj)
107
- property.__set__(self, cls, value)
108
- )", Py_file_input, d.ptr(), d.ptr()
109
- );
110
- if (result == nullptr)
111
- throw error_already_set();
112
- Py_DECREF(result);
113
- return (PyTypeObject *) d["pybind11_static_property"].cast<object>().release().ptr();
114
- }
115
-
116
- #endif // PYPY
117
-
118
- /** Types with static properties need to handle `Type.static_prop = x` in a specific way.
119
- By default, Python replaces the `static_property` itself, but for wrapped C++ types
120
- we need to call `static_property.__set__()` in order to propagate the new value to
121
- the underlying C++ data structure. */
122
- extern "C" inline int pybind11_meta_setattro(PyObject* obj, PyObject* name, PyObject* value) {
123
- // Use `_PyType_Lookup()` instead of `PyObject_GetAttr()` in order to get the raw
124
- // descriptor (`property`) instead of calling `tp_descr_get` (`property.__get__()`).
125
- PyObject *descr = _PyType_Lookup((PyTypeObject *) obj, name);
126
-
127
- // The following assignment combinations are possible:
128
- // 1. `Type.static_prop = value` --> descr_set: `Type.static_prop.__set__(value)`
129
- // 2. `Type.static_prop = other_static_prop` --> setattro: replace existing `static_prop`
130
- // 3. `Type.regular_attribute = value` --> setattro: regular attribute assignment
131
- const auto static_prop = (PyObject *) get_internals().static_property_type;
132
- const auto call_descr_set = (descr != nullptr) && (value != nullptr)
133
- && (PyObject_IsInstance(descr, static_prop) != 0)
134
- && (PyObject_IsInstance(value, static_prop) == 0);
135
- if (call_descr_set) {
136
- // Call `static_property.__set__()` instead of replacing the `static_property`.
137
- #if !defined(PYPY_VERSION)
138
- return Py_TYPE(descr)->tp_descr_set(descr, obj, value);
139
- #else
140
- if (PyObject *result = PyObject_CallMethod(descr, "__set__", "OO", obj, value)) {
141
- Py_DECREF(result);
142
- return 0;
143
- } else {
144
- return -1;
145
- }
146
- #endif
147
- } else {
148
- // Replace existing attribute.
149
- return PyType_Type.tp_setattro(obj, name, value);
150
- }
151
- }
152
-
153
- #if PY_MAJOR_VERSION >= 3
154
- /**
155
- * Python 3's PyInstanceMethod_Type hides itself via its tp_descr_get, which prevents aliasing
156
- * methods via cls.attr("m2") = cls.attr("m1"): instead the tp_descr_get returns a plain function,
157
- * when called on a class, or a PyMethod, when called on an instance. Override that behaviour here
158
- * to do a special case bypass for PyInstanceMethod_Types.
159
- */
160
- extern "C" inline PyObject *pybind11_meta_getattro(PyObject *obj, PyObject *name) {
161
- PyObject *descr = _PyType_Lookup((PyTypeObject *) obj, name);
162
- if (descr && PyInstanceMethod_Check(descr)) {
163
- Py_INCREF(descr);
164
- return descr;
165
- }
166
- return PyType_Type.tp_getattro(obj, name);
167
- }
168
- #endif
169
-
170
- /// metaclass `__call__` function that is used to create all pybind11 objects.
171
- extern "C" inline PyObject *pybind11_meta_call(PyObject *type, PyObject *args, PyObject *kwargs) {
172
-
173
- // use the default metaclass call to create/initialize the object
174
- PyObject *self = PyType_Type.tp_call(type, args, kwargs);
175
- if (self == nullptr) {
176
- return nullptr;
177
- }
178
-
179
- // This must be a pybind11 instance
180
- auto instance = reinterpret_cast<detail::instance *>(self);
181
-
182
- // Ensure that the base __init__ function(s) were called
183
- for (const auto &vh : values_and_holders(instance)) {
184
- if (!vh.holder_constructed()) {
185
- PyErr_Format(PyExc_TypeError, "%.200s.__init__() must be called when overriding __init__",
186
- get_fully_qualified_tp_name(vh.type->type).c_str());
187
- Py_DECREF(self);
188
- return nullptr;
189
- }
190
- }
191
-
192
- return self;
193
- }
194
-
195
- /// Cleanup the type-info for a pybind11-registered type.
196
- extern "C" inline void pybind11_meta_dealloc(PyObject *obj) {
197
- auto *type = (PyTypeObject *) obj;
198
- auto &internals = get_internals();
199
-
200
- // A pybind11-registered type will:
201
- // 1) be found in internals.registered_types_py
202
- // 2) have exactly one associated `detail::type_info`
203
- auto found_type = internals.registered_types_py.find(type);
204
- if (found_type != internals.registered_types_py.end() &&
205
- found_type->second.size() == 1 &&
206
- found_type->second[0]->type == type) {
207
-
208
- auto *tinfo = found_type->second[0];
209
- auto tindex = std::type_index(*tinfo->cpptype);
210
- internals.direct_conversions.erase(tindex);
211
-
212
- if (tinfo->module_local)
213
- get_local_internals().registered_types_cpp.erase(tindex);
214
- else
215
- internals.registered_types_cpp.erase(tindex);
216
- internals.registered_types_py.erase(tinfo->type);
217
-
218
- // Actually just `std::erase_if`, but that's only available in C++20
219
- auto &cache = internals.inactive_override_cache;
220
- for (auto it = cache.begin(), last = cache.end(); it != last; ) {
221
- if (it->first == (PyObject *) tinfo->type)
222
- it = cache.erase(it);
223
- else
224
- ++it;
225
- }
226
-
227
- delete tinfo;
228
- }
229
-
230
- PyType_Type.tp_dealloc(obj);
231
- }
232
-
233
- /** This metaclass is assigned by default to all pybind11 types and is required in order
234
- for static properties to function correctly. Users may override this using `py::metaclass`.
235
- Return value: New reference. */
236
- inline PyTypeObject* make_default_metaclass() {
237
- constexpr auto *name = "pybind11_type";
238
- auto name_obj = reinterpret_steal<object>(PYBIND11_FROM_STRING(name));
239
-
240
- /* Danger zone: from now (and until PyType_Ready), make sure to
241
- issue no Python C API calls which could potentially invoke the
242
- garbage collector (the GC will call type_traverse(), which will in
243
- turn find the newly constructed type in an invalid state) */
244
- auto heap_type = (PyHeapTypeObject *) PyType_Type.tp_alloc(&PyType_Type, 0);
245
- if (!heap_type)
246
- pybind11_fail("make_default_metaclass(): error allocating metaclass!");
247
-
248
- heap_type->ht_name = name_obj.inc_ref().ptr();
249
- #ifdef PYBIND11_BUILTIN_QUALNAME
250
- heap_type->ht_qualname = name_obj.inc_ref().ptr();
251
- #endif
252
-
253
- auto type = &heap_type->ht_type;
254
- type->tp_name = name;
255
- type->tp_base = type_incref(&PyType_Type);
256
- type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
257
-
258
- type->tp_call = pybind11_meta_call;
259
-
260
- type->tp_setattro = pybind11_meta_setattro;
261
- #if PY_MAJOR_VERSION >= 3
262
- type->tp_getattro = pybind11_meta_getattro;
263
- #endif
264
-
265
- type->tp_dealloc = pybind11_meta_dealloc;
266
-
267
- if (PyType_Ready(type) < 0)
268
- pybind11_fail("make_default_metaclass(): failure in PyType_Ready()!");
269
-
270
- setattr((PyObject *) type, "__module__", str("pybind11_builtins"));
271
- PYBIND11_SET_OLDPY_QUALNAME(type, name_obj);
272
-
273
- return type;
274
- }
275
-
276
- /// For multiple inheritance types we need to recursively register/deregister base pointers for any
277
- /// base classes with pointers that are difference from the instance value pointer so that we can
278
- /// correctly recognize an offset base class pointer. This calls a function with any offset base ptrs.
279
- inline void traverse_offset_bases(void *valueptr, const detail::type_info *tinfo, instance *self,
280
- bool (*f)(void * /*parentptr*/, instance * /*self*/)) {
281
- for (handle h : reinterpret_borrow<tuple>(tinfo->type->tp_bases)) {
282
- if (auto parent_tinfo = get_type_info((PyTypeObject *) h.ptr())) {
283
- for (auto &c : parent_tinfo->implicit_casts) {
284
- if (c.first == tinfo->cpptype) {
285
- auto *parentptr = c.second(valueptr);
286
- if (parentptr != valueptr)
287
- f(parentptr, self);
288
- traverse_offset_bases(parentptr, parent_tinfo, self, f);
289
- break;
290
- }
291
- }
292
- }
293
- }
294
- }
295
-
296
- inline bool register_instance_impl(void *ptr, instance *self) {
297
- get_internals().registered_instances.emplace(ptr, self);
298
- return true; // unused, but gives the same signature as the deregister func
299
- }
300
- inline bool deregister_instance_impl(void *ptr, instance *self) {
301
- auto &registered_instances = get_internals().registered_instances;
302
- auto range = registered_instances.equal_range(ptr);
303
- for (auto it = range.first; it != range.second; ++it) {
304
- if (self == it->second) {
305
- registered_instances.erase(it);
306
- return true;
307
- }
308
- }
309
- return false;
310
- }
311
-
312
- inline void register_instance(instance *self, void *valptr, const type_info *tinfo) {
313
- register_instance_impl(valptr, self);
314
- if (!tinfo->simple_ancestors)
315
- traverse_offset_bases(valptr, tinfo, self, register_instance_impl);
316
- }
317
-
318
- inline bool deregister_instance(instance *self, void *valptr, const type_info *tinfo) {
319
- bool ret = deregister_instance_impl(valptr, self);
320
- if (!tinfo->simple_ancestors)
321
- traverse_offset_bases(valptr, tinfo, self, deregister_instance_impl);
322
- return ret;
323
- }
324
-
325
- /// Instance creation function for all pybind11 types. It allocates the internal instance layout for
326
- /// holding C++ objects and holders. Allocation is done lazily (the first time the instance is cast
327
- /// to a reference or pointer), and initialization is done by an `__init__` function.
328
- inline PyObject *make_new_instance(PyTypeObject *type) {
329
- #if defined(PYPY_VERSION)
330
- // PyPy gets tp_basicsize wrong (issue 2482) under multiple inheritance when the first inherited
331
- // object is a plain Python type (i.e. not derived from an extension type). Fix it.
332
- ssize_t instance_size = static_cast<ssize_t>(sizeof(instance));
333
- if (type->tp_basicsize < instance_size) {
334
- type->tp_basicsize = instance_size;
335
- }
336
- #endif
337
- PyObject *self = type->tp_alloc(type, 0);
338
- auto inst = reinterpret_cast<instance *>(self);
339
- // Allocate the value/holder internals:
340
- inst->allocate_layout();
341
-
342
- return self;
343
- }
344
-
345
- /// Instance creation function for all pybind11 types. It only allocates space for the
346
- /// C++ object, but doesn't call the constructor -- an `__init__` function must do that.
347
- extern "C" inline PyObject *pybind11_object_new(PyTypeObject *type, PyObject *, PyObject *) {
348
- return make_new_instance(type);
349
- }
350
-
351
- /// An `__init__` function constructs the C++ object. Users should provide at least one
352
- /// of these using `py::init` or directly with `.def(__init__, ...)`. Otherwise, the
353
- /// following default function will be used which simply throws an exception.
354
- extern "C" inline int pybind11_object_init(PyObject *self, PyObject *, PyObject *) {
355
- PyTypeObject *type = Py_TYPE(self);
356
- std::string msg = get_fully_qualified_tp_name(type) + ": No constructor defined!";
357
- PyErr_SetString(PyExc_TypeError, msg.c_str());
358
- return -1;
359
- }
360
-
361
- inline void add_patient(PyObject *nurse, PyObject *patient) {
362
- auto &internals = get_internals();
363
- auto instance = reinterpret_cast<detail::instance *>(nurse);
364
- instance->has_patients = true;
365
- Py_INCREF(patient);
366
- internals.patients[nurse].push_back(patient);
367
- }
368
-
369
- inline void clear_patients(PyObject *self) {
370
- auto instance = reinterpret_cast<detail::instance *>(self);
371
- auto &internals = get_internals();
372
- auto pos = internals.patients.find(self);
373
- assert(pos != internals.patients.end());
374
- // Clearing the patients can cause more Python code to run, which
375
- // can invalidate the iterator. Extract the vector of patients
376
- // from the unordered_map first.
377
- auto patients = std::move(pos->second);
378
- internals.patients.erase(pos);
379
- instance->has_patients = false;
380
- for (PyObject *&patient : patients)
381
- Py_CLEAR(patient);
382
- }
383
-
384
- /// Clears all internal data from the instance and removes it from registered instances in
385
- /// preparation for deallocation.
386
- inline void clear_instance(PyObject *self) {
387
- auto instance = reinterpret_cast<detail::instance *>(self);
388
-
389
- // Deallocate any values/holders, if present:
390
- for (auto &v_h : values_and_holders(instance)) {
391
- if (v_h) {
392
-
393
- // We have to deregister before we call dealloc because, for virtual MI types, we still
394
- // need to be able to get the parent pointers.
395
- if (v_h.instance_registered() && !deregister_instance(instance, v_h.value_ptr(), v_h.type))
396
- pybind11_fail("pybind11_object_dealloc(): Tried to deallocate unregistered instance!");
397
-
398
- if (instance->owned || v_h.holder_constructed())
399
- v_h.type->dealloc(v_h);
400
- }
401
- }
402
- // Deallocate the value/holder layout internals:
403
- instance->deallocate_layout();
404
-
405
- if (instance->weakrefs)
406
- PyObject_ClearWeakRefs(self);
407
-
408
- PyObject **dict_ptr = _PyObject_GetDictPtr(self);
409
- if (dict_ptr)
410
- Py_CLEAR(*dict_ptr);
411
-
412
- if (instance->has_patients)
413
- clear_patients(self);
414
- }
415
-
416
- /// Instance destructor function for all pybind11 types. It calls `type_info.dealloc`
417
- /// to destroy the C++ object itself, while the rest is Python bookkeeping.
418
- extern "C" inline void pybind11_object_dealloc(PyObject *self) {
419
- clear_instance(self);
420
-
421
- auto type = Py_TYPE(self);
422
- type->tp_free(self);
423
-
424
- #if PY_VERSION_HEX < 0x03080000
425
- // `type->tp_dealloc != pybind11_object_dealloc` means that we're being called
426
- // as part of a derived type's dealloc, in which case we're not allowed to decref
427
- // the type here. For cross-module compatibility, we shouldn't compare directly
428
- // with `pybind11_object_dealloc`, but with the common one stashed in internals.
429
- auto pybind11_object_type = (PyTypeObject *) get_internals().instance_base;
430
- if (type->tp_dealloc == pybind11_object_type->tp_dealloc)
431
- Py_DECREF(type);
432
- #else
433
- // This was not needed before Python 3.8 (Python issue 35810)
434
- // https://github.com/pybind/pybind11/issues/1946
435
- Py_DECREF(type);
436
- #endif
437
- }
438
-
439
- /** Create the type which can be used as a common base for all classes. This is
440
- needed in order to satisfy Python's requirements for multiple inheritance.
441
- Return value: New reference. */
442
- inline PyObject *make_object_base_type(PyTypeObject *metaclass) {
443
- constexpr auto *name = "pybind11_object";
444
- auto name_obj = reinterpret_steal<object>(PYBIND11_FROM_STRING(name));
445
-
446
- /* Danger zone: from now (and until PyType_Ready), make sure to
447
- issue no Python C API calls which could potentially invoke the
448
- garbage collector (the GC will call type_traverse(), which will in
449
- turn find the newly constructed type in an invalid state) */
450
- auto heap_type = (PyHeapTypeObject *) metaclass->tp_alloc(metaclass, 0);
451
- if (!heap_type)
452
- pybind11_fail("make_object_base_type(): error allocating type!");
453
-
454
- heap_type->ht_name = name_obj.inc_ref().ptr();
455
- #ifdef PYBIND11_BUILTIN_QUALNAME
456
- heap_type->ht_qualname = name_obj.inc_ref().ptr();
457
- #endif
458
-
459
- auto type = &heap_type->ht_type;
460
- type->tp_name = name;
461
- type->tp_base = type_incref(&PyBaseObject_Type);
462
- type->tp_basicsize = static_cast<ssize_t>(sizeof(instance));
463
- type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
464
-
465
- type->tp_new = pybind11_object_new;
466
- type->tp_init = pybind11_object_init;
467
- type->tp_dealloc = pybind11_object_dealloc;
468
-
469
- /* Support weak references (needed for the keep_alive feature) */
470
- type->tp_weaklistoffset = offsetof(instance, weakrefs);
471
-
472
- if (PyType_Ready(type) < 0)
473
- pybind11_fail("PyType_Ready failed in make_object_base_type():" + error_string());
474
-
475
- setattr((PyObject *) type, "__module__", str("pybind11_builtins"));
476
- PYBIND11_SET_OLDPY_QUALNAME(type, name_obj);
477
-
478
- assert(!PyType_HasFeature(type, Py_TPFLAGS_HAVE_GC));
479
- return (PyObject *) heap_type;
480
- }
481
-
482
- /// dynamic_attr: Support for `d = instance.__dict__`.
483
- extern "C" inline PyObject *pybind11_get_dict(PyObject *self, void *) {
484
- PyObject *&dict = *_PyObject_GetDictPtr(self);
485
- if (!dict)
486
- dict = PyDict_New();
487
- Py_XINCREF(dict);
488
- return dict;
489
- }
490
-
491
- /// dynamic_attr: Support for `instance.__dict__ = dict()`.
492
- extern "C" inline int pybind11_set_dict(PyObject *self, PyObject *new_dict, void *) {
493
- if (!PyDict_Check(new_dict)) {
494
- PyErr_Format(PyExc_TypeError, "__dict__ must be set to a dictionary, not a '%.200s'",
495
- get_fully_qualified_tp_name(Py_TYPE(new_dict)).c_str());
496
- return -1;
497
- }
498
- PyObject *&dict = *_PyObject_GetDictPtr(self);
499
- Py_INCREF(new_dict);
500
- Py_CLEAR(dict);
501
- dict = new_dict;
502
- return 0;
503
- }
504
-
505
- /// dynamic_attr: Allow the garbage collector to traverse the internal instance `__dict__`.
506
- extern "C" inline int pybind11_traverse(PyObject *self, visitproc visit, void *arg) {
507
- PyObject *&dict = *_PyObject_GetDictPtr(self);
508
- Py_VISIT(dict);
509
- return 0;
510
- }
511
-
512
- /// dynamic_attr: Allow the GC to clear the dictionary.
513
- extern "C" inline int pybind11_clear(PyObject *self) {
514
- PyObject *&dict = *_PyObject_GetDictPtr(self);
515
- Py_CLEAR(dict);
516
- return 0;
517
- }
518
-
519
- /// Give instances of this type a `__dict__` and opt into garbage collection.
520
- inline void enable_dynamic_attributes(PyHeapTypeObject *heap_type) {
521
- auto type = &heap_type->ht_type;
522
- type->tp_flags |= Py_TPFLAGS_HAVE_GC;
523
- type->tp_dictoffset = type->tp_basicsize; // place dict at the end
524
- type->tp_basicsize += (ssize_t)sizeof(PyObject *); // and allocate enough space for it
525
- type->tp_traverse = pybind11_traverse;
526
- type->tp_clear = pybind11_clear;
527
-
528
- static PyGetSetDef getset[] = {
529
- {const_cast<char*>("__dict__"), pybind11_get_dict, pybind11_set_dict, nullptr, nullptr},
530
- {nullptr, nullptr, nullptr, nullptr, nullptr}
531
- };
532
- type->tp_getset = getset;
533
- }
534
-
535
- /// buffer_protocol: Fill in the view as specified by flags.
536
- extern "C" inline int pybind11_getbuffer(PyObject *obj, Py_buffer *view, int flags) {
537
- // Look for a `get_buffer` implementation in this type's info or any bases (following MRO).
538
- type_info *tinfo = nullptr;
539
- for (auto type : reinterpret_borrow<tuple>(Py_TYPE(obj)->tp_mro)) {
540
- tinfo = get_type_info((PyTypeObject *) type.ptr());
541
- if (tinfo && tinfo->get_buffer)
542
- break;
543
- }
544
- if (view == nullptr || !tinfo || !tinfo->get_buffer) {
545
- if (view)
546
- view->obj = nullptr;
547
- PyErr_SetString(PyExc_BufferError, "pybind11_getbuffer(): Internal error");
548
- return -1;
549
- }
550
- std::memset(view, 0, sizeof(Py_buffer));
551
- buffer_info *info = tinfo->get_buffer(obj, tinfo->get_buffer_data);
552
- if ((flags & PyBUF_WRITABLE) == PyBUF_WRITABLE && info->readonly) {
553
- delete info;
554
- // view->obj = nullptr; // Was just memset to 0, so not necessary
555
- PyErr_SetString(PyExc_BufferError, "Writable buffer requested for readonly storage");
556
- return -1;
557
- }
558
- view->obj = obj;
559
- view->ndim = 1;
560
- view->internal = info;
561
- view->buf = info->ptr;
562
- view->itemsize = info->itemsize;
563
- view->len = view->itemsize;
564
- for (auto s : info->shape)
565
- view->len *= s;
566
- view->readonly = static_cast<int>(info->readonly);
567
- if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT)
568
- view->format = const_cast<char *>(info->format.c_str());
569
- if ((flags & PyBUF_STRIDES) == PyBUF_STRIDES) {
570
- view->ndim = (int) info->ndim;
571
- view->strides = &info->strides[0];
572
- view->shape = &info->shape[0];
573
- }
574
- Py_INCREF(view->obj);
575
- return 0;
576
- }
577
-
578
- /// buffer_protocol: Release the resources of the buffer.
579
- extern "C" inline void pybind11_releasebuffer(PyObject *, Py_buffer *view) {
580
- delete (buffer_info *) view->internal;
581
- }
582
-
583
- /// Give this type a buffer interface.
584
- inline void enable_buffer_protocol(PyHeapTypeObject *heap_type) {
585
- heap_type->ht_type.tp_as_buffer = &heap_type->as_buffer;
586
- #if PY_MAJOR_VERSION < 3
587
- heap_type->ht_type.tp_flags |= Py_TPFLAGS_HAVE_NEWBUFFER;
588
- #endif
589
-
590
- heap_type->as_buffer.bf_getbuffer = pybind11_getbuffer;
591
- heap_type->as_buffer.bf_releasebuffer = pybind11_releasebuffer;
592
- }
593
-
594
- /** Create a brand new Python type according to the `type_record` specification.
595
- Return value: New reference. */
596
- inline PyObject* make_new_python_type(const type_record &rec) {
597
- auto name = reinterpret_steal<object>(PYBIND11_FROM_STRING(rec.name));
598
-
599
- auto qualname = name;
600
- if (rec.scope && !PyModule_Check(rec.scope.ptr()) && hasattr(rec.scope, "__qualname__")) {
601
- #if PY_MAJOR_VERSION >= 3
602
- qualname = reinterpret_steal<object>(
603
- PyUnicode_FromFormat("%U.%U", rec.scope.attr("__qualname__").ptr(), name.ptr()));
604
- #else
605
- qualname = str(rec.scope.attr("__qualname__").cast<std::string>() + "." + rec.name);
606
- #endif
607
- }
608
-
609
- object module_;
610
- if (rec.scope) {
611
- if (hasattr(rec.scope, "__module__"))
612
- module_ = rec.scope.attr("__module__");
613
- else if (hasattr(rec.scope, "__name__"))
614
- module_ = rec.scope.attr("__name__");
615
- }
616
-
617
- auto full_name = c_str(
618
- #if !defined(PYPY_VERSION)
619
- module_ ? str(module_).cast<std::string>() + "." + rec.name :
620
- #endif
621
- rec.name);
622
-
623
- char *tp_doc = nullptr;
624
- if (rec.doc && options::show_user_defined_docstrings()) {
625
- /* Allocate memory for docstring (using PyObject_MALLOC, since
626
- Python will free this later on) */
627
- size_t size = strlen(rec.doc) + 1;
628
- tp_doc = (char *) PyObject_MALLOC(size);
629
- memcpy((void *) tp_doc, rec.doc, size);
630
- }
631
-
632
- auto &internals = get_internals();
633
- auto bases = tuple(rec.bases);
634
- auto base = (bases.empty()) ? internals.instance_base
635
- : bases[0].ptr();
636
-
637
- /* Danger zone: from now (and until PyType_Ready), make sure to
638
- issue no Python C API calls which could potentially invoke the
639
- garbage collector (the GC will call type_traverse(), which will in
640
- turn find the newly constructed type in an invalid state) */
641
- auto metaclass = rec.metaclass.ptr() ? (PyTypeObject *) rec.metaclass.ptr()
642
- : internals.default_metaclass;
643
-
644
- auto heap_type = (PyHeapTypeObject *) metaclass->tp_alloc(metaclass, 0);
645
- if (!heap_type)
646
- pybind11_fail(std::string(rec.name) + ": Unable to create type object!");
647
-
648
- heap_type->ht_name = name.release().ptr();
649
- #ifdef PYBIND11_BUILTIN_QUALNAME
650
- heap_type->ht_qualname = qualname.inc_ref().ptr();
651
- #endif
652
-
653
- auto type = &heap_type->ht_type;
654
- type->tp_name = full_name;
655
- type->tp_doc = tp_doc;
656
- type->tp_base = type_incref((PyTypeObject *)base);
657
- type->tp_basicsize = static_cast<ssize_t>(sizeof(instance));
658
- if (!bases.empty())
659
- type->tp_bases = bases.release().ptr();
660
-
661
- /* Don't inherit base __init__ */
662
- type->tp_init = pybind11_object_init;
663
-
664
- /* Supported protocols */
665
- type->tp_as_number = &heap_type->as_number;
666
- type->tp_as_sequence = &heap_type->as_sequence;
667
- type->tp_as_mapping = &heap_type->as_mapping;
668
- #if PY_VERSION_HEX >= 0x03050000
669
- type->tp_as_async = &heap_type->as_async;
670
- #endif
671
-
672
- /* Flags */
673
- type->tp_flags |= Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE;
674
- #if PY_MAJOR_VERSION < 3
675
- type->tp_flags |= Py_TPFLAGS_CHECKTYPES;
676
- #endif
677
- if (!rec.is_final)
678
- type->tp_flags |= Py_TPFLAGS_BASETYPE;
679
-
680
- if (rec.dynamic_attr)
681
- enable_dynamic_attributes(heap_type);
682
-
683
- if (rec.buffer_protocol)
684
- enable_buffer_protocol(heap_type);
685
-
686
- if (rec.custom_type_setup_callback)
687
- rec.custom_type_setup_callback(heap_type);
688
-
689
- if (PyType_Ready(type) < 0)
690
- pybind11_fail(std::string(rec.name) + ": PyType_Ready failed (" + error_string() + ")!");
691
-
692
- assert(!rec.dynamic_attr || PyType_HasFeature(type, Py_TPFLAGS_HAVE_GC));
693
-
694
- /* Register type with the parent scope */
695
- if (rec.scope)
696
- setattr(rec.scope, rec.name, (PyObject *) type);
697
- else
698
- Py_INCREF(type); // Keep it alive forever (reference leak)
699
-
700
- if (module_) // Needed by pydoc
701
- setattr((PyObject *) type, "__module__", module_);
702
-
703
- PYBIND11_SET_OLDPY_QUALNAME(type, qualname);
704
-
705
- return (PyObject *) type;
706
- }
707
-
708
- PYBIND11_NAMESPACE_END(detail)
709
- PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)