1 /**
2   Mirror _pycapsule.h
3 
4   Capsule objects let you wrap a C "void *" pointer in a Python
5   object.  They're a way of passing data through the Python interpreter
6   without creating your own custom type.
7 
8   Capsules are used for communication between extension modules.
9   They provide a way for an extension module to export a C interface
10   to other extension modules, so that extension modules can use the
11   Python import mechanism to link to one another.
12 
13   This was introduced in python 2.7
14 
15 See_Also:
16    <a href="http://docs.python.org/c-api/capsule.html"> Capsules </a>
17   */
18 module deimos.python.pycapsule;
19 
20 import deimos.python.pyport;
21 import deimos.python.object;
22 
23 version(Python_3_1_Or_Later) {
24     version = PyCapsule;
25 }else version(Python_3_0_Or_Later) {
26 }else version(Python_2_7_Or_Later) {
27     version = PyCapsule;
28 }
29 
30 version(PyCapsule) {
31 extern(C):
32 // Python-header-file: Include/pycapsule.h:
33 
34 /// Availability: >= 2.7
35 mixin(PyAPI_DATA!"PyTypeObject PyCapsule_Type");
36 
37 /// Availability: >= 2.7
38 alias void function(PyObject*) PyCapsule_Destructor;
39 
40 /// Availability: >= 2.7
41 int PyCapsule_CheckExact()(PyObject* op) {
42     return Py_TYPE(op) == &PyCapsule_Type;
43 }
44 
45 /// Availability: >= 2.7
46 PyObject* PyCapsule_New(
47             void* pointer,
48             const(char)* name,
49             PyCapsule_Destructor destructor);
50 
51 /// Availability: >= 2.7
52 void* PyCapsule_GetPointer(PyObject* capsule, const(char)* name);
53 
54 /// Availability: >= 2.7
55 PyCapsule_Destructor PyCapsule_GetDestructor(PyObject* capsule);
56 
57 /// Availability: >= 2.7
58 const(char)* PyCapsule_GetName(PyObject* capsule);
59 
60 /// Availability: >= 2.7
61 void* PyCapsule_GetContext(PyObject* capsule);
62 
63 /// Availability: >= 2.7
64 int PyCapsule_IsValid(PyObject* capsule, const(char)* name);
65 
66 /// Availability: >= 2.7
67 int PyCapsule_SetPointer(PyObject* capsule, void* pointer);
68 
69 /// Availability: >= 2.7
70 int PyCapsule_SetDestructor(PyObject* capsule, PyCapsule_Destructor destructor);
71 
72 /// Availability: >= 2.7
73 int PyCapsule_SetName(PyObject* capsule, const(char)* name);
74 
75 /// Availability: >= 2.7
76 int PyCapsule_SetContext(PyObject* capsule, void* context);
77 
78 /// Availability: >= 2.7
79 void* PyCapsule_Import(const(char)* name, int no_block);
80 }