12 messages in net.java.dev.jna.usersRe: [jna-users] Buffer arguments as p...
FromSent OnAttachments
Albert StrasheimAug 22, 2007 3:47 pm 
Wayne MeissnerAug 22, 2007 4:19 pm 
Albert StrasheimAug 22, 2007 4:39 pm 
Wayne MeissnerAug 22, 2007 5:33 pm 
Albert StrasheimAug 22, 2007 5:47 pm 
Wayne MeissnerAug 22, 2007 6:13 pm 
Albert StrasheimAug 22, 2007 6:21 pm 
Albert StrasheimAug 22, 2007 6:26 pm 
Wayne MeissnerAug 22, 2007 8:05 pm 
Albert StrasheimAug 23, 2007 3:25 pm 
Wayne MeissnerAug 23, 2007 4:32 pm 
Albert StrasheimAug 23, 2007 4:50 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] Buffer arguments as pointer-to-bufferActions...
From:Wayne Meissner (wmei@gmail.com)
Date:Aug 22, 2007 6:13:25 pm
List:net.java.dev.jna.users

Ok, I've implemented heap Buffer arguments in V3. You can also do this via a TypeMapper + ToNativeConverter.

That would be great. With this implemented, I think all the bases are covered, namely:

- byte[] (VM pins or copies to give us a pointer) - heap ByteBuffer (since ByteBuffer#array returns a byte[] which the VM can pin or copy) - direct ByteBuffer (pointer is available via a JNI call) - float[] (VM pins or copies to give us a pointer) - heap FloatBuffer (since FloatBuffer#array returns a float[] which the VM can pin or copy) - direct FloatBuffer (pointer is available via a JNI call)

AFAIK, there is no way to create nor access the pointer on a direct FloatBuffer.

According to the javadoc, the only way they are created is via asFloatBuffer() on a direct ByteBuffer - and I couldn't see anyway to get back to the direct ByteBuffer from a FloatBuffer view.

That means something like this will throw an exception: FloatBuffer fb = ByteBuffer.allocateDirect(1024).asFloatBuffer(); some_function(fb);

Its a pretty weird corner case, and there's nothing JNA can do about it.