1 /**
2   Mirror _odictobject.h
3   */
4 module deimos.python.odictobject;
5 
6 import deimos.python.pyport;
7 import deimos.python.object;
8 import deimos.python.dictobject;
9 
10 
11 version(Python_3_5_Or_Later) {
12     mixin(PyAPI_DATA!"PyTypeObject PyODict_Type");
13     mixin(PyAPI_DATA!"PyTypeObject PyODictIter_Type");
14     mixin(PyAPI_DATA!"PyTypeObject PyODictKeys_Type");
15     mixin(PyAPI_DATA!"PyTypeObject PyODictItems_Type");
16     mixin(PyAPI_DATA!"PyTypeObject PyODictValues_Type");
17 
18     // D translation of C macro:
19     /// _
20     int PyODict_Check()(PyObject* op) {
21         return PyObject_TypeCheck(op, &PyODict_Type);
22     }
23 
24     // D translation of C macro:
25     /// _
26     int PyODict_CheckExact()(PyObject* op) {
27             return Py_TYPE(op) == &PyODict_Type;
28     }
29 
30     // D translation of C macro:
31     /// _
32     int PyODict_SIZE()(PyObject* op) {
33         version(Python_3_7_Or_Later) {
34             return PyDict_GET_SIZE(op);
35         }else{
36             return (cast(PyDictObject*)op).ma_used;
37         }
38     }
39 
40     // D translation of C macro:
41     /// _
42     bool PyODict_HasKey()(PyObject* od, char* key) {
43         return PyMapping_HasKey(od, key);
44     }
45 
46     /// _
47     PyObject* PyODict_New();
48 
49     /// _
50     int PyODict_SetItem(PyObject* od, PyObject* key, PyObject* item);
51 
52     /// _
53     int PyODict_DelItem(PyObject* od, PyObject* key);
54 
55     /// _
56     Borrowed!PyObject* PyODict_GetItem()(PyObject* od, PyObject* key) {
57         return PyDict_GetItem(od, key);
58     }
59 
60     /// _
61     Borrowed!PyObject* PyDict_GetItemWithError()(PyObject* od, PyObject* key) {
62         return PyDict_GetItemWithError(od, key);
63     }
64 
65     /// _
66     int PyODict_Contains()(PyObject* od, PyObject* key) {
67         return PyDict_Contains(od, key);
68     }
69 
70     /// _
71     Py_ssize_t PyODict_Size()(PyObject* od) {
72         return PyDict_Size(od);
73     }
74 
75     /// _
76     Borrowed!PyObject* PyODict_GetItemString()(PyObject* od, const(char)* key) {
77         return PyDict_GetItemString(od, key);
78     }
79 }