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.