tags:

views:

1952

answers:

2

How does one map the function below to java?

VOID WriteToStruct(BOOL *Status, STRUCT_MSG RecBuff)

What this function does:
1) Populates the struct RecBuff
2) Updates status

How do I map to a boolean pointer in Java and access the struct data updated by the function?

+1  A: 

I was searching for another issue concerning JNA and structs, and Google redirected me here. I hope this helps.

From JNA API

To pass a structure by value, first define the structure, then define an empty class from that which implements Structure.ByValue. Use the ByValue class as the argument or return type.

// Original C code
typedef struct _Point {
  int x, y;
} Point;

Point translate(Point pt, int dx, int dy);

// Equivalent JNA mapping
class Point extends Structure {
    public static class ByValue extends Point implements Structure.ByValue { }
    public int x, y;
}
Point.ByValue translate(Point.ByValue pt, int x, int y);
...
Point.ByValue pt = new Point.ByValue();
Point result = translate(pt, 100, 100);
Brian
A: 

You can use the ByReference class to pass values by reference. Presuming BOOL is an int you can use IntegerByReference.