Пример эквивалентного кода Java JNA - PullRequest
0 голосов
/ 22 февраля 2012

У меня есть такой код:

file: input.h

    struct Address{
       int a;
       int b;
    };
    void func(struct Address *a);    

Что такое эквивалентный код JNA Java?

1 Ответ

2 голосов
/ 22 февраля 2012

Просто так внутри интерфейса происходит от абстрактного Library или (если вы используете Windows) платформы com.sun.jna.win32.StdCallLibrary:

public interface MyLibrary extends Library {

    /**
     * Native library instance.
     */
    MyLibrary INSTANCE = (MyLibrary)Native.loadLibrary("MyLibrary", MyLibrary.class);

    /**
    struct Address{
       int a;
       int b;
    };      
    */

    public class Address extends Structure {
        public int    a;
        public int    b;
        public static class ByReference extends Address implements Structure.ByReference {

        };
        public static class ByValue extends Address implements Structure.ByValue {

        };        
    }; 

    /**
      void func(struct Address *a); 
    */
    void func(Address a);
}
...