8 messages in net.java.dev.jna.usersRe: [jna-users] getting at a structur...
FromSent OnAttachments
Paul LoyJan 23, 2008 10:34 am 
Timothy WallJan 23, 2008 11:04 am 
Paul LoyJan 24, 2008 5:29 am 
Paul LoyJan 24, 2008 5:30 am 
Timothy WallJan 24, 2008 5:38 am 
Paul LoyJan 25, 2008 5:24 am 
Timothy WallJan 25, 2008 5:58 am 
Paul LoyJan 25, 2008 6:50 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] getting at a structure with unknown structure sizeActions...
From:Paul Loy (pa@keteracel.com)
Date:Jan 25, 2008 6:50:05 am
List:net.java.dev.jna.users

if (audioDescription.getVersion() == 2) { Memory soundDescriptionHandle = new Memory(Pointer.SIZE); soundDescriptionHandle.setInt(0, QTObject.ID (audioDescription));

This is what PointerByReference does (auto-allocates memory to hold a pointer). So your method being called wants an *initialized* handle, I guess.

Yes. The Handle should be a pointer to a pointer to a reallocatable piece of memory (struct). I guess this is how Quicktime tries to be quick, by allocating enough memory for the smallest structure a call can expect, then reallocating it if necessary. PointerByReference doesn't drill down deep enough. It does not allow us to alloc the memory down through the Handle which would be realloced by the QT API call. So realloc on this address would (and does) fail.

Remind me why you can't define the full structure?

I can, I was just in Java mode, not wanting code duplication or have to jump through the odd hoop! Java Developer laziness I guess. I do feel I need to get dirty and do more native work again.

You *could*, but you're basically using OO to map one instance of a typecast, ignoring that there might be several alternate typecasts that are equally applicable. I chose not to explicitly support subclassing structs, because you can't do it in C so it's not clear what the behavior should be in Java. What might be convenient for one case might be rather annoying in another.

If the C structure defines nested structures, so should the Java definition.

Personally I would like it more Java-like on the Java end, but I take your point. Also, as you do far more native coding than me, you are more familiar with the different behaviours. It's not like it's difficult to use, just playing with things, seeing if they can be any easier.

Cheers,

Paul.