Embedding SWIG bindings for multiple languages in a single executable
Julien Marrec <[email protected]> Fri, 7 May 2021 17:01:33 +0200
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <CAEqKKtwB784TgZWTRnUm4-4kwWg9A5t2W6W4kOKO86Vu2_hm2g@mail.gmail.com> |
Hello,
We have a C++ project, and are exporting ruby and python bindings.
We wish to create a C++ CLI that embeds these bindings, so we can talk to
both python and ruby from C++. The goal is that users could write small
scripts in either ruby or python and they would be evaluated by the C++
driver.
The problem we are facing is that SWIG exports the same names for both Ruby
and Python, and when calling a *python* script at some point it ends up
calling the method from the *ruby* library instead.
The TYPES TABLES looks exactly the same on the ruby wrapper and the python
wrapper.
(I originally got another name clash with the `SwigDirector_T` but I'm
using a `#ifdef SWIGPYTHON; %rename("Python%s") "";` directive for the time
being)
Is there a way to avoid this conflict? Perhaps adding a top-level
namespace, or renaming the mangled types?
I tried overriding the `%define mangle(Type)` macro, which worked for stl
types but not for my types since it's actually not using it (seems like
`typesys.c` harcodes it to `SWIGTYPE%s`).
Has someone got an example of embedding SWIG bindings for two different
languages in the same executable? I realize this may not be your usual use
case scenario, but it's worth a shot :)
Thank you,
Julien
PS: I asked a similar question in February (
https://sourceforge.net/p/swig/mailman/swig-user/?viewmonth=202102), which
was trying to use ruby to call python, but failing to do so I'm exploring a
C++ driver now
--
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