Java SWIG:如何重新排序多参数类型映射的输入参数

时间:2016-01-19 15:42:13

标签: java c++ swig

假设我有来自第三方库的以下抽象C ++类,我无法更改。

 class Foo : virtual public FooBase {
   public:
     virtual void bar(void *pBuffer, int64_t address, int64_t length) = 0;
 };

我希望能够使用 director 在Java中实现此类。生成的Java类看起来应该是这样的。

private class Foo extends FooBase {
  ...
  public void bar(long address, byte[] pBuffer) {...}
}

我有一个类似于

的类型图
%typemap(in) (void *pBuffer, int64_t length) {
    $1 = (void*)(jenv)->GetByteArrayElements($input, NULL);
    $2 = (jenv)->GetArrayLength($input);
    if(!$1)
    {
        SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "Failed to convert byte array.");
    }
}

%typemap(freearg) (void *pBuffer, int64_t length) {
    (jenv)->SetByteArrayRegion($input, 0, (jsize) $2,  (const jbyte*)$1);
    (jenv)->ReleaseByteArrayElements($input, (jbyte*)$1, 0);
}

%typemap(jni) (void *pBuffer, int64_t length) "jbyteArray"
%typemap(jtype) (void *pBuffer, int64_t length) "byte[]"
%typemap(jstype) (void *pBuffer, int64_t length) "byte[]"
%typemap(javain) (void *pBuffer, int64_t length) "$javainput"

但只有在Foo::bar的输入有订单时才能应用它 int_t address, void* pBuffer, int64_t length

是否可以重新排列Foo::bar中的输入参数,以使多参数类型图有效?

0 个答案:

没有答案
相关问题