1 /**
2   Mirror _structseq.h
3   
4   Tuple object interface 
5 */
6 module deimos.python.structseq;
7 
8 import deimos.python.pyport;
9 import deimos.python.object;
10 import deimos.python.tupleobject;
11 
12 extern(C):
13 // Python-header-file: Include/structseq.h:
14 
15 /// _
16 struct PyStructSequence_Field {
17     /// _
18     char* name;
19     /// _
20     char* doc;
21 }
22 
23 /// _
24 struct PyStructSequence_Desc {
25     /// _
26     char* name;
27     /// _
28     char* doc;
29     /// _
30     PyStructSequence_Field* fields;
31     /// _
32     int n_in_sequence;
33 }
34 
35 /// _
36 void PyStructSequence_InitType(PyTypeObject* type, PyStructSequence_Desc* desc);
37 version(Python_3_2_Or_Later) {
38     /// Availability: >= 3.2
39     PyTypeObject* PyStructSequence_NewType(PyStructSequence_Desc* desc);
40 }
41 /// _
42 PyObject* PyStructSequence_New(PyTypeObject* type);
43 
44 version(Python_3_2_Or_Later) {
45     /// _
46     alias PyTupleObject PyStructSequence;
47     /// _
48     alias PyTuple_SET_ITEM PyStructSequence_SET_ITEM;
49 
50     /// Availability: >= 3.2
51     void PyStructSequence_SetItem(PyObject*, Py_ssize_t, PyObject*);
52     /// Availability: >= 3.2
53     PyObject* PyStructSequence_GetItem(PyObject*, Py_ssize_t);
54 }else{ 
55     /// _
56     struct PyStructSequence {
57         mixin PyObject_VAR_HEAD;
58         // Will the D layout for a 1-obj array be the same as the C layout?  I
59         // think the D array will be larger.
60         PyObject*[1] _ob_item;
61         /// _
62         PyObject** ob_item()() {
63             return _ob_item.ptr;
64         }
65     }
66     // D translation of C macro:
67     /** Macro, *only* to be used to fill in brand new objects */
68     PyObject* PyStructSequence_SET_ITEM()(PyObject* op, int i, PyObject* v) {
69         PyStructSequence* ot = cast(PyStructSequence*) op;
70         ot.ob_item[i] = v;
71         return v;
72     }
73 }