11 messages in net.java.dev.jna.usersRe: [jna-users] Re: Structure Order
FromSent OnAttachments
Nicolas VienneJan 10, 2008 2:15 am 
Albert StrasheimJan 10, 2008 2:32 am 
Nicolas VienneJan 10, 2008 2:56 am 
Albert StrasheimJan 10, 2008 3:02 am 
Albert StrasheimJan 10, 2008 3:08 am 
Timothy WallJan 12, 2008 10:49 am 
Nicolas VienneJan 17, 2008 3:45 am 
Albert StrasheimJan 17, 2008 3:48 am 
Timothy WallJan 17, 2008 5:15 am 
Nicolas VienneJan 17, 2008 5:53 am 
Nicolas VienneJan 17, 2008 5:56 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:Re: [jna-users] Re: Structure OrderActions...
From:Timothy Wall (twal@dev.java.net)
Date:Jan 17, 2008 5:15:46 am
List:net.java.dev.jna.users

On Jan 17, 2008, at 6:46 AM, Nicolas Vienne wrote:

I think you're leaving out some critical details about what you're trying to accomplish. Do you have some other high-level language which is auto-generating the struct layout? You will *always* need to tell the Java side how to map its struct fields into memory, whether it's by convention or explicit configuration.

Both side (Java and C++) a generated from a model and I have no control on the order in which fields are created.

Which is fine, but since you don't know a priori the order in which fields are declared, the only solution is to auto-generate the JNA structure definition as well, once the order *has* been generated.

Around the same subject, I've slightly modified the JNA source to gain a better control on the field order by using Java annotations. I mean that in a class extending Structure, I can choose which fields will be taken into account for the mapping and in which order. I just noticed that a new version was available, but anyway if someone is interested I may post the changes.

I'm inferring that you already know the memory layout of the structures, which is independent of the generated code. Is it that you want to modify the code generation to include the annotations, or write the annotations independently of the generated code?

The internals of Structure could certainly be augmented to take advantage of additional annotation information, if present, but I strongly prefer not to enforce annotations on the library, since structure definitions *without* annotations is simpler.