• Home
  • Raw
  • Download

Lines Matching refs:view

34 memory_getbuf(PyMemoryViewObject *self, Py_buffer *view, int flags)  in memory_getbuf()  argument
37 if (self->view.obj != NULL) in memory_getbuf()
38 res = PyObject_GetBuffer(self->view.obj, view, flags); in memory_getbuf()
39 if (view) in memory_getbuf()
40 dup_buffer(view, &self->view); in memory_getbuf()
45 memory_releasebuf(PyMemoryViewObject *self, Py_buffer *view) in memory_releasebuf() argument
47 PyBuffer_Release(view); in memory_releasebuf()
65 dup_buffer(&mview->view, info); in PyMemoryView_FromBuffer()
76 Py_buffer view; in PyMemoryView_FromObject() local
85 if (PyObject_GetBuffer(base, &view, PyBUF_FULL_RO) < 0) in PyMemoryView_FromObject()
88 mview = (PyMemoryViewObject *)PyMemoryView_FromBuffer(&view); in PyMemoryView_FromObject()
90 PyBuffer_Release(&view); in PyMemoryView_FromObject()
173 _indirect_copy_nd(char *dest, Py_buffer *view, char fort) in _indirect_copy_nd() argument
181 if (view->ndim > PY_SSIZE_T_MAX / sizeof(Py_ssize_t)) { in _indirect_copy_nd()
186 indices = (Py_ssize_t *)PyMem_Malloc(sizeof(Py_ssize_t)*view->ndim); in _indirect_copy_nd()
191 for (k=0; k<view->ndim;k++) { in _indirect_copy_nd()
196 for (k=0; k<view->ndim; k++) { in _indirect_copy_nd()
197 elements *= view->shape[k]; in _indirect_copy_nd()
206 func(view->ndim, indices, view->shape); in _indirect_copy_nd()
207 ptr = PyBuffer_GetPointer(view, indices); in _indirect_copy_nd()
208 memcpy(dest, ptr, view->itemsize); in _indirect_copy_nd()
209 dest += view->itemsize; in _indirect_copy_nd()
244 Py_buffer *view; in PyMemoryView_GetContiguous() local
258 view = &mem->view; in PyMemoryView_GetContiguous()
266 if (PyObject_GetBuffer(obj, view, flags) != 0) { in PyMemoryView_GetContiguous()
271 if (PyBuffer_IsContiguous(view, fort)) { in PyMemoryView_GetContiguous()
286 bytes = PyBytes_FromStringAndSize(NULL, view->len); in PyMemoryView_GetContiguous()
296 if (view->suboffsets==NULL) { in PyMemoryView_GetContiguous()
297 _strided_copy_nd(dest, view->buf, view->ndim, view->shape, in PyMemoryView_GetContiguous()
298 view->strides, view->itemsize, fort); in PyMemoryView_GetContiguous()
301 if (_indirect_copy_nd(dest, view, fort) < 0) { in PyMemoryView_GetContiguous()
309 view->buf = dest; in PyMemoryView_GetContiguous()
318 PyBuffer_Release(view); /* XXX ? */ in PyMemoryView_GetContiguous()
330 return PyString_FromString(self->view.format); in memory_format_get()
336 return PyLong_FromSsize_t(self->view.itemsize); in memory_itemsize_get()
366 return _IntTupleFromSsizet(self->view.ndim, self->view.shape); in memory_shape_get()
372 return _IntTupleFromSsizet(self->view.ndim, self->view.strides); in memory_strides_get()
378 return _IntTupleFromSsizet(self->view.ndim, self->view.suboffsets); in memory_suboffsets_get()
384 return PyBool_FromLong(self->view.readonly); in memory_readonly_get()
390 return PyLong_FromLong(self->view.ndim); in memory_ndim_get()
408 Py_buffer view; in memory_tobytes() local
411 if (PyObject_GetBuffer((PyObject *)self, &view, PyBUF_SIMPLE) < 0) in memory_tobytes()
414 res = PyBytes_FromStringAndSize(NULL, view.len); in memory_tobytes()
415 PyBuffer_ToContiguous(PyBytes_AS_STRING(res), &view, view.len, 'C'); in memory_tobytes()
416 PyBuffer_Release(&view); in memory_tobytes()
426 Py_buffer *view = &(mem->view); in memory_tolist() local
431 if (strcmp(view->format, "B") || view->itemsize != 1) { in memory_tolist()
436 if (view->ndim != 1) { in memory_tolist()
441 res = PyList_New(view->len); in memory_tolist()
444 buf = view->buf; in memory_tolist()
445 for (i = 0; i < view->len; i++) { in memory_tolist()
468 if (self->view.obj != NULL) { in memory_dealloc()
485 PyBuffer_Release(&(self->view)); in memory_dealloc()
488 PyBuffer_Release(&(self->view)); in memory_dealloc()
505 return get_shape0(&self->view); in memory_length()
514 Py_buffer *view = &(self->view); in memory_item() local
516 if (view->ndim == 0) { in memory_item()
521 if (view->ndim == 1) { in memory_item()
524 ptr = (char *)view->buf; in memory_item()
526 result += get_shape0(view); in memory_item()
528 if ((result < 0) || (result >= get_shape0(view))) { in memory_item()
533 if (view->strides == NULL) in memory_item()
534 ptr += view->itemsize * result; in memory_item()
536 ptr += view->strides[0] * result; in memory_item()
537 if (view->suboffsets != NULL && in memory_item()
538 view->suboffsets[0] >= 0) { in memory_item()
539 ptr = *((char **)ptr) + view->suboffsets[0]; in memory_item()
541 return PyBytes_FromStringAndSize(ptr, view->itemsize); in memory_item()
562 Py_buffer *view; in memory_subscript() local
563 view = &(self->view); in memory_subscript()
565 if (view->ndim == 0) { in memory_subscript()
587 if (PySlice_GetIndicesEx((PySliceObject*)key, get_shape0(view), in memory_subscript()
592 if (step == 1 && view->ndim == 1) { in memory_subscript()
594 void *newbuf = (char *) view->buf in memory_subscript()
595 + start * view->itemsize; in memory_subscript()
596 int newflags = view->readonly in memory_subscript()
600 if (view->obj != NULL) { in memory_subscript()
601 if (PyObject_GetBuffer(view->obj, &newview, newflags) == -1) in memory_subscript()
605 newview = *view; in memory_subscript()
609 newview.format = view->format; in memory_subscript()
631 Py_buffer *view = &(self->view); in memory_ass_sub() local
634 if (view->readonly) { in memory_ass_sub()
644 if (view->ndim != 1) { in memory_ass_sub()
653 start += get_shape0(view); in memory_ass_sub()
655 if ((start < 0) || (start >= get_shape0(view))) { in memory_ass_sub()
665 if (PySlice_GetIndicesEx((PySliceObject*)key, get_shape0(view), in memory_ass_sub()
686 if (srcview.itemsize != view->itemsize) { in memory_ass_sub()
689 view->obj->ob_type->tp_name, srcview.obj->ob_type->tp_name); in memory_ass_sub()
692 bytelen = len * view->itemsize; in memory_ass_sub()
699 destbuf = (char *) view->buf + start * view->itemsize; in memory_ass_sub()
763 if (self->view.obj != NULL) in memory_traverse()
764 Py_VISIT(self->view.obj); in memory_traverse()
772 PyBuffer_Release(&self->view); in memory_clear()