C++ to ruby and python: passing a Swig ruby object to a python function
Julien Marrec <[email protected]> Tue, 9 Feb 2021 17:58:31 +0100
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <CAEqKKtxEOMwRQuKs6VuQFUOXK+eJ3ebhi8c5ig4HYa2JTMr-1Q@mail.gmail.com> |
Hi all, I have a weird case, but I expose my C++ classes to both ruby and Python. We have a ruby "utility" gem that does a lot of things, and we do not to rewrite it. But we like to be able to plug some python code. We have "Measure" classes that derive from C++ that are being evaluated via their `run` method by that ruby gem. We'd like to have Python Measure that could be called via the gem too. Essentially,* I'm trying to pass a ruby wrapper object to a python function that expects a (python) wrapper and failing*. I'm currently trying to use PyCall to instantiate that. So far, aside from finding a workaround way to serialize my ruby object to a string and recreate a python one from that string, I'm coming kinda empty. (In my actual project, none of the arguments expected are easily serializable and use a couple dozen classes as private members...) *Does anyone have guidance on how I could achieve this? Somehow get the underlying C++ memory from the ruby type to create the python type or something?* *I've created a Minimum Complete and Verifiable Example (MCVE) project to illustrate my problem. More information can be found in the README*: https://github.com/jmarrec/Cpp_Swig_Ruby_Python_MCVE Bottom line, what I'm failing to do this is: https://github.com/jmarrec/Cpp_Swig_Ruby_Python_MCVE/blob/master/ruby/test_pycall_workaround.rb#L44-L54 Thanks in advance for any pointers, -- Julien Marrec, EBCP, BPI MFBA Owner at EffiBEM <http://www.effibem.com> T: +33 6 95 14 42 13 LinkedIn (en <https://www.linkedin.com/in/julienmarrec>) *| *(fr <https://fr.linkedin.com/in/julienmarrec/fr>) : <http://www.linkedin.com/in/julienmarrec> _______________________________________________ Swig-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/swig-user