2 messages in net.java.dev.jna.usersRe: [jna-users] Question about conve...
FromSent OnAttachments
Peter NabbefeldApr 19, 2008 3:12 pm 
Timothy WallApr 19, 2008 4:04 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] Question about converting a C struct (from linuxusb)Actions...
From:Timothy Wall (twal@dev.java.net)
Date:Apr 19, 2008 4:04:39 pm
List:net.java.dev.jna.users

On Apr 19, 2008, at 6:13 PM, Peter Nabbefeld wrote:

Hello!

I've no knowledge about c, so please excuse for this silly question about how to convert this struct from c:

C's not that complex, the K&R book is narrower than your pinky and the section on structs and pointers readable within an hour.

struct usb_device { struct usb_device *next, *prev;

Two pointers to struct. While they *could* be aliased to an array, common usage suggests they're not.

Java type: Pointer, or Structure.ByReference.

char filename[PATH_MAX + 1];

struct usb_bus *bus;

struct usb_device_descriptor descriptor;

This is a nested struct. You can inline the fields directly, or make a Java type usb_device_descriptor which extends com.sun.jna.Structure. By default, structure fields within a structure are nested. By contrast, structure arguments are treated as struct* by default.

struct usb_config_descriptor *config;

Pointer, or Structure type, if you choose to define one.

void *dev; /* Darwin support */

u_int8_t devnum;

unsigned char num_children; struct usb_device **children; };