Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | #ifndef Py_COBJECT_H |
2 | #define Py_COBJECT_H | |
3 | #ifdef __cplusplus | |
4 | extern "C" { | |
5 | #endif | |
6 | ||
7 | PyAPI_DATA(PyTypeObject) PyCObject_Type; | |
8 | ||
9 | #define PyCObject_Check(op) ((op)->ob_type == &PyCObject_Type) | |
10 | ||
11 | /* Create a PyCObject from a pointer to a C object and an optional | |
12 | destructor function. If the second argument is non-null, then it | |
13 | will be called with the first argument if and when the PyCObject is | |
14 | destroyed. | |
15 | ||
16 | */ | |
17 | PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtr( | |
18 | void *cobj, void (*destruct)(void*)); | |
19 | ||
20 | ||
21 | /* Create a PyCObject from a pointer to a C object, a description object, | |
22 | and an optional destructor function. If the third argument is non-null, | |
23 | then it will be called with the first and second arguments if and when | |
24 | the PyCObject is destroyed. | |
25 | */ | |
26 | PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtrAndDesc( | |
27 | void *cobj, void *desc, void (*destruct)(void*,void*)); | |
28 | ||
29 | /* Retrieve a pointer to a C object from a PyCObject. */ | |
30 | PyAPI_FUNC(void *) PyCObject_AsVoidPtr(PyObject *); | |
31 | ||
32 | /* Retrieve a pointer to a description object from a PyCObject. */ | |
33 | PyAPI_FUNC(void *) PyCObject_GetDesc(PyObject *); | |
34 | ||
35 | /* Import a pointer to a C object from a module using a PyCObject. */ | |
36 | PyAPI_FUNC(void *) PyCObject_Import(char *module_name, char *cobject_name); | |
37 | ||
38 | /* Modify a C object. Fails (==0) if object has a destructor. */ | |
39 | PyAPI_FUNC(int) PyCObject_SetVoidPtr(PyObject *self, void *cobj); | |
40 | ||
41 | #ifdef __cplusplus | |
42 | } | |
43 | #endif | |
44 | #endif /* !Py_COBJECT_H */ |