* This function replaces the strided loop with the passed in one, * and registers it with the given ufunc. */
| 193 | * and registers it with the given ufunc. |
| 194 | */ |
| 195 | static int |
| 196 | add_loop(PyObject *umath, const char *ufunc_name, |
| 197 | PyArrayMethod_Spec *spec, PyArrayMethod_StridedLoop *loop) |
| 198 | { |
| 199 | PyObject *name = PyUnicode_FromString(ufunc_name); |
| 200 | if (name == nullptr) { |
| 201 | return -1; |
| 202 | } |
| 203 | PyObject *ufunc = PyObject_GetItem(umath, name); |
| 204 | Py_DECREF(name); |
| 205 | if (ufunc == nullptr) { |
| 206 | return -1; |
| 207 | } |
| 208 | spec->slots[0].pfunc = (void *)loop; |
| 209 | |
| 210 | int res = PyUFunc_AddLoopFromSpec(ufunc, spec); |
| 211 | Py_DECREF(ufunc); |
| 212 | return res; |
| 213 | } |
| 214 | |
| 215 | |
| 216 | template<bool rstrip, typename character, COMP...> |
no test coverage detected