Open sayrer opened 4 years ago
Thanks for trying this. I don't know anything about SWIG so I'm not sure what it means to be "in SWIG". Why would this code work not in SWIG but fail in SWIG? Is it a toolchain version issue, or does SWIG contain something that conflicts with that member function? How does it fail without those ifndefs?
SWIG seems to have its own header parser, and it doesn't yet support variadic templates. The two places where these are used in cxx aren't needed for SWIG-generated code, so they are safe to elide from SWIG's parse with these ifndefs.
SWIG's error is something like header-file.h:105: Error: Syntax error in input(3).
To be clear, these ifndefs only apply as input to SWIG's code generation, not compiling the cxx library itself.
You can see some examples (still WIP) here:
https://github.com/sayrer/twitter-text/tree/b018b2b935d1b9b21a1ae46af7d774e4ad0a6d0a/rust_bindings
The twitter-text.i file generates bindings for Python, Java, and Ruby
Here's what's currently required, given changes in cxx.h and the way the command line now produces its output.
It looks like most of the issues I'm hitting at least have PRs in the SWIG repo, so hopefully things will get fixed up from that end.
With recent improvements in SWIG, SWIG 4.2.1 correctly handles the Box
variadic template instead of giving a Syntax error.
It mostly works. I had to make these small modifications for SWIG 4.0.1. There is a recent 4.0.2 that I haven't tried.
and