@@ -84,7 +84,33 @@ struct internals {
84
84
#endif
85
85
};
86
86
87
- // / Tracks the `internals` ABI version independent of the main library version
87
+ // / Additional type information which does not fit into the PyTypeObject.
88
+ // / Changes to this struct also require bumping `PYBIND11_INTERNALS_VERSION`.
89
+ struct type_info {
90
+ PyTypeObject *type;
91
+ const std::type_info *cpptype;
92
+ size_t type_size, holder_size_in_ptrs;
93
+ void *(*operator_new)(size_t );
94
+ void (*init_instance)(instance *, const void *);
95
+ void (*dealloc)(value_and_holder &v_h);
96
+ std::vector<PyObject *(*)(PyObject *, PyTypeObject *)> implicit_conversions;
97
+ std::vector<std::pair<const std::type_info *, void *(*)(void *)>> implicit_casts;
98
+ std::vector<bool (*)(PyObject *, void *&)> *direct_conversions;
99
+ buffer_info *(*get_buffer)(PyObject *, void *) = nullptr ;
100
+ void *get_buffer_data = nullptr ;
101
+ void *(*module_local_load)(PyObject *, const type_info *) = nullptr ;
102
+ /* A simple type never occurs as a (direct or indirect) parent
103
+ * of a class that makes use of multiple inheritance */
104
+ bool simple_type : 1 ;
105
+ /* True if there is no multiple inheritance in this type's inheritance tree */
106
+ bool simple_ancestors : 1 ;
107
+ /* for base vs derived holder_type checks */
108
+ bool default_holder : 1 ;
109
+ /* true if this is a type registered with py::module_local */
110
+ bool module_local : 1 ;
111
+ };
112
+
113
+ // / Tracks the `internals` and `type_info` ABI version independent of the main library version
88
114
#define PYBIND11_INTERNALS_VERSION 1
89
115
90
116
#if defined(WITH_THREAD)
@@ -96,6 +122,9 @@ struct internals {
96
122
#define PYBIND11_INTERNALS_ID " __pybind11_internals_v" \
97
123
PYBIND11_TOSTRING (PYBIND11_INTERNALS_VERSION) PYBIND11_INTERNALS_KIND "__"
98
124
125
+ #define PYBIND11_MODULE_LOCAL_ID " __pybind11_module_local_v" \
126
+ PYBIND11_TOSTRING (PYBIND11_INTERNALS_VERSION) PYBIND11_INTERNALS_KIND "__"
127
+
99
128
// / Each module locally stores a pointer to the `internals` data. The data
100
129
// / itself is shared among modules with the same `PYBIND11_INTERNALS_ID`.
101
130
inline internals *&get_internals_ptr() {
0 commit comments