| 444 | }; |
| 445 | |
| 446 | static PyObject * |
| 447 | arrayflags_getitem(PyArrayFlagsObject *self, PyObject *ind) |
| 448 | { |
| 449 | char *key = NULL; |
| 450 | char buf[16]; |
| 451 | int n; |
| 452 | if (PyUnicode_Check(ind)) { |
| 453 | PyObject *tmp_str; |
| 454 | tmp_str = PyUnicode_AsASCIIString(ind); |
| 455 | if (tmp_str == NULL) { |
| 456 | return NULL; |
| 457 | } |
| 458 | key = PyBytes_AS_STRING(tmp_str); |
| 459 | n = PyBytes_GET_SIZE(tmp_str); |
| 460 | if (n > 16) { |
| 461 | Py_DECREF(tmp_str); |
| 462 | goto fail; |
| 463 | } |
| 464 | memcpy(buf, key, n); |
| 465 | Py_DECREF(tmp_str); |
| 466 | key = buf; |
| 467 | } |
| 468 | else if (PyBytes_Check(ind)) { |
| 469 | key = PyBytes_AS_STRING(ind); |
| 470 | n = PyBytes_GET_SIZE(ind); |
| 471 | } |
| 472 | else { |
| 473 | goto fail; |
| 474 | } |
| 475 | switch(n) { |
| 476 | case 1: |
| 477 | switch(key[0]) { |
| 478 | case 'C': |
| 479 | return arrayflags_contiguous_get(self, NULL); |
| 480 | case 'F': |
| 481 | return arrayflags_fortran_get(self, NULL); |
| 482 | case 'W': |
| 483 | return arrayflags_writeable_get(self, NULL); |
| 484 | case 'B': |
| 485 | return arrayflags_behaved_get(self, NULL); |
| 486 | case 'O': |
| 487 | return arrayflags_owndata_get(self, NULL); |
| 488 | case 'A': |
| 489 | return arrayflags_aligned_get(self, NULL); |
| 490 | case 'X': |
| 491 | return arrayflags_writebackifcopy_get(self, NULL); |
| 492 | default: |
| 493 | goto fail; |
| 494 | } |
| 495 | break; |
| 496 | case 2: |
| 497 | if (strncmp(key, "CA", n) == 0) { |
| 498 | return arrayflags_carray_get(self, NULL); |
| 499 | } |
| 500 | if (strncmp(key, "FA", n) == 0) { |
| 501 | return arrayflags_farray_get(self, NULL); |
| 502 | } |
| 503 | break; |
nothing calls this directly
no test coverage detected