Skip to content

Commit

Permalink
Added PyArrayObject cast to some lines
Browse files Browse the repository at this point in the history
  • Loading branch information
OCopping committed Jun 27, 2024
1 parent 3e61eb4 commit 25cb7cc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/pvxs_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ Value inferPy(PyObject* py)
else if(PyList_Check(py))
code = TypeCode::StringA;
else if(PyArray_Check(py)) {
switch(PyArray_TYPE(py)) {
switch(PyArray_TYPE((PyArrayObject*)py)) {
#define CASE(NTYPE, PTYPE) case NTYPE: code = TypeCode::PTYPE; break
CASE(NPY_BOOL, BoolA); // bool stored as one byte
CASE(NPY_INT8, Int8A);
Expand Down Expand Up @@ -532,12 +532,12 @@ void storePy(Value& v, PyObject* py, bool forceCast)
PyRef arr(PyArray_FromAny(py, PyArray_DescrFromType(ntype), 0, 0,
NPY_CARRAY_RO|NPY_ARRAY_FORCECAST, nullptr));

if(PyArray_NDIM(arr.obj)!=1)
if(PyArray_NDIM((PyArrayObject*)arr.obj)!=1)
throw std::logic_error("Only 1-d array can be assigned");

auto dest(allocArray(v.type().arrayType(), PyArray_DIM(arr.obj, 0)));
auto dest(allocArray(v.type().arrayType(), PyArray_DIM((PyArrayObject*)arr.obj, 0)));

memcpy(dest.data(), PyArray_DATA(arr.obj), PyArray_NBYTES(arr.obj));
memcpy(dest.data(), PyArray_DATA((PyArrayObject*)arr.obj), PyArray_NBYTES((PyArrayObject*)arr.obj));

v = dest.freeze();
return;
Expand Down

0 comments on commit 25cb7cc

Please sign in to comment.