netgen-mesher 6.2.2504.post11.dev0__cp313-cp313-win_amd64.whl → 6.2.2506.post48.dev0__cp313-cp313-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.
- netgen/__init__.pyi +3 -3
- netgen/cmake/NetgenConfig.cmake +10 -9
- netgen/config/__init__.pyi +8 -8
- netgen/config/config.py +7 -7
- netgen/config/config.pyi +8 -8
- netgen/include/core/archive.hpp +18 -3
- netgen/include/core/array.hpp +20 -4
- netgen/include/core/autodiff.hpp +9 -11
- netgen/include/core/autodiffdiff.hpp +0 -2
- netgen/include/core/bitarray.hpp +1 -1
- netgen/include/core/flags.hpp +1 -1
- netgen/include/core/hashtable.hpp +1 -1
- netgen/include/core/memtracer.hpp +7 -7
- netgen/include/core/ngcore.hpp +5 -0
- netgen/include/core/ngcore_api.hpp +11 -0
- netgen/include/core/paje_trace.hpp +9 -8
- netgen/include/core/profiler.hpp +5 -5
- netgen/include/core/register_archive.hpp +8 -0
- netgen/include/core/simd.hpp +69 -1
- netgen/include/core/simd_arm64.hpp +205 -1
- netgen/include/core/simd_avx.hpp +72 -4
- netgen/include/core/simd_avx512.hpp +9 -0
- netgen/include/core/simd_generic.hpp +274 -8
- netgen/include/core/simd_math.hpp +178 -0
- netgen/include/core/simd_sse.hpp +11 -1
- netgen/include/core/statushandler.hpp +37 -0
- netgen/include/core/table.hpp +3 -2
- netgen/include/core/taskmanager.hpp +34 -1
- netgen/include/core/utils.hpp +3 -8
- netgen/include/include/netgen_version.hpp +4 -4
- netgen/include/meshing/basegeom.hpp +1 -4
- netgen/include/meshing/global.hpp +0 -17
- netgen/include/meshing/hpref_tet.hpp +41 -0
- netgen/include/meshing/hprefinement.hpp +2 -0
- netgen/include/meshing/meshtype.hpp +2 -1
- netgen/include/meshing/msghandler.hpp +9 -6
- netgen/include/meshing/topology.hpp +2 -2
- netgen/include/nginterface.h +3 -2
- netgen/include/occ/occ_utils.hpp +26 -0
- netgen/include/occ/occgeom.hpp +8 -0
- netgen/include/pybind11/attr.h +40 -8
- netgen/include/pybind11/buffer_info.h +14 -14
- netgen/include/pybind11/cast.h +553 -29
- netgen/include/pybind11/chrono.h +4 -1
- netgen/include/pybind11/conduit/README.txt +15 -0
- netgen/include/pybind11/conduit/pybind11_conduit_v1.h +116 -0
- netgen/include/pybind11/conduit/pybind11_platform_abi_id.h +87 -0
- netgen/include/pybind11/conduit/wrap_include_python_h.h +72 -0
- netgen/include/pybind11/critical_section.h +56 -0
- netgen/include/pybind11/detail/class.h +172 -97
- netgen/include/pybind11/detail/common.h +270 -189
- netgen/include/pybind11/detail/cpp_conduit.h +75 -0
- netgen/include/pybind11/detail/descr.h +55 -0
- netgen/include/pybind11/detail/dynamic_raw_ptr_cast_if_possible.h +39 -0
- netgen/include/pybind11/detail/exception_translation.h +71 -0
- netgen/include/pybind11/detail/function_record_pyobject.h +191 -0
- netgen/include/pybind11/detail/init.h +113 -9
- netgen/include/pybind11/detail/internals.h +479 -344
- netgen/include/pybind11/detail/native_enum_data.h +209 -0
- netgen/include/pybind11/detail/pybind11_namespace_macros.h +82 -0
- netgen/include/pybind11/detail/struct_smart_holder.h +378 -0
- netgen/include/pybind11/detail/type_caster_base.h +506 -133
- netgen/include/pybind11/detail/using_smart_holder.h +22 -0
- netgen/include/pybind11/detail/value_and_holder.h +90 -0
- netgen/include/pybind11/eigen/matrix.h +19 -10
- netgen/include/pybind11/eigen/tensor.h +15 -11
- netgen/include/pybind11/embed.h +50 -46
- netgen/include/pybind11/eval.h +11 -6
- netgen/include/pybind11/functional.h +58 -49
- netgen/include/pybind11/gil.h +34 -82
- netgen/include/pybind11/gil_safe_call_once.h +12 -1
- netgen/include/pybind11/gil_simple.h +37 -0
- netgen/include/pybind11/native_enum.h +67 -0
- netgen/include/pybind11/numpy.h +272 -93
- netgen/include/pybind11/pybind11.h +947 -265
- netgen/include/pybind11/pytypes.h +127 -21
- netgen/include/pybind11/stl/filesystem.h +23 -25
- netgen/include/pybind11/stl.h +277 -59
- netgen/include/pybind11/stl_bind.h +42 -7
- netgen/include/pybind11/subinterpreter.h +299 -0
- netgen/include/pybind11/trampoline_self_life_support.h +65 -0
- netgen/include/pybind11/typing.h +177 -4
- netgen/include/pybind11/warnings.h +75 -0
- netgen/include/visualization/mvdraw.hpp +48 -12
- netgen/include/visualization/vssolution.hpp +3 -1
- netgen/lib/libnggui.lib +0 -0
- netgen/lib/ngcore.lib +0 -0
- netgen/lib/nglib.lib +0 -0
- netgen/libnggui.dll +0 -0
- netgen/libngguipy.pyd +0 -0
- netgen/libngpy/_NgOCC.pyi +224 -139
- netgen/libngpy/_csg.pyi +26 -26
- netgen/libngpy/_geom2d.pyi +34 -25
- netgen/libngpy/_meshing.pyi +262 -111
- netgen/libngpy/_stl.pyi +3 -4
- netgen/libngpy.pyd +0 -0
- netgen/ngcore.dll +0 -0
- netgen/nglib.dll +0 -0
- netgen/read_gmsh.py +41 -0
- netgen/togl.dll +0 -0
- netgen/version.py +1 -1
- netgen/webgui.py +38 -2
- {netgen_mesher-6.2.2504.post11.dev0.dist-info → netgen_mesher-6.2.2506.post48.dev0.dist-info}/METADATA +2 -1
- {netgen_mesher-6.2.2504.post11.dev0.dist-info → netgen_mesher-6.2.2506.post48.dev0.dist-info}/RECORD +153 -132
- pyngcore/pyngcore.cp313-win_amd64.pyd +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/boundarycondition.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/boxcyl.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/circle_on_cube.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cone.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cube.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cubeandring.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cubeandspheres.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cubemcyl.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cubemsphere.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cylinder.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cylsphere.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/doc/ng4.pdf +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/ellipsoid.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/ellipticcyl.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/extrusion.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/fichera.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/frame.step +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/hinge.stl +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/lshape3d.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/manyholes.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/manyholes2.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/matrix.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/ortho.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/part1.stl +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/period.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/py_tutorials/exportNeutral.py +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/py_tutorials/mesh.py +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/py_tutorials/shaft.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/revolution.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/screw.step +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/sculpture.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/shaft.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/shell.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/sphere.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/sphereincube.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/square.in2d +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/squarecircle.in2d +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/squarehole.in2d +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/torus.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/trafo.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/twobricks.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/twocubes.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/twocyl.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.dist-info → netgen_mesher-6.2.2506.post48.dev0.dist-info}/AUTHORS +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.dist-info → netgen_mesher-6.2.2506.post48.dev0.dist-info}/LICENSE +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.dist-info → netgen_mesher-6.2.2506.post48.dev0.dist-info}/WHEEL +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.dist-info → netgen_mesher-6.2.2506.post48.dev0.dist-info}/entry_points.txt +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.dist-info → netgen_mesher-6.2.2506.post48.dev0.dist-info}/top_level.txt +0 -0
|
@@ -9,88 +9,42 @@
|
|
|
9
9
|
|
|
10
10
|
#pragma once
|
|
11
11
|
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
|
|
16
|
-
// Similar to Python's convention: https://docs.python.org/3/c-api/apiabiversion.html
|
|
17
|
-
// Additional convention: 0xD = dev
|
|
18
|
-
#define PYBIND11_VERSION_HEX 0x020C0000
|
|
19
|
-
|
|
20
|
-
// Define some generic pybind11 helper macros for warning management.
|
|
21
|
-
//
|
|
22
|
-
// Note that compiler-specific push/pop pairs are baked into the
|
|
23
|
-
// PYBIND11_NAMESPACE_BEGIN/PYBIND11_NAMESPACE_END pair of macros. Therefore manual
|
|
24
|
-
// PYBIND11_WARNING_PUSH/PYBIND11_WARNING_POP are usually only needed in `#include` sections.
|
|
25
|
-
//
|
|
26
|
-
// If you find you need to suppress a warning, please try to make the suppression as local as
|
|
27
|
-
// possible using these macros. Please also be sure to push/pop with the pybind11 macros. Please
|
|
28
|
-
// only use compiler specifics if you need to check specific versions, e.g. Apple Clang vs. vanilla
|
|
29
|
-
// Clang.
|
|
30
|
-
#if defined(_MSC_VER)
|
|
31
|
-
# define PYBIND11_COMPILER_MSVC
|
|
32
|
-
# define PYBIND11_PRAGMA(...) __pragma(__VA_ARGS__)
|
|
33
|
-
# define PYBIND11_WARNING_PUSH PYBIND11_PRAGMA(warning(push))
|
|
34
|
-
# define PYBIND11_WARNING_POP PYBIND11_PRAGMA(warning(pop))
|
|
35
|
-
#elif defined(__INTEL_COMPILER)
|
|
36
|
-
# define PYBIND11_COMPILER_INTEL
|
|
37
|
-
# define PYBIND11_PRAGMA(...) _Pragma(#__VA_ARGS__)
|
|
38
|
-
# define PYBIND11_WARNING_PUSH PYBIND11_PRAGMA(warning push)
|
|
39
|
-
# define PYBIND11_WARNING_POP PYBIND11_PRAGMA(warning pop)
|
|
40
|
-
#elif defined(__clang__)
|
|
41
|
-
# define PYBIND11_COMPILER_CLANG
|
|
42
|
-
# define PYBIND11_PRAGMA(...) _Pragma(#__VA_ARGS__)
|
|
43
|
-
# define PYBIND11_WARNING_PUSH PYBIND11_PRAGMA(clang diagnostic push)
|
|
44
|
-
# define PYBIND11_WARNING_POP PYBIND11_PRAGMA(clang diagnostic push)
|
|
45
|
-
#elif defined(__GNUC__)
|
|
46
|
-
# define PYBIND11_COMPILER_GCC
|
|
47
|
-
# define PYBIND11_PRAGMA(...) _Pragma(#__VA_ARGS__)
|
|
48
|
-
# define PYBIND11_WARNING_PUSH PYBIND11_PRAGMA(GCC diagnostic push)
|
|
49
|
-
# define PYBIND11_WARNING_POP PYBIND11_PRAGMA(GCC diagnostic pop)
|
|
50
|
-
#endif
|
|
51
|
-
|
|
52
|
-
#ifdef PYBIND11_COMPILER_MSVC
|
|
53
|
-
# define PYBIND11_WARNING_DISABLE_MSVC(name) PYBIND11_PRAGMA(warning(disable : name))
|
|
54
|
-
#else
|
|
55
|
-
# define PYBIND11_WARNING_DISABLE_MSVC(name)
|
|
12
|
+
#include <pybind11/conduit/wrap_include_python_h.h>
|
|
13
|
+
#if PY_VERSION_HEX < 0x03080000
|
|
14
|
+
# error "PYTHON < 3.8 IS UNSUPPORTED. pybind11 v2.13 was the last to support Python 3.7."
|
|
56
15
|
#endif
|
|
57
16
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
#
|
|
62
|
-
#
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
#
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
#
|
|
72
|
-
|
|
73
|
-
|
|
17
|
+
// Similar to Python's convention: https://docs.python.org/3/c-api/apiabiversion.html
|
|
18
|
+
// See also: https://github.com/python/cpython/blob/HEAD/Include/patchlevel.h
|
|
19
|
+
/* -- start version constants -- */
|
|
20
|
+
#define PYBIND11_VERSION_MAJOR 3
|
|
21
|
+
#define PYBIND11_VERSION_MINOR 0
|
|
22
|
+
#define PYBIND11_VERSION_MICRO 1
|
|
23
|
+
// ALPHA = 0xA, BETA = 0xB, GAMMA = 0xC (release candidate), FINAL = 0xF (stable release)
|
|
24
|
+
// - The release level is set to "alpha" for development versions.
|
|
25
|
+
// Use 0xA0 (LEVEL=0xA, SERIAL=0) for development versions.
|
|
26
|
+
// - For stable releases, set the serial to 0.
|
|
27
|
+
#define PYBIND11_VERSION_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL
|
|
28
|
+
#define PYBIND11_VERSION_RELEASE_SERIAL 0
|
|
29
|
+
// String version of (micro, release level, release serial), e.g.: 0a0, 0b1, 0rc1, 0
|
|
30
|
+
#define PYBIND11_VERSION_PATCH 1
|
|
31
|
+
/* -- end version constants -- */
|
|
32
|
+
|
|
33
|
+
#if !defined(Py_PACK_FULL_VERSION)
|
|
34
|
+
// Stable API since Python 3.14.0a4
|
|
35
|
+
# define Py_PACK_FULL_VERSION(X, Y, Z, LEVEL, SERIAL) \
|
|
36
|
+
((((X) & 0xff) << 24) | (((Y) & 0xff) << 16) | (((Z) & 0xff) << 8) \
|
|
37
|
+
| (((LEVEL) & 0xf) << 4) | (((SERIAL) & 0xf) << 0))
|
|
74
38
|
#endif
|
|
39
|
+
// Version as a single 4-byte hex number, e.g. 0x030C04B5 == 3.12.4b5.
|
|
40
|
+
#define PYBIND11_VERSION_HEX \
|
|
41
|
+
Py_PACK_FULL_VERSION(PYBIND11_VERSION_MAJOR, \
|
|
42
|
+
PYBIND11_VERSION_MINOR, \
|
|
43
|
+
PYBIND11_VERSION_MICRO, \
|
|
44
|
+
PYBIND11_VERSION_RELEASE_LEVEL, \
|
|
45
|
+
PYBIND11_VERSION_RELEASE_SERIAL)
|
|
75
46
|
|
|
76
|
-
#
|
|
77
|
-
namespace name { \
|
|
78
|
-
PYBIND11_WARNING_PUSH
|
|
79
|
-
|
|
80
|
-
#define PYBIND11_NAMESPACE_END(name) \
|
|
81
|
-
PYBIND11_WARNING_POP \
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Robust support for some features and loading modules compiled against different pybind versions
|
|
85
|
-
// requires forcing hidden visibility on pybind code, so we enforce this by setting the attribute
|
|
86
|
-
// on the main `pybind11` namespace.
|
|
87
|
-
#if !defined(PYBIND11_NAMESPACE)
|
|
88
|
-
# ifdef __GNUG__
|
|
89
|
-
# define PYBIND11_NAMESPACE pybind11 __attribute__((visibility("hidden")))
|
|
90
|
-
# else
|
|
91
|
-
# define PYBIND11_NAMESPACE pybind11
|
|
92
|
-
# endif
|
|
93
|
-
#endif
|
|
47
|
+
#include "pybind11_namespace_macros.h"
|
|
94
48
|
|
|
95
49
|
#if !(defined(_MSC_VER) && __cplusplus == 199711L)
|
|
96
50
|
# if __cplusplus >= 201402L
|
|
@@ -118,6 +72,29 @@
|
|
|
118
72
|
# endif
|
|
119
73
|
#endif
|
|
120
74
|
|
|
75
|
+
// These PYBIND11_HAS_... macros are consolidated in pybind11/detail/common.h
|
|
76
|
+
// to simplify backward compatibility handling for users (e.g., via #ifdef checks):
|
|
77
|
+
#define PYBIND11_HAS_TYPE_CASTER_STD_FUNCTION_SPECIALIZATIONS 1
|
|
78
|
+
#define PYBIND11_HAS_INTERNALS_WITH_SMART_HOLDER_SUPPORT 1
|
|
79
|
+
#define PYBIND11_HAS_CPP_CONDUIT 1
|
|
80
|
+
#define PYBIND11_HAS_NATIVE_ENUM 1
|
|
81
|
+
|
|
82
|
+
#if defined(PYBIND11_CPP17) && defined(__has_include)
|
|
83
|
+
# if __has_include(<filesystem>)
|
|
84
|
+
# define PYBIND11_HAS_FILESYSTEM 1
|
|
85
|
+
# elif __has_include(<experimental/filesystem>)
|
|
86
|
+
# define PYBIND11_HAS_EXPERIMENTAL_FILESYSTEM 1
|
|
87
|
+
# endif
|
|
88
|
+
#endif
|
|
89
|
+
|
|
90
|
+
#if defined(__cpp_lib_launder) && !(defined(_MSC_VER) && (_MSC_VER < 1914))
|
|
91
|
+
# define PYBIND11_STD_LAUNDER std::launder
|
|
92
|
+
# define PYBIND11_HAS_STD_LAUNDER 1
|
|
93
|
+
#else
|
|
94
|
+
# define PYBIND11_STD_LAUNDER
|
|
95
|
+
# define PYBIND11_HAS_STD_LAUNDER 0
|
|
96
|
+
#endif
|
|
97
|
+
|
|
121
98
|
#if defined(PYBIND11_CPP20)
|
|
122
99
|
# define PYBIND11_CONSTINIT constinit
|
|
123
100
|
# define PYBIND11_DTOR_CONSTEXPR constexpr
|
|
@@ -164,14 +141,6 @@
|
|
|
164
141
|
# endif
|
|
165
142
|
#endif
|
|
166
143
|
|
|
167
|
-
#if !defined(PYBIND11_EXPORT_EXCEPTION)
|
|
168
|
-
# if defined(__apple_build_version__)
|
|
169
|
-
# define PYBIND11_EXPORT_EXCEPTION PYBIND11_EXPORT
|
|
170
|
-
# else
|
|
171
|
-
# define PYBIND11_EXPORT_EXCEPTION
|
|
172
|
-
# endif
|
|
173
|
-
#endif
|
|
174
|
-
|
|
175
144
|
// For CUDA, GCC7, GCC8:
|
|
176
145
|
// PYBIND11_NOINLINE_FORCED is incompatible with `-Wattributes -Werror`.
|
|
177
146
|
// When defining PYBIND11_NOINLINE_FORCED, it is best to also use `-Wno-attributes`.
|
|
@@ -212,31 +181,6 @@
|
|
|
212
181
|
# define PYBIND11_MAYBE_UNUSED __attribute__((__unused__))
|
|
213
182
|
#endif
|
|
214
183
|
|
|
215
|
-
/* Don't let Python.h #define (v)snprintf as macro because they are implemented
|
|
216
|
-
properly in Visual Studio since 2015. */
|
|
217
|
-
#if defined(_MSC_VER)
|
|
218
|
-
# define HAVE_SNPRINTF 1
|
|
219
|
-
#endif
|
|
220
|
-
|
|
221
|
-
/// Include Python header, disable linking to pythonX_d.lib on Windows in debug mode
|
|
222
|
-
#if defined(_MSC_VER)
|
|
223
|
-
PYBIND11_WARNING_PUSH
|
|
224
|
-
PYBIND11_WARNING_DISABLE_MSVC(4505)
|
|
225
|
-
// C4505: 'PySlice_GetIndicesEx': unreferenced local function has been removed (PyPy only)
|
|
226
|
-
# if defined(_DEBUG) && !defined(Py_DEBUG)
|
|
227
|
-
// Workaround for a VS 2022 issue.
|
|
228
|
-
// NOTE: This workaround knowingly violates the Python.h include order requirement:
|
|
229
|
-
// https://docs.python.org/3/c-api/intro.html#include-files
|
|
230
|
-
// See https://github.com/pybind/pybind11/pull/3497 for full context.
|
|
231
|
-
# include <yvals.h>
|
|
232
|
-
# if _MSVC_STL_VERSION >= 143
|
|
233
|
-
# include <crtdefs.h>
|
|
234
|
-
# endif
|
|
235
|
-
# define PYBIND11_DEBUG_MARKER
|
|
236
|
-
# undef _DEBUG
|
|
237
|
-
# endif
|
|
238
|
-
#endif
|
|
239
|
-
|
|
240
184
|
// https://en.cppreference.com/w/c/chrono/localtime
|
|
241
185
|
#if defined(__STDC_LIB_EXT1__) && !defined(__STDC_WANT_LIB_EXT1__)
|
|
242
186
|
# define __STDC_WANT_LIB_EXT1__
|
|
@@ -261,57 +205,15 @@ PYBIND11_WARNING_DISABLE_MSVC(4505)
|
|
|
261
205
|
# define PYBIND11_HAS_VARIANT 1
|
|
262
206
|
#endif
|
|
263
207
|
|
|
264
|
-
#if defined(PYBIND11_CPP17)
|
|
265
|
-
|
|
266
|
-
#
|
|
267
|
-
# define PYBIND11_HAS_STRING_VIEW
|
|
268
|
-
# endif
|
|
269
|
-
# elif defined(_MSC_VER)
|
|
270
|
-
# define PYBIND11_HAS_STRING_VIEW
|
|
271
|
-
# endif
|
|
272
|
-
#endif
|
|
273
|
-
|
|
274
|
-
#include <Python.h>
|
|
275
|
-
// Reminder: WITH_THREAD is always defined if PY_VERSION_HEX >= 0x03070000
|
|
276
|
-
#if PY_VERSION_HEX < 0x03060000
|
|
277
|
-
# error "PYTHON < 3.6 IS UNSUPPORTED. pybind11 v2.9 was the last to support Python 2 and 3.5."
|
|
278
|
-
#endif
|
|
279
|
-
#include <frameobject.h>
|
|
280
|
-
#include <pythread.h>
|
|
281
|
-
|
|
282
|
-
/* Python #defines overrides on all sorts of core functions, which
|
|
283
|
-
tends to weak havok in C++ codebases that expect these to work
|
|
284
|
-
like regular functions (potentially with several overloads) */
|
|
285
|
-
#if defined(isalnum)
|
|
286
|
-
# undef isalnum
|
|
287
|
-
# undef isalpha
|
|
288
|
-
# undef islower
|
|
289
|
-
# undef isspace
|
|
290
|
-
# undef isupper
|
|
291
|
-
# undef tolower
|
|
292
|
-
# undef toupper
|
|
293
|
-
#endif
|
|
294
|
-
|
|
295
|
-
#if defined(copysign)
|
|
296
|
-
# undef copysign
|
|
208
|
+
#if defined(PYBIND11_CPP17) \
|
|
209
|
+
&& ((defined(__has_include) && __has_include(<string_view>)) || defined(_MSC_VER))
|
|
210
|
+
# define PYBIND11_HAS_STRING_VIEW 1
|
|
297
211
|
#endif
|
|
298
212
|
|
|
299
|
-
#if defined(
|
|
300
|
-
# define PYBIND11_INTERNAL_NUMPY_1_ONLY_DETECTED
|
|
301
|
-
#endif
|
|
302
|
-
|
|
303
|
-
#if defined(PYPY_VERSION) && !defined(PYBIND11_SIMPLE_GIL_MANAGEMENT)
|
|
213
|
+
#if (defined(PYPY_VERSION) || defined(GRAALVM_PYTHON)) && !defined(PYBIND11_SIMPLE_GIL_MANAGEMENT)
|
|
304
214
|
# define PYBIND11_SIMPLE_GIL_MANAGEMENT
|
|
305
215
|
#endif
|
|
306
216
|
|
|
307
|
-
#if defined(_MSC_VER)
|
|
308
|
-
# if defined(PYBIND11_DEBUG_MARKER)
|
|
309
|
-
# define _DEBUG
|
|
310
|
-
# undef PYBIND11_DEBUG_MARKER
|
|
311
|
-
# endif
|
|
312
|
-
PYBIND11_WARNING_POP
|
|
313
|
-
#endif
|
|
314
|
-
|
|
315
217
|
#include <cstddef>
|
|
316
218
|
#include <cstring>
|
|
317
219
|
#include <exception>
|
|
@@ -330,9 +232,20 @@ PYBIND11_WARNING_POP
|
|
|
330
232
|
# endif
|
|
331
233
|
#endif
|
|
332
234
|
|
|
235
|
+
// For libc++, the exceptions should be exported,
|
|
236
|
+
// otherwise, the exception translation would be incorrect.
|
|
237
|
+
// IMPORTANT: This code block must stay BELOW the #include <exception> above (see PR #5390).
|
|
238
|
+
#if !defined(PYBIND11_EXPORT_EXCEPTION)
|
|
239
|
+
# if defined(_LIBCPP_EXCEPTION)
|
|
240
|
+
# define PYBIND11_EXPORT_EXCEPTION PYBIND11_EXPORT
|
|
241
|
+
# else
|
|
242
|
+
# define PYBIND11_EXPORT_EXCEPTION
|
|
243
|
+
# endif
|
|
244
|
+
#endif
|
|
245
|
+
|
|
333
246
|
// Must be after including <version> or one of the other headers specified by the standard
|
|
334
247
|
#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
|
|
335
|
-
# define PYBIND11_HAS_U8STRING
|
|
248
|
+
# define PYBIND11_HAS_U8STRING 1
|
|
336
249
|
#endif
|
|
337
250
|
|
|
338
251
|
// See description of PR #4246:
|
|
@@ -341,6 +254,50 @@ PYBIND11_WARNING_POP
|
|
|
341
254
|
# define PYBIND11_ASSERT_GIL_HELD_INCREF_DECREF
|
|
342
255
|
#endif
|
|
343
256
|
|
|
257
|
+
// Slightly faster code paths are available when PYBIND11_HAS_SUBINTERPRETER_SUPPORT is *not*
|
|
258
|
+
// defined, so avoid defining it for implementations that do not support subinterpreters. However,
|
|
259
|
+
// defining it unnecessarily is not expected to break anything.
|
|
260
|
+
// This can be overridden by the user with -DPYBIND11_HAS_SUBINTERPRETER_SUPPORT=1 or 0
|
|
261
|
+
#ifndef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
|
|
262
|
+
# if PY_VERSION_HEX >= 0x030C0000 && !defined(PYPY_VERSION) && !defined(GRAALVM_PYTHON)
|
|
263
|
+
# define PYBIND11_HAS_SUBINTERPRETER_SUPPORT 1
|
|
264
|
+
# endif
|
|
265
|
+
#else
|
|
266
|
+
# if PYBIND11_HAS_SUBINTERPRETER_SUPPORT == 0
|
|
267
|
+
# undef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
|
|
268
|
+
# endif
|
|
269
|
+
#endif
|
|
270
|
+
|
|
271
|
+
// 3.13 Compatibility
|
|
272
|
+
#if 0x030D0000 <= PY_VERSION_HEX
|
|
273
|
+
# define PYBIND11_TYPE_IS_TYPE_HINT "typing.TypeIs"
|
|
274
|
+
# define PYBIND11_CAPSULE_TYPE_TYPE_HINT "types.CapsuleType"
|
|
275
|
+
#else
|
|
276
|
+
# define PYBIND11_TYPE_IS_TYPE_HINT "typing_extensions.TypeIs"
|
|
277
|
+
# define PYBIND11_CAPSULE_TYPE_TYPE_HINT "typing_extensions.CapsuleType"
|
|
278
|
+
#endif
|
|
279
|
+
|
|
280
|
+
// 3.12 Compatibility
|
|
281
|
+
#if 0x030C0000 <= PY_VERSION_HEX
|
|
282
|
+
# define PYBIND11_BUFFER_TYPE_HINT "collections.abc.Buffer"
|
|
283
|
+
#else
|
|
284
|
+
# define PYBIND11_BUFFER_TYPE_HINT "typing_extensions.Buffer"
|
|
285
|
+
#endif
|
|
286
|
+
|
|
287
|
+
// 3.11 Compatibility
|
|
288
|
+
#if 0x030B0000 <= PY_VERSION_HEX
|
|
289
|
+
# define PYBIND11_NEVER_TYPE_HINT "typing.Never"
|
|
290
|
+
#else
|
|
291
|
+
# define PYBIND11_NEVER_TYPE_HINT "typing_extensions.Never"
|
|
292
|
+
#endif
|
|
293
|
+
|
|
294
|
+
// 3.10 Compatibility
|
|
295
|
+
#if 0x030A0000 <= PY_VERSION_HEX
|
|
296
|
+
# define PYBIND11_TYPE_GUARD_TYPE_HINT "typing.TypeGuard"
|
|
297
|
+
#else
|
|
298
|
+
# define PYBIND11_TYPE_GUARD_TYPE_HINT "typing_extensions.TypeGuard"
|
|
299
|
+
#endif
|
|
300
|
+
|
|
344
301
|
// #define PYBIND11_STR_LEGACY_PERMISSIVE
|
|
345
302
|
// If DEFINED, pybind11::str can hold PyUnicodeObject or PyBytesObject
|
|
346
303
|
// (probably surprising and never documented, but this was the
|
|
@@ -378,15 +335,35 @@ PYBIND11_WARNING_POP
|
|
|
378
335
|
#define PYBIND11_BUILTINS_MODULE "builtins"
|
|
379
336
|
// Providing a separate declaration to make Clang's -Wmissing-prototypes happy.
|
|
380
337
|
// See comment for PYBIND11_MODULE below for why this is marked "maybe unused".
|
|
338
|
+
#define PYBIND11_PLUGIN_DECL(name) \
|
|
339
|
+
extern "C" PYBIND11_MAYBE_UNUSED PYBIND11_EXPORT PyObject *PyInit_##name();
|
|
381
340
|
#define PYBIND11_PLUGIN_IMPL(name) \
|
|
382
|
-
|
|
341
|
+
PYBIND11_PLUGIN_DECL(name) \
|
|
383
342
|
extern "C" PYBIND11_EXPORT PyObject *PyInit_##name()
|
|
384
343
|
|
|
385
344
|
#define PYBIND11_TRY_NEXT_OVERLOAD ((PyObject *) 1) // special failure return code
|
|
386
345
|
#define PYBIND11_STRINGIFY(x) #x
|
|
387
346
|
#define PYBIND11_TOSTRING(x) PYBIND11_STRINGIFY(x)
|
|
388
347
|
#define PYBIND11_CONCAT(first, second) first##second
|
|
389
|
-
#define PYBIND11_ENSURE_INTERNALS_READY
|
|
348
|
+
#define PYBIND11_ENSURE_INTERNALS_READY \
|
|
349
|
+
{ \
|
|
350
|
+
pybind11::detail::get_internals_pp_manager().unref(); \
|
|
351
|
+
pybind11::detail::get_internals(); \
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
#if !defined(GRAALVM_PYTHON)
|
|
355
|
+
# define PYBIND11_PYCFUNCTION_GET_DOC(func) ((func)->m_ml->ml_doc)
|
|
356
|
+
# define PYBIND11_PYCFUNCTION_SET_DOC(func, doc) \
|
|
357
|
+
do { \
|
|
358
|
+
(func)->m_ml->ml_doc = (doc); \
|
|
359
|
+
} while (0)
|
|
360
|
+
#else
|
|
361
|
+
# define PYBIND11_PYCFUNCTION_GET_DOC(func) (GraalPyCFunction_GetDoc((PyObject *) (func)))
|
|
362
|
+
# define PYBIND11_PYCFUNCTION_SET_DOC(func, doc) \
|
|
363
|
+
do { \
|
|
364
|
+
GraalPyCFunction_SetDoc((PyObject *) (func), (doc)); \
|
|
365
|
+
} while (0)
|
|
366
|
+
#endif
|
|
390
367
|
|
|
391
368
|
#define PYBIND11_CHECK_PYTHON_VERSION \
|
|
392
369
|
{ \
|
|
@@ -408,11 +385,9 @@ PYBIND11_WARNING_POP
|
|
|
408
385
|
#define PYBIND11_CATCH_INIT_EXCEPTIONS \
|
|
409
386
|
catch (pybind11::error_already_set & e) { \
|
|
410
387
|
pybind11::raise_from(e, PyExc_ImportError, "initialization failed"); \
|
|
411
|
-
return nullptr; \
|
|
412
388
|
} \
|
|
413
389
|
catch (const std::exception &e) { \
|
|
414
390
|
::pybind11::set_error(PyExc_ImportError, e.what()); \
|
|
415
|
-
return nullptr; \
|
|
416
391
|
}
|
|
417
392
|
|
|
418
393
|
/** \rst
|
|
@@ -440,14 +415,63 @@ PYBIND11_WARNING_POP
|
|
|
440
415
|
return pybind11_init(); \
|
|
441
416
|
} \
|
|
442
417
|
PYBIND11_CATCH_INIT_EXCEPTIONS \
|
|
418
|
+
return nullptr; \
|
|
443
419
|
} \
|
|
444
420
|
PyObject *pybind11_init()
|
|
445
421
|
|
|
422
|
+
// this push is for the next several macros
|
|
423
|
+
PYBIND11_WARNING_PUSH
|
|
424
|
+
PYBIND11_WARNING_DISABLE_CLANG("-Wgnu-zero-variadic-macro-arguments")
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
Create a PyInit_ function for this module.
|
|
428
|
+
|
|
429
|
+
Note that this is run once for each (sub-)interpreter the module is imported into, including
|
|
430
|
+
possibly concurrently. The PyModuleDef is allowed to be static, but the PyObject* resulting from
|
|
431
|
+
PyModuleDef_Init should be treated like any other PyObject (so not shared across interpreters).
|
|
432
|
+
*/
|
|
433
|
+
#define PYBIND11_MODULE_PYINIT(name, pre_init, ...) \
|
|
434
|
+
static int PYBIND11_CONCAT(pybind11_exec_, name)(PyObject *); \
|
|
435
|
+
PYBIND11_PLUGIN_IMPL(name) { \
|
|
436
|
+
PYBIND11_CHECK_PYTHON_VERSION \
|
|
437
|
+
pre_init; \
|
|
438
|
+
PYBIND11_ENSURE_INTERNALS_READY \
|
|
439
|
+
static ::pybind11::detail::slots_array mod_def_slots = ::pybind11::detail::init_slots( \
|
|
440
|
+
&PYBIND11_CONCAT(pybind11_exec_, name), ##__VA_ARGS__); \
|
|
441
|
+
static PyModuleDef def{/* m_base */ PyModuleDef_HEAD_INIT, \
|
|
442
|
+
/* m_name */ PYBIND11_TOSTRING(name), \
|
|
443
|
+
/* m_doc */ nullptr, \
|
|
444
|
+
/* m_size */ 0, \
|
|
445
|
+
/* m_methods */ nullptr, \
|
|
446
|
+
/* m_slots */ mod_def_slots.data(), \
|
|
447
|
+
/* m_traverse */ nullptr, \
|
|
448
|
+
/* m_clear */ nullptr, \
|
|
449
|
+
/* m_free */ nullptr}; \
|
|
450
|
+
return PyModuleDef_Init(&def); \
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
#define PYBIND11_MODULE_EXEC(name, variable) \
|
|
454
|
+
static void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ &); \
|
|
455
|
+
int PYBIND11_CONCAT(pybind11_exec_, name)(PyObject * pm) { \
|
|
456
|
+
try { \
|
|
457
|
+
auto m = pybind11::reinterpret_borrow<::pybind11::module_>(pm); \
|
|
458
|
+
if (!pybind11::detail::get_cached_module(m.attr("__spec__").attr("name"))) { \
|
|
459
|
+
PYBIND11_CONCAT(pybind11_init_, name)(m); \
|
|
460
|
+
pybind11::detail::cache_completed_module(m); \
|
|
461
|
+
} \
|
|
462
|
+
return 0; \
|
|
463
|
+
} \
|
|
464
|
+
PYBIND11_CATCH_INIT_EXCEPTIONS \
|
|
465
|
+
return -1; \
|
|
466
|
+
} \
|
|
467
|
+
void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ \
|
|
468
|
+
& variable) // NOLINT(bugprone-macro-parentheses)
|
|
469
|
+
|
|
446
470
|
/** \rst
|
|
447
471
|
This macro creates the entry point that will be invoked when the Python interpreter
|
|
448
472
|
imports an extension module. The module name is given as the first argument and it
|
|
449
473
|
should not be in quotes. The second macro argument defines a variable of type
|
|
450
|
-
|
|
474
|
+
``py::module_`` which can be used to initialize the module.
|
|
451
475
|
|
|
452
476
|
The entry point is marked as "maybe unused" to aid dead-code detection analysis:
|
|
453
477
|
since the entry point is typically only looked up at runtime and not referenced
|
|
@@ -463,24 +487,32 @@ PYBIND11_WARNING_POP
|
|
|
463
487
|
return "Hello, World!";
|
|
464
488
|
});
|
|
465
489
|
}
|
|
490
|
+
|
|
491
|
+
The third and subsequent macro arguments are optional (available since 2.13.0), and
|
|
492
|
+
can be used to mark the extension module as supporting various Python features.
|
|
493
|
+
|
|
494
|
+
- ``mod_gil_not_used()``
|
|
495
|
+
- ``multiple_interpreters::per_interpreter_gil()``
|
|
496
|
+
- ``multiple_interpreters::shared_gil()``
|
|
497
|
+
- ``multiple_interpreters::not_supported()``
|
|
498
|
+
|
|
499
|
+
.. code-block:: cpp
|
|
500
|
+
|
|
501
|
+
PYBIND11_MODULE(example, m, py::mod_gil_not_used()) {
|
|
502
|
+
m.doc() = "pybind11 example module safe to run without the GIL";
|
|
503
|
+
m.def("foo", []() {
|
|
504
|
+
return "Hello, Free-threaded World!";
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
|
|
466
508
|
\endrst */
|
|
467
|
-
#define PYBIND11_MODULE(name, variable)
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
PYBIND11_ENSURE_INTERNALS_READY \
|
|
475
|
-
auto m = ::pybind11::module_::create_extension_module( \
|
|
476
|
-
PYBIND11_TOSTRING(name), nullptr, &PYBIND11_CONCAT(pybind11_module_def_, name)); \
|
|
477
|
-
try { \
|
|
478
|
-
PYBIND11_CONCAT(pybind11_init_, name)(m); \
|
|
479
|
-
return m.ptr(); \
|
|
480
|
-
} \
|
|
481
|
-
PYBIND11_CATCH_INIT_EXCEPTIONS \
|
|
482
|
-
} \
|
|
483
|
-
void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ & (variable))
|
|
509
|
+
#define PYBIND11_MODULE(name, variable, ...) \
|
|
510
|
+
PYBIND11_MODULE_PYINIT( \
|
|
511
|
+
name, (pybind11::detail::get_num_interpreters_seen() += 1), ##__VA_ARGS__) \
|
|
512
|
+
PYBIND11_MODULE_EXEC(name, variable)
|
|
513
|
+
|
|
514
|
+
// pop gnu-zero-variadic-macro-arguments
|
|
515
|
+
PYBIND11_WARNING_POP
|
|
484
516
|
|
|
485
517
|
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
|
486
518
|
|
|
@@ -536,7 +568,7 @@ enum class return_value_policy : uint8_t {
|
|
|
536
568
|
object without taking ownership similar to the above
|
|
537
569
|
return_value_policy::reference policy. In contrast to that policy, the
|
|
538
570
|
function or property's implicit this argument (called the parent) is
|
|
539
|
-
considered to be the
|
|
571
|
+
considered to be the owner of the return value (the child).
|
|
540
572
|
pybind11 then couples the lifetime of the parent to the child via a
|
|
541
573
|
reference relationship that ensures that the parent cannot be garbage
|
|
542
574
|
collected while Python is still using the child. More advanced
|
|
@@ -619,6 +651,8 @@ struct instance {
|
|
|
619
651
|
bool simple_instance_registered : 1;
|
|
620
652
|
/// If true, get_internals().patients has an entry for this object
|
|
621
653
|
bool has_patients : 1;
|
|
654
|
+
/// If true, this Python object needs to be kept alive for the lifetime of the C++ value.
|
|
655
|
+
bool is_alias : 1;
|
|
622
656
|
|
|
623
657
|
/// Initializes all of the above type/values/holders data (but not the instance values
|
|
624
658
|
/// themselves)
|
|
@@ -641,6 +675,14 @@ struct instance {
|
|
|
641
675
|
static_assert(std::is_standard_layout<instance>::value,
|
|
642
676
|
"Internal error: `pybind11::detail::instance` is not standard layout!");
|
|
643
677
|
|
|
678
|
+
// Some older compilers (e.g. gcc 9.4.0) require
|
|
679
|
+
// static_assert(always_false<T>::value, "...");
|
|
680
|
+
// instead of
|
|
681
|
+
// static_assert(false, "...");
|
|
682
|
+
// to trigger the static_assert() in a template only if it is actually instantiated.
|
|
683
|
+
template <typename>
|
|
684
|
+
struct always_false : std::false_type {};
|
|
685
|
+
|
|
644
686
|
/// from __cpp_future__ import (convenient aliases from C++14/17)
|
|
645
687
|
#if defined(PYBIND11_CPP14)
|
|
646
688
|
using std::conditional_t;
|
|
@@ -658,7 +700,7 @@ template <typename T>
|
|
|
658
700
|
using remove_reference_t = typename std::remove_reference<T>::type;
|
|
659
701
|
#endif
|
|
660
702
|
|
|
661
|
-
#if defined(PYBIND11_CPP20)
|
|
703
|
+
#if defined(PYBIND11_CPP20) && defined(__cpp_lib_remove_cvref)
|
|
662
704
|
using std::remove_cvref;
|
|
663
705
|
using std::remove_cvref_t;
|
|
664
706
|
#else
|
|
@@ -681,14 +723,49 @@ using std::make_index_sequence;
|
|
|
681
723
|
#else
|
|
682
724
|
template <size_t...>
|
|
683
725
|
struct index_sequence {};
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
726
|
+
// Comments about the algorithm below.
|
|
727
|
+
//
|
|
728
|
+
// Credit: This is based on an algorithm by taocpp here:
|
|
729
|
+
// https://github.com/taocpp/sequences/blob/main/include/tao/seq/make_integer_sequence.hpp
|
|
730
|
+
// but significantly simplified.
|
|
731
|
+
//
|
|
732
|
+
// We build up a sequence S by repeatedly doubling its length and sometimes adding 1 to the end.
|
|
733
|
+
// E.g. if the current S is 0...3, then we either go to 0...7 or 0...8 on the next pass.
|
|
734
|
+
// The goal is to end with S = 0...N-1.
|
|
735
|
+
// The key insight is that the times we need to add an additional digit to S correspond
|
|
736
|
+
// exactly to the 1's in the binary representation of the number N.
|
|
737
|
+
//
|
|
738
|
+
// Invariants:
|
|
739
|
+
// - digit is a power of 2
|
|
740
|
+
// - N_digit_is_1 is whether N's binary representation has a 1 in that digit's position.
|
|
741
|
+
// - end <= N
|
|
742
|
+
// - S is 0...end-1.
|
|
743
|
+
// - if digit > 0, end * digit * 2 <= N < (end+1) * digit * 2
|
|
744
|
+
//
|
|
745
|
+
// The process starts with digit > N, end = 0, and S is empty.
|
|
746
|
+
// The process concludes with digit=0, in which case, end == N and S is 0...N-1.
|
|
747
|
+
|
|
748
|
+
template <size_t digit, bool N_digit_is_1, size_t N, size_t end, size_t... S> // N_digit_is_1=false
|
|
749
|
+
struct make_index_sequence_impl
|
|
750
|
+
: make_index_sequence_impl<digit / 2, (N & (digit / 2)) != 0, N, 2 * end, S..., (S + end)...> {
|
|
751
|
+
};
|
|
752
|
+
template <size_t digit, size_t N, size_t end, size_t... S>
|
|
753
|
+
struct make_index_sequence_impl<digit, true, N, end, S...>
|
|
754
|
+
: make_index_sequence_impl<digit / 2,
|
|
755
|
+
(N & (digit / 2)) != 0,
|
|
756
|
+
N,
|
|
757
|
+
2 * end + 1,
|
|
758
|
+
S...,
|
|
759
|
+
(S + end)...,
|
|
760
|
+
2 * end> {};
|
|
761
|
+
template <size_t N, size_t end, size_t... S>
|
|
762
|
+
struct make_index_sequence_impl<0, false, N, end, S...> {
|
|
688
763
|
using type = index_sequence<S...>;
|
|
689
764
|
};
|
|
765
|
+
constexpr size_t next_power_of_2(size_t N) { return N == 0 ? 1 : next_power_of_2(N >> 1) << 1; }
|
|
690
766
|
template <size_t N>
|
|
691
|
-
using make_index_sequence =
|
|
767
|
+
using make_index_sequence =
|
|
768
|
+
typename make_index_sequence_impl<next_power_of_2(N), false, N, 0>::type;
|
|
692
769
|
#endif
|
|
693
770
|
|
|
694
771
|
/// Make an index sequence of the indices of true arguments
|
|
@@ -925,8 +1002,7 @@ using is_template_base_of
|
|
|
925
1002
|
= decltype(is_template_base_of_impl<Base>::check((intrinsic_t<T> *) nullptr));
|
|
926
1003
|
#else
|
|
927
1004
|
struct is_template_base_of
|
|
928
|
-
: decltype(is_template_base_of_impl<Base>::check((intrinsic_t<T> *) nullptr))
|
|
929
|
-
};
|
|
1005
|
+
: decltype(is_template_base_of_impl<Base>::check((intrinsic_t<T> *) nullptr)){};
|
|
930
1006
|
#endif
|
|
931
1007
|
|
|
932
1008
|
/// Check if T is an instantiation of the template `Class`. For example:
|
|
@@ -1263,5 +1339,10 @@ constexpr
|
|
|
1263
1339
|
# define PYBIND11_DETAILED_ERROR_MESSAGES
|
|
1264
1340
|
#endif
|
|
1265
1341
|
|
|
1342
|
+
// CPython 3.11+ provides Py_TPFLAGS_MANAGED_DICT, but PyPy3.11 does not, see PR #5508.
|
|
1343
|
+
#if PY_VERSION_HEX < 0x030B0000 || defined(PYPY_VERSION)
|
|
1344
|
+
# define PYBIND11_BACKWARD_COMPATIBILITY_TP_DICTOFFSET
|
|
1345
|
+
#endif
|
|
1346
|
+
|
|
1266
1347
|
PYBIND11_NAMESPACE_END(detail)
|
|
1267
1348
|
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|