MCPcopy Create free account
hub / github.com/Distributive-Network/PythonMonkey / JSObjectKeysProxy_richcompare

Method JSObjectKeysProxy_richcompare

src/JSObjectKeysProxy.cc:91–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91PyObject *JSObjectKeysProxyMethodDefinitions::JSObjectKeysProxy_richcompare(JSObjectKeysProxy *self, PyObject *other, int op) {
92 Py_ssize_t len_self, len_other;
93 int ok;
94 PyObject *result;
95
96 if (!PyAnySet_Check(other) && !PyDictViewSet_Check(other)) {
97 Py_RETURN_NOTIMPLEMENTED;
98 }
99
100 len_self = JSObjectProxyMethodDefinitions::JSObjectProxy_length((JSObjectProxy *)self->dv.dv_dict);
101 if (len_self < 0) {
102 return NULL;
103 }
104
105 if (PyObject_TypeCheck(other, &JSObjectKeysProxyType)) {
106 len_other = JSObjectProxyMethodDefinitions::JSObjectProxy_length((JSObjectProxy *)self->dv.dv_dict);
107 }
108 else {
109 len_other = PyObject_Size(other);
110 }
111 if (len_other < 0) {
112 return NULL;
113 }
114
115 ok = 0;
116 switch (op) {
117 case Py_NE:
118 case Py_EQ:
119 if (len_self == len_other) {
120
121 ok = all_contained_in((PyObject *)self, other);
122 }
123 if (op == Py_NE && ok >= 0) {
124 ok = !ok;
125 }
126 break;
127
128 case Py_LT:
129 if (len_self < len_other) {
130 ok = all_contained_in((PyObject *)self, other);
131 }
132 break;
133
134 case Py_LE:
135 if (len_self <= len_other) {
136 ok = all_contained_in((PyObject *)self, other);
137 }
138 break;
139
140 case Py_GT:
141 if (len_self > len_other) {
142 ok = all_contained_in(other, (PyObject *)self);
143 }
144 break;
145
146 case Py_GE:
147 if (len_self >= len_other) {
148 ok = all_contained_in(other, (PyObject *)self);

Callers

nothing calls this directly

Calls 1

all_contained_inFunction · 0.70

Tested by

no test coverage detected