Skip to content

Commit 671e39f

Browse files
wlavvgvassilev
authored andcommitted
for array types, add the proper number of indirections ('*') for the typename
1 parent d4d7e41 commit 671e39f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/TemplateProxy.cxx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,18 @@ PyObject* TemplateProxy::Instantiate(const std::string& fname,
127127
// special case for arrays
128128
PyObject* pytc = PyObject_GetAttr(itemi, PyStrings::gTypeCode);
129129
if (pytc) {
130-
PyObject* pyptrname = TC2CppName(pytc, "*", true);
130+
Py_buffer bufinfo;
131+
memset(&bufinfo, 0, sizeof(Py_buffer));
132+
std::string ptrdef;
133+
if (PyObject_GetBuffer(itemi, &bufinfo, PyBUF_FORMAT) == 0) {
134+
for (int i = 0; i < bufinfo.ndim; ++i) ptrdef += "*";
135+
CPyCppyy_PyBuffer_Release(itemi, &bufinfo);
136+
} else {
137+
ptrdef += "*";
138+
PyErr_Clear();
139+
}
140+
141+
PyObject* pyptrname = TC2CppName(pytc, ptrdef.c_str(), true);
131142
if (pyptrname) {
132143
PyTuple_SET_ITEM(tpArgs, i, pyptrname);
133144
bArgSet = true;

0 commit comments

Comments
 (0)