| 1042 | } |
| 1043 | |
| 1044 | PyObject *JSArrayProxyMethodDefinitions::JSArrayProxy_count(JSArrayProxy *self, PyObject *value) { |
| 1045 | Py_ssize_t count = 0; |
| 1046 | |
| 1047 | Py_ssize_t length = JSArrayProxy_length(self); |
| 1048 | JS::RootedValue elementVal(GLOBAL_CX); |
| 1049 | for (Py_ssize_t index = 0; index < length; index++) { |
| 1050 | JS_GetElement(GLOBAL_CX, *(self->jsArray), index, &elementVal); |
| 1051 | PyObject *obj = pyTypeFactory(GLOBAL_CX, elementVal); |
| 1052 | Py_INCREF(obj); |
| 1053 | int cmp = PyObject_RichCompareBool(obj, value, Py_EQ); |
| 1054 | Py_DECREF(obj); |
| 1055 | Py_DECREF(obj); |
| 1056 | if (cmp > 0) { |
| 1057 | count++; |
| 1058 | } |
| 1059 | else if (cmp < 0) { |
| 1060 | return NULL; |
| 1061 | } |
| 1062 | } |
| 1063 | return PyLong_FromSsize_t(count); |
| 1064 | } |
| 1065 | |
| 1066 | PyObject *JSArrayProxyMethodDefinitions::JSArrayProxy_reverse(JSArrayProxy *self) { |
| 1067 | if (JSArrayProxy_length(self) > 1) { |
nothing calls this directly
no test coverage detected