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
134 if (!ia)
return nullptr;
136 ia->ia_klass = klass;
137 ia->ia_array_start = address;
142 PyObject_GC_Track(ia);
144 }
else if (1 < dims.
ndim()) {
146 size_t block_size = 0;
147 for (
Py_ssize_t i = 1; i < dims.
ndim(); ++i) block_size += (
size_t)dims[i];
151 PyObject* tup = PyTuple_New(nelems);
154 (
char*)address + i*block_size, klass, dims.
sub()));
159 int nelems = (
int)dims[0];
161 if (block_size == 0) {
162 PyErr_Format(PyExc_TypeError,
163 "can not determine size of type \"%s\" for array indexing",
170 PyObject* tup = PyTuple_New(nelems);
171 for (
int i = 0; i < nelems; ++i) {
174 PyTuple_SetItem(tup, i,
181 Py_INCREF(tup); PyTuple_SET_ITEM(args, 0, tup);
197 (
char*)
"cppyy.InstancesArray",
215 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES |
217 (
char*)
"array of C++ instances",
242#if PY_VERSION_HEX >= 0x02030000
245#if PY_VERSION_HEX >= 0x02060000
248#if PY_VERSION_HEX >= 0x03040000
251#if PY_VERSION_HEX >= 0x03080000
254#if PY_VERSION_HEX >= 0x030c0000
#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)