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
netgen/include/pybind11/gil.h
CHANGED
|
@@ -9,26 +9,38 @@
|
|
|
9
9
|
|
|
10
10
|
#pragma once
|
|
11
11
|
|
|
12
|
-
#
|
|
12
|
+
#if defined(PYBIND11_SIMPLE_GIL_MANAGEMENT)
|
|
13
13
|
|
|
14
|
-
#include
|
|
14
|
+
# include "detail/common.h"
|
|
15
|
+
# include "gil_simple.h"
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
|
18
|
+
|
|
19
|
+
using gil_scoped_acquire = gil_scoped_acquire_simple;
|
|
20
|
+
using gil_scoped_release = gil_scoped_release_simple;
|
|
21
|
+
|
|
22
|
+
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|
|
23
|
+
|
|
24
|
+
#else
|
|
25
|
+
|
|
26
|
+
# include "detail/common.h"
|
|
17
27
|
# include "detail/internals.h"
|
|
18
|
-
|
|
28
|
+
|
|
29
|
+
# include <cassert>
|
|
19
30
|
|
|
20
31
|
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
|
21
32
|
|
|
22
33
|
PYBIND11_NAMESPACE_BEGIN(detail)
|
|
23
34
|
|
|
35
|
+
PYBIND11_WARNING_PUSH
|
|
36
|
+
PYBIND11_WARNING_DISABLE_GCC("-Wredundant-decls")
|
|
37
|
+
|
|
24
38
|
// forward declarations
|
|
25
39
|
PyThreadState *get_thread_state_unchecked();
|
|
26
40
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
#if defined(WITH_THREAD)
|
|
41
|
+
PYBIND11_WARNING_POP
|
|
30
42
|
|
|
31
|
-
|
|
43
|
+
PYBIND11_NAMESPACE_END(detail)
|
|
32
44
|
|
|
33
45
|
/* The functions below essentially reproduce the PyGILState_* API using a RAII
|
|
34
46
|
* pattern, but there are a few important differences:
|
|
@@ -56,7 +68,7 @@ class gil_scoped_acquire {
|
|
|
56
68
|
public:
|
|
57
69
|
PYBIND11_NOINLINE gil_scoped_acquire() {
|
|
58
70
|
auto &internals = detail::get_internals();
|
|
59
|
-
tstate =
|
|
71
|
+
tstate = internals.tstate.get();
|
|
60
72
|
|
|
61
73
|
if (!tstate) {
|
|
62
74
|
/* Check if the GIL was acquired using the PyGILState_* API instead (e.g. if
|
|
@@ -69,13 +81,13 @@ public:
|
|
|
69
81
|
|
|
70
82
|
if (!tstate) {
|
|
71
83
|
tstate = PyThreadState_New(internals.istate);
|
|
72
|
-
#
|
|
84
|
+
# if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
|
|
73
85
|
if (!tstate) {
|
|
74
86
|
pybind11_fail("scoped_acquire: could not create thread state!");
|
|
75
87
|
}
|
|
76
|
-
#
|
|
88
|
+
# endif
|
|
77
89
|
tstate->gilstate_counter = 0;
|
|
78
|
-
|
|
90
|
+
internals.tstate = tstate;
|
|
79
91
|
} else {
|
|
80
92
|
release = detail::get_thread_state_unchecked() != tstate;
|
|
81
93
|
}
|
|
@@ -94,31 +106,31 @@ public:
|
|
|
94
106
|
|
|
95
107
|
PYBIND11_NOINLINE void dec_ref() {
|
|
96
108
|
--tstate->gilstate_counter;
|
|
97
|
-
#
|
|
109
|
+
# if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
|
|
98
110
|
if (detail::get_thread_state_unchecked() != tstate) {
|
|
99
111
|
pybind11_fail("scoped_acquire::dec_ref(): thread state must be current!");
|
|
100
112
|
}
|
|
101
113
|
if (tstate->gilstate_counter < 0) {
|
|
102
114
|
pybind11_fail("scoped_acquire::dec_ref(): reference count underflow!");
|
|
103
115
|
}
|
|
104
|
-
#
|
|
116
|
+
# endif
|
|
105
117
|
if (tstate->gilstate_counter == 0) {
|
|
106
|
-
#
|
|
118
|
+
# if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
|
|
107
119
|
if (!release) {
|
|
108
120
|
pybind11_fail("scoped_acquire::dec_ref(): internal error!");
|
|
109
121
|
}
|
|
110
|
-
#
|
|
122
|
+
# endif
|
|
111
123
|
PyThreadState_Clear(tstate);
|
|
112
124
|
if (active) {
|
|
113
125
|
PyThreadState_DeleteCurrent();
|
|
114
126
|
}
|
|
115
|
-
|
|
127
|
+
detail::get_internals().tstate.reset();
|
|
116
128
|
release = false;
|
|
117
129
|
}
|
|
118
130
|
}
|
|
119
131
|
|
|
120
132
|
/// This method will disable the PyThreadState_DeleteCurrent call and the
|
|
121
|
-
/// GIL won't be
|
|
133
|
+
/// GIL won't be released. This method should be used if the interpreter
|
|
122
134
|
/// could be shutting down when this is called, as thread deletion is not
|
|
123
135
|
/// allowed during shutdown. Check _Py_IsFinalizing() on Python 3.7+, and
|
|
124
136
|
/// protect subsequent code.
|
|
@@ -149,10 +161,7 @@ public:
|
|
|
149
161
|
// NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
|
|
150
162
|
tstate = PyEval_SaveThread();
|
|
151
163
|
if (disassoc) {
|
|
152
|
-
|
|
153
|
-
// NOLINTNEXTLINE(readability-qualified-auto)
|
|
154
|
-
auto key = internals.tstate;
|
|
155
|
-
PYBIND11_TLS_DELETE_VALUE(key);
|
|
164
|
+
internals.tstate.reset();
|
|
156
165
|
}
|
|
157
166
|
}
|
|
158
167
|
|
|
@@ -175,10 +184,7 @@ public:
|
|
|
175
184
|
PyEval_RestoreThread(tstate);
|
|
176
185
|
}
|
|
177
186
|
if (disassoc) {
|
|
178
|
-
|
|
179
|
-
// NOLINTNEXTLINE(readability-qualified-auto)
|
|
180
|
-
auto key = detail::get_internals().tstate;
|
|
181
|
-
PYBIND11_TLS_REPLACE_VALUE(key, tstate);
|
|
187
|
+
detail::get_internals().tstate = tstate;
|
|
182
188
|
}
|
|
183
189
|
}
|
|
184
190
|
|
|
@@ -188,60 +194,6 @@ private:
|
|
|
188
194
|
bool active = true;
|
|
189
195
|
};
|
|
190
196
|
|
|
191
|
-
# else // PYBIND11_SIMPLE_GIL_MANAGEMENT
|
|
192
|
-
|
|
193
|
-
class gil_scoped_acquire {
|
|
194
|
-
PyGILState_STATE state;
|
|
195
|
-
|
|
196
|
-
public:
|
|
197
|
-
gil_scoped_acquire() : state{PyGILState_Ensure()} {}
|
|
198
|
-
gil_scoped_acquire(const gil_scoped_acquire &) = delete;
|
|
199
|
-
gil_scoped_acquire &operator=(const gil_scoped_acquire &) = delete;
|
|
200
|
-
~gil_scoped_acquire() { PyGILState_Release(state); }
|
|
201
|
-
void disarm() {}
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
class gil_scoped_release {
|
|
205
|
-
PyThreadState *state;
|
|
206
|
-
|
|
207
|
-
public:
|
|
208
|
-
// PRECONDITION: The GIL must be held when this constructor is called.
|
|
209
|
-
gil_scoped_release() {
|
|
210
|
-
assert(PyGILState_Check());
|
|
211
|
-
state = PyEval_SaveThread();
|
|
212
|
-
}
|
|
213
|
-
gil_scoped_release(const gil_scoped_release &) = delete;
|
|
214
|
-
gil_scoped_release &operator=(const gil_scoped_release &) = delete;
|
|
215
|
-
~gil_scoped_release() { PyEval_RestoreThread(state); }
|
|
216
|
-
void disarm() {}
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
# endif // PYBIND11_SIMPLE_GIL_MANAGEMENT
|
|
220
|
-
|
|
221
|
-
#else // WITH_THREAD
|
|
222
|
-
|
|
223
|
-
class gil_scoped_acquire {
|
|
224
|
-
public:
|
|
225
|
-
gil_scoped_acquire() {
|
|
226
|
-
// Trick to suppress `unused variable` error messages (at call sites).
|
|
227
|
-
(void) (this != (this + 1));
|
|
228
|
-
}
|
|
229
|
-
gil_scoped_acquire(const gil_scoped_acquire &) = delete;
|
|
230
|
-
gil_scoped_acquire &operator=(const gil_scoped_acquire &) = delete;
|
|
231
|
-
void disarm() {}
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
class gil_scoped_release {
|
|
235
|
-
public:
|
|
236
|
-
gil_scoped_release() {
|
|
237
|
-
// Trick to suppress `unused variable` error messages (at call sites).
|
|
238
|
-
(void) (this != (this + 1));
|
|
239
|
-
}
|
|
240
|
-
gil_scoped_release(const gil_scoped_release &) = delete;
|
|
241
|
-
gil_scoped_release &operator=(const gil_scoped_release &) = delete;
|
|
242
|
-
void disarm() {}
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
#endif // WITH_THREAD
|
|
246
|
-
|
|
247
197
|
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|
|
198
|
+
|
|
199
|
+
#endif // !PYBIND11_SIMPLE_GIL_MANAGEMENT
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
#include <cassert>
|
|
9
9
|
#include <mutex>
|
|
10
10
|
|
|
11
|
+
#ifdef Py_GIL_DISABLED
|
|
12
|
+
# include <atomic>
|
|
13
|
+
#endif
|
|
14
|
+
|
|
11
15
|
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
|
12
16
|
|
|
13
17
|
// Use the `gil_safe_call_once_and_store` class below instead of the naive
|
|
@@ -42,6 +46,8 @@ PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
|
|
42
46
|
// get processed only when it is the main thread's turn again and it is running
|
|
43
47
|
// normal Python code. However, this will be unnoticeable for quick call-once
|
|
44
48
|
// functions, which is usually the case.
|
|
49
|
+
//
|
|
50
|
+
// For in-depth background, see docs/advanced/deadlock.md
|
|
45
51
|
template <typename T>
|
|
46
52
|
class gil_safe_call_once_and_store {
|
|
47
53
|
public:
|
|
@@ -82,7 +88,12 @@ public:
|
|
|
82
88
|
private:
|
|
83
89
|
alignas(T) char storage_[sizeof(T)] = {};
|
|
84
90
|
std::once_flag once_flag_ = {};
|
|
85
|
-
|
|
91
|
+
#ifdef Py_GIL_DISABLED
|
|
92
|
+
std::atomic_bool
|
|
93
|
+
#else
|
|
94
|
+
bool
|
|
95
|
+
#endif
|
|
96
|
+
is_initialized_{false};
|
|
86
97
|
// The `is_initialized_`-`storage_` pair is very similar to `std::optional`,
|
|
87
98
|
// but the latter does not have the triviality properties of former,
|
|
88
99
|
// therefore `std::optional` is not a viable alternative here.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Copyright (c) 2016-2025 The Pybind Development Team.
|
|
2
|
+
// All rights reserved. Use of this source code is governed by a
|
|
3
|
+
// BSD-style license that can be found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include "detail/common.h"
|
|
8
|
+
|
|
9
|
+
#include <cassert>
|
|
10
|
+
|
|
11
|
+
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
|
12
|
+
|
|
13
|
+
class gil_scoped_acquire_simple {
|
|
14
|
+
PyGILState_STATE state;
|
|
15
|
+
|
|
16
|
+
public:
|
|
17
|
+
gil_scoped_acquire_simple() : state{PyGILState_Ensure()} {}
|
|
18
|
+
gil_scoped_acquire_simple(const gil_scoped_acquire_simple &) = delete;
|
|
19
|
+
gil_scoped_acquire_simple &operator=(const gil_scoped_acquire_simple &) = delete;
|
|
20
|
+
~gil_scoped_acquire_simple() { PyGILState_Release(state); }
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
class gil_scoped_release_simple {
|
|
24
|
+
PyThreadState *state;
|
|
25
|
+
|
|
26
|
+
public:
|
|
27
|
+
// PRECONDITION: The GIL must be held when this constructor is called.
|
|
28
|
+
gil_scoped_release_simple() {
|
|
29
|
+
assert(PyGILState_Check());
|
|
30
|
+
state = PyEval_SaveThread();
|
|
31
|
+
}
|
|
32
|
+
gil_scoped_release_simple(const gil_scoped_release_simple &) = delete;
|
|
33
|
+
gil_scoped_release_simple &operator=(const gil_scoped_release_simple &) = delete;
|
|
34
|
+
~gil_scoped_release_simple() { PyEval_RestoreThread(state); }
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Copyright (c) 2022-2025 The pybind Community.
|
|
2
|
+
// All rights reserved. Use of this source code is governed by a
|
|
3
|
+
// BSD-style license that can be found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include "detail/common.h"
|
|
8
|
+
#include "detail/native_enum_data.h"
|
|
9
|
+
#include "detail/type_caster_base.h"
|
|
10
|
+
#include "cast.h"
|
|
11
|
+
|
|
12
|
+
#include <cassert>
|
|
13
|
+
#include <limits>
|
|
14
|
+
#include <type_traits>
|
|
15
|
+
#include <typeindex>
|
|
16
|
+
|
|
17
|
+
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
|
18
|
+
|
|
19
|
+
/// Conversions between Python's native (stdlib) enum types and C++ enums.
|
|
20
|
+
template <typename EnumType>
|
|
21
|
+
class native_enum : public detail::native_enum_data {
|
|
22
|
+
public:
|
|
23
|
+
using Underlying = typename std::underlying_type<EnumType>::type;
|
|
24
|
+
|
|
25
|
+
native_enum(const object &parent_scope,
|
|
26
|
+
const char *name,
|
|
27
|
+
const char *native_type_name,
|
|
28
|
+
const char *class_doc = "")
|
|
29
|
+
: detail::native_enum_data(
|
|
30
|
+
parent_scope, name, native_type_name, class_doc, std::type_index(typeid(EnumType))) {
|
|
31
|
+
if (detail::get_local_type_info(typeid(EnumType)) != nullptr
|
|
32
|
+
|| detail::get_global_type_info(typeid(EnumType)) != nullptr) {
|
|
33
|
+
pybind11_fail(
|
|
34
|
+
"pybind11::native_enum<...>(\"" + enum_name_encoded
|
|
35
|
+
+ "\") is already registered as a `pybind11::enum_` or `pybind11::class_`!");
|
|
36
|
+
}
|
|
37
|
+
if (detail::global_internals_native_enum_type_map_contains(enum_type_index)) {
|
|
38
|
+
pybind11_fail("pybind11::native_enum<...>(\"" + enum_name_encoded
|
|
39
|
+
+ "\") is already registered!");
|
|
40
|
+
}
|
|
41
|
+
arm_finalize_check();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/// Export enumeration entries into the parent scope
|
|
45
|
+
native_enum &export_values() {
|
|
46
|
+
assert(!export_values_flag); // Catch redundant calls.
|
|
47
|
+
export_values_flag = true;
|
|
48
|
+
return *this;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/// Add an enumeration entry
|
|
52
|
+
native_enum &value(char const *name, EnumType value, const char *doc = nullptr) {
|
|
53
|
+
// Disarm for the case that the native_enum_data dtor runs during exception unwinding.
|
|
54
|
+
disarm_finalize_check("value after finalize");
|
|
55
|
+
members.append(make_tuple(name, static_cast<Underlying>(value)));
|
|
56
|
+
if (doc) {
|
|
57
|
+
member_docs.append(make_tuple(name, doc));
|
|
58
|
+
}
|
|
59
|
+
arm_finalize_check(); // There was no exception.
|
|
60
|
+
return *this;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
native_enum(const native_enum &) = delete;
|
|
64
|
+
native_enum &operator=(const native_enum &) = delete;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|