1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package testj;
import com.sun.jna.Native;
import testj.TestJ.StructureProtocol.Value.ByValueValue;
/**
*
* @author Entreprise
*/
public class TestJ {
public interface StructureProtocol extends com.sun.jna.Library{
public static class Value extends com.sun.jna.Union{
public static class ByValueValue extends Value implements com.sun.jna.Union.ByValue{ };
public int i;
public int u;
public float f;
public String s = null;
public static class ByReferenceValue extends Value implements com.sun.jna.Union.ByReference{ };
}
public static class IoDyn extends com.sun.jna.Structure {
public static class ByValueIoDyn extends IoDyn implements com.sun.jna.Structure.ByValue { };
public boolean init;
public ByValueValue value = new ByValueValue();
public boolean def,invalid,overflow;
public static class ByReferenceIoDyn extends IoDyn implements com.sun.jna.Structure.ByReference {
};
}
public void plop(StructureProtocol.IoDyn.ByReferenceIoDyn io);
}
static {
System.setProperty("jna.library.path",".");
}
private StructureProtocol lib;
public TestJ(){
this.lib = (StructureProtocol) Native.loadLibrary("Structure", StructureProtocol.class);
}
public StructureProtocol getLib() {
return lib;
}
public static void main(String[] args) {
TestJ t = new TestJ();
StructureProtocol.IoDyn.ByReferenceIoDyn io = new StructureProtocol.IoDyn.ByReferenceIoDyn();
io.def = true;
io.init = false;
io.invalid = false;
io.overflow = true;
io.value.s = " Salutttttttttttt";
io.value.setType(String.class);
t.getLib().plop(io);
}
}
[/QUOTE]
Reponse du Main :
[QUOTE] init 0 def 1 invalide 1 overflow 1 value Salutttttttttttt |
Partager