3 messages in net.java.dev.jna.usersRe: [jna-users] what is the JNA type ...
FromSent OnAttachments
Roberto CavalcanteDec 17, 2008 2:41 pm 
Timothy WallDec 17, 2008 5:43 pm 
Roberto CavalcanteDec 17, 2008 10:33 pm 
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:Re: [jna-users] what is the JNA type for "**short", "unsigned long" and enum?Actions...
From:Roberto Cavalcante (rmca@gmail.com)
Date:Dec 17, 2008 10:33:19 pm
List:net.java.dev.jna.users

Timothy,

Ty for your answer. I'll try it and I'll send a feed back to the list.

Thanks again man

Roberto

On Thu, Dec 18, 2008 at 2:43 AM, Timothy Wall <twal@dev.java.net>wrote:

On Dec 17, 2008, at 5:41 PM, Roberto Cavalcante wrote:

Hi,

I have a C DLL witch I have to use. There is a function inside this DLL that requires a **short.

Header: typedef struct ZONING_RAWDATA { unsigned long triplet; /* Triplet for raw Data */ short **sheetXY; /* Array of Lenght colum and Width lines */ }ZONING_RAWDATA;

NativeLong and Pointer.

unsigned short ZONING_GetRawData(char * PlanName, ZONING_PLAN Plan, short NumberOfZone, short Triplet, ZONING_RAWDATA * Rawdata, double * Probability);

C code for using the function: RawData.sheetXY=(short **) malloc(50*sizeof(short*)); for (i=0;i<50;i++) { RawData.sheetXY[i]=(short *) malloc(100*sizeof(short)); }

_result = ZONING_GetRawData(PlanName,Plan,1,Triplet,&RawData, &Probability);

-----------------------------

As you can see, I need a solution for representing "short **sheetXY" and for "unsigned long triplet" witch are inside the struct ZONING_RAWDATA. I know allocation is not a problem, I just want what type should I use for both struct elements and if the recommended type have some tricky code do get and set data, please, write this trick code too.

You have an array of pointers, each of which points to an array of float. Pointer.setPointer(offset, p) can be used to set individual pointers in the array, which will be Memory if you allocate them yourself.

See Function.PointerArray or StringArray for an example of an array of pointers. You can't use Pointer[] or String[] directly within the struct, since that will be interpreted as a nested array rather than a single Pointer field.

Now for the C enum, I have this enumeration: typedef enum Action { ADD_PLAN = 0, /* Add Plan */ MODIFY_PLAN = 1, /* Modification */ DELETE_PLAN = 2, /* Deletion */ ADD_ZONE = 3, /* Add Zone */ MODIFY_ZONE = 4, /* Modify or Delete Zone */ } Action;

How can I represent it?

Most C compilers use "int" to represent enum. If yours doesn't it'll be documented.

I'm kind of desperate, so thanks a lot for any help you can provide.

Roberto M. Cavalcante