You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For my current project, I would need support for translating C++ std::vector<std::vector<double>> (and more generally nested vectors with various contents and nesting depths) to and from multidimensional arrays in the target languages. It seems that the current implementation of C++ standard library typemaps have this capability for Python, but not for Perl.
Looking at source files, it looks like the Python typemaps are using the new fancy %fragment stuff, but the Perl ones are not. Would it be possible to update the Perl implementations to get automatic support for multidimensional arrays also?
Here's an example demonstrating the difference in behaviour between Perl and Python. The C++ function test2_out returns a vector<vector<double>> and test2_in takes on as an input.
Perhaps @talby- can comment, but it looks to me that Perl isn't using the full STL container support in SWIG and someone will needs to make the improvements necessary and is most likely a non-trivial task. So yes it is possible, like all SWIG development, it requires someone to volunteer.
Yes, the std::vector support in Perl is incomplete. I made a breif attempt at repairs but realized I needed to learn more about the typemap templates to align Perl's std::vector handling with the other languages. I'll try to dig up any partial results I might have from the previous effort.
Thanks for the replies. Unfortunately I am not familiar enough with Perl/C interface or swig internals to attempt implementing this myself in the near future.
For my current project, I would need support for translating C++
std::vector<std::vector<double>>
(and more generally nested vectors with various contents and nesting depths) to and from multidimensional arrays in the target languages. It seems that the current implementation of C++ standard library typemaps have this capability for Python, but not for Perl.Looking at source files, it looks like the Python typemaps are using the new fancy
%fragment
stuff, but the Perl ones are not. Would it be possible to update the Perl implementations to get automatic support for multidimensional arrays also?Here's an example demonstrating the difference in behaviour between Perl and Python. The C++ function
test2_out
returns avector<vector<double>>
andtest2_in
takes on as an input.foo.cpp
:foo.h
:foo.i
:in Perl:
Calling
foo::test2_out()
returns an array of proxy objects:Calling
foo::test2_in([[0.25, 0.25], [0.25, 0.25]])
fails with type error from SWIG, though passing the output of test2_out works as expected.in Python:
Calling
foo.test2_in()
returns a tuple of tuples:Calling
foo.test2_in([[0.25, 0.25], [0.25, 0.25]])
works as expected.The text was updated successfully, but these errors were encountered: