4 The CObject module is now *deprecated* as of Python 3.1.
5 Please use the Capsule API instead; see "pycapsule.h".
15 PyAPI_DATA(PyTypeObject
) PyCObject_Type
;
17 #define PyCObject_Check(op) (Py_TYPE(op) == &PyCObject_Type)
19 /* Create a PyCObject from a pointer to a C object and an optional
20 destructor function. If the second argument is non-null, then it
21 will be called with the first argument if and when the PyCObject is
25 PyAPI_FUNC(PyObject
*) PyCObject_FromVoidPtr(
26 void *cobj
, void (*destruct
)(void*));
29 /* Create a PyCObject from a pointer to a C object, a description object,
30 and an optional destructor function. If the third argument is non-null,
31 then it will be called with the first and second arguments if and when
32 the PyCObject is destroyed.
34 PyAPI_FUNC(PyObject
*) PyCObject_FromVoidPtrAndDesc(
35 void *cobj
, void *desc
, void (*destruct
)(void*,void*));
37 /* Retrieve a pointer to a C object from a PyCObject. */
38 PyAPI_FUNC(void *) PyCObject_AsVoidPtr(PyObject
*);
40 /* Retrieve a pointer to a description object from a PyCObject. */
41 PyAPI_FUNC(void *) PyCObject_GetDesc(PyObject
*);
43 /* Import a pointer to a C object from a module using a PyCObject. */
44 PyAPI_FUNC(void *) PyCObject_Import(char *module_name
, char *cobject_name
);
46 /* Modify a C object. Fails (==0) if object has a destructor. */
47 PyAPI_FUNC(int) PyCObject_SetVoidPtr(PyObject
*self
, void *cobj
);
54 void (*destructor
)(void *);
61 #endif /* !Py_COBJECT_H */