| 836 | } |
| 837 | |
| 838 | static int |
| 839 | PyArray_BusDayRollConverter(PyObject *roll_in, NPY_BUSDAY_ROLL *roll) |
| 840 | { |
| 841 | PyObject *obj = roll_in; |
| 842 | |
| 843 | /* Make obj into an UTF8 string */ |
| 844 | if (PyBytes_Check(obj)) { |
| 845 | /* accept bytes input */ |
| 846 | PyObject *obj_str = PyUnicode_FromEncodedObject(obj, NULL, NULL); |
| 847 | if (obj_str == NULL) { |
| 848 | return 0; |
| 849 | } |
| 850 | obj = obj_str; |
| 851 | } |
| 852 | else { |
| 853 | Py_INCREF(obj); |
| 854 | } |
| 855 | |
| 856 | Py_ssize_t len; |
| 857 | char const *str = PyUnicode_AsUTF8AndSize(obj, &len); |
| 858 | if (str == NULL) { |
| 859 | Py_DECREF(obj); |
| 860 | return 0; |
| 861 | } |
| 862 | |
| 863 | /* Use switch statements to quickly isolate the right enum value */ |
| 864 | switch (str[0]) { |
| 865 | case 'b': |
| 866 | if (strcmp(str, "backward") == 0) { |
| 867 | *roll = NPY_BUSDAY_BACKWARD; |
| 868 | goto finish; |
| 869 | } |
| 870 | break; |
| 871 | case 'f': |
| 872 | if (len > 2) switch (str[2]) { |
| 873 | case 'r': |
| 874 | if (strcmp(str, "forward") == 0) { |
| 875 | *roll = NPY_BUSDAY_FORWARD; |
| 876 | goto finish; |
| 877 | } |
| 878 | break; |
| 879 | case 'l': |
| 880 | if (strcmp(str, "following") == 0) { |
| 881 | *roll = NPY_BUSDAY_FOLLOWING; |
| 882 | goto finish; |
| 883 | } |
| 884 | break; |
| 885 | } |
| 886 | break; |
| 887 | case 'm': |
| 888 | if (len > 8) switch (str[8]) { |
| 889 | case 'f': |
| 890 | if (strcmp(str, "modifiedfollowing") == 0) { |
| 891 | *roll = NPY_BUSDAY_MODIFIEDFOLLOWING; |
| 892 | goto finish; |
| 893 | } |
| 894 | break; |
| 895 | case 'p': |
nothing calls this directly
no outgoing calls
no test coverage detected