2 messages in net.java.dev.jna.usersPointer to Structure Array
FromSent OnAttachments
Simon BASLEJun 20, 2007 6:31 pm 
Timothy WallJun 21, 2007 4:44 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Pointer to Structure ArrayActions...
From:Simon BASLE (sba@free.fr)
Date:Jun 20, 2007 6:31:01 pm
List:net.java.dev.jna.users

Hi Once again it seems that I'm unable to correctly understand the examples on javadoc overview... I have a function that expects three parameters : an input int code, an int by reference which will receive the number of tasks running and an array of struct pvmtaskinfo by reference, which will receive an array of structures pvmtaskinfo, one for each running task in the system...

I've mapped the int by reference to an IntByReference (so far so good :p)

and I've tried mapping the last parameter to pvmtaskinfo, pvmtaskinfo[] and PointerByReference but no matter what I do I don't manage to get it work. I've overriden useMemory which was protected => just a call to super.useMemory(Pointer)... Also I have an no-arg constructor for pvmtaskinfo.

Here is my current code (with the PointerByReference version) : ======================================== PointerByReference ptr = new PointerByReference(); IntByReference nbTasks = new IntByReference(); test.pvm_tasks(0, nbTasks, ptr); Pointer[] allPtr = ptr.getValue().getPointerArray(0, nbTasks.getValue()); for(int i = 0 ; i < allPtr.length ; i++) { if (allPtr[i] != null){ pvmtaskinfo toto = new pvmtaskinfo(); toto.useMemory(allPtr[i]); toto.read(); //System.out.println(toto.ti_tid); } } ======================================= Any clever idea? Need an expert point of view :p Thanks Simon