Hello
Thanks for the quick reply.
Unfortunately I can't use this approach in my case since I have some code
depends on being able to get the backing array of the FloatBuffer as a
float[].
Unless I'm mistaken, ByteBuffer#asFloatBuffer() returns a FloatBuffer that
throws UnsupportedOperationException when you call array(), so there's no
way for me to get a float[] from this kind of buffer without copying.
Thus, it would be useful if I could pass these kinds of buffers directly to
JNA.
Regards,
Albert
----- Original Message -----
From: "Wayne Meissner" <wmei...@gmail.com>
To: <use...@jna.dev.java.net>
Sent: Thursday, August 23, 2007 1:20 AM
Subject: Re: [jna-users] Buffer arguments as pointer-to-buffer
You could always use ByteBuffer.asFloatBuffer()
e.g.
Pointer ptr = ...;
FloatBuffer fb = ptr.getByteBuffer(0, 8).asFloatBuffer();
float f = fb.get();
I just updated PointerTest to include tests for Int, Long, Float, Double
Buffer usage, and it all seems to work sanely.