Typemap javaimports doesn't work for inner C++ class

246 Views Asked by At

Assuming I have nested.i like :

%typemap(javaimports) Outer "
/**
* Outer class
*/"

%typemap(javaimports) Outer::Inner "
/**
* Outer::Inner class
*/"

%javamethodmodifiers Outer::outer_method(int) "
  /**
  * Outer::outer_method(int)
  */
  public";

%javamethodmodifiers Outer::Inner::inner_method(int) "
  /**
  * Outer::Inner::inner_method(int)
  */
  public";

struct Outer {
  int outer_method(int);
  struct Inner {
    int inner_method(int);
  };
};

and trying to generate Java like

$ swig -java -c++ -module Sample nested.i

As a result 3 import and modifiers are appeared except Outer::Inner class.

Environment: MS Windows 7

$ swig -version

SWIG Version 3.0.7

Compiled with i586-mingw32msvc-g++ [i586-pc-mingw32msvc]

Configured options: +pcre

Please see http://www.swig.org for reporting bugs and further information
1

There are 1 best solutions below

0
V-master On

javaimports do add code to import section, and while you are wrapping nested class, it is located inside single file and share same includes. javaimports for nested class is ignored.


personally for class documentation i use javaclassmodifiers like so:

%typemap(javaclassmodifiers) Outer::Inner "
/**
* Outer::Inner class
*/
public class";

in case of inner class it generates:

  static 
  /**
  * Outer::Inner class
  */
  public class Inner

which is not that very nice, it compiles, but javadoc is not generated for that class.