Recorded merge of revisions 81364 via svnmerge from
[python/dscho.git] / Include / pycapsule.h
blobeba82ee0b24fd970bcb87699c929c3eaa5b89fa6
2 /* Capsule objects let you wrap a C "void *" pointer in a Python
3 object. They're a way of passing data through the Python interpreter
4 without creating your own custom type.
6 Capsules are used for communication between extension modules.
7 They provide a way for an extension module to export a C interface
8 to other extension modules, so that extension modules can use the
9 Python import mechanism to link to one another.
11 For more information, please see "c-api/capsule.html" in the
12 documentation.
15 #ifndef Py_CAPSULE_H
16 #define Py_CAPSULE_H
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
21 PyAPI_DATA(PyTypeObject) PyCapsule_Type;
23 typedef void (*PyCapsule_Destructor)(PyObject *);
25 #define PyCapsule_CheckExact(op) (Py_TYPE(op) == &PyCapsule_Type)
28 PyAPI_FUNC(PyObject *) PyCapsule_New(
29 void *pointer,
30 const char *name,
31 PyCapsule_Destructor destructor);
33 PyAPI_FUNC(void *) PyCapsule_GetPointer(PyObject *capsule, const char *name);
35 PyAPI_FUNC(PyCapsule_Destructor) PyCapsule_GetDestructor(PyObject *capsule);
37 PyAPI_FUNC(const char *) PyCapsule_GetName(PyObject *capsule);
39 PyAPI_FUNC(void *) PyCapsule_GetContext(PyObject *capsule);
41 PyAPI_FUNC(int) PyCapsule_IsValid(PyObject *capsule, const char *name);
43 PyAPI_FUNC(int) PyCapsule_SetPointer(PyObject *capsule, void *pointer);
45 PyAPI_FUNC(int) PyCapsule_SetDestructor(PyObject *capsule, PyCapsule_Destructor destructor);
47 PyAPI_FUNC(int) PyCapsule_SetName(PyObject *capsule, const char *name);
49 PyAPI_FUNC(int) PyCapsule_SetContext(PyObject *capsule, void *context);
51 PyAPI_FUNC(void *) PyCapsule_Import(const char *name, int no_block);
54 #ifdef __cplusplus
56 #endif
57 #endif /* !Py_CAPSULE_H */