'Convert STL complex type from C+++ to java in swig

I am trying to convert a C++ code to java using swig. The code contains a class method that returns a std::complex<double>. The problem is that I end up getting a SWIGTYPE_p_std__complexT_double_t type in my java output. Is there a way to transform this type to a more generic type that can be handled more easily in java?

C++ header example:

class test
{
public:
    std::complex<double> getValue();
};

Swig .i file example:

/* File : example.i */
%module example

%inline %{
#include "test.h"
%}

%include "test.h"

Java class output:

/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 4.0.2
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */


public class test {
  private transient long swigCPtr;
  protected transient boolean swigCMemOwn;

  protected test(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  protected static long getCPtr(test obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  @SuppressWarnings("deprecation")
  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        exampleJNI.delete_test(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public SWIGTYPE_p_std__complexT_double_t getValue() {
    return new SWIGTYPE_p_std__complexT_double_t(exampleJNI.test_getValue(swigCPtr, this), true);
  }

  public test() {
    this(exampleJNI.new_test(), true);
  }

}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source