* unpack tuple of dtype->fields (descr, offset, title[not-needed]) * * @param "value" should be the tuple. * * @return "descr" will be set to the field's dtype * @return "offset" will be set to the field's offset * * returns -1 on failure, 0 on success. */
| 307 | * returns -1 on failure, 0 on success. |
| 308 | */ |
| 309 | NPY_NO_EXPORT int |
| 310 | _unpack_field(PyObject *value, PyArray_Descr **descr, npy_intp *offset) |
| 311 | { |
| 312 | PyObject * off; |
| 313 | if (PyTuple_GET_SIZE(value) < 2) { |
| 314 | return -1; |
| 315 | } |
| 316 | *descr = (PyArray_Descr *)PyTuple_GET_ITEM(value, 0); |
| 317 | off = PyTuple_GET_ITEM(value, 1); |
| 318 | |
| 319 | if (PyLong_Check(off)) { |
| 320 | *offset = PyLong_AsSsize_t(off); |
| 321 | } |
| 322 | else { |
| 323 | PyErr_SetString(PyExc_IndexError, "can't convert offset"); |
| 324 | return -1; |
| 325 | } |
| 326 | |
| 327 | return 0; |
| 328 | } |
| 329 | |
| 330 | /* |
| 331 | * check whether arrays with datatype dtype might have object fields. This will |