如何在Java中将swig生成的SWIGTYPE_p_type作为参数传递

时间:2015-04-14 12:44:57

标签: java c swig

我在C:

中有一个enum

type.h

typedef enum{one, two, three=0x0}numbers;
work(numbers* param);

generate.i

%module swig
%{
#include "type.h"
%}
%include "type.h"

swig会生成wierd SWIGTYPE_p_numbers类。如何使用它?如何在函数中将其作为参数传递?

编辑:

swig.java

public class swig {
  public static void work(SWIGTYPE_p_numbers param){
    swigJNI.work(SWIGTYPE_p_numbers.getCPtr(param));
  }
}

SWIGTYPE_p_numbers.java

public class SWIGTYPE_p_numbers {
  private long swigCPtr;

  protected SWIGTYPE_p_numbers (long cPtr, boolean futureUse) {
    swigCPtr = cPtr;
  }

  protected SWIGTYPE_p_numbers () {
    swigCPtr = 0;
  }

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

0 个答案:

没有答案