Re: Embedding SWIG bindings for multiple languages in a single executable
Alexey Sokolov <[email protected]> Wed, 23 Jun 2021 12:12:41 +0100
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <[email protected]> |
07.05.2021 16:01, Julien Marrec пишет:
> 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 :)
ZNC embeds perl and python, so didn't have this specific issue. Those
names don't clash.
But the code is under modperl/ and modpython/ at
https://github.com/znc/znc/tree/master/modules
Can I suggest replacing ruby bindings with perl? :)
>
> Thank you,
> Julien
>
>
> PS: I asked a similar question in February
> (https://sourceforge.net/p/swig/mailman/swig-user/?viewmonth=202102
> <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
>
--
Best regards,
Alexey "DarthGandalf" Sokolov
_______________________________________________
Swig-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/swig-user