Sequence slice accessor (set): `object[i:j] = x`. */
| 1936 | |
| 1937 | /** Sequence slice accessor (set): `object[i:j] = x`. */ |
| 1938 | static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *seq) |
| 1939 | { |
| 1940 | int vec_num = 0; |
| 1941 | float *vec = nullptr; |
| 1942 | |
| 1943 | if (BaseMath_ReadCallback_ForWrite(self) == -1) { |
| 1944 | return -1; |
| 1945 | } |
| 1946 | |
| 1947 | CLAMP(begin, 0, self->vec_num); |
| 1948 | CLAMP(end, 0, self->vec_num); |
| 1949 | begin = std::min(begin, end); |
| 1950 | |
| 1951 | vec_num = (end - begin); |
| 1952 | if (mathutils_array_parse_alloc(&vec, vec_num, seq, "vector[begin:end] = [...]") == -1) { |
| 1953 | return -1; |
| 1954 | } |
| 1955 | |
| 1956 | if (vec == nullptr) { |
| 1957 | PyErr_SetString(PyExc_MemoryError, |
| 1958 | "vec[:] = seq: " |
| 1959 | "problem allocating pointer space"); |
| 1960 | return -1; |
| 1961 | } |
| 1962 | |
| 1963 | /* Parsed well - now set in vector. */ |
| 1964 | memcpy(self->vec + begin, vec, vec_num * sizeof(float)); |
| 1965 | |
| 1966 | PyMem_Free(vec); |
| 1967 | |
| 1968 | if (BaseMath_WriteCallback(self) == -1) { |
| 1969 | return -1; |
| 1970 | } |
| 1971 | |
| 1972 | return 0; |
| 1973 | } |
| 1974 | |
| 1975 | /** Sequence generic subscript (get): `x = object[...]`. */ |
| 1976 | static PyObject *Vector_subscript(VectorObject *self, PyObject *item) |
no test coverage detected