1 /**
2   Mirror _memoryobject.h
3   */
4 module deimos.python.memoryobject;
5 
6 import deimos.python.pyport;
7 import deimos.python.object;
8 
9 extern(C):
10 // Python-header-file: Include/memoryobject.h:
11 version(Python_2_7_Or_Later) {
12     /// Availability: >= 2.7
13     mixin(PyAPI_DATA!"PyTypeObject PyMemoryView_Type");
14 
15     /// Availability: >= 2.7
16     int PyMemoryView_Check()(PyObject* op) {
17         return Py_TYPE(op) == &PyMemoryView_Type;
18     }
19 
20     /// Availability: >= 2.7
21     auto PyMemoryView_GET_BUFFER()(PyObject* op) {
22         return &(cast(PyMemoryViewObject*)op).view;
23     }
24 
25     /// Availability: >= 2.7
26     auto PyMemoryView_GET_BASE()(PyObject* op) {
27         return (cast(PyMemoryViewObject*) op).view.obj;
28     }
29 
30     /// Availability: >= 2.7
31     PyObject* PyMemoryView_GetContiguous(PyObject* base,
32             int buffertype, char fort);
33 
34     /// Availability: >= 2.7
35     PyObject* PyMemoryView_FromObject(PyObject* base);
36 
37     /// Availability: >= 2.7
38     PyObject* PyMemoryView_FromBuffer(Py_buffer* info);
39 
40     version(Python_3_4_Or_Later) {
41         /// _
42         struct _PyManagedBufferObject {
43             mixin PyObject_HEAD;
44             /// _
45             int flags;
46             /// _
47             Py_ssize_t exports;
48             /// _
49             Py_buffer master;
50         }
51     }
52 	enum _Py_MEMORYVIEW_MAX_FORMAT = 3;
53 
54     /// subclass of PyObject
55     /// Availability: >= 2.7
56     struct PyMemoryViewObject {
57         version(Python_3_4_Or_Later) {
58 			mixin PyObject_VAR_HEAD;
59 
60             /// _
61 			_PyManagedBufferObject* mbuf;
62             /// _
63 			Py_hash_t hash;
64             /// _
65 			int flags;
66             /// _
67 			Py_ssize_t exports;
68             /// _
69 			Py_buffer view;
70             version(Python_3_5_Or_Later) {
71             }else{
72                 /// Availability: 3.4
73                 char[_Py_MEMORYVIEW_MAX_FORMAT] format;
74             }
75             /// _
76 			PyObject* weakreflist;
77             /// _
78 			Py_ssize_t[1] _ob_array;
79 
80             /// _
81             @property Py_ssize_t* ob_array()() {
82                 return _ob_array.ptr;
83             }
84         }else{
85             mixin PyObject_HEAD;
86             /// Availability: 2.7
87             PyObject* base;
88             /// _
89             Py_buffer view;
90         }
91     }
92 
93 }