Accessing 2d array from a python swig object

guhan balasubramanian <[email protected]> Tue, 10 Oct 2023 12:18:48 -0700
Newsgroups gmane.comp.programming.swig
Message-ID <CAMNAJg1JENDGq80FPvcHbVeCQOgrSPtRhm0LdHZwQ2d-i6j5Sg@mail.gmail.com>
Hi,

I have a 2D array filled up by a swig interface where the underlying
implementation is in C and the interface is in Python. I am not sure how to
read the elements of this swig object as it is not subscriptable. I
confirmed the type of swig object is the same as what is mentioned in the
documentation.

I was able to make it work with typemaps, but I ended up serializing the
data into a python list of lists. The typemaps only work if the size is
hardcoded and matched exactly.

Could you please help me with the best approach or references to go about
this?

Example for reference:
When I access the element from Python, I get the following:
For 2d array of primitive type : Swig Object of type 'uint64_t (*)[2]'
For 2d array of complex type : Swig Object of type 'SomeStructure (*)[2]'

The corresponding C definitions for the above:
uint64_t s[2][2];
struct SomeStructure[2][2];


Thanks,
Guhan

_______________________________________________
Swig-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/swig-user