From 558389f22d7a257e422ae50385364dcc74c4f106 Mon Sep 17 00:00:00 2001 From: sg215889 Date: Mon, 13 Jul 2009 01:29:44 -0700 Subject: Add: Extended support for CVM: - GLX, CGL, WGL - GL2ES12 desktop ES1 and ES2 common profile Add: BufferFactory: Determine the Buffer's Endianess Add: com.sun.gluegen.runtime.PointerBuffer - Solution for CDC/CVM (no LongBuffer), holds a buffer of pointer objects in native endian format and converts natively passed 32bit pointers to 64 bit. - supports a few Buffer mechanics, so the BufferFactory can easily use them. - behaves as an NIO Buffer, code generation - included a unit test Add: StructAccessor get/set long value, incl. endian check --- test/TestPointerBufferEndian.java | 33 +++++++++++++++++++++++++++++++++ test/TestStructAccessorEndian.java | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 test/TestPointerBufferEndian.java create mode 100644 test/TestStructAccessorEndian.java (limited to 'test') diff --git a/test/TestPointerBufferEndian.java b/test/TestPointerBufferEndian.java new file mode 100644 index 0000000..43eda84 --- /dev/null +++ b/test/TestPointerBufferEndian.java @@ -0,0 +1,33 @@ + +import com.sun.gluegen.runtime.*; +import java.nio.*; + +public class TestPointerBufferEndian { + public static void main (String[] args) { + boolean direct = args.length>0 && args[0].equals("-direct"); + boolean ok = true; + System.out.println("Buffer is in: "+ (BufferFactory.isLittleEndian()?"little":"big") + " endian"); + PointerBuffer ptr = direct ? PointerBuffer.allocateDirect(3) : PointerBuffer.allocate(3); + ptr.put(0, 0x0123456789ABCDEFL); + ptr.put(1, 0x8877665544332211L); + ptr.put(2, 0xAFFEDEADBEEFAFFEL); + long v = ptr.get(0); + if( 0x0123456789ABCDEFL != v ) { + System.out.println("Err[0] shall 0x0123456789ABCDEF, is: "+Long.toHexString(v)); + ok=false; + } + v = ptr.get(1); + if( 0x8877665544332211L != v ) { + System.out.println("Err[1] shall 0x8877665544332211, is: "+Long.toHexString(v)); + ok=false; + } + v = ptr.get(2); + if( 0xAFFEDEADBEEFAFFEL != v ) { + System.out.println("Err[2] shall 0xAFFEDEADBEEFAFFE, is: "+Long.toHexString(v)); + ok=false; + } + if(!ok) { + throw new RuntimeException("Long conversion failure"); + } + } +} diff --git a/test/TestStructAccessorEndian.java b/test/TestStructAccessorEndian.java new file mode 100644 index 0000000..9d294ed --- /dev/null +++ b/test/TestStructAccessorEndian.java @@ -0,0 +1,33 @@ + +import com.sun.gluegen.runtime.*; +import java.nio.*; + +public class TestStructAccessorEndian { + public static void main (String args[]) { + boolean ok = true; + System.out.println("CPU is : "+ (CPU.isLittleEndian()?"little":"big") + " endian"); + ByteBuffer tst = BufferFactory.newDirectByteBuffer(BufferFactory.SIZEOF_LONG * 3); + StructAccessor acc = new StructAccessor(tst); + acc.setLongAt(0, 0x0123456789ABCDEF); + acc.setLongAt(1, 0x8877665544332211); + acc.setLongAt(2, 0xAFFEDEADBEEFAFFE); + long v = acc.getLongAt(0); + if( 0x0123456789ABCDEF != v ) { + System.out.println("Err[0] shall 0x0123456789ABCDEF, is: "+Long.toHexString(v)); + ok=false; + } + v = acc.getLongAt(1); + if( 0x8877665544332211 != v ) { + System.out.println("Err[1] shall 0x8877665544332211, is: "+Long.toHexString(v)); + ok=false; + } + v = acc.getLongAt(2); + if( 0xAFFEDEADBEEFAFFE != v ) { + System.out.println("Err[2] shall 0xAFFEDEADBEEFAFFE, is: "+Long.toHexString(v)); + ok=false; + } + if(!ok) { + throw new RuntimeException("Long conversion failure"); + } + } +} -- cgit v1.2.3