Author: mturk Date: Sat Apr 25 16:50:28 2009 New Revision: 768562 URL: http://svn.apache.org/viewvc?rev=768562&view=rev Log: Add more copy and move methods to the Pointer
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor.java commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer32.java commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer64.java commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestMemory.java Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor.java?rev=768562&r1=768561&r2=768562&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor.java Sat Apr 25 16:50:28 2009 @@ -68,6 +68,7 @@ * @see Object#finalize() * @throws Throwable the {...@code Exception} raised by this method. */ + @Override protected final void finalize() throws Throwable { Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java?rev=768562&r1=768561&r2=768562&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java Sat Apr 25 16:50:28 2009 @@ -49,6 +49,38 @@ NULL = nullp0(); } + /** Alignment to {...@code boundary} function. + * @return {...@code int} aligned to the {...@code boundary}. + */ + public static final int align(int size, int boundary) + { + return (((size) + ((boundary) - 1)) & ~((boundary) - 1)); + } + + /** Alignment to default {...@code boundary} function. + * @return {...@code int} aligned to {...@code 8} bytes. + */ + public static final int align(int size) + { + return align(size, 8); + } + + /** Alignment to {...@code boundary} function. + * @return {...@code long} aligned to the {...@code boundary}. + */ + public static final long align(long size, int boundary) + { + return (((size) + ((boundary) - 1)) & ~((boundary) - 1)); + } + + /** Alignment to default {...@code boundary} function. + * @return {...@code long} aligned to {...@code 8} bytes. + */ + public static final long align(long size) + { + return align(size, 8); + } + /** * Size in bytes of the storage needed to represent the Pointer. */ @@ -102,6 +134,7 @@ * @see Object#finalize() * @throws Throwable the {...@code Exception} raised by this method. */ + @Override protected final void finalize() throws Throwable { @@ -197,6 +230,72 @@ NullPointerException; /** + * Copy the memory area from {...@code this} pointer to array + * pointed by {...@code dst}. + * + * @param srcPos starting position in the source memory. + * @param dst destination {...@code array}. + * @param dstPos starting position in the destination array. + * @param length the number of bytes to be copied. + * + * @throws IllegalArgumentException if the {...@code srcPos} or + * {...@code dstPos} is {...@code negative} or {...@code length} + * is {...@code zero}. + * @throws IndexOutOfBoundsException if the operation would cause + * access of data outside allocated memory bounds. + * @throws NullPointerException if {...@code this} or {...@code dst} is + * {...@code null}. + */ + public abstract void copy(long srcPos, char[] dst, + int dstPos, int length) + throws IndexOutOfBoundsException, IllegalArgumentException, + NullPointerException; + + /** + * Copy the memory area from {...@code this} pointer to array + * pointed by {...@code dst}. + * + * @param srcPos starting position in the source memory. + * @param dst destination {...@code array}. + * @param dstPos starting position in the destination array. + * @param length the number of bytes to be copied. + * + * @throws IllegalArgumentException if the {...@code srcPos} or + * {...@code dstPos} is {...@code negative} or {...@code length} + * is {...@code zero}. + * @throws IndexOutOfBoundsException if the operation would cause + * access of data outside allocated memory bounds. + * @throws NullPointerException if {...@code this} or {...@code dst} is + * {...@code null}. + */ + public abstract void copy(long srcPos, int[] dst, + int dstPos, int length) + throws IndexOutOfBoundsException, IllegalArgumentException, + NullPointerException; + + /** + * Copy the memory area from {...@code this} pointer to array + * pointed by {...@code dst}. + * + * @param srcPos starting position in the source memory. + * @param dst destination {...@code array}. + * @param dstPos starting position in the destination array. + * @param length the number of bytes to be copied. + * + * @throws IllegalArgumentException if the {...@code srcPos} or + * {...@code dstPos} is {...@code negative} or {...@code length} + * is {...@code zero}. + * @throws IndexOutOfBoundsException if the operation would cause + * access of data outside allocated memory bounds. + * @throws NullPointerException if {...@code this} or {...@code dst} is + * {...@code null}. + */ + public abstract void copy(long srcPos, long[] dst, + int dstPos, int length) + throws IndexOutOfBoundsException, IllegalArgumentException, + NullPointerException; + + /** * Copy the memory area to {...@code this} pointer from array * pointed by {...@code dst}. * @@ -219,6 +318,72 @@ NullPointerException; /** + * Copy the memory area to {...@code this} pointer from array + * pointed by {...@code dst}. + * + * @param src source {...@code array}. + * @param dstPos starting position in the source memory. + * @param srcPos starting position in the destination array. + * @param length the number of bytes to be copied. + * + * @throws IllegalArgumentException if the {...@code srcPos} or + * {...@code dstPos} is {...@code negative} or {...@code length} + * is {...@code zero}. + * @throws IndexOutOfBoundsException if the operation would cause + * access of data outside allocated memory bounds. + * @throws NullPointerException if {...@code this} or {...@code dst} is + * {...@code null}. + */ + public abstract void move(char[] src, int srcPos, + long dstPos, int length) + throws IndexOutOfBoundsException, IllegalArgumentException, + NullPointerException; + + /** + * Copy the memory area to {...@code this} pointer from array + * pointed by {...@code dst}. + * + * @param src source {...@code array}. + * @param dstPos starting position in the source memory. + * @param srcPos starting position in the destination array. + * @param length the number of bytes to be copied. + * + * @throws IllegalArgumentException if the {...@code srcPos} or + * {...@code dstPos} is {...@code negative} or {...@code length} + * is {...@code zero}. + * @throws IndexOutOfBoundsException if the operation would cause + * access of data outside allocated memory bounds. + * @throws NullPointerException if {...@code this} or {...@code dst} is + * {...@code null}. + */ + public abstract void move(int[] src, int srcPos, + long dstPos, int length) + throws IndexOutOfBoundsException, IllegalArgumentException, + NullPointerException; + + /** + * Copy the memory area to {...@code this} pointer from array + * pointed by {...@code dst}. + * + * @param src source {...@code array}. + * @param dstPos starting position in the source memory. + * @param srcPos starting position in the destination array. + * @param length the number of bytes to be copied. + * + * @throws IllegalArgumentException if the {...@code srcPos} or + * {...@code dstPos} is {...@code negative} or {...@code length} + * is {...@code zero}. + * @throws IndexOutOfBoundsException if the operation would cause + * access of data outside allocated memory bounds. + * @throws NullPointerException if {...@code this} or {...@code dst} is + * {...@code null}. + */ + public abstract void move(long[] src, int srcPos, + long dstPos, int length) + throws IndexOutOfBoundsException, IllegalArgumentException, + NullPointerException; + + /** * Copy the memory area from pointer {...@code src} to {...@code this} pointer. * <p> * Method uses the {...@code memmove} function to do a copying, meaning Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer32.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer32.java?rev=768562&r1=768561&r2=768562&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer32.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer32.java Sat Apr 25 16:50:28 2009 @@ -90,8 +90,14 @@ private static native void copy0(int src, int dst, int length); private static native void copy1(int addr, byte[] d, int dstPos, int len); + private static native void copy2(int addr, char[] d, int dstPos, int len); + private static native void copy3(int addr, int [] d, int dstPos, int len); + private static native void copy4(int addr, long[] d, int dstPos, int len); private static native void move0(int src, int dst, int length); private static native void move1(int addr, byte[] d, int srcPos, int len); + private static native void move2(int addr, char[] d, int srcPos, int len); + private static native void move3(int addr, int [] d, int srcPos, int len); + private static native void move4(int addr, long[] d, int srcPos, int len); public void copy(long srcPos, Pointer dst, long dstPos, long length) @@ -126,6 +132,57 @@ copy1(POINTER + (int)srcPos, dst, dstPos, length); } + public void copy(long srcPos, char[] dst, + int dstPos, int length) + throws IndexOutOfBoundsException, IllegalArgumentException, + NullPointerException + { + long srcOff = srcPos * 2; + if (POINTER == 0) + throw new NullPointerException(); + else if (srcPos < 0L || dstPos < 0 || length == 0) + throw new IllegalArgumentException(); + else if ((int)(srcOff + (length * 2)) > PLENGTH) + throw new IndexOutOfBoundsException(); + else if ((dstPos + length) > dst.length) + throw new IndexOutOfBoundsException(); + copy2(POINTER + (int)srcOff, dst, dstPos, length); + } + + public void copy(long srcPos, int[] dst, + int dstPos, int length) + throws IndexOutOfBoundsException, IllegalArgumentException, + NullPointerException + { + long srcOff = srcPos * 4; + if (POINTER == 0) + throw new NullPointerException(); + else if (srcPos < 0L || dstPos < 0 || length == 0) + throw new IllegalArgumentException(); + else if ((int)(srcOff + (length * 4)) > PLENGTH) + throw new IndexOutOfBoundsException(); + else if ((dstPos + length) > dst.length) + throw new IndexOutOfBoundsException(); + copy3(POINTER + (int)srcOff, dst, dstPos, length); + } + + public void copy(long srcPos, long[] dst, + int dstPos, int length) + throws IndexOutOfBoundsException, IllegalArgumentException, + NullPointerException + { + long srcOff = srcPos * 8; + if (POINTER == 0) + throw new NullPointerException(); + else if (srcPos < 0L || dstPos < 0 || length == 0) + throw new IllegalArgumentException(); + else if ((int)(srcOff + (length * 8)) > PLENGTH) + throw new IndexOutOfBoundsException(); + else if ((dstPos + length) > dst.length) + throw new IndexOutOfBoundsException(); + copy4(POINTER + (int)srcOff, dst, dstPos, length); + } + public void move(Pointer src, long srcPos, long dstPos, long length) throws IndexOutOfBoundsException, IllegalArgumentException, @@ -159,6 +216,57 @@ move1(POINTER + (int)dstPos, src, srcPos, length); } + public void move(char[] src, int srcPos, + long dstPos, int length) + throws IndexOutOfBoundsException, IllegalArgumentException, + NullPointerException + { + long dstOff = dstPos * 2; + if (POINTER == 0) + throw new NullPointerException(); + else if (srcPos < 0 || dstPos < 0 || length == 0) + throw new IllegalArgumentException(); + else if ((int)(dstOff + (length * 2)) > PLENGTH) + throw new IndexOutOfBoundsException(); + else if ((srcPos + length) > src.length) + throw new IndexOutOfBoundsException(); + move2(POINTER + (int)dstOff, src, srcPos, length); + } + + public void move(int[] src, int srcPos, + long dstPos, int length) + throws IndexOutOfBoundsException, IllegalArgumentException, + NullPointerException + { + long dstOff = dstPos * 4; + if (POINTER == 0) + throw new NullPointerException(); + else if (srcPos < 0 || dstPos < 0 || length == 0) + throw new IllegalArgumentException(); + else if ((int)(dstOff + (length * 4)) > PLENGTH) + throw new IndexOutOfBoundsException(); + else if ((srcPos + length) > src.length) + throw new IndexOutOfBoundsException(); + move3(POINTER + (int)dstOff, src, srcPos, length); + } + + public void move(long[] src, int srcPos, + long dstPos, int length) + throws IndexOutOfBoundsException, IllegalArgumentException, + NullPointerException + { + long dstOff = dstPos * 8; + if (POINTER == 0) + throw new NullPointerException(); + else if (srcPos < 0 || dstPos < 0 || length == 0) + throw new IllegalArgumentException(); + else if ((int)(dstOff + (length * 8)) > PLENGTH) + throw new IndexOutOfBoundsException(); + else if ((srcPos + length) > src.length) + throw new IndexOutOfBoundsException(); + move4(POINTER + (int)dstOff, src, srcPos, length); + } + public String toString() { if (POINTER != 0) { Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer64.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer64.java?rev=768562&r1=768561&r2=768562&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer64.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer64.java Sat Apr 25 16:50:28 2009 @@ -90,8 +90,14 @@ private static native void copy0(long src, long dst, long length); private static native void copy1(long addr, byte[] d, int dstPos, int len); + private static native void copy2(long addr, char[] d, int dstPos, int len); + private static native void copy3(long addr, int [] d, int dstPos, int len); + private static native void copy4(long addr, long[] d, int dstPos, int len); private static native void move0(long src, long dst, long length); private static native void move1(long addr, byte[] d, int srcPos, int len); + private static native void move2(long addr, char[] d, int srcPos, int len); + private static native void move3(long addr, int [] d, int srcPos, int len); + private static native void move4(long addr, long[] d, int srcPos, int len); public void copy(long srcPos, Pointer dst, long dstPos, long length) @@ -126,6 +132,57 @@ copy1(POINTER + srcPos, dst, dstPos, length); } + public void copy(long srcPos, char[] dst, + int dstPos, int length) + throws IndexOutOfBoundsException, IllegalArgumentException, + NullPointerException + { + long srcOff = srcPos * 2; + if (POINTER == 0L) + throw new NullPointerException(); + else if (srcPos < 0L || dstPos < 0 || length == 0) + throw new IllegalArgumentException(); + else if ((srcOff + (length * 2)) > PLENGTH) + throw new IndexOutOfBoundsException(); + else if ((dstPos + length) > dst.length) + throw new IndexOutOfBoundsException(); + copy2(POINTER + srcOff, dst, dstPos, length); + } + + public void copy(long srcPos, int[] dst, + int dstPos, int length) + throws IndexOutOfBoundsException, IllegalArgumentException, + NullPointerException + { + long srcOff = srcPos * 4; + if (POINTER == 0L) + throw new NullPointerException(); + else if (srcPos < 0L || dstPos < 0 || length == 0) + throw new IllegalArgumentException(); + else if ((srcOff + (length * 4)) > PLENGTH) + throw new IndexOutOfBoundsException(); + else if ((dstPos + length) > dst.length) + throw new IndexOutOfBoundsException(); + copy3(POINTER + srcOff, dst, dstPos, length); + } + + public void copy(long srcPos, long[] dst, + int dstPos, int length) + throws IndexOutOfBoundsException, IllegalArgumentException, + NullPointerException + { + long srcOff = srcPos * 8; + if (POINTER == 0L) + throw new NullPointerException(); + else if (srcPos < 0L || dstPos < 0 || length == 0) + throw new IllegalArgumentException(); + else if ((srcOff + (length * 8)) > PLENGTH) + throw new IndexOutOfBoundsException(); + else if ((dstPos + length) > dst.length) + throw new IndexOutOfBoundsException(); + copy4(POINTER + srcOff, dst, dstPos, length); + } + public void move(Pointer src, long srcPos, long dstPos, long length) throws IndexOutOfBoundsException, IllegalArgumentException, @@ -150,7 +207,7 @@ { if (POINTER == 0L) throw new NullPointerException(); - else if (srcPos < 0L || dstPos < 0L || length == 0) + else if (srcPos < 0 || dstPos < 0L || length == 0) throw new IllegalArgumentException(); else if ((dstPos + length) > PLENGTH) throw new IndexOutOfBoundsException(); @@ -159,6 +216,57 @@ move1(POINTER + dstPos, src, srcPos, length); } + public void move(char[] src, int srcPos, + long dstPos, int length) + throws IndexOutOfBoundsException, IllegalArgumentException, + NullPointerException + { + long dstOff = dstPos * 2; + if (POINTER == 0) + throw new NullPointerException(); + else if (srcPos < 0 || dstPos < 0 || length == 0) + throw new IllegalArgumentException(); + else if ((dstOff + (length * 2)) > PLENGTH) + throw new IndexOutOfBoundsException(); + else if ((srcPos + length) > src.length) + throw new IndexOutOfBoundsException(); + move2(POINTER + dstOff, src, srcPos, length); + } + + public void move(int[] src, int srcPos, + long dstPos, int length) + throws IndexOutOfBoundsException, IllegalArgumentException, + NullPointerException + { + long dstOff = dstPos * 4; + if (POINTER == 0) + throw new NullPointerException(); + else if (srcPos < 0 || dstPos < 0 || length == 0) + throw new IllegalArgumentException(); + else if ((dstOff + (length * 4)) > PLENGTH) + throw new IndexOutOfBoundsException(); + else if ((srcPos + length) > src.length) + throw new IndexOutOfBoundsException(); + move3(POINTER + dstOff, src, srcPos, length); + } + + public void move(long[] src, int srcPos, + long dstPos, int length) + throws IndexOutOfBoundsException, IllegalArgumentException, + NullPointerException + { + long dstOff = dstPos * 8; + if (POINTER == 0) + throw new NullPointerException(); + else if (srcPos < 0 || dstPos < 0 || length == 0) + throw new IllegalArgumentException(); + else if ((dstOff + (length * 8)) > PLENGTH) + throw new IndexOutOfBoundsException(); + else if ((srcPos + length) > src.length) + throw new IndexOutOfBoundsException(); + move4(POINTER + dstOff, src, srcPos, length); + } + public String toString() { if (POINTER != 0L) { Modified: commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c?rev=768562&r1=768561&r2=768562&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c Sat Apr 25 16:50:28 2009 @@ -208,6 +208,30 @@ (*_E)->SetByteArrayRegion(_E, dst, (jsize)off, (jsize)len, N2P(a, jbyte *)); } +ACR_PTR_EXPORT_DECLARE(void, copy2)(ACR_JNISTDARGS, jniptr a, jcharArray dst, + jint off, jint len) +{ + UNREFERENCED_O; + + (*_E)->SetCharArrayRegion(_E, dst, (jsize)off, (jsize)len, N2P(a, jchar *)); +} + +ACR_PTR_EXPORT_DECLARE(void, copy3)(ACR_JNISTDARGS, jniptr a, jintArray dst, + jint off, jint len) +{ + UNREFERENCED_O; + + (*_E)->SetIntArrayRegion(_E, dst, (jsize)off, (jsize)len, N2P(a, jint *)); +} + +ACR_PTR_EXPORT_DECLARE(void, copy4)(ACR_JNISTDARGS, jniptr a, jlongArray dst, + jint off, jint len) +{ + UNREFERENCED_O; + + (*_E)->SetLongArrayRegion(_E, dst, (jsize)off, (jsize)len, N2P(a, jlong *)); +} + ACR_PTR_EXPORT_DECLARE(void, move1)(ACR_JNISTDARGS, jniptr a, jbyteArray src, jint off, jint len) { @@ -216,6 +240,30 @@ (*_E)->GetByteArrayRegion(_E, src, (jsize)off, (jsize)len, N2P(a, jbyte *)); } +ACR_PTR_EXPORT_DECLARE(void, move2)(ACR_JNISTDARGS, jniptr a, jcharArray src, + jint off, jint len) +{ + UNREFERENCED_O; + + (*_E)->GetCharArrayRegion(_E, src, (jsize)off, (jsize)len, N2P(a, jchar *)); +} + +ACR_PTR_EXPORT_DECLARE(void, move3)(ACR_JNISTDARGS, jniptr a, jintArray src, + jint off, jint len) +{ + UNREFERENCED_O; + + (*_E)->GetIntArrayRegion(_E, src, (jsize)off, (jsize)len, N2P(a, jint *)); +} + +ACR_PTR_EXPORT_DECLARE(void, move4)(ACR_JNISTDARGS, jniptr a, jlongArray src, + jint off, jint len) +{ + UNREFERENCED_O; + + (*_E)->GetLongArrayRegion(_E, src, (jsize)off, (jsize)len, N2P(a, jlong *)); +} + ACR_DECLARE(jobject) ACR_PointerCreate(JNIEnv *_E, void *p, size_t len, acr_pointer_cleanup_fn_t *cb) Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestMemory.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestMemory.java?rev=768562&r1=768561&r2=768562&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestMemory.java (original) +++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestMemory.java Sat Apr 25 16:50:28 2009 @@ -40,7 +40,16 @@ initp0(0); } - + public void testAlign() + throws Exception + { + assertEquals("Align", 4, Pointer.align(3, 4)); + assertEquals("Align", 8, Pointer.align(3)); + assertEquals("Align", 0, Pointer.align(0)); + assertEquals("Align", 0, Pointer.align(-3)); + assertEquals("Align", -8, Pointer.align(-8)); + assertEquals("Align", 16L, Pointer.align(1L, 16)); + } public void testNull() throws Throwable @@ -251,6 +260,51 @@ } + public void testCopyToCharArray() + { + Pointer p = Memory.calloc(1000); + assertNotNull("Pointer", p); + Memory.set(p, 0, 1000, 0xFF); + p.poke(0, 0x11); + p.poke(1, 0x11); + char [] c = new char[32]; + + p.copy(0, c, 0, c.length); + assertEquals("Value", 0x1111, c[0]); + assertEquals("Value", (char)0xFFFF, c[1]); + + } + + public void testCopyToIntArray() + { + Pointer p = Memory.calloc(1000); + assertNotNull("Pointer", p); + Memory.set(p, 0, 1000, 0xFF); + for (int j = 0; j < 4; j++) + p.poke(j, 0x11); + int [] i = new int[32]; + + p.copy(0, i, 0, i.length); + assertEquals("Value", 0x11111111, i[0]); + assertEquals("Value", 0xFFFFFFFF, i[1]); + + } + + public void testCopyToLongArray() + { + Pointer p = Memory.calloc(1000); + assertNotNull("Pointer", p); + Memory.set(p, 0, 1000, 0xFF); + for (int j = 0; j < 8; j++) + p.poke(j, 0x11); + long [] l = new long[32]; + + p.copy(0, l, 0, l.length); + assertEquals("Value", 0x1111111111111111L, l[0]); + assertEquals("Value", 0xFFFFFFFFFFFFFFFFL, l[1]); + + } + public void testCopyFromArray() { Pointer p = Memory.calloc(1000); @@ -265,5 +319,50 @@ } + public void testCopyFromCharArray() + { + Pointer p = Memory.calloc(1000); + assertNotNull("Pointer", p); + Memory.set(p, 0, 1000, 0xFF); + p.poke(0, 23); + char [] c = new char[32]; + + p.move(c, 0, 1, c.length); + assertEquals("Value", 23, p.peek(0)); + assertEquals("Value", -1, p.peek(1)); + assertEquals("Value", 0, p.peek(2)); + + } + + public void testCopyFromIntArray() + { + Pointer p = Memory.calloc(1000); + assertNotNull("Pointer", p); + Memory.set(p, 0, 1000, 0xFF); + p.poke(0, 23); + int [] i = new int[32]; + + p.move(i, 0, 1, i.length); + assertEquals("Value", 23, p.peek(0)); + assertEquals("Value", -1, p.peek(3)); + assertEquals("Value", 0, p.peek(4)); + + } + + public void testCopyFromLongArray() + { + Pointer p = Memory.calloc(1000); + assertNotNull("Pointer", p); + Memory.set(p, 0, 1000, 0xFF); + p.poke(0, 23); + long [] l = new long[32]; + + p.move(l, 0, 1, l.length); + assertEquals("Value", 23, p.peek(0)); + assertEquals("Value", -1, p.peek(7)); + assertEquals("Value", 0, p.peek(8)); + + } + }