English 中文(简体)
在Swig,我如何使用我自己的jni 函数在课堂上?
原标题:In swig, how do I use my own jni function inside a class?
  • 时间:2012-05-25 17:19:01
  •  标签:
  • java
  • swig

我有一个 c++ 类, 我用 Swig 将它包到 java 。 我想在这个类中扩展或添加一个新的成员函数, 但我也想使用我自己的 jni 函数作为这个新成员函数, 或者让自己的 jni 函数在新的成员函数中被调用 。 我如何用 swig 来做到这一点? 我知道 % native, 但是它似乎只产生静态方法, 但我想要它生成对象方法 。

问题回答

如果您只想在一个代理类中加插一个额外的 national 方法, 您可以使用类似 :

%module test;

%typemap(javacode) foo %{
  public void native HandRolled();
%}

struct foo {
  void bar();
};

void test(foo& f);

个人而言,如果您拥有许多本地代码,而您不想直接使用该代码 我倾向于将其分为不同的类别,即您拥有SWIG生成的部件和手册, JNI 部件作为不同的项目。然后您可以使用类型图来“质谱”将纯 JNI 部件“ ” 生成到 SWIG 中。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签