@@ -57,7 +57,7 @@ struct _xidata {
5757    // likely a registered "xidatafunc", is responsible for 
5858    // ensuring it owns the reference (i.e. incref). 
5959    PyObject  * obj ;
60-     // interp  is the ID of the owning interpreter of the original 
60+     // interpid  is the ID of the owning interpreter of the original 
6161    // object.  It corresponds to the active interpreter when 
6262    // _PyObject_GetXIData() was called.  This should only 
6363    // be set by the cross-interpreter machinery. 
@@ -93,37 +93,6 @@ PyAPI_FUNC(void) _PyXIData_Free(_PyXIData_t *data);
9393// Users should not need getters for "new_object" or "free". 
9494
9595
96- /* getting cross-interpreter data */ 
97- 
98- typedef  int  (* xidatafunc )(PyThreadState  * tstate , PyObject  * , _PyXIData_t  * );
99- 
100- PyAPI_FUNC (PyObject  * ) _PyXIData_GetNotShareableErrorType (PyThreadState  * );
101- PyAPI_FUNC (void ) _PyXIData_SetNotShareableError (PyThreadState  * , const  char  * );
102- PyAPI_FUNC (void ) _PyXIData_FormatNotShareableError (
103-         PyThreadState  * ,
104-         const  char  * ,
105-         ...);
106- 
107- PyAPI_FUNC (xidatafunc ) _PyXIData_Lookup (
108-         PyThreadState  * ,
109-         PyObject  * );
110- PyAPI_FUNC (int ) _PyObject_CheckXIData (
111-         PyThreadState  * ,
112-         PyObject  * );
113- 
114- PyAPI_FUNC (int ) _PyObject_GetXIData (
115-         PyThreadState  * ,
116-         PyObject  * ,
117-         _PyXIData_t  * );
118- 
119- 
120- /* using cross-interpreter data */ 
121- 
122- PyAPI_FUNC (PyObject  * ) _PyXIData_NewObject (_PyXIData_t  * );
123- PyAPI_FUNC (int ) _PyXIData_Release (_PyXIData_t  * );
124- PyAPI_FUNC (int ) _PyXIData_ReleaseAndRawFree (_PyXIData_t  * );
125- 
126- 
12796/* defining cross-interpreter data */ 
12897
12998PyAPI_FUNC (void ) _PyXIData_Init (
@@ -134,7 +103,7 @@ PyAPI_FUNC(int) _PyXIData_InitWithSize(
134103        _PyXIData_t  * ,
135104        PyInterpreterState  * interp , const  size_t , PyObject  * ,
136105        xid_newobjfunc );
137- PyAPI_FUNC (void ) _PyXIData_Clear (  PyInterpreterState  * , _PyXIData_t  * );
106+ PyAPI_FUNC (void ) _PyXIData_Clear (PyInterpreterState  * , _PyXIData_t  * );
138107
139108// Normally the Init* functions are sufficient.  The only time 
140109// additional initialization might be needed is to set the "free" func, 
@@ -143,6 +112,8 @@ PyAPI_FUNC(void) _PyXIData_Clear( PyInterpreterState *, _PyXIData_t *);
143112    do { \
144113        (DATA)->free = (FUNC); \
145114    } while (0)
115+ #define  _PyXIData_CHECK_FREE (DATA , FUNC ) \
116+     ((DATA)->free == (FUNC))
146117// Additionally, some shareable types are essentially light wrappers 
147118// around other shareable types.  The xidatafunc of the wrapper 
148119// can often be implemented by calling the wrapped object's 
@@ -154,6 +125,65 @@ PyAPI_FUNC(void) _PyXIData_Clear( PyInterpreterState *, _PyXIData_t *);
154125    do { \
155126        (DATA)->new_object = (FUNC); \
156127    } while (0)
128+ #define  _PyXIData_CHECK_NEW_OBJECT (DATA , FUNC ) \
129+     ((DATA)->new_object == (FUNC))
130+ 
131+ 
132+ /* getting cross-interpreter data */ 
133+ 
134+ typedef  int  (* xidatafunc )(PyThreadState  * tstate , PyObject  * , _PyXIData_t  * );
135+ 
136+ PyAPI_FUNC (PyObject  * ) _PyXIData_GetNotShareableErrorType (PyThreadState  * );
137+ PyAPI_FUNC (void ) _PyXIData_SetNotShareableError (PyThreadState  * , const  char  * );
138+ PyAPI_FUNC (void ) _PyXIData_FormatNotShareableError (
139+         PyThreadState  * ,
140+         const  char  * ,
141+         ...);
142+ 
143+ PyAPI_FUNC (xidatafunc ) _PyXIData_Lookup (
144+         PyThreadState  * ,
145+         PyObject  * );
146+ PyAPI_FUNC (int ) _PyObject_CheckXIData (
147+         PyThreadState  * ,
148+         PyObject  * );
149+ 
150+ PyAPI_FUNC (int ) _PyObject_GetXIData (
151+         PyThreadState  * ,
152+         PyObject  * ,
153+         _PyXIData_t  * );
154+ 
155+ // _PyObject_GetXIData() for bytes 
156+ typedef  struct  {
157+     const  char  * bytes ;
158+     Py_ssize_t  len ;
159+ } _PyBytes_data_t ;
160+ PyAPI_FUNC (int ) _PyBytes_GetData (PyObject  * , _PyBytes_data_t  * );
161+ PyAPI_FUNC (PyObject  * ) _PyBytes_FromData (_PyBytes_data_t  * );
162+ PyAPI_FUNC (PyObject  * ) _PyBytes_FromXIData (_PyXIData_t  * );
163+ PyAPI_FUNC (int ) _PyBytes_GetXIData (
164+         PyThreadState  * ,
165+         PyObject  * ,
166+         _PyXIData_t  * );
167+ PyAPI_FUNC (_PyBytes_data_t  * ) _PyBytes_GetXIDataWrapped (
168+         PyThreadState  * ,
169+         PyObject  * ,
170+         size_t ,
171+         xid_newobjfunc ,
172+         _PyXIData_t  * );
173+ 
174+ // _PyObject_GetXIData() for marshal 
175+ PyAPI_FUNC (PyObject  * ) _PyMarshal_ReadObjectFromXIData (_PyXIData_t  * );
176+ PyAPI_FUNC (int ) _PyMarshal_GetXIData (
177+         PyThreadState  * ,
178+         PyObject  * ,
179+         _PyXIData_t  * );
180+ 
181+ 
182+ /* using cross-interpreter data */ 
183+ 
184+ PyAPI_FUNC (PyObject  * ) _PyXIData_NewObject (_PyXIData_t  * );
185+ PyAPI_FUNC (int ) _PyXIData_Release (_PyXIData_t  * );
186+ PyAPI_FUNC (int ) _PyXIData_ReleaseAndRawFree (_PyXIData_t  * );
157187
158188
159189/* cross-interpreter data registry */ 
0 commit comments