mirror of
https://github.com/pybind/pybind11.git
synced 2025-01-19 17:32:37 +00:00
Add a simplified buffer_info ctor for 1-D case
This commit is contained in:
parent
6636ae9d4e
commit
98ba98c06b
@ -210,6 +210,7 @@ struct buffer_info {
|
||||
std::vector<size_t> strides; // Number of entries between adjacent entries (for each per dimension)
|
||||
|
||||
buffer_info() : ptr(nullptr), view(nullptr) {}
|
||||
|
||||
buffer_info(void *ptr, size_t itemsize, const std::string &format, size_t ndim,
|
||||
const std::vector<size_t> &shape, const std::vector<size_t> &strides)
|
||||
: ptr(ptr), itemsize(itemsize), size(1), format(format),
|
||||
@ -218,6 +219,10 @@ struct buffer_info {
|
||||
size *= shape[i];
|
||||
}
|
||||
|
||||
buffer_info(void *ptr, size_t itemsize, const std::string &format, size_t size)
|
||||
: buffer_info(ptr, itemsize, format, 1, std::vector<size_t> { size },
|
||||
std::vector<size_t> { itemsize }) { }
|
||||
|
||||
buffer_info(Py_buffer *view)
|
||||
: ptr(view->buf), itemsize((size_t) view->itemsize), size(1), format(view->format),
|
||||
ndim((size_t) view->ndim), shape((size_t) view->ndim), strides((size_t) view->ndim), view(view) {
|
||||
|
Loading…
Reference in New Issue
Block a user