babyinEclipse
babyinEclipse

Reputation: 513

SWIG: using %typemap(javabase) and calling super class constructor in java

In C++

class A{
..
..
}

class B{
..
..
}

Now in java I am able to generate A.java, B.java classes. Now I want in java A to extend B. So I used %typemap(javabase) A "B". I can see that A extends B in A.java

Now I don't have default constructor in class B. So in generated A.java I am getting error

"implicit super constructor B() is undefined."

If I add manually super to the generated constructor of A everything will works. But I don't want to edit A.java.

Using swig typemaps can I generate the constructor for A which will call super constructor?

Upvotes: 0

Views: 453

Answers (1)

babyinEclipse
babyinEclipse

Reputation: 513

    %typemap(javabody) A %{
      private long swigCPtr;
      protected boolean swigCMemOwn;

      protected $javaclassname(long cPtr, boolean cMemoryOwn) {
      super(cPtr,cMemoryOwn);
        swigCMemOwn = cMemoryOwn;
        swigCPtr = cPtr;
      }
     %}

Solved the problem

Upvotes: 1

Related Questions