| 
									
										
										
										
											2024-11-07 09:32:42 -07:00
										 |  |  | #ifndef Py_CORE_CROSSINTERP_DATA_REGISTRY_H
 | 
					
						
							|  |  |  | #  error "this header must not be included directly"
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // For now we use a global registry of shareable classes.  An
 | 
					
						
							|  |  |  | // alternative would be to add a tp_* slot for a class's
 | 
					
						
							|  |  |  | // xidatafunc. It would be simpler and more efficient.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-11 15:58:46 -07:00
										 |  |  | struct _xid_regitem; | 
					
						
							| 
									
										
										
										
											2024-11-07 09:32:42 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-11 15:58:46 -07:00
										 |  |  | typedef struct _xid_regitem { | 
					
						
							|  |  |  |     struct _xid_regitem *prev; | 
					
						
							|  |  |  |     struct _xid_regitem *next; | 
					
						
							| 
									
										
										
										
											2024-11-07 09:32:42 -07:00
										 |  |  |     /* This can be a dangling pointer, but only if weakref is set. */ | 
					
						
							|  |  |  |     PyTypeObject *cls; | 
					
						
							|  |  |  |     /* This is NULL for builtin types. */ | 
					
						
							|  |  |  |     PyObject *weakref; | 
					
						
							|  |  |  |     size_t refcount; | 
					
						
							|  |  |  |     xidatafunc getdata; | 
					
						
							| 
									
										
										
										
											2024-11-11 15:58:46 -07:00
										 |  |  | } _PyXIData_regitem_t; | 
					
						
							| 
									
										
										
										
											2024-11-07 09:32:42 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-11 15:58:46 -07:00
										 |  |  | typedef struct { | 
					
						
							| 
									
										
										
										
											2024-11-07 09:32:42 -07:00
										 |  |  |     int global;  /* builtin types or heap types */ | 
					
						
							|  |  |  |     int initialized; | 
					
						
							|  |  |  |     PyMutex mutex; | 
					
						
							| 
									
										
										
										
											2024-11-11 15:58:46 -07:00
										 |  |  |     _PyXIData_regitem_t *head; | 
					
						
							|  |  |  | } _PyXIData_registry_t; | 
					
						
							| 
									
										
										
										
											2024-11-07 09:32:42 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-12 10:41:51 -07:00
										 |  |  | PyAPI_FUNC(int) _PyXIData_RegisterClass( | 
					
						
							| 
									
										
										
										
											2025-04-25 14:43:38 -06:00
										 |  |  |     PyThreadState *, | 
					
						
							| 
									
										
										
										
											2024-11-12 10:41:51 -07:00
										 |  |  |     PyTypeObject *, | 
					
						
							|  |  |  |     xidatafunc); | 
					
						
							|  |  |  | PyAPI_FUNC(int) _PyXIData_UnregisterClass( | 
					
						
							| 
									
										
										
										
											2025-04-25 14:43:38 -06:00
										 |  |  |     PyThreadState *, | 
					
						
							| 
									
										
										
										
											2024-11-12 10:41:51 -07:00
										 |  |  |     PyTypeObject *); | 
					
						
							| 
									
										
										
										
											2024-11-07 09:32:42 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | struct _xid_lookup_state { | 
					
						
							|  |  |  |     // XXX Remove this field once we have a tp_* slot.
 | 
					
						
							| 
									
										
										
										
											2024-11-11 15:58:46 -07:00
										 |  |  |     _PyXIData_registry_t registry; | 
					
						
							| 
									
										
										
										
											2024-11-07 09:32:42 -07:00
										 |  |  | }; |