

![]() | 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: |
6 messages in net.java.dev.jna.usersRe: [jna-users] Pointer to structure ...| From | Sent On | Attachments |
|---|---|---|
| Jean-Baptiste Bugeaud | May 16, 2007 7:08 am | |
| Timothy Wall | May 17, 2007 10:40 am | |
| Timothy Wall | May 17, 2007 11:20 am | |
| Jean-Baptiste Bugeaud | May 18, 2007 5:55 am | |
| Timothy Wall | May 18, 2007 6:51 am | |
| Jean-Baptiste Bugeaud | May 18, 2007 1:11 pm |

![]() | 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: | Re: [jna-users] Pointer to structure arrays ? | Actions... |
|---|---|---|
| From: | Timothy Wall (twal...@dev.java.net) | |
| Date: | May 17, 2007 11:20:12 am | |
| List: | net.java.dev.jna.users | |
I think the simplest way to represent this would be to pass in an array of structure, leaving JNA to actually initialize the individual elements if not already.
To make this work with the current code, you would initialize the desired structure type and force its size to be N times the size for a single structure, then use toArray() to construct the appropriate array of structures.
public MyStructure(int nelements) { allocateMemory(size()*nelements); }
As for integrating with nlink, I've sent email to kohsuke, but haven't heard any response. At any rate, at this point I don't think there are any nlink features that are not yet covered by jna.
Do you have any specific annotations that you think would be useful? At the moment, I don't have any cases that are truly compelling and useful in the general case (ditto for generics).
If you have specific examples of cases where generics and/or annotations would help or simplify things, please share them.
Next time we post a release I'll include the javadocs and a source jar; are you unable to do a subversion checkout?
On May 16, 2007, at 10:09 AM, Jean-Baptiste Bugeaud wrote:
Hello all,
I am trying to access the GetRawInputDeviceList from Windows's User32.dll
see http://msdn2.microsoft.com/en-us/library/ms645598.aspx
What is the prefered equivalence of the p/invoke Marshal.PtrToStructure under JNA ? IE, getting a Structure from a raw Pointer, enabling some pointer computation to get an structure array, given a number of element ?
I am able to access the pRawInputDeviceList "array" using a Memory with signature : int GetRawInputDeviceList(Pointer pRawInputDeviceList, IntByReference puiNumDevices, int cbSize); doing manual field access (direct offset computing)... working, but very painfull and dumping lots of interrest of using JNA :(
But neither accesing with a Structure like : int GetRawInputDeviceList(RAWINPUTDEVICE pRawInputDeviceList, IntByReference puiNumDevices, int cbSize); nor with an array structure like : int GetRawInputDeviceList(RAWINPUTDEVICE[] pRawInputDeviceList, IntByReference puiNumDevices, int cbSize); is working (assuming the array is filled to the right size) !
When passing a Structure, I am able to get the first one (of index 0), but requesting toArray() on the Structure would then fail (even making the underlying memory of the structure allocated to the array required size).
Any ideas/solutions ?
Second question, is there any formal plan to integrate nlink to JNA ? IE, use annotations, genericity ... to get simpler and more intuitive code ?
Last question, coud you provide the sources and the javadocs as JAR files on the website ? This would be very handy ;-)
Regards, Jean-Baptiste BUGEAUD







