blob: d9ecda7a4b6e4a1f26500770e79b7996425d3832 [file] [log] [blame]
Benjamin Petersonb173f782009-05-05 22:31:58 +00001
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.
Georg Brandl5483fe52009-05-17 22:19:14 +00005
Benjamin Petersonb173f782009-05-05 22:31:58 +00006 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.
Georg Brandl5483fe52009-05-17 22:19:14 +000010
Benjamin Petersonb173f782009-05-05 22:31:58 +000011 For more information, please see "c-api/capsule.html" in the
12 documentation.
13*/
14
15#ifndef Py_CAPSULE_H
16#define Py_CAPSULE_H
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21PyAPI_DATA(PyTypeObject) PyCapsule_Type;
22
23typedef void (*PyCapsule_Destructor)(PyObject *);
24
25#define PyCapsule_CheckExact(op) (Py_TYPE(op) == &PyCapsule_Type)
26
27
28PyAPI_FUNC(PyObject *) PyCapsule_New(
Georg Brandl5483fe52009-05-17 22:19:14 +000029 void *pointer,
Benjamin Petersonb173f782009-05-05 22:31:58 +000030 const char *name,
31 PyCapsule_Destructor destructor);
32
33PyAPI_FUNC(void *) PyCapsule_GetPointer(PyObject *capsule, const char *name);
34
35PyAPI_FUNC(PyCapsule_Destructor) PyCapsule_GetDestructor(PyObject *capsule);
36
37PyAPI_FUNC(const char *) PyCapsule_GetName(PyObject *capsule);
38
39PyAPI_FUNC(void *) PyCapsule_GetContext(PyObject *capsule);
40
41PyAPI_FUNC(int) PyCapsule_IsValid(PyObject *capsule, const char *name);
42
43PyAPI_FUNC(int) PyCapsule_SetPointer(PyObject *capsule, void *pointer);
44
45PyAPI_FUNC(int) PyCapsule_SetDestructor(PyObject *capsule, PyCapsule_Destructor destructor);
46
47PyAPI_FUNC(int) PyCapsule_SetName(PyObject *capsule, const char *name);
48
49PyAPI_FUNC(int) PyCapsule_SetContext(PyObject *capsule, void *context);
50
Victor Stinnerd7e76402011-02-22 23:38:34 +000051PyAPI_FUNC(void *) PyCapsule_Import(
52 const char *name, /* UTF-8 encoded string */
53 int no_block);
Benjamin Petersonb173f782009-05-05 22:31:58 +000054
55
56#ifdef __cplusplus
57}
58#endif
59#endif /* !Py_CAPSULE_H */