| 45 | |
| 46 | template<typename T, typename TSCAL, typename TCLASS> |
| 47 | void PyDefVecBuffer( TCLASS & c ) |
| 48 | { |
| 49 | c.def_buffer([](T &self) -> py::buffer_info { |
| 50 | return py::buffer_info |
| 51 | ( |
| 52 | &self[0], /* Pointer to buffer */ |
| 53 | sizeof(TSCAL), /* Size of one scalar */ |
| 54 | py::format_descriptor<TSCAL>::format(), /* Python struct-style format descriptor */ |
| 55 | 1, /* Number of dimensions */ |
| 56 | { self.Size() }, /* Buffer dimensions */ |
| 57 | { sizeof(TSCAL)*(self.Addr(1)-self.Addr(0)) } /* Strides (in bytes) for each index */ |
| 58 | ); |
| 59 | }); |
| 60 | } |
| 61 | |
| 62 | |
| 63 | |