Is there anyway to remove the SWIGTYPE part from the generated class names and replace with another string literal?
i.e. change SWIGTYPE_p_ex_session.java to ex_session.java (strip off generated “SWIGTYPE_p_”)
SWIG .i file:
%module Example
%{
#include "ExampleApi.h"
struct ex_session{};
%}
%include "ExampleApi.h"
ExampleApi.h contains the below:
typedef struct ex_session session_t;
Assuming the real issue here is the “ugly name” then I’d solve this one by making sure SWIG has at least an empty definition (not just a declaration) visible when it’s generating the wrapper, for example given:
SWIG generates
SWIGTYPE_p_ExampleNiceName.javaWe can make this a whole lot better just by doing something like:
instead of
in this example, which causes SWIG to generate
ExampleNiceName.javaas a wrapped type instead. It doesn’t expose anything more than previously exposed and is perfectly legal/sane. We’re telling SWIG not just “this type exists”, but “this type exists and we’d like you to wrap nothing beyond it’s name” by doing this.You can also use
%renameto make the name on the Java side different from the C++ class name, for example:with the previous example would cause
JavaClassNameto be used in place ofExampleNiceNamein the generated Java.