18static PyObject* ia_iternext(ia_iterobject* ia) {
19 if (ia->ia_len != -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}
61 (
char*)
"cppyy.instancearrayiter",
62 sizeof(ia_iterobject),
64 (destructor)PyObject_GC_Del,
65 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
69 (traverseproc)ia_traverse,
72 (iternextfunc)ia_iternext,
73 0, 0, ia_getset, 0, 0, 0, 0,
75 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
76#
if PY_VERSION_HEX >= 0x02030000
79#
if PY_VERSION_HEX >= 0x02060000
82#
if PY_VERSION_HEX >= 0x03040000
93 if (ndims == -1 || dims[0] == -1 ) {
96 if (!ia)
return nullptr;
99 ia->ia_array_start = address;
104 PyObject_GC_Track(ia);
106 }
else if (1 < ndims) {
108 int nelems = (
int)dims[0];
109 size_t block_size = 0;
110 for (
int i = 1; i < (
int)ndims; ++i) block_size += (
size_t)dims[i];
113 PyObject* tup = PyTuple_New(nelems);
114 for (
int i = 0; i < nelems; ++i) {
116 (
char*)address + i*block_size, klass, ndims-1, dims+1));
121 int nelems = (
int)dims[0];
123 if (block_size == 0) {
124 PyErr_Format(PyExc_TypeError,
125 "can not determine size of type \"%s\" for array indexing",
132 PyObject* tup = PyTuple_New(nelems);
133 for (
int i = 0; i < nelems; ++i) {
136 PyTuple_SetItem(tup, i,
143 Py_INCREF(tup); PyTuple_SET_ITEM(args, 0, tup);
145 if (PyErr_Occurred()) PyErr_Print();
160 (
char*)
"cppyy.InstancesArray",
178 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES |
180 (
char*)
"array of C++ instances",
205#if PY_VERSION_HEX >= 0x02030000
208#if PY_VERSION_HEX >= 0x02060000
211#if PY_VERSION_HEX >= 0x03040000
#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
Set of helper functions that are invoked from the pythonizors, on the Python side.
PyObject * BindCppObjectNoCast(Cppyy::TCppObject_t object, Cppyy::TCppType_t klass, const unsigned flags=0)
PyObject * TupleOfInstances_New(Cppyy::TCppObject_t address, Cppyy::TCppType_t klass, dim_t ndims, dims_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)