Re: Renaming a generated SWIGTYPE

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Renaming a generated SWIGTYPE

William S Fulton
Without a cutdown test case it is hard to recommend something. Usually you get type wrapper classes because you are missing type information.

On 3 December 2016 at 06:41, Kustaa Nyholm <[hidden email]> wrote:
Hi,


Background: I'm extending jCAE/occjava which is used to access a huge
C++ CAD/solid modeling library called OpenCasCade from Java.


Some C++ side objects need to compared for equality so that I can test that it actually
is the very same instance.

To do that I've added following:


%typemap(javacode) Handle_Standard_Type& %{
  public boolean equals(Object obj) {
    boolean equal = false;
    if (obj instanceof $javaclassname)
      equal = ((($javaclassname)obj).swigCPtr == this.swigCPtr);
    return equal;
  }
%}

And this works but generates and ugly SWIGTYPE_p_Hanlde_Standard_Type Java name.

I've been up and down the information highway looking for a solution but
none of the suggestions I've seem to work.

For example if in my .i file I add

class Handle_Standard_Type {}

the I get the pretty name but the equals() method does not get injected into the
generated code.

A further complication is that, most of the classes/objects in this library
(OCC) are accessed via handles, so that for each class, say for example
'Geom_Curve' there is a class 'Handle_Geom_Curve'.

To get rid of that 'Handle_' ugliness on the Java side occjava defines adds a
bunch of SWIG definitions like this:

%rename(Geom_Curve) Handle_Geom_Curve;

which the expose the actual methods like this:

%extend Handle_Geom_Curve
{
.....
Standard_Boolean isClosed() const
  {
    return (*self)->IsClosed();
  }
......
}

And so I'm looking for a solution that would be compatible with this renaming
convention.

wbr Kusti




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/intel
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Loading...