18static PyObject* ia_iternext(ia_iterobject* ia) {
19 if (ia->ia_len != (
Py_ssize_t)-1 && ia->ia_pos >= ia->ia_len) {
22 }
else if (ia->ia_stride == 0 && ia->ia_pos != 0) {
23 PyErr_SetString(PyExc_ReferenceError,
"no stride available for indexing");
27 (
char*)ia->ia_array_start + ia->ia_pos*ia->ia_stride, ia->ia_klass);
32static int ia_traverse(ia_iterobject*, visitproc,
void*) {
36static PyObject* ia_getsize(ia_iterobject* ia,
void*) {
40static int ia_setsize(ia_iterobject* ia,
PyObject* pysize,
void*) {
48static PyGetSetDef ia_getset[] = {
49 {(
char*)
"size", (getter)ia_getsize, (setter)ia_setsize,
50 (
char*)
"set size of array to which this iterator refers",
nullptr},
51 {(
char*)
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
69 if (ia->ia_len != (
Py_ssize_t)-1 && (idx < 0 || ia->ia_len <= idx)) {
70 PyErr_SetString(PyExc_IndexError,
"index out of range");
75 (
char*)ia->ia_array_start + ia->ia_pos*ia->ia_stride, ia->ia_klass);
78static PyMappingMethods ia_as_mapping = {
80 (binaryfunc) ia_subscript,
81 (objobjargproc)
nullptr,
91 (
char*)
"cppyy.instancearrayiter",
92 sizeof(ia_iterobject),
94 (destructor)PyObject_GC_Del,
101 (traverseproc)ia_traverse,
104 (iternextfunc)ia_iternext,
107 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
108#
if PY_VERSION_HEX >= 0x02030000
111#
if PY_VERSION_HEX >= 0x02060000
114#
if PY_VERSION_HEX >= 0x03040000
117#
if PY_VERSION_HEX >= 0x03080000
120#
if PY_VERSION_HEX >= 0x030c0000
123#
if PY_VERSION_HEX >= 0x030d0000
137 if (!ia)
return nullptr;
139 ia->ia_klass = klass;
140 ia->ia_array_start = address;
145 PyObject_GC_Track(ia);
147 }
else if (1 < dims.
ndim()) {
149 size_t block_size = 0;
150 for (
Py_ssize_t i = 1; i < dims.
ndim(); ++i) block_size += (
size_t)dims[i];
154 PyObject* tup = PyTuple_New(nelems);
157 (
char*)address + i*block_size, klass, dims.
sub()));
162 int nelems = (
int)dims[0];
164 if (block_size == 0) {
165 PyErr_Format(PyExc_TypeError,
166 "can not determine size of type \"%s\" for array indexing",
173 PyObject* tup = PyTuple_New(nelems);
174 for (
int i = 0; i < nelems; ++i) {
177 PyTuple_SetItem(tup, i,
184 Py_INCREF(tup); PyTuple_SET_ITEM(args, 0, tup);
200 (
char*)
"cppyy.InstancesArray",
218 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES |
220 (
char*)
"array of C++ instances",
245#if PY_VERSION_HEX >= 0x02030000
248#if PY_VERSION_HEX >= 0x02060000
251#if PY_VERSION_HEX >= 0x03040000
254#if PY_VERSION_HEX >= 0x03080000
257#if PY_VERSION_HEX >= 0x030c0000
260#if PY_VERSION_HEX >= 0x030d0000
#define PyInt_FromSsize_t
#define PyVarObject_HEAD_INIT(type, size)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
PyObject * BindCppObjectNoCast(Cppyy::TCppObject_t object, Cppyy::TCppType_t klass, const unsigned flags=0)
static const dim_t UNKNOWN_SIZE
PyObject * TupleOfInstances_New(Cppyy::TCppObject_t address, Cppyy::TCppType_t klass, cdims_t dims)
PyTypeObject InstanceArrayIter_Type
PyTypeObject TupleOfInstances_Type
Representation of C-style array of instances.
RPY_EXPORTED size_t SizeOf(TCppType_t klass)
RPY_EXPORTED std::string GetScopedFinalName(TCppType_t type)