netgen-mesher 6.2.2506.post35.dev0__cp314-cp314-win_amd64.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.
Files changed (340) hide show
  1. netgen/NgOCC.py +7 -0
  2. netgen/__init__.py +114 -0
  3. netgen/__init__.pyi +22 -0
  4. netgen/__main__.py +53 -0
  5. netgen/cmake/NetgenConfig.cmake +79 -0
  6. netgen/cmake/netgen-targets-release.cmake +69 -0
  7. netgen/cmake/netgen-targets.cmake +146 -0
  8. netgen/config/__init__.py +1 -0
  9. netgen/config/__init__.pyi +52 -0
  10. netgen/config/__main__.py +4 -0
  11. netgen/config/config.py +68 -0
  12. netgen/config/config.pyi +54 -0
  13. netgen/csg.py +25 -0
  14. netgen/geom2d.py +178 -0
  15. netgen/gui.py +82 -0
  16. netgen/include/core/archive.hpp +1256 -0
  17. netgen/include/core/array.hpp +1760 -0
  18. netgen/include/core/autodiff.hpp +1131 -0
  19. netgen/include/core/autodiffdiff.hpp +733 -0
  20. netgen/include/core/bitarray.hpp +240 -0
  21. netgen/include/core/concurrentqueue.h +3619 -0
  22. netgen/include/core/exception.hpp +145 -0
  23. netgen/include/core/flags.hpp +199 -0
  24. netgen/include/core/hashtable.hpp +1281 -0
  25. netgen/include/core/localheap.hpp +318 -0
  26. netgen/include/core/logging.hpp +117 -0
  27. netgen/include/core/memtracer.hpp +221 -0
  28. netgen/include/core/mpi4py_pycapi.h +245 -0
  29. netgen/include/core/mpi_wrapper.hpp +643 -0
  30. netgen/include/core/ng_mpi.hpp +94 -0
  31. netgen/include/core/ng_mpi_generated_declarations.hpp +155 -0
  32. netgen/include/core/ng_mpi_native.hpp +25 -0
  33. netgen/include/core/ngcore.hpp +32 -0
  34. netgen/include/core/ngcore_api.hpp +152 -0
  35. netgen/include/core/ngstream.hpp +115 -0
  36. netgen/include/core/paje_trace.hpp +279 -0
  37. netgen/include/core/profiler.hpp +382 -0
  38. netgen/include/core/python_ngcore.hpp +457 -0
  39. netgen/include/core/ranges.hpp +109 -0
  40. netgen/include/core/register_archive.hpp +100 -0
  41. netgen/include/core/signal.hpp +82 -0
  42. netgen/include/core/simd.hpp +160 -0
  43. netgen/include/core/simd_arm64.hpp +407 -0
  44. netgen/include/core/simd_avx.hpp +394 -0
  45. netgen/include/core/simd_avx512.hpp +285 -0
  46. netgen/include/core/simd_generic.hpp +1053 -0
  47. netgen/include/core/simd_math.hpp +178 -0
  48. netgen/include/core/simd_sse.hpp +289 -0
  49. netgen/include/core/statushandler.hpp +37 -0
  50. netgen/include/core/symboltable.hpp +153 -0
  51. netgen/include/core/table.hpp +810 -0
  52. netgen/include/core/taskmanager.hpp +1161 -0
  53. netgen/include/core/type_traits.hpp +65 -0
  54. netgen/include/core/utils.hpp +385 -0
  55. netgen/include/core/version.hpp +102 -0
  56. netgen/include/core/xbool.hpp +47 -0
  57. netgen/include/csg/algprim.hpp +563 -0
  58. netgen/include/csg/brick.hpp +150 -0
  59. netgen/include/csg/csg.hpp +43 -0
  60. netgen/include/csg/csgeom.hpp +389 -0
  61. netgen/include/csg/csgparser.hpp +101 -0
  62. netgen/include/csg/curve2d.hpp +67 -0
  63. netgen/include/csg/edgeflw.hpp +112 -0
  64. netgen/include/csg/explicitcurve2d.hpp +113 -0
  65. netgen/include/csg/extrusion.hpp +185 -0
  66. netgen/include/csg/gencyl.hpp +70 -0
  67. netgen/include/csg/geoml.hpp +16 -0
  68. netgen/include/csg/identify.hpp +213 -0
  69. netgen/include/csg/manifold.hpp +29 -0
  70. netgen/include/csg/meshsurf.hpp +46 -0
  71. netgen/include/csg/polyhedra.hpp +121 -0
  72. netgen/include/csg/revolution.hpp +180 -0
  73. netgen/include/csg/singularref.hpp +84 -0
  74. netgen/include/csg/solid.hpp +295 -0
  75. netgen/include/csg/specpoin.hpp +194 -0
  76. netgen/include/csg/spline3d.hpp +99 -0
  77. netgen/include/csg/splinesurface.hpp +85 -0
  78. netgen/include/csg/surface.hpp +394 -0
  79. netgen/include/csg/triapprox.hpp +63 -0
  80. netgen/include/csg/vscsg.hpp +34 -0
  81. netgen/include/general/autodiff.hpp +356 -0
  82. netgen/include/general/autoptr.hpp +39 -0
  83. netgen/include/general/gzstream.h +121 -0
  84. netgen/include/general/hashtabl.hpp +1692 -0
  85. netgen/include/general/myadt.hpp +48 -0
  86. netgen/include/general/mystring.hpp +226 -0
  87. netgen/include/general/netgenout.hpp +205 -0
  88. netgen/include/general/ngarray.hpp +797 -0
  89. netgen/include/general/ngbitarray.hpp +149 -0
  90. netgen/include/general/ngpython.hpp +74 -0
  91. netgen/include/general/optmem.hpp +44 -0
  92. netgen/include/general/parthreads.hpp +138 -0
  93. netgen/include/general/seti.hpp +50 -0
  94. netgen/include/general/sort.hpp +47 -0
  95. netgen/include/general/spbita2d.hpp +59 -0
  96. netgen/include/general/stack.hpp +114 -0
  97. netgen/include/general/table.hpp +280 -0
  98. netgen/include/general/template.hpp +509 -0
  99. netgen/include/geom2d/csg2d.hpp +750 -0
  100. netgen/include/geom2d/geometry2d.hpp +280 -0
  101. netgen/include/geom2d/spline2d.hpp +234 -0
  102. netgen/include/geom2d/vsgeom2d.hpp +28 -0
  103. netgen/include/gprim/adtree.hpp +1392 -0
  104. netgen/include/gprim/geom2d.hpp +858 -0
  105. netgen/include/gprim/geom3d.hpp +749 -0
  106. netgen/include/gprim/geomfuncs.hpp +212 -0
  107. netgen/include/gprim/geomobjects.hpp +544 -0
  108. netgen/include/gprim/geomops.hpp +404 -0
  109. netgen/include/gprim/geomtest3d.hpp +101 -0
  110. netgen/include/gprim/gprim.hpp +33 -0
  111. netgen/include/gprim/spline.hpp +778 -0
  112. netgen/include/gprim/splinegeometry.hpp +73 -0
  113. netgen/include/gprim/transform3d.hpp +216 -0
  114. netgen/include/include/acisgeom.hpp +3 -0
  115. netgen/include/include/csg.hpp +1 -0
  116. netgen/include/include/geometry2d.hpp +1 -0
  117. netgen/include/include/gprim.hpp +1 -0
  118. netgen/include/include/incopengl.hpp +62 -0
  119. netgen/include/include/inctcl.hpp +13 -0
  120. netgen/include/include/incvis.hpp +6 -0
  121. netgen/include/include/linalg.hpp +1 -0
  122. netgen/include/include/meshing.hpp +1 -0
  123. netgen/include/include/myadt.hpp +1 -0
  124. netgen/include/include/mydefs.hpp +70 -0
  125. netgen/include/include/mystdlib.h +59 -0
  126. netgen/include/include/netgen_config.hpp +27 -0
  127. netgen/include/include/netgen_version.hpp +9 -0
  128. netgen/include/include/nginterface_v2_impl.hpp +395 -0
  129. netgen/include/include/ngsimd.hpp +1 -0
  130. netgen/include/include/occgeom.hpp +1 -0
  131. netgen/include/include/opti.hpp +1 -0
  132. netgen/include/include/parallel.hpp +1 -0
  133. netgen/include/include/stlgeom.hpp +1 -0
  134. netgen/include/include/visual.hpp +1 -0
  135. netgen/include/interface/rw_medit.hpp +11 -0
  136. netgen/include/interface/writeuser.hpp +80 -0
  137. netgen/include/linalg/densemat.hpp +414 -0
  138. netgen/include/linalg/linalg.hpp +29 -0
  139. netgen/include/linalg/opti.hpp +142 -0
  140. netgen/include/linalg/polynomial.hpp +47 -0
  141. netgen/include/linalg/vector.hpp +217 -0
  142. netgen/include/meshing/adfront2.hpp +274 -0
  143. netgen/include/meshing/adfront3.hpp +332 -0
  144. netgen/include/meshing/basegeom.hpp +370 -0
  145. netgen/include/meshing/bcfunctions.hpp +53 -0
  146. netgen/include/meshing/bisect.hpp +72 -0
  147. netgen/include/meshing/boundarylayer.hpp +113 -0
  148. netgen/include/meshing/classifyhpel.hpp +1984 -0
  149. netgen/include/meshing/clusters.hpp +46 -0
  150. netgen/include/meshing/curvedelems.hpp +274 -0
  151. netgen/include/meshing/delaunay2d.hpp +73 -0
  152. netgen/include/meshing/fieldlines.hpp +103 -0
  153. netgen/include/meshing/findip.hpp +198 -0
  154. netgen/include/meshing/findip2.hpp +103 -0
  155. netgen/include/meshing/geomsearch.hpp +69 -0
  156. netgen/include/meshing/global.hpp +54 -0
  157. netgen/include/meshing/hpref_hex.hpp +330 -0
  158. netgen/include/meshing/hpref_prism.hpp +3405 -0
  159. netgen/include/meshing/hpref_pyramid.hpp +154 -0
  160. netgen/include/meshing/hpref_quad.hpp +2082 -0
  161. netgen/include/meshing/hpref_segm.hpp +122 -0
  162. netgen/include/meshing/hpref_tet.hpp +4230 -0
  163. netgen/include/meshing/hpref_trig.hpp +848 -0
  164. netgen/include/meshing/hprefinement.hpp +366 -0
  165. netgen/include/meshing/improve2.hpp +178 -0
  166. netgen/include/meshing/improve3.hpp +151 -0
  167. netgen/include/meshing/localh.hpp +223 -0
  168. netgen/include/meshing/meshclass.hpp +1076 -0
  169. netgen/include/meshing/meshfunc.hpp +47 -0
  170. netgen/include/meshing/meshing.hpp +63 -0
  171. netgen/include/meshing/meshing2.hpp +163 -0
  172. netgen/include/meshing/meshing3.hpp +123 -0
  173. netgen/include/meshing/meshtool.hpp +90 -0
  174. netgen/include/meshing/meshtype.hpp +1930 -0
  175. netgen/include/meshing/msghandler.hpp +62 -0
  176. netgen/include/meshing/paralleltop.hpp +172 -0
  177. netgen/include/meshing/python_mesh.hpp +206 -0
  178. netgen/include/meshing/ruler2.hpp +172 -0
  179. netgen/include/meshing/ruler3.hpp +211 -0
  180. netgen/include/meshing/soldata.hpp +141 -0
  181. netgen/include/meshing/specials.hpp +17 -0
  182. netgen/include/meshing/surfacegeom.hpp +73 -0
  183. netgen/include/meshing/topology.hpp +1003 -0
  184. netgen/include/meshing/validate.hpp +21 -0
  185. netgen/include/meshing/visual_interface.hpp +71 -0
  186. netgen/include/mydefs.hpp +70 -0
  187. netgen/include/nginterface.h +474 -0
  188. netgen/include/nginterface_v2.hpp +406 -0
  189. netgen/include/nglib.h +697 -0
  190. netgen/include/nglib_occ.h +50 -0
  191. netgen/include/occ/occ_edge.hpp +47 -0
  192. netgen/include/occ/occ_face.hpp +52 -0
  193. netgen/include/occ/occ_solid.hpp +23 -0
  194. netgen/include/occ/occ_utils.hpp +376 -0
  195. netgen/include/occ/occ_vertex.hpp +30 -0
  196. netgen/include/occ/occgeom.hpp +659 -0
  197. netgen/include/occ/occmeshsurf.hpp +168 -0
  198. netgen/include/occ/vsocc.hpp +33 -0
  199. netgen/include/pybind11/LICENSE +29 -0
  200. netgen/include/pybind11/attr.h +722 -0
  201. netgen/include/pybind11/buffer_info.h +208 -0
  202. netgen/include/pybind11/cast.h +2361 -0
  203. netgen/include/pybind11/chrono.h +228 -0
  204. netgen/include/pybind11/common.h +2 -0
  205. netgen/include/pybind11/complex.h +74 -0
  206. netgen/include/pybind11/conduit/README.txt +15 -0
  207. netgen/include/pybind11/conduit/pybind11_conduit_v1.h +116 -0
  208. netgen/include/pybind11/conduit/pybind11_platform_abi_id.h +87 -0
  209. netgen/include/pybind11/conduit/wrap_include_python_h.h +72 -0
  210. netgen/include/pybind11/critical_section.h +56 -0
  211. netgen/include/pybind11/detail/class.h +823 -0
  212. netgen/include/pybind11/detail/common.h +1348 -0
  213. netgen/include/pybind11/detail/cpp_conduit.h +75 -0
  214. netgen/include/pybind11/detail/descr.h +226 -0
  215. netgen/include/pybind11/detail/dynamic_raw_ptr_cast_if_possible.h +39 -0
  216. netgen/include/pybind11/detail/exception_translation.h +71 -0
  217. netgen/include/pybind11/detail/function_record_pyobject.h +191 -0
  218. netgen/include/pybind11/detail/init.h +538 -0
  219. netgen/include/pybind11/detail/internals.h +799 -0
  220. netgen/include/pybind11/detail/native_enum_data.h +209 -0
  221. netgen/include/pybind11/detail/pybind11_namespace_macros.h +82 -0
  222. netgen/include/pybind11/detail/struct_smart_holder.h +378 -0
  223. netgen/include/pybind11/detail/type_caster_base.h +1591 -0
  224. netgen/include/pybind11/detail/typeid.h +65 -0
  225. netgen/include/pybind11/detail/using_smart_holder.h +22 -0
  226. netgen/include/pybind11/detail/value_and_holder.h +90 -0
  227. netgen/include/pybind11/eigen/common.h +9 -0
  228. netgen/include/pybind11/eigen/matrix.h +723 -0
  229. netgen/include/pybind11/eigen/tensor.h +521 -0
  230. netgen/include/pybind11/eigen.h +12 -0
  231. netgen/include/pybind11/embed.h +320 -0
  232. netgen/include/pybind11/eval.h +161 -0
  233. netgen/include/pybind11/functional.h +147 -0
  234. netgen/include/pybind11/gil.h +199 -0
  235. netgen/include/pybind11/gil_safe_call_once.h +102 -0
  236. netgen/include/pybind11/gil_simple.h +37 -0
  237. netgen/include/pybind11/iostream.h +265 -0
  238. netgen/include/pybind11/native_enum.h +67 -0
  239. netgen/include/pybind11/numpy.h +2312 -0
  240. netgen/include/pybind11/operators.h +202 -0
  241. netgen/include/pybind11/options.h +92 -0
  242. netgen/include/pybind11/pybind11.h +3645 -0
  243. netgen/include/pybind11/pytypes.h +2680 -0
  244. netgen/include/pybind11/stl/filesystem.h +114 -0
  245. netgen/include/pybind11/stl.h +666 -0
  246. netgen/include/pybind11/stl_bind.h +858 -0
  247. netgen/include/pybind11/subinterpreter.h +299 -0
  248. netgen/include/pybind11/trampoline_self_life_support.h +65 -0
  249. netgen/include/pybind11/type_caster_pyobject_ptr.h +61 -0
  250. netgen/include/pybind11/typing.h +298 -0
  251. netgen/include/pybind11/warnings.h +75 -0
  252. netgen/include/stlgeom/meshstlsurface.hpp +67 -0
  253. netgen/include/stlgeom/stlgeom.hpp +491 -0
  254. netgen/include/stlgeom/stlline.hpp +193 -0
  255. netgen/include/stlgeom/stltool.hpp +331 -0
  256. netgen/include/stlgeom/stltopology.hpp +419 -0
  257. netgen/include/stlgeom/vsstl.hpp +58 -0
  258. netgen/include/visualization/meshdoc.hpp +42 -0
  259. netgen/include/visualization/mvdraw.hpp +325 -0
  260. netgen/include/visualization/vispar.hpp +128 -0
  261. netgen/include/visualization/visual.hpp +28 -0
  262. netgen/include/visualization/visual_api.hpp +10 -0
  263. netgen/include/visualization/vssolution.hpp +399 -0
  264. netgen/lib/libnggui.lib +0 -0
  265. netgen/lib/ngcore.lib +0 -0
  266. netgen/lib/nglib.lib +0 -0
  267. netgen/lib/togl.lib +0 -0
  268. netgen/libnggui.dll +0 -0
  269. netgen/libngguipy.lib +0 -0
  270. netgen/libngguipy.pyd +0 -0
  271. netgen/libngpy/_NgOCC.pyi +1545 -0
  272. netgen/libngpy/__init__.pyi +7 -0
  273. netgen/libngpy/_csg.pyi +259 -0
  274. netgen/libngpy/_geom2d.pyi +323 -0
  275. netgen/libngpy/_meshing.pyi +1111 -0
  276. netgen/libngpy/_stl.pyi +131 -0
  277. netgen/libngpy.lib +0 -0
  278. netgen/libngpy.pyd +0 -0
  279. netgen/meshing.py +65 -0
  280. netgen/ngcore.dll +0 -0
  281. netgen/nglib.dll +0 -0
  282. netgen/occ.py +52 -0
  283. netgen/read_gmsh.py +259 -0
  284. netgen/read_meshio.py +22 -0
  285. netgen/stl.py +2 -0
  286. netgen/togl.dll +0 -0
  287. netgen/version.py +2 -0
  288. netgen/webgui.py +529 -0
  289. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/boundarycondition.geo +16 -0
  290. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/boxcyl.geo +32 -0
  291. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/circle_on_cube.geo +27 -0
  292. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cone.geo +13 -0
  293. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cube.geo +16 -0
  294. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cubeandring.geo +55 -0
  295. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cubeandspheres.geo +21 -0
  296. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cubemcyl.geo +18 -0
  297. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cubemsphere.geo +19 -0
  298. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cylinder.geo +12 -0
  299. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cylsphere.geo +12 -0
  300. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/doc/ng4.pdf +0 -0
  301. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/ellipsoid.geo +8 -0
  302. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/ellipticcyl.geo +10 -0
  303. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/extrusion.geo +99 -0
  304. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/fichera.geo +24 -0
  305. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/frame.step +11683 -0
  306. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/hinge.stl +8486 -0
  307. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/lshape3d.geo +26 -0
  308. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/manyholes.geo +26 -0
  309. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/manyholes2.geo +26 -0
  310. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/matrix.geo +27 -0
  311. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/ortho.geo +11 -0
  312. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/part1.stl +2662 -0
  313. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/period.geo +33 -0
  314. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/py_tutorials/exportNeutral.py +26 -0
  315. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/py_tutorials/mesh.py +19 -0
  316. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/py_tutorials/shaft.geo +65 -0
  317. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/revolution.geo +18 -0
  318. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/screw.step +1694 -0
  319. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/sculpture.geo +13 -0
  320. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/shaft.geo +65 -0
  321. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/shell.geo +10 -0
  322. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/sphere.geo +8 -0
  323. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/sphereincube.geo +17 -0
  324. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/square.in2d +35 -0
  325. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/squarecircle.in2d +48 -0
  326. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/squarehole.in2d +47 -0
  327. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/torus.geo +8 -0
  328. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/trafo.geo +57 -0
  329. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/twobricks.geo +15 -0
  330. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/twocubes.geo +18 -0
  331. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/twocyl.geo +16 -0
  332. netgen_mesher-6.2.2506.post35.dev0.dist-info/METADATA +15 -0
  333. netgen_mesher-6.2.2506.post35.dev0.dist-info/RECORD +340 -0
  334. netgen_mesher-6.2.2506.post35.dev0.dist-info/WHEEL +5 -0
  335. netgen_mesher-6.2.2506.post35.dev0.dist-info/entry_points.txt +2 -0
  336. netgen_mesher-6.2.2506.post35.dev0.dist-info/licenses/AUTHORS +1 -0
  337. netgen_mesher-6.2.2506.post35.dev0.dist-info/licenses/LICENSE +504 -0
  338. netgen_mesher-6.2.2506.post35.dev0.dist-info/top_level.txt +2 -0
  339. pyngcore/__init__.py +1 -0
  340. pyngcore/pyngcore.cp314-win_amd64.pyd +0 -0
@@ -0,0 +1,722 @@
1
+ /*
2
+ pybind11/attr.h: Infrastructure for processing custom
3
+ type and function attributes
4
+
5
+ Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
6
+
7
+ All rights reserved. Use of this source code is governed by a
8
+ BSD-style license that can be found in the LICENSE file.
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include "detail/common.h"
14
+ #include "cast.h"
15
+ #include "trampoline_self_life_support.h"
16
+
17
+ #include <functional>
18
+
19
+ PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
20
+
21
+ /// \addtogroup annotations
22
+ /// @{
23
+
24
+ /// Annotation for methods
25
+ struct is_method {
26
+ handle class_;
27
+ explicit is_method(const handle &c) : class_(c) {}
28
+ };
29
+
30
+ /// Annotation for setters
31
+ struct is_setter {};
32
+
33
+ /// Annotation for operators
34
+ struct is_operator {};
35
+
36
+ /// Annotation for classes that cannot be subclassed
37
+ struct is_final {};
38
+
39
+ /// Annotation for parent scope
40
+ struct scope {
41
+ handle value;
42
+ explicit scope(const handle &s) : value(s) {}
43
+ };
44
+
45
+ /// Annotation for documentation
46
+ struct doc {
47
+ const char *value;
48
+ explicit doc(const char *value) : value(value) {}
49
+ };
50
+
51
+ /// Annotation for function names
52
+ struct name {
53
+ const char *value;
54
+ explicit name(const char *value) : value(value) {}
55
+ };
56
+
57
+ /// Annotation indicating that a function is an overload associated with a given "sibling"
58
+ struct sibling {
59
+ handle value;
60
+ explicit sibling(const handle &value) : value(value.ptr()) {}
61
+ };
62
+
63
+ /// Annotation indicating that a class derives from another given type
64
+ template <typename T>
65
+ struct base {
66
+
67
+ PYBIND11_DEPRECATED(
68
+ "base<T>() was deprecated in favor of specifying 'T' as a template argument to class_")
69
+ base() = default;
70
+ };
71
+
72
+ /// Keep patient alive while nurse lives
73
+ template <size_t Nurse, size_t Patient>
74
+ struct keep_alive {};
75
+
76
+ /// Annotation indicating that a class is involved in a multiple inheritance relationship
77
+ struct multiple_inheritance {};
78
+
79
+ /// Annotation which enables dynamic attributes, i.e. adds `__dict__` to a class
80
+ struct dynamic_attr {};
81
+
82
+ /// Annotation which enables the buffer protocol for a type
83
+ struct buffer_protocol {};
84
+
85
+ /// Annotation which enables releasing the GIL before calling the C++ destructor of wrapped
86
+ /// instances (pybind/pybind11#1446).
87
+ struct release_gil_before_calling_cpp_dtor {};
88
+
89
+ /// Annotation which requests that a special metaclass is created for a type
90
+ struct metaclass {
91
+ handle value;
92
+
93
+ PYBIND11_DEPRECATED("py::metaclass() is no longer required. It's turned on by default now.")
94
+ metaclass() = default;
95
+
96
+ /// Override pybind11's default metaclass
97
+ explicit metaclass(handle value) : value(value) {}
98
+ };
99
+
100
+ /// Specifies a custom callback with signature `void (PyHeapTypeObject*)` that
101
+ /// may be used to customize the Python type.
102
+ ///
103
+ /// The callback is invoked immediately before `PyType_Ready`.
104
+ ///
105
+ /// Note: This is an advanced interface, and uses of it may require changes to
106
+ /// work with later versions of pybind11. You may wish to consult the
107
+ /// implementation of `make_new_python_type` in `detail/classes.h` to understand
108
+ /// the context in which the callback will be run.
109
+ struct custom_type_setup {
110
+ using callback = std::function<void(PyHeapTypeObject *heap_type)>;
111
+
112
+ explicit custom_type_setup(callback value) : value(std::move(value)) {}
113
+
114
+ callback value;
115
+ };
116
+
117
+ /// Annotation that marks a class as local to the module:
118
+ struct module_local {
119
+ const bool value;
120
+ constexpr explicit module_local(bool v = true) : value(v) {}
121
+ };
122
+
123
+ /// Annotation to mark enums as an arithmetic type
124
+ struct arithmetic {};
125
+
126
+ /// Mark a function for addition at the beginning of the existing overload chain instead of the end
127
+ struct prepend {};
128
+
129
+ /** \rst
130
+ A call policy which places one or more guard variables (``Ts...``) around the function call.
131
+
132
+ For example, this definition:
133
+
134
+ .. code-block:: cpp
135
+
136
+ m.def("foo", foo, py::call_guard<T>());
137
+
138
+ is equivalent to the following pseudocode:
139
+
140
+ .. code-block:: cpp
141
+
142
+ m.def("foo", [](args...) {
143
+ T scope_guard;
144
+ return foo(args...); // forwarded arguments
145
+ });
146
+ \endrst */
147
+ template <typename... Ts>
148
+ struct call_guard;
149
+
150
+ template <>
151
+ struct call_guard<> {
152
+ using type = detail::void_type;
153
+ };
154
+
155
+ template <typename T>
156
+ struct call_guard<T> {
157
+ static_assert(std::is_default_constructible<T>::value,
158
+ "The guard type must be default constructible");
159
+
160
+ using type = T;
161
+ };
162
+
163
+ template <typename T, typename... Ts>
164
+ struct call_guard<T, Ts...> {
165
+ struct type {
166
+ T guard{}; // Compose multiple guard types with left-to-right default-constructor order
167
+ typename call_guard<Ts...>::type next{};
168
+ };
169
+ };
170
+
171
+ /// @} annotations
172
+
173
+ PYBIND11_NAMESPACE_BEGIN(detail)
174
+ /* Forward declarations */
175
+ enum op_id : int;
176
+ enum op_type : int;
177
+ struct undefined_t;
178
+ template <op_id id, op_type ot, typename L = undefined_t, typename R = undefined_t>
179
+ struct op_;
180
+ void keep_alive_impl(size_t Nurse, size_t Patient, function_call &call, handle ret);
181
+
182
+ /// Internal data structure which holds metadata about a keyword argument
183
+ struct argument_record {
184
+ const char *name; ///< Argument name
185
+ const char *descr; ///< Human-readable version of the argument value
186
+ handle value; ///< Associated Python object
187
+ bool convert : 1; ///< True if the argument is allowed to convert when loading
188
+ bool none : 1; ///< True if None is allowed when loading
189
+
190
+ argument_record(const char *name, const char *descr, handle value, bool convert, bool none)
191
+ : name(name), descr(descr), value(value), convert(convert), none(none) {}
192
+ };
193
+
194
+ /// Internal data structure which holds metadata about a bound function (signature, overloads,
195
+ /// etc.)
196
+ #define PYBIND11_DETAIL_FUNCTION_RECORD_ABI_ID "v1" // PLEASE UPDATE if the struct is changed.
197
+ struct function_record {
198
+ function_record()
199
+ : is_constructor(false), is_new_style_constructor(false), is_stateless(false),
200
+ is_operator(false), is_method(false), is_setter(false), has_args(false),
201
+ has_kwargs(false), prepend(false) {}
202
+
203
+ /// Function name
204
+ char *name = nullptr; /* why no C++ strings? They generate heavier code.. */
205
+
206
+ // User-specified documentation string
207
+ char *doc = nullptr;
208
+
209
+ /// Human-readable version of the function signature
210
+ char *signature = nullptr;
211
+
212
+ /// List of registered keyword arguments
213
+ std::vector<argument_record> args;
214
+
215
+ /// Pointer to lambda function which converts arguments and performs the actual call
216
+ handle (*impl)(function_call &) = nullptr;
217
+
218
+ /// Storage for the wrapped function pointer and captured data, if any
219
+ void *data[3] = {};
220
+
221
+ /// Pointer to custom destructor for 'data' (if needed)
222
+ void (*free_data)(function_record *ptr) = nullptr;
223
+
224
+ /// Return value policy associated with this function
225
+ return_value_policy policy = return_value_policy::automatic;
226
+
227
+ /// True if name == '__init__'
228
+ bool is_constructor : 1;
229
+
230
+ /// True if this is a new-style `__init__` defined in `detail/init.h`
231
+ bool is_new_style_constructor : 1;
232
+
233
+ /// True if this is a stateless function pointer
234
+ bool is_stateless : 1;
235
+
236
+ /// True if this is an operator (__add__), etc.
237
+ bool is_operator : 1;
238
+
239
+ /// True if this is a method
240
+ bool is_method : 1;
241
+
242
+ /// True if this is a setter
243
+ bool is_setter : 1;
244
+
245
+ /// True if the function has a '*args' argument
246
+ bool has_args : 1;
247
+
248
+ /// True if the function has a '**kwargs' argument
249
+ bool has_kwargs : 1;
250
+
251
+ /// True if this function is to be inserted at the beginning of the overload resolution chain
252
+ bool prepend : 1;
253
+
254
+ /// Number of arguments (including py::args and/or py::kwargs, if present)
255
+ std::uint16_t nargs;
256
+
257
+ /// Number of leading positional arguments, which are terminated by a py::args or py::kwargs
258
+ /// argument or by a py::kw_only annotation.
259
+ std::uint16_t nargs_pos = 0;
260
+
261
+ /// Number of leading arguments (counted in `nargs`) that are positional-only
262
+ std::uint16_t nargs_pos_only = 0;
263
+
264
+ /// Python method object
265
+ PyMethodDef *def = nullptr;
266
+
267
+ /// Python handle to the parent scope (a class or a module)
268
+ handle scope;
269
+
270
+ /// Python handle to the sibling function representing an overload chain
271
+ handle sibling;
272
+
273
+ /// Pointer to next overload
274
+ function_record *next = nullptr;
275
+ };
276
+ // The main purpose of this macro is to make it easy to pin-point the critically related code
277
+ // sections.
278
+ #define PYBIND11_ENSURE_PRECONDITION_FOR_FUNCTIONAL_H_PERFORMANCE_OPTIMIZATIONS(...) \
279
+ static_assert( \
280
+ __VA_ARGS__, \
281
+ "Violation of precondition for pybind11/functional.h performance optimizations!")
282
+
283
+ /// Special data structure which (temporarily) holds metadata about a bound class
284
+ struct type_record {
285
+ PYBIND11_NOINLINE type_record()
286
+ : multiple_inheritance(false), dynamic_attr(false), buffer_protocol(false),
287
+ module_local(false), is_final(false), release_gil_before_calling_cpp_dtor(false) {}
288
+
289
+ /// Handle to the parent scope
290
+ handle scope;
291
+
292
+ /// Name of the class
293
+ const char *name = nullptr;
294
+
295
+ // Pointer to RTTI type_info data structure
296
+ const std::type_info *type = nullptr;
297
+
298
+ /// How large is the underlying C++ type?
299
+ size_t type_size = 0;
300
+
301
+ /// What is the alignment of the underlying C++ type?
302
+ size_t type_align = 0;
303
+
304
+ /// How large is the type's holder?
305
+ size_t holder_size = 0;
306
+
307
+ /// The global operator new can be overridden with a class-specific variant
308
+ void *(*operator_new)(size_t) = nullptr;
309
+
310
+ /// Function pointer to class_<..>::init_instance
311
+ void (*init_instance)(instance *, const void *) = nullptr;
312
+
313
+ /// Function pointer to class_<..>::dealloc
314
+ void (*dealloc)(detail::value_and_holder &) = nullptr;
315
+
316
+ /// Function pointer for casting alias class (aka trampoline) pointer to
317
+ /// trampoline_self_life_support pointer. Sidesteps cross-DSO RTTI issues
318
+ /// on platforms like macOS (see PR #5728 for details).
319
+ get_trampoline_self_life_support_fn get_trampoline_self_life_support
320
+ = [](void *) -> trampoline_self_life_support * { return nullptr; };
321
+
322
+ /// List of base classes of the newly created type
323
+ list bases;
324
+
325
+ /// Optional docstring
326
+ const char *doc = nullptr;
327
+
328
+ /// Custom metaclass (optional)
329
+ handle metaclass;
330
+
331
+ /// Custom type setup.
332
+ custom_type_setup::callback custom_type_setup_callback;
333
+
334
+ /// Multiple inheritance marker
335
+ bool multiple_inheritance : 1;
336
+
337
+ /// Does the class manage a __dict__?
338
+ bool dynamic_attr : 1;
339
+
340
+ /// Does the class implement the buffer protocol?
341
+ bool buffer_protocol : 1;
342
+
343
+ /// Is the class definition local to the module shared object?
344
+ bool module_local : 1;
345
+
346
+ /// Is the class inheritable from python classes?
347
+ bool is_final : 1;
348
+
349
+ /// Solves pybind/pybind11#1446
350
+ bool release_gil_before_calling_cpp_dtor : 1;
351
+
352
+ holder_enum_t holder_enum_v = holder_enum_t::undefined;
353
+
354
+ PYBIND11_NOINLINE void add_base(const std::type_info &base, void *(*caster)(void *) ) {
355
+ auto *base_info = detail::get_type_info(base, false);
356
+ if (!base_info) {
357
+ std::string tname(base.name());
358
+ detail::clean_type_id(tname);
359
+ pybind11_fail("generic_type: type \"" + std::string(name)
360
+ + "\" referenced unknown base type \"" + tname + "\"");
361
+ }
362
+
363
+ // SMART_HOLDER_BAKEIN_FOLLOW_ON: Refine holder compatibility checks.
364
+ bool this_has_unique_ptr_holder = (holder_enum_v == holder_enum_t::std_unique_ptr);
365
+ bool base_has_unique_ptr_holder
366
+ = (base_info->holder_enum_v == holder_enum_t::std_unique_ptr);
367
+ if (this_has_unique_ptr_holder != base_has_unique_ptr_holder) {
368
+ std::string tname(base.name());
369
+ detail::clean_type_id(tname);
370
+ pybind11_fail("generic_type: type \"" + std::string(name) + "\" "
371
+ + (this_has_unique_ptr_holder ? "does not have" : "has")
372
+ + " a non-default holder type while its base \"" + tname + "\" "
373
+ + (base_has_unique_ptr_holder ? "does not" : "does"));
374
+ }
375
+
376
+ bases.append((PyObject *) base_info->type);
377
+
378
+ #ifdef PYBIND11_BACKWARD_COMPATIBILITY_TP_DICTOFFSET
379
+ dynamic_attr |= base_info->type->tp_dictoffset != 0;
380
+ #else
381
+ dynamic_attr |= (base_info->type->tp_flags & Py_TPFLAGS_MANAGED_DICT) != 0;
382
+ #endif
383
+
384
+ if (caster) {
385
+ base_info->implicit_casts.emplace_back(type, caster);
386
+ }
387
+ }
388
+ };
389
+
390
+ inline function_call::function_call(const function_record &f, handle p) : func(f), parent(p) {
391
+ args.reserve(f.nargs);
392
+ args_convert.reserve(f.nargs);
393
+ }
394
+
395
+ /// Tag for a new-style `__init__` defined in `detail/init.h`
396
+ struct is_new_style_constructor {};
397
+
398
+ /**
399
+ * Partial template specializations to process custom attributes provided to
400
+ * cpp_function_ and class_. These are either used to initialize the respective
401
+ * fields in the type_record and function_record data structures or executed at
402
+ * runtime to deal with custom call policies (e.g. keep_alive).
403
+ */
404
+ template <typename T, typename SFINAE = void>
405
+ struct process_attribute;
406
+
407
+ template <typename T>
408
+ struct process_attribute_default {
409
+ /// Default implementation: do nothing
410
+ static void init(const T &, function_record *) {}
411
+ static void init(const T &, type_record *) {}
412
+ static void precall(function_call &) {}
413
+ static void postcall(function_call &, handle) {}
414
+ };
415
+
416
+ /// Process an attribute specifying the function's name
417
+ template <>
418
+ struct process_attribute<name> : process_attribute_default<name> {
419
+ static void init(const name &n, function_record *r) { r->name = const_cast<char *>(n.value); }
420
+ };
421
+
422
+ /// Process an attribute specifying the function's docstring
423
+ template <>
424
+ struct process_attribute<doc> : process_attribute_default<doc> {
425
+ static void init(const doc &n, function_record *r) { r->doc = const_cast<char *>(n.value); }
426
+ };
427
+
428
+ /// Process an attribute specifying the function's docstring (provided as a C-style string)
429
+ template <>
430
+ struct process_attribute<const char *> : process_attribute_default<const char *> {
431
+ static void init(const char *d, function_record *r) { r->doc = const_cast<char *>(d); }
432
+ static void init(const char *d, type_record *r) { r->doc = d; }
433
+ };
434
+ template <>
435
+ struct process_attribute<char *> : process_attribute<const char *> {};
436
+
437
+ /// Process an attribute indicating the function's return value policy
438
+ template <>
439
+ struct process_attribute<return_value_policy> : process_attribute_default<return_value_policy> {
440
+ static void init(const return_value_policy &p, function_record *r) { r->policy = p; }
441
+ };
442
+
443
+ /// Process an attribute which indicates that this is an overloaded function associated with a
444
+ /// given sibling
445
+ template <>
446
+ struct process_attribute<sibling> : process_attribute_default<sibling> {
447
+ static void init(const sibling &s, function_record *r) { r->sibling = s.value; }
448
+ };
449
+
450
+ /// Process an attribute which indicates that this function is a method
451
+ template <>
452
+ struct process_attribute<is_method> : process_attribute_default<is_method> {
453
+ static void init(const is_method &s, function_record *r) {
454
+ r->is_method = true;
455
+ r->scope = s.class_;
456
+ }
457
+ };
458
+
459
+ /// Process an attribute which indicates that this function is a setter
460
+ template <>
461
+ struct process_attribute<is_setter> : process_attribute_default<is_setter> {
462
+ static void init(const is_setter &, function_record *r) { r->is_setter = true; }
463
+ };
464
+
465
+ /// Process an attribute which indicates the parent scope of a method
466
+ template <>
467
+ struct process_attribute<scope> : process_attribute_default<scope> {
468
+ static void init(const scope &s, function_record *r) { r->scope = s.value; }
469
+ };
470
+
471
+ /// Process an attribute which indicates that this function is an operator
472
+ template <>
473
+ struct process_attribute<is_operator> : process_attribute_default<is_operator> {
474
+ static void init(const is_operator &, function_record *r) { r->is_operator = true; }
475
+ };
476
+
477
+ template <>
478
+ struct process_attribute<is_new_style_constructor>
479
+ : process_attribute_default<is_new_style_constructor> {
480
+ static void init(const is_new_style_constructor &, function_record *r) {
481
+ r->is_new_style_constructor = true;
482
+ }
483
+ };
484
+
485
+ inline void check_kw_only_arg(const arg &a, function_record *r) {
486
+ if (r->args.size() > r->nargs_pos && (!a.name || a.name[0] == '\0')) {
487
+ pybind11_fail("arg(): cannot specify an unnamed argument after a kw_only() annotation or "
488
+ "args() argument");
489
+ }
490
+ }
491
+
492
+ inline void append_self_arg_if_needed(function_record *r) {
493
+ if (r->is_method && r->args.empty()) {
494
+ r->args.emplace_back("self", nullptr, handle(), /*convert=*/true, /*none=*/false);
495
+ }
496
+ }
497
+
498
+ /// Process a keyword argument attribute (*without* a default value)
499
+ template <>
500
+ struct process_attribute<arg> : process_attribute_default<arg> {
501
+ static void init(const arg &a, function_record *r) {
502
+ append_self_arg_if_needed(r);
503
+ r->args.emplace_back(a.name, nullptr, handle(), !a.flag_noconvert, a.flag_none);
504
+
505
+ check_kw_only_arg(a, r);
506
+ }
507
+ };
508
+
509
+ /// Process a keyword argument attribute (*with* a default value)
510
+ template <>
511
+ struct process_attribute<arg_v> : process_attribute_default<arg_v> {
512
+ static void init(const arg_v &a, function_record *r) {
513
+ if (r->is_method && r->args.empty()) {
514
+ r->args.emplace_back(
515
+ "self", /*descr=*/nullptr, /*parent=*/handle(), /*convert=*/true, /*none=*/false);
516
+ }
517
+
518
+ if (!a.value) {
519
+ #if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
520
+ std::string descr("'");
521
+ if (a.name) {
522
+ descr += std::string(a.name) + ": ";
523
+ }
524
+ descr += a.type + "'";
525
+ if (r->is_method) {
526
+ if (r->name) {
527
+ descr += " in method '" + (std::string) str(r->scope) + "."
528
+ + (std::string) r->name + "'";
529
+ } else {
530
+ descr += " in method of '" + (std::string) str(r->scope) + "'";
531
+ }
532
+ } else if (r->name) {
533
+ descr += " in function '" + (std::string) r->name + "'";
534
+ }
535
+ pybind11_fail("arg(): could not convert default argument " + descr
536
+ + " into a Python object (type not registered yet?)");
537
+ #else
538
+ pybind11_fail("arg(): could not convert default argument "
539
+ "into a Python object (type not registered yet?). "
540
+ "#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for "
541
+ "more information.");
542
+ #endif
543
+ }
544
+ r->args.emplace_back(a.name, a.descr, a.value.inc_ref(), !a.flag_noconvert, a.flag_none);
545
+
546
+ check_kw_only_arg(a, r);
547
+ }
548
+ };
549
+
550
+ /// Process a keyword-only-arguments-follow pseudo argument
551
+ template <>
552
+ struct process_attribute<kw_only> : process_attribute_default<kw_only> {
553
+ static void init(const kw_only &, function_record *r) {
554
+ append_self_arg_if_needed(r);
555
+ if (r->has_args && r->nargs_pos != static_cast<std::uint16_t>(r->args.size())) {
556
+ pybind11_fail("Mismatched args() and kw_only(): they must occur at the same relative "
557
+ "argument location (or omit kw_only() entirely)");
558
+ }
559
+ r->nargs_pos = static_cast<std::uint16_t>(r->args.size());
560
+ }
561
+ };
562
+
563
+ /// Process a positional-only-argument maker
564
+ template <>
565
+ struct process_attribute<pos_only> : process_attribute_default<pos_only> {
566
+ static void init(const pos_only &, function_record *r) {
567
+ append_self_arg_if_needed(r);
568
+ r->nargs_pos_only = static_cast<std::uint16_t>(r->args.size());
569
+ if (r->nargs_pos_only > r->nargs_pos) {
570
+ pybind11_fail("pos_only(): cannot follow a py::args() argument");
571
+ }
572
+ // It also can't follow a kw_only, but a static_assert in pybind11.h checks that
573
+ }
574
+ };
575
+
576
+ /// Process a parent class attribute. Single inheritance only (class_ itself already guarantees
577
+ /// that)
578
+ template <typename T>
579
+ struct process_attribute<T, enable_if_t<is_pyobject<T>::value>>
580
+ : process_attribute_default<handle> {
581
+ static void init(const handle &h, type_record *r) { r->bases.append(h); }
582
+ };
583
+
584
+ /// Process a parent class attribute (deprecated, does not support multiple inheritance)
585
+ template <typename T>
586
+ struct process_attribute<base<T>> : process_attribute_default<base<T>> {
587
+ static void init(const base<T> &, type_record *r) { r->add_base(typeid(T), nullptr); }
588
+ };
589
+
590
+ /// Process a multiple inheritance attribute
591
+ template <>
592
+ struct process_attribute<multiple_inheritance> : process_attribute_default<multiple_inheritance> {
593
+ static void init(const multiple_inheritance &, type_record *r) {
594
+ r->multiple_inheritance = true;
595
+ }
596
+ };
597
+
598
+ template <>
599
+ struct process_attribute<dynamic_attr> : process_attribute_default<dynamic_attr> {
600
+ static void init(const dynamic_attr &, type_record *r) { r->dynamic_attr = true; }
601
+ };
602
+
603
+ template <>
604
+ struct process_attribute<custom_type_setup> {
605
+ static void init(const custom_type_setup &value, type_record *r) {
606
+ r->custom_type_setup_callback = value.value;
607
+ }
608
+ };
609
+
610
+ template <>
611
+ struct process_attribute<is_final> : process_attribute_default<is_final> {
612
+ static void init(const is_final &, type_record *r) { r->is_final = true; }
613
+ };
614
+
615
+ template <>
616
+ struct process_attribute<buffer_protocol> : process_attribute_default<buffer_protocol> {
617
+ static void init(const buffer_protocol &, type_record *r) { r->buffer_protocol = true; }
618
+ };
619
+
620
+ template <>
621
+ struct process_attribute<metaclass> : process_attribute_default<metaclass> {
622
+ static void init(const metaclass &m, type_record *r) { r->metaclass = m.value; }
623
+ };
624
+
625
+ template <>
626
+ struct process_attribute<module_local> : process_attribute_default<module_local> {
627
+ static void init(const module_local &l, type_record *r) { r->module_local = l.value; }
628
+ };
629
+
630
+ template <>
631
+ struct process_attribute<release_gil_before_calling_cpp_dtor>
632
+ : process_attribute_default<release_gil_before_calling_cpp_dtor> {
633
+ static void init(const release_gil_before_calling_cpp_dtor &, type_record *r) {
634
+ r->release_gil_before_calling_cpp_dtor = true;
635
+ }
636
+ };
637
+
638
+ /// Process a 'prepend' attribute, putting this at the beginning of the overload chain
639
+ template <>
640
+ struct process_attribute<prepend> : process_attribute_default<prepend> {
641
+ static void init(const prepend &, function_record *r) { r->prepend = true; }
642
+ };
643
+
644
+ /// Process an 'arithmetic' attribute for enums (does nothing here)
645
+ template <>
646
+ struct process_attribute<arithmetic> : process_attribute_default<arithmetic> {};
647
+
648
+ template <typename... Ts>
649
+ struct process_attribute<call_guard<Ts...>> : process_attribute_default<call_guard<Ts...>> {};
650
+
651
+ /**
652
+ * Process a keep_alive call policy -- invokes keep_alive_impl during the
653
+ * pre-call handler if both Nurse, Patient != 0 and use the post-call handler
654
+ * otherwise
655
+ */
656
+ template <size_t Nurse, size_t Patient>
657
+ struct process_attribute<keep_alive<Nurse, Patient>>
658
+ : public process_attribute_default<keep_alive<Nurse, Patient>> {
659
+ template <size_t N = Nurse, size_t P = Patient, enable_if_t<N != 0 && P != 0, int> = 0>
660
+ static void precall(function_call &call) {
661
+ keep_alive_impl(Nurse, Patient, call, handle());
662
+ }
663
+ template <size_t N = Nurse, size_t P = Patient, enable_if_t<N != 0 && P != 0, int> = 0>
664
+ static void postcall(function_call &, handle) {}
665
+ template <size_t N = Nurse, size_t P = Patient, enable_if_t<N == 0 || P == 0, int> = 0>
666
+ static void precall(function_call &) {}
667
+ template <size_t N = Nurse, size_t P = Patient, enable_if_t<N == 0 || P == 0, int> = 0>
668
+ static void postcall(function_call &call, handle ret) {
669
+ keep_alive_impl(Nurse, Patient, call, ret);
670
+ }
671
+ };
672
+
673
+ /// Recursively iterate over variadic template arguments
674
+ template <typename... Args>
675
+ struct process_attributes {
676
+ static void init(const Args &...args, function_record *r) {
677
+ PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(r);
678
+ PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(r);
679
+ using expander = int[];
680
+ (void) expander{
681
+ 0, ((void) process_attribute<typename std::decay<Args>::type>::init(args, r), 0)...};
682
+ }
683
+ static void init(const Args &...args, type_record *r) {
684
+ PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(r);
685
+ PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(r);
686
+ using expander = int[];
687
+ (void) expander{0,
688
+ (process_attribute<typename std::decay<Args>::type>::init(args, r), 0)...};
689
+ }
690
+ static void precall(function_call &call) {
691
+ PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(call);
692
+ using expander = int[];
693
+ (void) expander{0,
694
+ (process_attribute<typename std::decay<Args>::type>::precall(call), 0)...};
695
+ }
696
+ static void postcall(function_call &call, handle fn_ret) {
697
+ PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(call, fn_ret);
698
+ PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(fn_ret);
699
+ using expander = int[];
700
+ (void) expander{
701
+ 0, (process_attribute<typename std::decay<Args>::type>::postcall(call, fn_ret), 0)...};
702
+ }
703
+ };
704
+
705
+ template <typename T>
706
+ using is_call_guard = is_instantiation<call_guard, T>;
707
+
708
+ /// Extract the ``type`` from the first `call_guard` in `Extras...` (or `void_type` if none found)
709
+ template <typename... Extra>
710
+ using extract_guard_t = typename exactly_one_t<is_call_guard, call_guard<>, Extra...>::type;
711
+
712
+ /// Check the number of named arguments at compile time
713
+ template <typename... Extra,
714
+ size_t named = constexpr_sum(std::is_base_of<arg, Extra>::value...),
715
+ size_t self = constexpr_sum(std::is_same<is_method, Extra>::value...)>
716
+ constexpr bool expected_num_args(size_t nargs, bool has_args, bool has_kwargs) {
717
+ PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(nargs, has_args, has_kwargs);
718
+ return named == 0 || (self + named + size_t(has_args) + size_t(has_kwargs)) == nargs;
719
+ }
720
+
721
+ PYBIND11_NAMESPACE_END(detail)
722
+ PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)