Chris@87: /* Chris@87: CObjects are marked Pending Deprecation as of Python 2.7. Chris@87: The full schedule for 2.x is as follows: Chris@87: - CObjects are marked Pending Deprecation in Python 2.7. Chris@87: - CObjects will be marked Deprecated in Python 2.8 Chris@87: (if there is one). Chris@87: - CObjects will be removed in Python 2.9 (if there is one). Chris@87: Chris@87: Additionally, for the Python 3.x series: Chris@87: - CObjects were marked Deprecated in Python 3.1. Chris@87: - CObjects will be removed in Python 3.2. Chris@87: Chris@87: You should switch all use of CObjects to capsules. Capsules Chris@87: have a safer and more consistent API. For more information, Chris@87: see Include/pycapsule.h, or read the "Capsules" topic in Chris@87: the "Python/C API Reference Manual". Chris@87: Chris@87: Python 2.7 no longer uses CObjects itself; all objects which Chris@87: were formerly CObjects are now capsules. Note that this change Chris@87: does not by itself break binary compatibility with extensions Chris@87: built for previous versions of Python--PyCObject_AsVoidPtr() Chris@87: has been changed to also understand capsules. Chris@87: Chris@87: */ Chris@87: Chris@87: /* original file header comment follows: */ Chris@87: Chris@87: /* C objects to be exported from one extension module to another. Chris@87: Chris@87: C objects are used for communication between extension modules. Chris@87: They provide a way for an extension module to export a C interface Chris@87: to other extension modules, so that extension modules can use the Chris@87: Python import mechanism to link to one another. Chris@87: Chris@87: */ Chris@87: Chris@87: #ifndef Py_COBJECT_H Chris@87: #define Py_COBJECT_H Chris@87: #ifdef __cplusplus Chris@87: extern "C" { Chris@87: #endif Chris@87: Chris@87: PyAPI_DATA(PyTypeObject) PyCObject_Type; Chris@87: Chris@87: #define PyCObject_Check(op) (Py_TYPE(op) == &PyCObject_Type) Chris@87: Chris@87: /* Create a PyCObject from a pointer to a C object and an optional Chris@87: destructor function. If the second argument is non-null, then it Chris@87: will be called with the first argument if and when the PyCObject is Chris@87: destroyed. Chris@87: Chris@87: */ Chris@87: PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtr( Chris@87: void *cobj, void (*destruct)(void*)); Chris@87: Chris@87: Chris@87: /* Create a PyCObject from a pointer to a C object, a description object, Chris@87: and an optional destructor function. If the third argument is non-null, Chris@87: then it will be called with the first and second arguments if and when Chris@87: the PyCObject is destroyed. Chris@87: */ Chris@87: PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtrAndDesc( Chris@87: void *cobj, void *desc, void (*destruct)(void*,void*)); Chris@87: Chris@87: /* Retrieve a pointer to a C object from a PyCObject. */ Chris@87: PyAPI_FUNC(void *) PyCObject_AsVoidPtr(PyObject *); Chris@87: Chris@87: /* Retrieve a pointer to a description object from a PyCObject. */ Chris@87: PyAPI_FUNC(void *) PyCObject_GetDesc(PyObject *); Chris@87: Chris@87: /* Import a pointer to a C object from a module using a PyCObject. */ Chris@87: PyAPI_FUNC(void *) PyCObject_Import(char *module_name, char *cobject_name); Chris@87: Chris@87: /* Modify a C object. Fails (==0) if object has a destructor. */ Chris@87: PyAPI_FUNC(int) PyCObject_SetVoidPtr(PyObject *self, void *cobj); Chris@87: Chris@87: Chris@87: typedef struct { Chris@87: PyObject_HEAD Chris@87: void *cobject; Chris@87: void *desc; Chris@87: void (*destructor)(void *); Chris@87: } PyCObject; Chris@87: Chris@87: Chris@87: #ifdef __cplusplus Chris@87: } Chris@87: #endif Chris@87: #endif /* !Py_COBJECT_H */