

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
4 messages in net.java.dev.jna.usersstruct containing pointer to struct a...| From | Sent On | Attachments |
|---|---|---|
| seb bratieres | Jul 17, 2007 7:28 am | |
| Timothy Wall | Jul 17, 2007 9:19 am | |
| j impala | Jul 17, 2007 10:24 am | |
| Timothy Wall | Jul 17, 2007 11:26 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | struct containing pointer to struct array | Actions... |
|---|---|---|
| From: | seb bratieres (mabo...@yahoo.de) | |
| Date: | Jul 17, 2007 7:28:01 am | |
| List: | net.java.dev.jna.users | |
Hi,
I have trouble to correctly construct and pass a struct that contains a pointer
to a struct array. Here is the problem case. I have tried two solutions which I
could think of, none of which works.
Thank you
Sebastien
* C types
typedef struct VI_TagEntry_t{
TCHAR* name;
VI_Variant value; // another struct
} VI_TagEntry;
// tag list storage
typedef struct VI_TagList_t{
unsigned long size;
VI_TagEntry* list;
} VI_TagList;
* JNA types
public static class VI_TagEntry extends Structure {
public Pointer name;
public VI_Variant value; // another Structure
}
public static class VI_TagList extends Structure {
public long size;
public Pointer list; // VI_TagEntry* list;
}
* JNA test code
private Dll.VI_TagList createSampleVI_TagList() {
Dll.VI_TagList tagList = new Dll.VI_TagList();
Structure[] tagEntryArray = (new Dll.VI_TagEntry()).toArray(2);
tagEntryArray[0] = createSampleVI_TagEntry();
Dll.VI_TagEntry intermediate = createSampleVI_TagEntry();
intermediate.value.data.longVal = 13;
tagList.list = tagEntryArray[0].getPointer();
tagEntryArray[1] = intermediate;
tagList.size = 2;
tagList.write();
return tagList;
}
public void testVI_TagList() {
lib.testVI_TagList(createSampleVI_TagList());
}
* C test code
_declspec(dllexport) void __cdecl testVI_TagEntry(VI_TagEntry* tagEntry) {
printf("tagEntry.name=%S \n", tagEntry->name);
printf("tagEntry.value.d.longVal=%i \n", tagEntry->value.d.longVal);
}
_declspec(dllexport) void __cdecl testVI_TagList(VI_TagList* tagList) {
printf("tagList->size=%i \n", tagList->size);
testVI_TagEntry(tagList->list);
}
* output
tagList->size=2
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0af51f43, pid=3500, tid=4004
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_11-b03 mixed mode)
etc
* same output when using in Java test code
Dll.VI_TagEntry[] tagEntryArrayBase = new Dll.VI_TagEntry[2];
Structure[] tagEntryArray = (new
Dll.VI_TagEntry()).toArray(tagEntryArrayBase);
* same output when using as Java test code
private Dll.VI_TagList createSampleVI_TagList() {
Dll.VI_TagList tagList = new Dll.VI_TagList();
tagList.list = new Memory((new Dll.VI_TagEntry()).size()*2);
Dll.VI_TagEntry tagEntry0 = createSampleVI_TagEntry();
byte[] bbuf = tagEntry0.getPointer().getByteArray(0, (new
Dll.VI_TagEntry()).size());
tagList.list.write(0, bbuf, 0, bbuf.length);
tagList.size = 2;
tagList.write();
return tagList;
}
___________________________________________________________
Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail:
http://mail.yahoo.de







