Hi all:
I had sent email for help in Apr. 27, I has not got the answer.
Please help me.
I want to pass a structure arrays in structure from java to c.
The code is like as:
C++ code:
typedef struct {
int searchType;
char* name;
DETAIL* details;
int detailSize;
} SEARCHCONDITION;
typedef struct {
char* name;
int value;
} DETAIL;
int search(SEARCHCONDITION* condition);
Java code:
public interface JnaServerLibrary extends Library {
public static class _Detail extends Structure {
public String name;
public int value;
}
public static class _SearchCondition extends Structure {
public int searchType;
public String name;
public Pointer details; // DETAIL arrays
public int detailSize;
}
int search(_SearchCondition condition);
}
And I use DetailArray class to make Pointer to pass to C++.
public class DetailArray extends Memory {
private static final Integer DETAILSTRUCTURESIZE = 8;
public DetailArray (JnaServerLibrary._Detail[] datas) {
super((datas.length + 1) * DETAILSTRUCTURESIZE);
for (int i=0;i < datas.length;i++) {
Pointer p = null;
if (datas[i] != null) {
p = datas[i].getPointer();
setPointer(DETAILSTRUCTURESIZE * i, p);
} else {
setPointer(DETAILSTRUCTURESIZE * i, null);
}
}
setPointer(DETAILSTRUCTURESIZE * datas.length, null);
}
}
Pass to c++:
_SearchCondition searchCondition = new SearchCondition();
searchCondition.searchType = 0;
searchCondition.name = "name";
searchCondition.detailSize = n;
_Detail[] details = new _Detail[n];
details[0] = new _Detail();
details[0].name = "entryDate";
details[0].value = "2009/04/30";
......
DetailArray detailArray = new DetailArray(details);
searchCondition.details = detailArray.getPointer(0);
jna.search (searchCondition);
I can run it, and no error, but can't pass details value
to C++. The pointer value is as same as c++.