I am currently reorganizing the Tcl plugin library written in C ++. The code was originally written by hand. There is a second library that does the same for Java.
The reorganized library will be a single C ++ library that can be used to create bindings to various languages.
My first tests with SWIG are promising. However, a lot of garbage appears. Various base classes and utilities are exported. They do not make sense in terms of scenarios and only increase the clutter.
Possible solutions that I can think of:
- Use
#ifndef SWIG
in source code base to filter out unnecessary code - Create a SWIG-compatible wrapper around the API classes.
- Distinguish between public and private headlines. Public headers are pure abstract base classes that do not contain an implementation. Private headers inherit and implement them. Only SWIG publishes headlines.
- The opposite of the solution above: inherit a SWIG-compatible class for each API class.
I'm currently leaning toward solution 3. However, I'm not sure, so I would like to know the opinion of the SO community about this. Feel free to share your thoughts.
Update
I forgot to list one solution:
- Code that should not be exported by SWIG should probably not be in the public section of your class.
Perhaps this is the answer. I will have a different look on Monday.
Update
I decided with a solution. See my answer.
source
share