You must define the typemap before the class it applies to is parsed by
SWIG, so if you really do it in the order shown above, it's never going to
work.

FWIW I can confirm that using javacode typemaps to define equals() for
the generated Java wrappers does work, so you're on the right track (BTW,
I'm not a Java expert, but I believe you should override hashCode() as well
if you override equals()).

Re: Extending the Java proxy class

> On 4 Dec 2016, at 16:05, Vadim Zeitlin <[hidden email]> wrote:
>
> You must define the typemap before the class it applies to is parsed by
> SWIG, so if you really do it in the order shown above, it's never going to
> work.

Brilliant!

That solved the issue. I sort knew this but it did not connect and in
my confusion I figured that the class def needs to be before the typemap
cause typically in programming language you introduce types before you
use them, but of course here it works the other way round because it is
the scope of the typemap that matters, as explained in SWIG manual 10.2.2

For the posterity this is what made it work for me. Of course the rename
is not functionally necessary, it is just to conform to occjava naming
convention.

> I'm not a Java expert, but I believe you should override hashCode() as well
> if you override equals()).

That is of course correct and a good reminder. Not 100% sure what is the best
approach here. I guess I could use the "swigCPtr" then at least it would
work correctly, not sure if that would an optimal hash code.

Re: Re-using SWIG Python binding to create Java bingings?

Currently there is a nice but not complete interface occjava which is based on SWIG.

There is also a complete Python binging for OCC which is based on SWIG.

Is there any (automatic) way to leverage the Python binding to create a corresponding Java binging?

SWIG is only a semi-automated tool for wrapping C++ code. How much additional code you need to write to better support Java in addition to existing Python bindings really depends on how much the Python bindings have been customized. If there are lots of customizations, such as Python typemaps and python specific SWIG features, then an equivalent may need to be supplied for Java. Sounds like someone needs to roll up their sleeves and add in the missing Java SWIG code.

Re: Re-using SWIG Python binding to create Java bingings?

> SWIG is only a semi-automated tool for wrapping C++ code. How much additional code you need to write to better support Java in addition to existing Python bindings really depends on how much the Python bindings have been customized. If there are lots of customizations, such as Python typemaps and python specific SWIG features, then an equivalent may need to be supplied for Java. Sounds like someone needs to roll up their sleeves and add in the missing Java SWIG code.
>
> William

Thanks, I just wanted to know before I roll up my leaves if there was
some way to automatically leverage those. Of course they can provide
guidance ... oh well time get back in the saddle.